mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
sw_engine raster: code refactoring.
Move partial region in rasterClear()
This commit is contained in:
parent
0ce2208be0
commit
f18d2557e3
3 changed files with 13 additions and 15 deletions
|
@ -357,7 +357,7 @@ bool rasterShape(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8
|
|||
bool rasterImage(SwSurface* surface, SwImage* image, const RenderMesh* mesh, const Matrix* transform, const SwBBox& bbox, uint32_t opacity);
|
||||
bool rasterStroke(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||
bool rasterGradientStroke(SwSurface* surface, SwShape* shape, unsigned id);
|
||||
bool rasterClear(SwSurface* surface);
|
||||
bool rasterClear(SwSurface* surface, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
|
||||
void rasterRGBA32(uint32_t *dst, uint32_t val, uint32_t offset, int32_t len);
|
||||
void rasterUnpremultiply(Surface* surface);
|
||||
void rasterPremultiply(Surface* surface);
|
||||
|
|
|
@ -1466,15 +1466,18 @@ bool rasterCompositor(SwSurface* surface)
|
|||
}
|
||||
|
||||
|
||||
bool rasterClear(SwSurface* surface)
|
||||
bool rasterClear(SwSurface* surface, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
|
||||
{
|
||||
if (!surface || !surface->buffer || surface->stride <= 0 || surface->w <= 0 || surface->h <= 0) return false;
|
||||
if (!surface || !surface->buffer || surface->stride == 0 || surface->w == 0 || surface->h == 0) return false;
|
||||
|
||||
//full clear
|
||||
if (surface->w == surface->stride) {
|
||||
rasterRGBA32(surface->buffer, 0x00000000, 0, surface->w * surface->h);
|
||||
rasterRGBA32(surface->buffer + (surface->stride * y + x), 0x00000000, x, w * h);
|
||||
//partial clear
|
||||
} else {
|
||||
for (uint32_t i = 0; i < surface->h; i++) {
|
||||
rasterRGBA32(surface->buffer + surface->stride * i, 0x00000000, 0, surface->w);
|
||||
auto offset = surface->stride * y + x;
|
||||
for (uint32_t i = 0; i < h; i++) {
|
||||
rasterRGBA32(surface->buffer + (offset * i), 0x00000000, x, w);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -449,9 +449,10 @@ bool SwRenderer::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t
|
|||
|
||||
bool SwRenderer::preRender()
|
||||
{
|
||||
return rasterClear(surface);
|
||||
return rasterClear(surface, 0, 0, surface->w, surface->h);
|
||||
}
|
||||
|
||||
|
||||
void SwRenderer::clearCompositors()
|
||||
{
|
||||
//Free Composite Caches
|
||||
|
@ -631,18 +632,12 @@ Compositor* SwRenderer::target(const RenderRegion& region, ColorSpace cs)
|
|||
cmp->compositor->image.h = surface->h;
|
||||
cmp->compositor->image.direct = true;
|
||||
|
||||
//We know partial clear region
|
||||
cmp->buffer = cmp->compositor->image.data + (cmp->stride * y + x);
|
||||
cmp->w = w;
|
||||
cmp->h = h;
|
||||
|
||||
rasterClear(cmp);
|
||||
|
||||
//Recover context
|
||||
cmp->buffer = cmp->compositor->image.data;
|
||||
cmp->w = cmp->compositor->image.w;
|
||||
cmp->h = cmp->compositor->image.h;
|
||||
|
||||
rasterClear(cmp, x, y, w, h);
|
||||
|
||||
//Switch render target
|
||||
surface = cmp;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue