MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / surfacecpy

Function surfacecpy

LibLemon/src/gfx/graphics.cpp:216–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214 }
215
216 void surfacecpy(surface_t* dest, surface_t* src, vector2i_t offset){
217 if(dest->height == src->height && dest->width == src->width && offset.x == 0 && offset.y == 0) {
218 memcpy_optimized(dest->buffer, src->buffer, dest->width * dest->height);
219 return;
220 }
221
222 int rowSize = ((offset.x + src->width) > dest->width) ? dest->width - offset.x : src->width;
223 int rowOffset = 0;
224
225 if(offset.x < 0){
226 rowOffset = -offset.x * 4;
227 rowSize += offset.x;
228 offset.x = 0;
229 }
230
231 int i = 0;
232
233 if(offset.y < 0){
234 i += offset.y;
235 offset.y = 0;
236 }
237
238 for(; i < src->height && i < dest->height - offset.y; i++){
239 if(rowSize <= 0) return;
240
241 memcpy_optimized(dest->buffer + ((i+offset.y)*(dest->width*4) + offset.x*4), src->buffer + i*src->width*4 + rowOffset, rowSize);
242 }
243 }
244
245 void surfacecpy(surface_t* dest, surface_t* src, vector2i_t offset, rect_t srcRegion){
246 if(offset.x >= dest->width || offset.y >= dest->height || srcRegion.pos.x >= src->width || srcRegion.pos.y >= src->height) return;

Callers 6

DrawMethod · 0.85
PaintMethod · 0.85
PaintFunction · 0.85
PaintMethod · 0.85
PaintMethod · 0.85
PaintMethod · 0.85

Calls 1

absFunction · 0.85

Tested by

no test coverage detected