mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 781731 - Use a similar surface for non-blurred shadows to improve performance. r=joe
This commit is contained in:
parent
38dffad114
commit
0aef976df5
@ -313,7 +313,7 @@ public:
|
||||
|
||||
mTarget =
|
||||
mCtx->mTarget->CreateShadowDrawTarget(IntSize(int32_t(mTempRect.width), int32_t(mTempRect.height)),
|
||||
FORMAT_B8G8R8A8);
|
||||
FORMAT_B8G8R8A8, mSigma);
|
||||
|
||||
if (!mTarget) {
|
||||
// XXX - Deal with the situation where our temp size is too big to
|
||||
|
@ -729,9 +729,15 @@ public:
|
||||
|
||||
/*
|
||||
* Create a draw target optimized for drawing a shadow.
|
||||
*
|
||||
* Note that aSigma is the blur radius that must be used when we draw the
|
||||
* shadow. Also note that this doesn't affect the size of the allocated
|
||||
* surface, the caller is still responsible for including the shadow area in
|
||||
* its size.
|
||||
*/
|
||||
virtual TemporaryRef<DrawTarget>
|
||||
CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
|
||||
CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat,
|
||||
float aSigma) const
|
||||
{
|
||||
return CreateSimilarDrawTarget(aSize, aFormat);
|
||||
}
|
||||
|
@ -393,8 +393,14 @@ DrawTargetCairo::DrawSurfaceWithShadow(SourceSurface *aSurface,
|
||||
|
||||
SourceSurfaceCairo* source = static_cast<SourceSurfaceCairo*>(aSurface);
|
||||
cairo_surface_t* sourcesurf = source->GetSurface();
|
||||
cairo_surface_t* blursurf = cairo_tee_surface_index(sourcesurf, 0);
|
||||
cairo_surface_t* surf = cairo_tee_surface_index(sourcesurf, 1);
|
||||
cairo_surface_t* blursurf;
|
||||
cairo_surface_t* surf;
|
||||
|
||||
// We only use the A8 surface for blurred shadows. Unblurred shadows can just
|
||||
// use the RGBA surface directly.
|
||||
if (cairo_surface_get_type(sourcesurf) == CAIRO_SURFACE_TYPE_TEE) {
|
||||
blursurf = cairo_tee_surface_index(sourcesurf, 0);
|
||||
surf = cairo_tee_surface_index(sourcesurf, 1);
|
||||
|
||||
MOZ_ASSERT(cairo_surface_get_type(blursurf) == CAIRO_SURFACE_TYPE_IMAGE);
|
||||
Rect extents(0, 0, width, height);
|
||||
@ -403,6 +409,10 @@ DrawTargetCairo::DrawSurfaceWithShadow(SourceSurface *aSurface,
|
||||
cairo_image_surface_get_stride(blursurf),
|
||||
aSigma);
|
||||
blur.Blur();
|
||||
} else {
|
||||
blursurf = sourcesurf;
|
||||
surf = sourcesurf;
|
||||
}
|
||||
|
||||
WillChange();
|
||||
ClearSurfaceForUnboundedSource(aOperator);
|
||||
@ -792,7 +802,8 @@ DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize&
|
||||
}
|
||||
|
||||
TemporaryRef<DrawTarget>
|
||||
DrawTargetCairo::CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
|
||||
DrawTargetCairo::CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat,
|
||||
float aSigma) const
|
||||
{
|
||||
cairo_surface_t* similar = cairo_surface_create_similar(cairo_get_target(mContext),
|
||||
GfxFormatToCairoContent(aFormat),
|
||||
@ -802,6 +813,14 @@ DrawTargetCairo::CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFor
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If we don't have a blur then we can use the RGBA mask and keep all the
|
||||
// operations in graphics memory.
|
||||
if (aSigma == 0.0F) {
|
||||
RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
|
||||
target->InitAlreadyReferenced(similar, aSize);
|
||||
return target;
|
||||
}
|
||||
|
||||
cairo_surface_t* blursurf = cairo_image_surface_create(CAIRO_FORMAT_A8,
|
||||
aSize.width,
|
||||
aSize.height);
|
||||
|
@ -116,7 +116,8 @@ public:
|
||||
virtual TemporaryRef<DrawTarget>
|
||||
CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
|
||||
virtual TemporaryRef<DrawTarget>
|
||||
CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
|
||||
CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat,
|
||||
float aSigma) const;
|
||||
|
||||
virtual TemporaryRef<GradientStops>
|
||||
CreateGradientStops(GradientStop *aStops,
|
||||
|
Loading…
Reference in New Issue
Block a user