Bug 991028 - Stop using OpenDescriptor in ContentClientIncremental. r=nical

This commit is contained in:
Matt Woodrow 2014-04-07 13:32:49 +12:00
parent 75309237f6
commit 364dbbb0aa
5 changed files with 19 additions and 23 deletions

View File

@ -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<gfxContext> 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<gfxASurface> onBlack = GetUpdateSurface(BUFFER_BLACK, drawRegionCopy);
nsRefPtr<gfxASurface> onWhite = GetUpdateSurface(BUFFER_WHITE, aPaintState.mRegionToDraw);
RefPtr<DrawTarget> onBlack = GetUpdateSurface(BUFFER_BLACK, drawRegionCopy);
RefPtr<DrawTarget> 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<DrawTarget> onBlackDT = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(onBlack, onBlack->GetSize().ToIntSize());
RefPtr<DrawTarget> onWhiteDT = gfxPlatform::GetPlatform()->CreateDrawTargetForUpdateSurface(onWhite, onWhite->GetSize().ToIntSize());
mLoanedDrawTarget = Factory::CreateDualDrawTarget(onBlackDT, onWhiteDT);
mLoanedDrawTarget = Factory::CreateDualDrawTarget(onBlack, onWhite);
} else {
mLoanedDrawTarget = nullptr;
}
} else {
nsRefPtr<gfxASurface> 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<gfxASurface>
TemporaryRef<DrawTarget>
ContentClientIncremental::GetUpdateSurface(BufferType aType,
const nsIntRegion& aUpdateRegion)
{
@ -883,9 +882,6 @@ ContentClientIncremental::GetUpdateSurface(BufferType aType,
return nullptr;
}
nsRefPtr<gfxASurface> 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);
}
}

View File

@ -459,7 +459,7 @@ private:
}
already_AddRefed<gfxASurface> GetUpdateSurface(BufferType aType,
TemporaryRef<gfx::DrawTarget> GetUpdateSurface(BufferType aType,
const nsIntRegion& aUpdateRegion);
TextureInfo mTextureInfo;

View File

@ -312,7 +312,7 @@ bool
CompositorParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
SurfaceDescriptor* aOutSnapshot)
{
RefPtr<DrawTarget> target = GetDrawTargetForDescriptor(aInSnapshot);
RefPtr<DrawTarget> target = GetDrawTargetForDescriptor(aInSnapshot, gfx::BackendType::CAIRO);
ForceComposeToTarget(target);
*aOutSnapshot = aInSnapshot;
return true;

View File

@ -77,12 +77,12 @@ GetAddressFromDescriptor(const SurfaceDescriptor& aDescriptor, size_t& aSize)
}
TemporaryRef<gfx::DrawTarget>
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<gfx::DataSourceSurface>

View File

@ -72,7 +72,7 @@ bool IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface);
bool IsSurfaceDescriptorOwned(const SurfaceDescriptor& aDescriptor);
bool ReleaseOwnedSurfaceDescriptor(const SurfaceDescriptor& aDescriptor);
TemporaryRef<gfx::DrawTarget> GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor);
TemporaryRef<gfx::DrawTarget> GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor, gfx::BackendType aBackend);
TemporaryRef<gfx::DataSourceSurface> GetSurfaceForDescriptor(const SurfaceDescriptor& aDescriptor);
/**
* An interface used to create and destroy surfaces that are shared with the