From 8d73e0be6f0cece5ff163b543e77e96ff109ba83 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Thu, 3 Apr 2014 20:28:52 -0700 Subject: [PATCH] Backed out 5 changesets (bug 991032, bug 990933, bug 990876, bug 990871) for build bustage CLOSED TREE Backed out changeset c28e1344a6da (bug 991032) Backed out changeset c85326be7e94 (bug 990876) Backed out changeset 7cd1a8c883cb (bug 990876) Backed out changeset 3052e8a3c505 (bug 990933) Backed out changeset 6685770cf674 (bug 990871) --- gfx/layers/ImageContainer.cpp | 6 +- gfx/layers/RotatedBuffer.cpp | 6 +- gfx/layers/basic/TextureClientX11.cpp | 34 ++++- gfx/layers/basic/TextureClientX11.h | 40 ++++-- gfx/layers/basic/X11TextureSourceBasic.h | 6 +- gfx/layers/client/CanvasClient.cpp | 6 +- gfx/layers/client/ContentClient.cpp | 17 +-- gfx/layers/client/ImageClient.cpp | 6 +- gfx/layers/client/SimpleTextureClientPool.cpp | 2 +- .../client/SimpleTiledContentClient.cpp | 35 +++-- gfx/layers/client/TextureClient.cpp | 56 +++++++- gfx/layers/client/TextureClient.h | 126 +++++++++++------- gfx/layers/client/TextureClientPool.cpp | 2 +- gfx/layers/client/TiledContentClient.cpp | 6 +- gfx/layers/composite/X11TextureHost.h | 7 +- gfx/layers/d3d11/TextureD3D11.h | 7 +- gfx/layers/d3d9/TextureD3D9.h | 22 ++- gfx/layers/opengl/TextureClientOGL.h | 20 --- gfx/layers/opengl/X11TextureSourceOGL.h | 18 ++- gfx/tests/gtest/TestTextures.cpp | 94 ++++++------- 20 files changed, 308 insertions(+), 208 deletions(-) diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index 3fbc0816fad..9efdb9fb8c5 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -692,15 +692,15 @@ CairoImage::GetTextureClient(CompositableClient *aClient) TEXTURE_FLAGS_DEFAULT, gfx::BackendType::NONE, surface->GetSize()); - MOZ_ASSERT(textureClient->CanExposeDrawTarget()); - if (!textureClient->AllocateForSurface(surface->GetSize()) || + MOZ_ASSERT(textureClient->AsTextureClientDrawTarget()); + if (!textureClient->AsTextureClientDrawTarget()->AllocateForSurface(surface->GetSize()) || !textureClient->Lock(OPEN_WRITE_ONLY)) { return nullptr; } { // We must not keep a reference to the DrawTarget after it has been unlocked. - RefPtr dt = textureClient->GetAsDrawTarget(); + RefPtr dt = textureClient->AsTextureClientDrawTarget()->GetAsDrawTarget(); dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint()); } diff --git a/gfx/layers/RotatedBuffer.cpp b/gfx/layers/RotatedBuffer.cpp index aa864975109..67b710fa59d 100644 --- a/gfx/layers/RotatedBuffer.cpp +++ b/gfx/layers/RotatedBuffer.cpp @@ -293,7 +293,7 @@ RotatedContentBuffer::BufferContentType() SurfaceFormat format; if (mBufferProvider) { - format = mBufferProvider->GetFormat(); + format = mBufferProvider->AsTextureClientDrawTarget()->GetFormat(); } else if (mDTBuffer) { format = mDTBuffer->GetFormat(); } @@ -317,7 +317,7 @@ RotatedContentBuffer::EnsureBuffer() NS_ASSERTION(!mLoanedDrawTarget, "Loaned draw target must be returned"); if (!mDTBuffer) { if (mBufferProvider) { - mDTBuffer = mBufferProvider->GetAsDrawTarget(); + mDTBuffer = mBufferProvider->AsTextureClientDrawTarget()->GetAsDrawTarget(); } } @@ -332,7 +332,7 @@ RotatedContentBuffer::EnsureBufferOnWhite() if (!mDTBufferOnWhite) { if (mBufferProviderOnWhite) { mDTBufferOnWhite = - mBufferProviderOnWhite->GetAsDrawTarget(); + mBufferProviderOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget(); } } diff --git a/gfx/layers/basic/TextureClientX11.cpp b/gfx/layers/basic/TextureClientX11.cpp index 8fe309f3455..aba9e39be4c 100644 --- a/gfx/layers/basic/TextureClientX11.cpp +++ b/gfx/layers/basic/TextureClientX11.cpp @@ -40,7 +40,8 @@ TextureClientX11::IsAllocated() const bool TextureClientX11::Lock(OpenMode aMode) { - MOZ_ASSERT(!mLocked, "The TextureClient is already Locked!"); + // XXX - Turn this into a fatal assertion as soon as Bug 952507 is fixed + NS_WARN_IF_FALSE(!mLocked, "The TextureClient is already Locked!"); mLocked = IsValid() && IsAllocated(); return mLocked; } @@ -48,7 +49,8 @@ TextureClientX11::Lock(OpenMode aMode) void TextureClientX11::Unlock() { - MOZ_ASSERT(mLocked, "The TextureClient is already Unlocked!"); + // XXX - Turn this into a fatal assertion as soon as Bug 952507 is fixed + NS_WARN_IF_FALSE(mLocked, "The TextureClient is already Unlocked!"); mLocked = false; if (mSurface) { @@ -75,6 +77,34 @@ TextureClientX11::DropTextureData() return nullptr; } +bool +TextureClientX11::UpdateSurface(gfxASurface* aSurface) +{ + MOZ_ASSERT(IsValid()); + + RefPtr dt = GetAsDrawTarget(); + if (!dt) { + return false; + } + + RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface); + dt->CopySurface(source, IntRect(IntPoint(), GetSize()), IntPoint()); + + return true; +} + +already_AddRefed +TextureClientX11::GetAsSurface() +{ + MOZ_ASSERT(IsValid()); + if (!mSurface) { + return nullptr; + } + + nsRefPtr temp = mSurface.get(); + return temp.forget(); +} + bool TextureClientX11::AllocateForSurface(IntSize aSize, TextureAllocationFlags aTextureFlags) { diff --git a/gfx/layers/basic/TextureClientX11.h b/gfx/layers/basic/TextureClientX11.h index 6af54ff42c2..8a9c14693f5 100644 --- a/gfx/layers/basic/TextureClientX11.h +++ b/gfx/layers/basic/TextureClientX11.h @@ -7,6 +7,7 @@ #define MOZILLA_GFX_TEXTURECLIENT_X11_H #include "mozilla/layers/TextureClient.h" +#include "ISurfaceAllocator.h" // For IsSurfaceDescriptorValid #include "mozilla/layers/ShadowLayerUtilsX11.h" namespace mozilla { @@ -15,32 +16,43 @@ namespace layers { /** * A TextureClient implementation based on Xlib. */ -class TextureClientX11 : public TextureClient +class TextureClientX11 + : public TextureClient, + public TextureClientSurface, + public TextureClientDrawTarget { public: TextureClientX11(gfx::SurfaceFormat format, TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT); - ~TextureClientX11(); - virtual bool IsAllocated() const MOZ_OVERRIDE; + // TextureClient - virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; + TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; } + TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; } - virtual TextureClientData* DropTextureData() MOZ_OVERRIDE; + bool IsAllocated() const MOZ_OVERRIDE; + bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; + TextureClientData* DropTextureData() MOZ_OVERRIDE; + gfx::IntSize GetSize() const { + return mSize; + } - virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; } + bool Lock(OpenMode aMode) MOZ_OVERRIDE; + void Unlock() MOZ_OVERRIDE; + bool IsLocked() const MOZ_OVERRIDE { return mLocked; } - virtual bool Lock(OpenMode aMode) MOZ_OVERRIDE; + // TextureClientSurface - virtual void Unlock() MOZ_OVERRIDE; + bool UpdateSurface(gfxASurface* aSurface) MOZ_OVERRIDE; + already_AddRefed GetAsSurface() MOZ_OVERRIDE; + bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags flags) MOZ_OVERRIDE; - virtual bool IsLocked() const MOZ_OVERRIDE { return mLocked; } + // TextureClientDrawTarget - virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags flags) MOZ_OVERRIDE; - - virtual TemporaryRef GetAsDrawTarget() MOZ_OVERRIDE; - - virtual gfx::SurfaceFormat GetFormat() const { return mFormat; } + TemporaryRef GetAsDrawTarget() MOZ_OVERRIDE; + gfx::SurfaceFormat GetFormat() const { + return mFormat; + } virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; } diff --git a/gfx/layers/basic/X11TextureSourceBasic.h b/gfx/layers/basic/X11TextureSourceBasic.h index c578df5a4ff..45916648587 100644 --- a/gfx/layers/basic/X11TextureSourceBasic.h +++ b/gfx/layers/basic/X11TextureSourceBasic.h @@ -16,8 +16,8 @@ class BasicCompositor; // TextureSource for Xlib-backed surfaces. class X11TextureSourceBasic - : public TextureSourceBasic - , public NewTextureSource + : public TextureSourceBasic, + public NewTextureSource { public: X11TextureSourceBasic(BasicCompositor* aCompositor, gfxXlibSurface* aSurface); @@ -25,9 +25,7 @@ public: virtual X11TextureSourceBasic* AsSourceBasic() MOZ_OVERRIDE { return this; } virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; - virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE; - virtual gfx::SourceSurface* GetSurface() MOZ_OVERRIDE; virtual void DeallocateDeviceData() MOZ_OVERRIDE { } diff --git a/gfx/layers/client/CanvasClient.cpp b/gfx/layers/client/CanvasClient.cpp index aa7708bcb3b..87fd0769a80 100644 --- a/gfx/layers/client/CanvasClient.cpp +++ b/gfx/layers/client/CanvasClient.cpp @@ -68,8 +68,8 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) mBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format), flags, gfxPlatform::GetPlatform()->GetPreferredCanvasBackend()); - MOZ_ASSERT(mBuffer->CanExposeDrawTarget()); - mBuffer->AllocateForSurface(aSize); + MOZ_ASSERT(mBuffer->AsTextureClientSurface()); + mBuffer->AsTextureClientSurface()->AllocateForSurface(aSize); bufferCreated = true; } @@ -82,7 +82,7 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) { // Restrict drawTarget to a scope so that terminates before Unlock. RefPtr target = - mBuffer->GetAsDrawTarget(); + mBuffer->AsTextureClientDrawTarget()->GetAsDrawTarget(); if (target) { aLayer->UpdateTarget(target); updated = true; diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index faba0526eb4..4f60484c19b 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -177,7 +177,7 @@ ContentClientRemoteBuffer::CreateAndAllocateTextureClient(RefPtr& return false; } - if (!aClient->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) { + if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) { aClient = CreateTextureClientForDrawing(mSurfaceFormat, mTextureInfo.mTextureFlags | TEXTURE_ALLOC_FALLBACK | aFlags, gfx::BackendType::NONE, @@ -185,7 +185,7 @@ ContentClientRemoteBuffer::CreateAndAllocateTextureClient(RefPtr& if (!aClient) { return false; } - if (!aClient->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) { + if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) { NS_WARNING("Could not allocate texture client"); aClient = nullptr; return false; @@ -253,12 +253,12 @@ ContentClientRemoteBuffer::CreateBuffer(ContentType aType, DebugOnly locked = mTextureClient->Lock(OPEN_READ_WRITE); MOZ_ASSERT(locked, "Could not lock the TextureClient"); - *aBlackDT = mTextureClient->GetAsDrawTarget(); + *aBlackDT = mTextureClient->AsTextureClientDrawTarget()->GetAsDrawTarget(); if (aFlags & BUFFER_COMPONENT_ALPHA) { locked = mTextureClientOnWhite->Lock(OPEN_READ_WRITE); MOZ_ASSERT(locked, "Could not lock the second TextureClient for component alpha"); - *aWhiteDT = mTextureClientOnWhite->GetAsDrawTarget(); + *aWhiteDT = mTextureClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget(); } } @@ -457,9 +457,10 @@ ContentClientDoubleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw) // Restrict the DrawTargets and frontBuffer to a scope to make // sure there is no more external references to the DrawTargets // when we Unlock the TextureClients. - RefPtr dt = mFrontClient->GetAsDrawTarget(); + RefPtr dt = + mFrontClient->AsTextureClientDrawTarget()->GetAsDrawTarget(); RefPtr dtOnWhite = mFrontClientOnWhite - ? mFrontClientOnWhite->GetAsDrawTarget() + ? mFrontClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget() : nullptr; RotatedBuffer frontBuffer(dt, dtOnWhite, @@ -539,7 +540,7 @@ ContentClientSingleBuffered::PrepareFrame() if (!backBuffer && mTextureClient) { DebugOnly locked = mTextureClient->Lock(OPEN_READ_WRITE); MOZ_ASSERT(locked); - backBuffer = mTextureClient->GetAsDrawTarget(); + backBuffer = mTextureClient->AsTextureClientDrawTarget()->GetAsDrawTarget(); } RefPtr oldBuffer; @@ -551,7 +552,7 @@ ContentClientSingleBuffered::PrepareFrame() if (!backBuffer && mTextureClientOnWhite) { DebugOnly locked = mTextureClientOnWhite->Lock(OPEN_READ_WRITE); MOZ_ASSERT(locked); - backBuffer = mTextureClientOnWhite->GetAsDrawTarget(); + backBuffer = mTextureClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget(); } oldBuffer = SetDTBufferOnWhite(backBuffer); diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index 274c86dc7a0..82d12d902b6 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -233,8 +233,8 @@ ImageClientSingle::UpdateImageInternal(ImageContainer* aContainer, = gfxPlatform::GetPlatform()->OptimalFormatForContent(gfx::ContentForFormat(surface->GetFormat())); mFrontBuffer = CreateTextureClientForDrawing(gfx::ImageFormatToSurfaceFormat(format), mTextureFlags, gfx::BackendType::NONE, size); - MOZ_ASSERT(mFrontBuffer->CanExposeDrawTarget()); - if (!mFrontBuffer->AllocateForSurface(size)) { + MOZ_ASSERT(mFrontBuffer->AsTextureClientDrawTarget()); + if (!mFrontBuffer->AsTextureClientDrawTarget()->AllocateForSurface(size)) { mFrontBuffer = nullptr; return false; } @@ -248,7 +248,7 @@ ImageClientSingle::UpdateImageInternal(ImageContainer* aContainer, { // We must not keep a reference to the DrawTarget after it has been unlocked. - RefPtr dt = mFrontBuffer->GetAsDrawTarget(); + RefPtr dt = mFrontBuffer->AsTextureClientDrawTarget()->GetAsDrawTarget(); MOZ_ASSERT(surface.get()); dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint()); } diff --git a/gfx/layers/client/SimpleTextureClientPool.cpp b/gfx/layers/client/SimpleTextureClientPool.cpp index 354bebdc9e0..2f650f06118 100644 --- a/gfx/layers/client/SimpleTextureClientPool.cpp +++ b/gfx/layers/client/SimpleTextureClientPool.cpp @@ -77,7 +77,7 @@ SimpleTextureClientPool::GetTextureClient(bool aAutoRecycle) textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator, mFormat, TEXTURE_FLAGS_DEFAULT | TEXTURE_RECYCLE, gfx::BackendType::NONE, mSize); } - if (!textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT)) { + if (!textureClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_DEFAULT)) { NS_WARNING("TextureClient::AllocateForSurface failed!"); } RECYCLE_LOG("%s Must allocate (0 left), returning %p\n", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), textureClient.get()); diff --git a/gfx/layers/client/SimpleTiledContentClient.cpp b/gfx/layers/client/SimpleTiledContentClient.cpp index f795cb49956..cf2a8871afb 100644 --- a/gfx/layers/client/SimpleTiledContentClient.cpp +++ b/gfx/layers/client/SimpleTiledContentClient.cpp @@ -89,17 +89,19 @@ SimpleTiledLayerBuffer::ValidateTile(SimpleTiledLayerTile aTile, return SimpleTiledLayerTile(); } - if (!textureClient->Lock(OPEN_READ_WRITE)) { + if (!textureClient->Lock(OPEN_WRITE)) { NS_WARNING("TextureClient lock failed"); return SimpleTiledLayerTile(); } - if (!textureClient->CanExposeDrawTarget()) { + TextureClientSurface *textureClientSurf = textureClient->AsTextureClientSurface(); + if (!textureClientSurf) { doBufferedDrawing = false; } RefPtr drawTarget; + nsRefPtr clientAsImageSurface; unsigned char *bufferData = nullptr; // these are set/updated differently based on doBufferedDrawing @@ -107,25 +109,23 @@ SimpleTiledLayerBuffer::ValidateTile(SimpleTiledLayerTile aTile, nsIntRegion drawRegion; nsIntRegion invalidateRegion; - RefPtr srcDT; - uint8_t* srcData = nullptr; - int32_t srcStride = 0; - gfx::IntSize srcSize; - gfx::SurfaceFormat srcFormat = gfx::SurfaceFormat::UNKNOWN; - if (doBufferedDrawing) { - // try to directly access the pixels of the TextureClient - srcDT = textureClient->GetAsDrawTarget(); - if (srcDT->LockBits(&srcData, &srcSize, &srcStride, &srcFormat)) { + // try to obtain the TextureClient as an ImageSurface, so that we can + // access the pixels directly + nsRefPtr asurf = textureClientSurf->GetAsSurface(); + clientAsImageSurface = asurf ? asurf->GetAsImageSurface() : nullptr; + if (clientAsImageSurface) { + int32_t bufferStride = clientAsImageSurface->Stride(); + if (!aTile.mCachedBuffer) { - aTile.mCachedBuffer = SharedBuffer::Create(srcStride * srcSize.height); + aTile.mCachedBuffer = SharedBuffer::Create(clientAsImageSurface->GetDataSize()); fullPaint = true; } bufferData = (unsigned char*) aTile.mCachedBuffer->Data(); drawTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForData(bufferData, kTileSize, - srcStride, + bufferStride, tileFormat); if (fullPaint) { @@ -146,7 +146,7 @@ SimpleTiledLayerBuffer::ValidateTile(SimpleTiledLayerTile aTile, // this might get set above if we couldn't extract out a buffer if (!doBufferedDrawing) { - drawTarget = textureClient->GetAsDrawTarget(); + drawTarget = textureClient->AsTextureClientDrawTarget()->GetAsDrawTarget(); fullPaint = true; drawBounds = nsIntRect(aTileOrigin.x, aTileOrigin.y, GetScaledTileLength(), GetScaledTileLength()); @@ -169,15 +169,14 @@ SimpleTiledLayerBuffer::ValidateTile(SimpleTiledLayerTile aTile, mCallbackData); ctxt = nullptr; + drawTarget = nullptr; if (doBufferedDrawing) { - memcpy(srcData, bufferData, srcSize.height * srcStride); + memcpy(clientAsImageSurface->Data(), bufferData, clientAsImageSurface->GetDataSize()); + clientAsImageSurface = nullptr; bufferData = nullptr; - srcDT->ReleaseBits(srcData); - srcDT = nullptr; } - drawTarget = nullptr; textureClient->Unlock(); if (!mCompositableClient->AddTextureClient(textureClient)) { diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 155a602417f..4bf30903876 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -350,7 +350,8 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator, result = CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, aMoz2DBackend); } - MOZ_ASSERT(!result || result->CanExposeDrawTarget(), "texture cannot expose a DrawTarget?"); + MOZ_ASSERT(!result || result->AsTextureClientDrawTarget(), + "Not a TextureClientDrawTarget?"); return result; } @@ -484,12 +485,12 @@ bool TextureClient::CopyToTextureClient(TextureClient* aTarget, MOZ_ASSERT(IsLocked()); MOZ_ASSERT(aTarget->IsLocked()); - if (!aTarget->CanExposeDrawTarget() || !CanExposeDrawTarget()) { + if (!aTarget->AsTextureClientDrawTarget() || !AsTextureClientDrawTarget()) { return false; } - RefPtr destinationTarget = aTarget->GetAsDrawTarget(); - RefPtr sourceTarget = GetAsDrawTarget(); + RefPtr destinationTarget = aTarget->AsTextureClientDrawTarget()->GetAsDrawTarget(); + RefPtr sourceTarget = AsTextureClientDrawTarget()->GetAsDrawTarget(); RefPtr source = sourceTarget->Snapshot(); destinationTarget->CopySurface(source, aRect ? *aRect : gfx::IntRect(gfx::IntPoint(0, 0), GetSize()), @@ -662,6 +663,51 @@ BufferTextureClient::GetAllocator() const return mAllocator; } +bool +BufferTextureClient::UpdateSurface(gfxASurface* aSurface) +{ + MOZ_ASSERT(mLocked); + MOZ_ASSERT(aSurface); + MOZ_ASSERT(!IsImmutable()); + MOZ_ASSERT(IsValid()); + + ImageDataSerializer serializer(GetBuffer(), GetBufferSize()); + if (!serializer.IsValid()) { + return false; + } + + RefPtr dt = GetAsDrawTarget(); + RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface); + + dt->CopySurface(source, IntRect(IntPoint(), serializer.GetSize()), IntPoint()); + // XXX - if the Moz2D backend is D2D, we would be much better off memcpying + // the content of the surface directly because with D2D, GetAsDrawTarget is + // very expensive. + + if (TextureRequiresLocking(mFlags) && !ImplementsLocking()) { + // We don't have support for proper locking yet, so we'll + // have to be immutable instead. + MarkImmutable(); + } + return true; +} + +already_AddRefed +BufferTextureClient::GetAsSurface() +{ + MOZ_ASSERT(mLocked); + MOZ_ASSERT(IsValid()); + + ImageDataSerializer serializer(GetBuffer(), GetBufferSize()); + if (!serializer.IsValid()) { + return nullptr; + } + + RefPtr surf = serializer.GetAsThebesSurface(); + nsRefPtr result = surf.get(); + return result.forget(); +} + bool BufferTextureClient::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) { @@ -742,7 +788,7 @@ BufferTextureClient::Unlock() return; } - // see the comment on TextureClient::GetAsDrawTarget. + // see the comment on TextureClientDrawTarget::GetAsDrawTarget. // This DrawTarget is internal to the TextureClient and is only exposed to the // outside world between Lock() and Unlock(). This assertion checks that no outside // reference remains by the time Unlock() is called. diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index 54aef59e106..f6bc6ecb6eb 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -50,8 +50,8 @@ class BufferTextureClient; * TextureClient is the abstraction that allows us to share data between the * content and the compositor side. * TextureClient can also provide with some more "producer" facing APIs - * such as TextureClientYCbCr, that can be queried using - * AsTextureClientYCbCr(), etc. + * such as TextureClientSurface and TextureClientYCbCr, that can be queried + * using AsTextureCLientSurface(), etc. */ enum TextureAllocationFlags { @@ -59,6 +59,69 @@ enum TextureAllocationFlags { ALLOC_CLEAR_BUFFER = 1 }; +/** + * Interface for TextureClients that can be updated using a gfxASurface. + */ +class TextureClientSurface +{ +public: + virtual bool UpdateSurface(gfxASurface* aSurface) = 0; + virtual already_AddRefed GetAsSurface() = 0; + /** + * Allocates for a given surface size, taking into account the pixel format + * which is part of the state of the TextureClient. + * + * Does not clear the surface by default, clearing the surface can be done + * by passing the CLEAR_BUFFER flag. + */ + virtual bool AllocateForSurface(gfx::IntSize aSize, + TextureAllocationFlags flags = ALLOC_DEFAULT) = 0; +}; + +/** + * Interface for TextureClients that can be updated using a DrawTarget. + */ +class TextureClientDrawTarget +{ +public: + /** + * Returns a DrawTarget to draw into the TextureClient. + * + * This must never be called on a TextureClient that is not sucessfully locked. + * When called several times within one Lock/Unlock pair, this method should + * return the same DrawTarget. + * The DrawTarget is automatically flushed by the TextureClient when the latter + * is unlocked, and the DrawTarget that will be returned within the next + * lock/unlock pair may or may not be the same object. + * Do not keep references to the DrawTarget outside of the lock/unlock pair. + * + * This is typically used as follows: + * + * if (!texture->Lock(OPEN_READ_WRITE)) { + * return false; + * } + * { + * // Restrict this code's scope to ensure all references to dt are gone + * // when Unlock is called. + * RefPtr dt = texture->AsTextureClientDrawTarget()->GetAsDrawTarget(); + * // use the draw target ... + * } + * texture->Unlock(); + * + */ + virtual TemporaryRef GetAsDrawTarget() = 0; + virtual gfx::SurfaceFormat GetFormat() const = 0; + /** + * Allocates for a given surface size, taking into account the pixel format + * which is part of the state of the TextureClient. + * + * Does not clear the surface by default, clearing the surface can be done + * by passing the CLEAR_BUFFER flag. + */ + virtual bool AllocateForSurface(gfx::IntSize aSize, + TextureAllocationFlags flags = ALLOC_DEFAULT) = 0; +}; + /** * Interface for TextureClients that can be updated using YCbCr data. */ @@ -149,6 +212,8 @@ public: gfx::BackendType aMoz2dBackend, const gfx::IntSize& aSizeHint); + virtual TextureClientSurface* AsTextureClientSurface() { return nullptr; } + virtual TextureClientDrawTarget* AsTextureClientDrawTarget() { return nullptr; } virtual TextureClientYCbCr* AsTextureClientYCbCr() { return nullptr; } /** @@ -163,47 +228,6 @@ public: virtual bool IsLocked() const = 0; - virtual bool CanExposeDrawTarget() const { return false; } - - /** - * Returns a DrawTarget to draw into the TextureClient. - * - * This must never be called on a TextureClient that is not sucessfully locked. - * When called several times within one Lock/Unlock pair, this method should - * return the same DrawTarget. - * The DrawTarget is automatically flushed by the TextureClient when the latter - * is unlocked, and the DrawTarget that will be returned within the next - * lock/unlock pair may or may not be the same object. - * Do not keep references to the DrawTarget outside of the lock/unlock pair. - * - * This is typically used as follows: - * - * if (!texture->Lock(OPEN_READ_WRITE)) { - * return false; - * } - * { - * // Restrict this code's scope to ensure all references to dt are gone - * // when Unlock is called. - * RefPtr dt = texture->GetAsDrawTarget(); - * // use the draw target ... - * } - * texture->Unlock(); - * - */ - virtual TemporaryRef GetAsDrawTarget() { return nullptr; } - - virtual gfx::SurfaceFormat GetFormat() const = 0; - - /** - * Allocates for a given surface size, taking into account the pixel format - * which is part of the state of the TextureClient. - * - * Does not clear the surface by default, clearing the surface can be done - * by passing the CLEAR_BUFFER flag. - */ - virtual bool AllocateForSurface(gfx::IntSize aSize, - TextureAllocationFlags flags = ALLOC_DEFAULT) = 0; - /** * Copies a rectangle from this texture client to a position in aTarget. * It is assumed that the necessary locks are in place; so this should at @@ -372,7 +396,9 @@ protected: * (see ShmemTextureClient and MemoryTextureClient) */ class BufferTextureClient : public TextureClient + , public TextureClientSurface , public TextureClientYCbCr + , public TextureClientDrawTarget { public: BufferTextureClient(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat, @@ -394,13 +420,23 @@ public: virtual bool IsLocked() const MOZ_OVERRIDE { return mLocked; } - virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; } + // TextureClientSurface - virtual TemporaryRef GetAsDrawTarget() MOZ_OVERRIDE; + virtual TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; } + + virtual bool UpdateSurface(gfxASurface* aSurface) MOZ_OVERRIDE; + + virtual already_AddRefed GetAsSurface() MOZ_OVERRIDE; virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE; + // TextureClientDrawTarget + + virtual TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; } + + virtual TemporaryRef GetAsDrawTarget() MOZ_OVERRIDE; + // TextureClientYCbCr virtual TextureClientYCbCr* AsTextureClientYCbCr() MOZ_OVERRIDE { return this; } diff --git a/gfx/layers/client/TextureClientPool.cpp b/gfx/layers/client/TextureClientPool.cpp index ed5a7536e1c..ecf2b5c1708 100644 --- a/gfx/layers/client/TextureClientPool.cpp +++ b/gfx/layers/client/TextureClientPool.cpp @@ -62,7 +62,7 @@ TextureClientPool::GetTextureClient() textureClient = TextureClient::CreateTextureClientForDrawing(mSurfaceAllocator, mFormat, TEXTURE_IMMEDIATE_UPLOAD, gfx::BackendType::NONE, mSize); } - textureClient->AllocateForSurface(mSize, ALLOC_DEFAULT); + textureClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_DEFAULT); return textureClient; } diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index effd2e549db..a08841b4b0d 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -472,7 +472,7 @@ TileClient::DiscardFrontBuffer() { if (mFrontBuffer) { MOZ_ASSERT(mFrontLock); - mManager->GetTexturePool(mFrontBuffer->GetFormat())->ReturnTextureClientDeferred(mFrontBuffer); + mManager->GetTexturePool(mFrontBuffer->AsTextureClientDrawTarget()->GetFormat())->ReturnTextureClientDeferred(mFrontBuffer); mFrontLock->ReadUnlock(); mFrontBuffer = nullptr; mFrontLock = nullptr; @@ -484,7 +484,7 @@ TileClient::DiscardBackBuffer() { if (mBackBuffer) { MOZ_ASSERT(mBackLock); - mManager->GetTexturePool(mBackBuffer->GetFormat())->ReturnTextureClient(mBackBuffer); + mManager->GetTexturePool(mBackBuffer->AsTextureClientDrawTarget()->GetFormat())->ReturnTextureClient(mBackBuffer); mBackLock->ReadUnlock(); mBackBuffer = nullptr; mBackLock = nullptr; @@ -750,7 +750,7 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile, // We must not keep a reference to the DrawTarget after it has been unlocked, // make sure these are null'd before unlocking as destruction of the context // may cause the target to be flushed. - RefPtr drawTarget = backBuffer->GetAsDrawTarget(); + RefPtr drawTarget = backBuffer->AsTextureClientDrawTarget()->GetAsDrawTarget(); drawTarget->SetTransform(Matrix()); RefPtr ctxt = new gfxContext(drawTarget); diff --git a/gfx/layers/composite/X11TextureHost.h b/gfx/layers/composite/X11TextureHost.h index 352a09f91f4..68e8d9a8310 100644 --- a/gfx/layers/composite/X11TextureHost.h +++ b/gfx/layers/composite/X11TextureHost.h @@ -8,14 +8,14 @@ #include "mozilla/layers/TextureHost.h" #include "mozilla/layers/LayersSurfaces.h" -#include "mozilla/gfx/Types.h" +#include "mozilla/gfx/2D.h" class gfxXlibSurface; namespace mozilla { namespace layers { -// TextureHost for Xlib-backed TextureSources. +// TextureSource for Xlib-backed TextureSources. class X11TextureHost : public TextureHost { public: @@ -23,11 +23,8 @@ public: const SurfaceDescriptorX11& aDescriptor); virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; - virtual bool Lock() MOZ_OVERRIDE; - virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE; - virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index 9a22ec151c2..4a921c4d622 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -25,7 +25,8 @@ class CompositorD3D11; * A TextureClient to share a D3D10 texture with the compositor thread. * The corresponding TextureHost is DXGITextureHostD3D11 */ -class TextureClientD3D11 : public TextureClient +class TextureClientD3D11 : public TextureClient, + public TextureClientDrawTarget { public: TextureClientD3D11(gfx::SurfaceFormat aFormat, TextureFlags aFlags); @@ -52,9 +53,11 @@ public: virtual TextureClientData* DropTextureData() MOZ_OVERRIDE { return nullptr; } + // TextureClientDrawTarget + virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } - virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; } + virtual TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; } virtual TemporaryRef GetAsDrawTarget() MOZ_OVERRIDE; diff --git a/gfx/layers/d3d9/TextureD3D9.h b/gfx/layers/d3d9/TextureD3D9.h index 8906ae2d9da..0c4c4f63760 100644 --- a/gfx/layers/d3d9/TextureD3D9.h +++ b/gfx/layers/d3d9/TextureD3D9.h @@ -185,6 +185,7 @@ protected: * The corresponding TextureHost is TextureHostD3D9. */ class CairoTextureClientD3D9 : public TextureClient + , public TextureClientDrawTarget { public: CairoTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags); @@ -209,6 +210,10 @@ public: virtual TextureClientData* DropTextureData() MOZ_OVERRIDE; + // TextureClientDrawTarget + + virtual TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; } + virtual TemporaryRef GetAsDrawTarget() MOZ_OVERRIDE; virtual bool AllocateForSurface(gfx::IntSize aSize, @@ -234,6 +239,7 @@ private: * The coresponding TextureHost is DIBTextureHostD3D9. */ class DIBTextureClientD3D9 : public TextureClient + , public TextureClientDrawTarget { public: DIBTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags); @@ -258,7 +264,9 @@ public: virtual TextureClientData* DropTextureData() MOZ_OVERRIDE; - virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; } + // TextureClientDrawTarget + + virtual TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; } virtual TemporaryRef GetAsDrawTarget() MOZ_OVERRIDE; @@ -314,16 +322,6 @@ public: virtual TextureClientData* DropTextureData() MOZ_OVERRIDE; - virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE - { - return gfx::SurfaceFormat::UNKNOWN; - } - - virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE - { - return false; - } - private: RefPtr mTexture; gfx::SurfaceFormat mFormat; @@ -395,8 +393,6 @@ public: virtual void Updated(const nsIntRegion* aRegion = nullptr); - virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; } - virtual TemporaryRef GetAsSurface() MOZ_OVERRIDE { return nullptr; // TODO: cf bug 872568 diff --git a/gfx/layers/opengl/TextureClientOGL.h b/gfx/layers/opengl/TextureClientOGL.h index 903059c1ab0..9d617001235 100644 --- a/gfx/layers/opengl/TextureClientOGL.h +++ b/gfx/layers/opengl/TextureClientOGL.h @@ -64,16 +64,6 @@ public: return nullptr; } - virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE - { - return gfx::SurfaceFormat::UNKNOWN; - } - - virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE - { - return false; - } - protected: gl::SharedTextureHandle mHandle; gfx::IntSize mSize; @@ -110,16 +100,6 @@ public: virtual gfx::IntSize GetSize() const { return gfx::IntSize(); } - virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE - { - return gfx::SurfaceFormat::UNKNOWN; - } - - virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE - { - return false; - } - protected: bool mIsLocked; RefPtr mStream; diff --git a/gfx/layers/opengl/X11TextureSourceOGL.h b/gfx/layers/opengl/X11TextureSourceOGL.h index 5032b2c48ae..7fe0ff605ce 100644 --- a/gfx/layers/opengl/X11TextureSourceOGL.h +++ b/gfx/layers/opengl/X11TextureSourceOGL.h @@ -16,8 +16,8 @@ namespace layers { // TextureSource for Xlib-backed surfaces. class X11TextureSourceOGL - : public TextureSourceOGL - , public NewTextureSource + : public TextureSourceOGL, + public NewTextureSource { public: X11TextureSourceOGL(CompositorOGL* aCompositor, gfxXlibSurface* aSurface); @@ -26,23 +26,21 @@ public: virtual X11TextureSourceOGL* AsSourceOGL() MOZ_OVERRIDE { return this; } virtual bool IsValid() const MOZ_OVERRIDE { return !!gl(); } ; - virtual void BindTexture(GLenum aTextureUnit, gfx::Filter aFilter) MOZ_OVERRIDE; - virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; - - virtual GLenum GetTextureTarget() const MOZ_OVERRIDE { return LOCAL_GL_TEXTURE_2D; } - + virtual GLenum GetTextureTarget() const MOZ_OVERRIDE { + return LOCAL_GL_TEXTURE_2D; + } virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE; - - virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; } + virtual GLenum GetWrapMode() const MOZ_OVERRIDE { + return LOCAL_GL_CLAMP_TO_EDGE; + } virtual void DeallocateDeviceData() MOZ_OVERRIDE; virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; gl::GLContext* gl() const; - static gfx::SurfaceFormat ContentTypeToSurfaceFormat(gfxContentType aType); protected: diff --git a/gfx/tests/gtest/TestTextures.cpp b/gfx/tests/gtest/TestTextures.cpp index 4f854ade345..c67686d6bfb 100644 --- a/gfx/tests/gtest/TestTextures.cpp +++ b/gfx/tests/gtest/TestTextures.cpp @@ -9,7 +9,8 @@ #include "mozilla/layers/TextureClient.h" #include "mozilla/layers/TextureHost.h" #include "gfx2DGlue.h" -#include "mozilla/gfx/Tools.h" +#include "gfxImageSurface.h" +#include "gfxTypes.h" #include "ImageContainer.h" #include "mozilla/layers/YCbCrImageDataSerializer.h" @@ -31,14 +32,13 @@ using namespace mozilla::layers; // fills the surface with values betwee 0 and 100. -void SetupSurface(gfx::DataSourceSurface* surface) { - uint8_t* data = surface->GetData(); - gfx::IntSize size = surface->GetSize(); - uint32_t stride = surface->Stride(); - int bpp = gfx::BytesPerPixel(surface->GetFormat()); +void SetupSurface(gfxImageSurface* surface) { + int bpp = gfxASurface::BytePerPixelFromFormat(surface->Format()); + int stride = surface->Stride(); uint8_t val = 0; - for (int y = 0; y < size.width; ++y) { - for (int x = 0; x < size.height; ++x) { + uint8_t* data = surface->Data(); + for (int y = 0; y < surface->Height(); ++y) { + for (int x = 0; x < surface->Height(); ++x) { for (int b = 0; b < bpp; ++b) { data[y*stride + x*bpp + b] = val; if (val == 100) { @@ -52,20 +52,20 @@ void SetupSurface(gfx::DataSourceSurface* surface) { } // return true if two surfaces contain the same data -void AssertSurfacesEqual(gfx::DataSourceSurface* surface1, - gfx::DataSourceSurface* surface2) +void AssertSurfacesEqual(gfxImageSurface* surface1, + gfxImageSurface* surface2) { ASSERT_EQ(surface1->GetSize(), surface2->GetSize()); - ASSERT_EQ(surface1->GetFormat(), surface2->GetFormat()); + ASSERT_EQ(surface1->Format(), surface2->Format()); - uint8_t* data1 = surface1->GetData(); - uint8_t* data2 = surface2->GetData(); + uint8_t* data1 = surface1->Data(); + uint8_t* data2 = surface2->Data(); int stride1 = surface1->Stride(); int stride2 = surface2->Stride(); - int bpp = gfx::BytesPerPixel(surface1->GetFormat()); + int bpp = gfxASurface::BytePerPixelFromFormat(surface1->Format()); - for (int y = 0; y < surface1->GetSize().height; ++y) { - for (int x = 0; x < surface1->GetSize().width; ++x) { + for (int y = 0; y < surface1->Height(); ++y) { + for (int x = 0; x < surface1->Width(); ++x) { for (int b = 0; b < bpp; ++b) { ASSERT_EQ(data1[y*stride1 + x*bpp + b], data2[y*stride2 + x*bpp + b]); @@ -100,18 +100,22 @@ void AssertYCbCrSurfacesEqual(PlanarYCbCrData* surface1, } // Run the test for a texture client and a surface -void TestTextureClientSurface(TextureClient* texture, gfx::DataSourceSurface* surface) { +void TestTextureClientSurface(TextureClient* texture, gfxImageSurface* surface) { // client allocation - ASSERT_TRUE(texture->CanExposeDrawTarget()); - texture->AllocateForSurface(surface->GetSize()); + ASSERT_TRUE(texture->AsTextureClientSurface() != nullptr); + TextureClientSurface* client = texture->AsTextureClientSurface(); + client->AllocateForSurface(ToIntSize(surface->GetSize())); ASSERT_TRUE(texture->IsAllocated()); ASSERT_TRUE(texture->Lock(OPEN_READ_WRITE)); // client painting - RefPtr dt = texture->GetAsDrawTarget(); - dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint()); - dt = nullptr; + client->UpdateSurface(surface); + + nsRefPtr aSurface = client->GetAsSurface(); + nsRefPtr clientSurface = aSurface->GetAsImageSurface(); + + AssertSurfacesEqual(surface, clientSurface); texture->Unlock(); // client serialization @@ -130,9 +134,14 @@ void TestTextureClientSurface(TextureClient* texture, gfx::DataSourceSurface* su // host read ASSERT_TRUE(host->Lock()); RefPtr hostDataSurface = host->GetAsSurface(); - AssertSurfacesEqual(surface, hostDataSurface); - host->Unlock(); + + nsRefPtr hostSurface = + new gfxImageSurface(hostDataSurface->GetData(), + ThebesIntSize(hostDataSurface->GetSize()), + hostDataSurface->Stride(), + SurfaceFormatToImageFormat(hostDataSurface->GetFormat())); + AssertSurfacesEqual(surface, hostSurface.get()); } // Same as above, for YCbCr surfaces @@ -196,21 +205,20 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) { TEST(Layers, TextureSerialization) { // the test is run on all the following image formats - gfx::SurfaceFormat formats[3] = { - gfx::SurfaceFormat::B8G8R8A8, - gfx::SurfaceFormat::R8G8B8X8, - gfx::SurfaceFormat::A8, + gfxImageFormat formats[3] = { + gfxImageFormat::ARGB32, + gfxImageFormat::RGB24, + gfxImageFormat::A8, }; for (int f = 0; f < 3; ++f) { - RefPtr surface = - gfx::Factory::CreateDataSourceSurface(gfx::IntSize(400,300), formats[f]); - SetupSurface(surface); + RefPtr surface = new gfxImageSurface(gfxIntSize(400,300), formats[f]); + SetupSurface(surface.get()); AssertSurfacesEqual(surface, surface); RefPtr client = new MemoryTextureClient(nullptr, - surface->GetFormat(), + mozilla::gfx::ImageFormatToSurfaceFormat(surface->Format()), gfx::BackendType::CAIRO, TEXTURE_DEALLOCATE_CLIENT); @@ -221,24 +229,20 @@ TEST(Layers, TextureSerialization) { } TEST(Layers, TextureYCbCrSerialization) { - RefPtr ySurface = gfx::Factory::CreateDataSourceSurface( - IntSize(400,300), gfx::SurfaceFormat::A8); - RefPtr cbSurface = gfx::Factory::CreateDataSourceSurface( - IntSize(200,150), gfx::SurfaceFormat::A8); - RefPtr crSurface = gfx::Factory::CreateDataSourceSurface( - IntSize(200,150), gfx::SurfaceFormat::A8); - + RefPtr ySurface = new gfxImageSurface(gfxIntSize(400,300), gfxImageFormat::A8); + RefPtr cbSurface = new gfxImageSurface(gfxIntSize(200,150), gfxImageFormat::A8); + RefPtr crSurface = new gfxImageSurface(gfxIntSize(200,150), gfxImageFormat::A8); SetupSurface(ySurface.get()); SetupSurface(cbSurface.get()); SetupSurface(crSurface.get()); PlanarYCbCrData clientData; - clientData.mYChannel = ySurface->GetData(); - clientData.mCbChannel = cbSurface->GetData(); - clientData.mCrChannel = crSurface->GetData(); - clientData.mYSize = ySurface->GetSize(); - clientData.mPicSize = ySurface->GetSize(); - clientData.mCbCrSize = cbSurface->GetSize(); + clientData.mYChannel = ySurface->Data(); + clientData.mCbChannel = cbSurface->Data(); + clientData.mCrChannel = crSurface->Data(); + clientData.mYSize = ySurface->GetSize().ToIntSize(); + clientData.mPicSize = ySurface->GetSize().ToIntSize(); + clientData.mCbCrSize = cbSurface->GetSize().ToIntSize(); clientData.mYStride = ySurface->Stride(); clientData.mCbCrStride = cbSurface->Stride(); clientData.mStereoMode = StereoMode::MONO;