diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 4f60484c19b..4bc84f6b3be 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -572,14 +572,16 @@ WrapRotationAxis(int32_t* aRotationPoint, int32_t aSize) } static void -FillSurface(gfxASurface* aSurface, const nsIntRegion& aRegion, +FillSurface(DrawTarget* aDT, const nsIntRegion& aRegion, const nsIntPoint& aOffset, const gfxRGBA& aColor) { - nsRefPtr ctx = new gfxContext(aSurface); - ctx->Translate(-gfxPoint(aOffset.x, aOffset.y)); - gfxUtils::ClipToRegion(ctx, aRegion); - ctx->SetColor(aColor); - ctx->Paint(); + nsIntRegionRectIterator iter(aRegion); + const nsIntRect* r; + while ((r = iter.Next()) != nullptr) { + aDT->FillRect(Rect(r->x - aOffset.x, r->y - aOffset.y, + r->width, r->height), + ColorPattern(ToColor(aColor))); + } } RotatedContentBuffer::PaintState @@ -799,22 +801,19 @@ ContentClientIncremental::BorrowDrawTargetForPainting(ThebesLayer* aLayer, // if it wants more to be repainted than we request. if (aPaintState.mMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) { nsIntRegion drawRegionCopy = aPaintState.mRegionToDraw; - nsRefPtr onBlack = GetUpdateSurface(BUFFER_BLACK, drawRegionCopy); - nsRefPtr onWhite = GetUpdateSurface(BUFFER_WHITE, aPaintState.mRegionToDraw); + RefPtr onBlack = GetUpdateSurface(BUFFER_BLACK, drawRegionCopy); + RefPtr onWhite = GetUpdateSurface(BUFFER_WHITE, aPaintState.mRegionToDraw); if (onBlack && onWhite) { NS_ASSERTION(aPaintState.mRegionToDraw == drawRegionCopy, "BeginUpdate should always modify the draw region in the same way!"); FillSurface(onBlack, aPaintState.mRegionToDraw, nsIntPoint(drawBounds.x, drawBounds.y), gfxRGBA(0.0, 0.0, 0.0, 1.0)); FillSurface(onWhite, aPaintState.mRegionToDraw, nsIntPoint(drawBounds.x, drawBounds.y), gfxRGBA(1.0, 1.0, 1.0, 1.0)); - RefPtr onBlackDT = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(onBlack, onBlack->GetSize().ToIntSize()); - RefPtr onWhiteDT = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(onWhite, onWhite->GetSize().ToIntSize()); - mLoanedDrawTarget = Factory::CreateDualDrawTarget(onBlackDT, onWhiteDT); + mLoanedDrawTarget = Factory::CreateDualDrawTarget(onBlack, onWhite); } else { mLoanedDrawTarget = nullptr; } } else { - nsRefPtr surf = GetUpdateSurface(BUFFER_BLACK, aPaintState.mRegionToDraw); - mLoanedDrawTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(surf, surf->GetSize().ToIntSize()); + mLoanedDrawTarget = GetUpdateSurface(BUFFER_BLACK, aPaintState.mRegionToDraw); } if (!mLoanedDrawTarget) { NS_WARNING("unable to get context for update"); @@ -866,7 +865,7 @@ ContentClientIncremental::Updated(const nsIntRegion& aRegionToDraw, } -already_AddRefed +TemporaryRef ContentClientIncremental::GetUpdateSurface(BufferType aType, const nsIntRegion& aUpdateRegion) { @@ -883,9 +882,6 @@ ContentClientIncremental::GetUpdateSurface(BufferType aType, return nullptr; } - nsRefPtr tmpASurface = - ShadowLayerForwarder::OpenDescriptor(OPEN_READ_WRITE, desc); - if (aType == BUFFER_BLACK) { MOZ_ASSERT(!IsSurfaceDescriptorValid(mUpdateDescriptor)); mUpdateDescriptor = desc; @@ -895,7 +891,7 @@ ContentClientIncremental::GetUpdateSurface(BufferType aType, mUpdateDescriptorOnWhite = desc; } - return tmpASurface.forget(); + return GetDrawTargetForDescriptor(desc, gfx::BackendType::COREGRAPHICS); } } diff --git a/gfx/layers/client/ContentClient.h b/gfx/layers/client/ContentClient.h index 9e784004c59..a395cdb9760 100644 --- a/gfx/layers/client/ContentClient.h +++ b/gfx/layers/client/ContentClient.h @@ -459,7 +459,7 @@ private: } - already_AddRefed GetUpdateSurface(BufferType aType, + TemporaryRef GetUpdateSurface(BufferType aType, const nsIntRegion& aUpdateRegion); TextureInfo mTextureInfo; diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index b3bf35ec6d9..f892265153d 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -312,7 +312,7 @@ bool CompositorParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, SurfaceDescriptor* aOutSnapshot) { - RefPtr target = GetDrawTargetForDescriptor(aInSnapshot); + RefPtr target = GetDrawTargetForDescriptor(aInSnapshot, gfx::BackendType::CAIRO); ForceComposeToTarget(target); *aOutSnapshot = aInSnapshot; return true; diff --git a/gfx/layers/ipc/ISurfaceAllocator.cpp b/gfx/layers/ipc/ISurfaceAllocator.cpp index 0ed39a636d0..cacb495df5c 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.cpp +++ b/gfx/layers/ipc/ISurfaceAllocator.cpp @@ -77,12 +77,12 @@ GetAddressFromDescriptor(const SurfaceDescriptor& aDescriptor, size_t& aSize) } TemporaryRef -GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor) +GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor, gfx::BackendType aBackend) { size_t size; uint8_t* data = GetAddressFromDescriptor(aDescriptor, size); ImageDataDeserializer image(data, size); - return image.GetAsDrawTarget(gfx::BackendType::CAIRO); + return image.GetAsDrawTarget(aBackend); } TemporaryRef diff --git a/gfx/layers/ipc/ISurfaceAllocator.h b/gfx/layers/ipc/ISurfaceAllocator.h index 0852533bfd3..5a2813d1078 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.h +++ b/gfx/layers/ipc/ISurfaceAllocator.h @@ -72,7 +72,7 @@ bool IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface); bool IsSurfaceDescriptorOwned(const SurfaceDescriptor& aDescriptor); bool ReleaseOwnedSurfaceDescriptor(const SurfaceDescriptor& aDescriptor); -TemporaryRef GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor); +TemporaryRef GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor, gfx::BackendType aBackend); TemporaryRef GetSurfaceForDescriptor(const SurfaceDescriptor& aDescriptor); /** * An interface used to create and destroy surfaces that are shared with the