mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-09 16:15:41 +00:00
sw_engine: dropshadow stability++
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
removed the direct rendering optimization of the dropshadow, because it's a buggy.
This commit is contained in:
parent
4e645918c7
commit
78753eed31
3 changed files with 6 additions and 15 deletions
|
@ -672,7 +672,7 @@ uint32_t rasterUnpremultiply(uint32_t data);
|
||||||
bool effectGaussianBlur(SwCompositor* cmp, SwSurface* surface, const RenderEffectGaussianBlur* params);
|
bool effectGaussianBlur(SwCompositor* cmp, SwSurface* surface, const RenderEffectGaussianBlur* params);
|
||||||
bool effectGaussianBlurRegion(RenderEffectGaussianBlur* effect);
|
bool effectGaussianBlurRegion(RenderEffectGaussianBlur* effect);
|
||||||
void effectGaussianBlurUpdate(RenderEffectGaussianBlur* effect, const Matrix& transform);
|
void effectGaussianBlurUpdate(RenderEffectGaussianBlur* effect, const Matrix& transform);
|
||||||
bool effectDropShadow(SwCompositor* cmp, SwSurface* surfaces[2], const RenderEffectDropShadow* params, bool direct);
|
bool effectDropShadow(SwCompositor* cmp, SwSurface* surfaces[2], const RenderEffectDropShadow* params);
|
||||||
bool effectDropShadowRegion(RenderEffectDropShadow* effect);
|
bool effectDropShadowRegion(RenderEffectDropShadow* effect);
|
||||||
void effectDropShadowUpdate(RenderEffectDropShadow* effect, const Matrix& transform);
|
void effectDropShadowUpdate(RenderEffectDropShadow* effect, const Matrix& transform);
|
||||||
void effectFillUpdate(RenderEffectFill* effect);
|
void effectFillUpdate(RenderEffectFill* effect);
|
||||||
|
|
|
@ -267,14 +267,14 @@ static void _dropShadowFilter(uint32_t* dst, uint32_t* src, int stride, int w, i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void _dropShadowShift(uint32_t* dst, uint32_t* src, int dstride, int sstride, RenderRegion& bbox, SwPoint& offset, uint8_t opacity, bool direct)
|
static void _dropShadowShift(uint32_t* dst, uint32_t* src, int dstride, int sstride, RenderRegion& bbox, SwPoint& offset, uint8_t opacity)
|
||||||
{
|
{
|
||||||
src += (bbox.min.y * sstride + bbox.min.x);
|
src += (bbox.min.y * sstride + bbox.min.x);
|
||||||
dst += (bbox.min.y * dstride + bbox.min.x);
|
dst += (bbox.min.y * dstride + bbox.min.x);
|
||||||
|
|
||||||
auto w = bbox.max.x - bbox.min.x;
|
auto w = bbox.max.x - bbox.min.x;
|
||||||
auto h = bbox.max.y - bbox.min.y;
|
auto h = bbox.max.y - bbox.min.y;
|
||||||
auto translucent = (direct || opacity < 255);
|
auto translucent = (opacity < 255);
|
||||||
|
|
||||||
//shift offset
|
//shift offset
|
||||||
if (bbox.min.x + offset.x < 0) src -= offset.x;
|
if (bbox.min.x + offset.x < 0) src -= offset.x;
|
||||||
|
@ -342,7 +342,7 @@ void effectDropShadowUpdate(RenderEffectDropShadow* params, const Matrix& transf
|
||||||
//A quite same integration with effectGaussianBlur(). See it for detailed comments.
|
//A quite same integration with effectGaussianBlur(). See it for detailed comments.
|
||||||
//surface[0]: the original image, to overlay it into the filtered image.
|
//surface[0]: the original image, to overlay it into the filtered image.
|
||||||
//surface[1]: temporary buffer for generating the filtered image.
|
//surface[1]: temporary buffer for generating the filtered image.
|
||||||
bool effectDropShadow(SwCompositor* cmp, SwSurface* surface[2], const RenderEffectDropShadow* params, bool direct)
|
bool effectDropShadow(SwCompositor* cmp, SwSurface* surface[2], const RenderEffectDropShadow* params)
|
||||||
{
|
{
|
||||||
//FIXME: if the body is partially visible due to clipping, the shadow also becomes partially visible.
|
//FIXME: if the body is partially visible due to clipping, the shadow also becomes partially visible.
|
||||||
|
|
||||||
|
@ -360,8 +360,6 @@ bool effectDropShadow(SwCompositor* cmp, SwSurface* surface[2], const RenderEffe
|
||||||
auto front = cmp->image.buf32;
|
auto front = cmp->image.buf32;
|
||||||
auto back = buffer[1]->buf32;
|
auto back = buffer[1]->buf32;
|
||||||
|
|
||||||
auto opacity = direct ? MULTIPLY(params->color[3], cmp->opacity) : params->color[3];
|
|
||||||
|
|
||||||
TVGLOG("SW_ENGINE", "DropShadow region(%d, %d, %d, %d) params(%f %f %f), level(%d)", bbox.min.x, bbox.min.y, bbox.max.x, bbox.max.y, params->angle, params->distance, params->sigma, data->level);
|
TVGLOG("SW_ENGINE", "DropShadow region(%d, %d, %d, %d) params(%f %f %f), level(%d)", bbox.min.x, bbox.min.y, bbox.max.x, bbox.max.y, params->angle, params->distance, params->sigma, data->level);
|
||||||
|
|
||||||
//saving the original image in order to overlay it into the filtered image.
|
//saving the original image in order to overlay it into the filtered image.
|
||||||
|
@ -387,16 +385,9 @@ bool effectDropShadow(SwCompositor* cmp, SwSurface* surface[2], const RenderEffe
|
||||||
rasterXYFlip(front, back, stride, h, w, bbox, true);
|
rasterXYFlip(front, back, stride, h, w, bbox, true);
|
||||||
std::swap(cmp->image.buf32, back);
|
std::swap(cmp->image.buf32, back);
|
||||||
|
|
||||||
//draw to the main surface directly
|
|
||||||
if (direct) {
|
|
||||||
_dropShadowShift(cmp->recoverSfc->buf32, cmp->image.buf32, cmp->recoverSfc->stride, stride, bbox, data->offset, opacity, direct);
|
|
||||||
std::swap(cmp->image.buf32, buffer[0]->buf32);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//draw to the intermediate surface
|
//draw to the intermediate surface
|
||||||
rasterClear(surface[1], bbox.min.x, bbox.min.y, w, h);
|
rasterClear(surface[1], bbox.min.x, bbox.min.y, w, h);
|
||||||
_dropShadowShift(buffer[1]->buf32, cmp->image.buf32, stride, stride, bbox, data->offset, opacity, direct);
|
_dropShadowShift(buffer[1]->buf32, cmp->image.buf32, stride, stride, bbox, data->offset, params->color[3]);
|
||||||
std::swap(cmp->image.buf32, buffer[1]->buf32);
|
std::swap(cmp->image.buf32, buffer[1]->buf32);
|
||||||
|
|
||||||
//compositing shadow and body
|
//compositing shadow and body
|
||||||
|
|
|
@ -731,7 +731,7 @@ bool SwRenderer::render(RenderCompositor* cmp, const RenderEffect* effect, bool
|
||||||
cmp1->compositor->valid = false;
|
cmp1->compositor->valid = false;
|
||||||
auto cmp2 = request(surface->channelSize, true);
|
auto cmp2 = request(surface->channelSize, true);
|
||||||
SwSurface* surfaces[] = {cmp1, cmp2};
|
SwSurface* surfaces[] = {cmp1, cmp2};
|
||||||
auto ret = effectDropShadow(p, surfaces, static_cast<const RenderEffectDropShadow*>(effect), direct);
|
auto ret = effectDropShadow(p, surfaces, static_cast<const RenderEffectDropShadow*>(effect));
|
||||||
cmp1->compositor->valid = true;
|
cmp1->compositor->valid = true;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue