MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / movePixels

Method movePixels

src/OpenLoco/src/Graphics/SoftwareDrawingEngine.cpp:387–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385 }
386
387 void SoftwareDrawingEngine::movePixels(
388 const RenderTarget& rt,
389 int16_t dstX,
390 int16_t dstY,
391 int16_t width,
392 int16_t height,
393 int16_t srcX,
394 int16_t srcY)
395 {
396 if (dstX == 0 && dstY == 0)
397 {
398 return;
399 }
400
401 // Adjust for move off canvas.
402 // NOTE: when zooming, there can be x, y, dx, dy combinations that go off the
403 // canvas; hence the checks. This code should ultimately not be called when
404 // zooming because this function is specific to updating the screen on move
405 int32_t lmargin = std::min(dstX - srcX, 0);
406 int32_t rmargin = std::min((int32_t)rt.width - (dstX - srcX + width), 0);
407 int32_t tmargin = std::min(dstY - srcY, 0);
408 int32_t bmargin = std::min((int32_t)rt.height - (dstY - srcY + height), 0);
409
410 dstX -= lmargin;
411 dstY -= tmargin;
412 width += lmargin + rmargin;
413 height += tmargin + bmargin;
414
415 int32_t stride = rt.width + rt.pitch;
416 uint8_t* to = rt.bits + dstY * stride + dstX;
417 uint8_t* from = rt.bits + (dstY - srcY) * stride + dstX - srcX;
418
419 if (srcY > 0)
420 {
421 // If positive dy, reverse directions
422 to += (height - 1) * stride;
423 from += (height - 1) * stride;
424 stride = -stride;
425 }
426
427 // Move bytes
428 for (int32_t i = 0; i < height; i++)
429 {
430 std::memmove(to, from, width);
431 to += stride;
432 from += stride;
433 }
434 }
435
436 const Ui::ScreenInfo& SoftwareDrawingEngine::getScreenInfo() const
437 {

Callers 1

movePixelsOnScreenFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected