From 29d87378326a5a758f2d1fb032652070e2dc5176 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Mon, 7 Apr 2014 13:32:48 +1200 Subject: [PATCH] Bug 991028 - Remove AutoOpenSurface. r=nical --- gfx/layers/ImageDataSerializer.h | 1 + gfx/layers/basic/AutoMaskData.h | 10 +--- gfx/layers/basic/BasicCompositor.cpp | 1 - gfx/layers/basic/BasicImageLayer.cpp | 6 +- gfx/layers/basic/BasicImplData.h | 3 +- gfx/layers/basic/BasicLayersImpl.cpp | 27 ++------- gfx/layers/basic/BasicLayersImpl.h | 1 - gfx/layers/client/ClientLayerManager.cpp | 9 ++- gfx/layers/composite/ContentHost.cpp | 14 +---- gfx/layers/d3d11/TextureD3D11.cpp | 1 - gfx/layers/d3d9/CanvasLayerD3D9.cpp | 1 - gfx/layers/d3d9/ImageLayerD3D9.cpp | 1 - gfx/layers/d3d9/TextureD3D9.cpp | 1 - gfx/layers/d3d9/ThebesLayerD3D9.cpp | 2 - gfx/layers/ipc/AutoOpenSurface.h | 73 ------------------------ gfx/layers/ipc/CompositableForwarder.h | 1 - gfx/layers/ipc/CompositorParent.cpp | 8 +-- gfx/layers/ipc/ISurfaceAllocator.cpp | 37 ++++++++++++ gfx/layers/ipc/ISurfaceAllocator.h | 6 ++ gfx/layers/ipc/ShadowLayers.cpp | 73 ------------------------ gfx/layers/ipc/ShadowLayers.h | 2 - gfx/layers/opengl/TextureHostOGL.cpp | 1 - 22 files changed, 61 insertions(+), 218 deletions(-) delete mode 100644 gfx/layers/ipc/AutoOpenSurface.h diff --git a/gfx/layers/ImageDataSerializer.h b/gfx/layers/ImageDataSerializer.h index 78dce50740e2..90567925bdfa 100644 --- a/gfx/layers/ImageDataSerializer.h +++ b/gfx/layers/ImageDataSerializer.h @@ -89,6 +89,7 @@ public: { Validate(); } + }; } // namespace layers diff --git a/gfx/layers/basic/AutoMaskData.h b/gfx/layers/basic/AutoMaskData.h index d3917db72a3f..f9cfc54f57cc 100644 --- a/gfx/layers/basic/AutoMaskData.h +++ b/gfx/layers/basic/AutoMaskData.h @@ -14,12 +14,8 @@ namespace layers { /** * Drawing with a mask requires a mask surface and a transform. - * Sometimes the mask surface is a direct gfxASurface, but other times - * it's a SurfaceDescriptor. For SurfaceDescriptor, we need to use a - * scoped AutoOpenSurface to get a gfxASurface for the - * SurfaceDescriptor. * - * This helper class manages the gfxASurface-or-SurfaceDescriptor + * This helper class manages the gfxASurface * logic. */ class MOZ_STACK_CLASS AutoMaskData { @@ -37,9 +33,6 @@ public: void Construct(const gfx::Matrix& aTransform, gfxASurface* aSurface); - void Construct(const gfx::Matrix& aTransform, - const SurfaceDescriptor& aSurface); - /** The returned surface can't escape the scope of |this|. */ gfxASurface* GetSurface(); const gfx::Matrix& GetTransform(); @@ -49,7 +42,6 @@ private: gfx::Matrix mTransform; nsRefPtr mSurface; - Maybe mSurfaceOpener; AutoMaskData(const AutoMaskData&) MOZ_DELETE; AutoMaskData& operator=(const AutoMaskData&) MOZ_DELETE; diff --git a/gfx/layers/basic/BasicCompositor.cpp b/gfx/layers/basic/BasicCompositor.cpp index 629152f48915..a85fce43cc00 100644 --- a/gfx/layers/basic/BasicCompositor.cpp +++ b/gfx/layers/basic/BasicCompositor.cpp @@ -5,7 +5,6 @@ #include "BasicCompositor.h" #include "TextureHostBasic.h" -#include "ipc/AutoOpenSurface.h" #include "mozilla/layers/Effects.h" #include "mozilla/layers/YCbCrImageDataSerializer.h" #include "nsIWidget.h" diff --git a/gfx/layers/basic/BasicImageLayer.cpp b/gfx/layers/basic/BasicImageLayer.cpp index 07835bd7fb9e..372ad7790b90 100644 --- a/gfx/layers/basic/BasicImageLayer.cpp +++ b/gfx/layers/basic/BasicImageLayer.cpp @@ -53,8 +53,7 @@ public: virtual void Paint(DrawTarget* aDT, Layer* aMaskLayer) MOZ_OVERRIDE; - virtual bool GetAsSurface(gfxASurface** aSurface, - SurfaceDescriptor* aDescriptor); + virtual bool GetAsSurface(gfxASurface** aSurface); virtual TemporaryRef GetAsSourceSurface() MOZ_OVERRIDE; protected: @@ -134,8 +133,7 @@ BasicImageLayer::GetAndPaintCurrentImage(DrawTarget* aTarget, } bool -BasicImageLayer::GetAsSurface(gfxASurface** aSurface, - SurfaceDescriptor* aDescriptor) +BasicImageLayer::GetAsSurface(gfxASurface** aSurface) { if (!mContainer) { return false; diff --git a/gfx/layers/basic/BasicImplData.h b/gfx/layers/basic/BasicImplData.h index cf256c008ce5..b112c0ca6160 100644 --- a/gfx/layers/basic/BasicImplData.h +++ b/gfx/layers/basic/BasicImplData.h @@ -117,8 +117,7 @@ public: * return false if a surface cannot be created. If true is * returned, only one of |aSurface| or |aDescriptor| is valid. */ - virtual bool GetAsSurface(gfxASurface** aSurface, - SurfaceDescriptor* aDescriptor) + virtual bool GetAsSurface(gfxASurface** aSurface) { return false; } virtual TemporaryRef GetAsSourceSurface() { return nullptr; } diff --git a/gfx/layers/basic/BasicLayersImpl.cpp b/gfx/layers/basic/BasicLayersImpl.cpp index 2551a9c2d6be..aaad410044f8 100644 --- a/gfx/layers/basic/BasicLayersImpl.cpp +++ b/gfx/layers/basic/BasicLayersImpl.cpp @@ -27,23 +27,11 @@ AutoMaskData::Construct(const gfx::Matrix& aTransform, mSurface = aSurface; } -void -AutoMaskData::Construct(const gfx::Matrix& aTransform, - const SurfaceDescriptor& aSurface) -{ - MOZ_ASSERT(!IsConstructed()); - mTransform = aTransform; - mSurfaceOpener.construct(OPEN_READ_ONLY, aSurface); -} - gfxASurface* AutoMaskData::GetSurface() { MOZ_ASSERT(IsConstructed()); - if (mSurface) { - return mSurface.get(); - } - return mSurfaceOpener.ref().Get(); + return mSurface.get(); } const gfx::Matrix& @@ -56,7 +44,7 @@ AutoMaskData::GetTransform() bool AutoMaskData::IsConstructed() { - return !!mSurface || !mSurfaceOpener.empty(); + return !!mSurface; } bool @@ -64,19 +52,14 @@ GetMaskData(Layer* aMaskLayer, AutoMaskData* aMaskData) { if (aMaskLayer) { nsRefPtr surface; - SurfaceDescriptor descriptor; if (static_cast(aMaskLayer->ImplData()) - ->GetAsSurface(getter_AddRefs(surface), &descriptor) && - (surface || IsSurfaceDescriptorValid(descriptor))) { + ->GetAsSurface(getter_AddRefs(surface)) && + surface) { Matrix transform; Matrix4x4 effectiveTransform = aMaskLayer->GetEffectiveTransform(); DebugOnly maskIs2D = effectiveTransform.CanDraw2D(&transform); NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!"); - if (surface) { - aMaskData->Construct(transform, surface); - } else { - aMaskData->Construct(transform, descriptor); - } + aMaskData->Construct(transform, surface); return true; } } diff --git a/gfx/layers/basic/BasicLayersImpl.h b/gfx/layers/basic/BasicLayersImpl.h index a9130460af63..e54fcead8c60 100644 --- a/gfx/layers/basic/BasicLayersImpl.h +++ b/gfx/layers/basic/BasicLayersImpl.h @@ -11,7 +11,6 @@ #include "ReadbackLayer.h" // for ReadbackLayer #include "gfxASurface.h" // for gfxASurface #include "gfxContext.h" // for gfxContext, etc -#include "ipc/AutoOpenSurface.h" // for AutoOpenSurface #include "mozilla/Attributes.h" // for MOZ_DELETE, MOZ_STACK_CLASS #include "mozilla/Maybe.h" // for Maybe #include "nsAutoPtr.h" // for nsRefPtr diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 3359d46f9123..f88163786f15 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -7,7 +7,6 @@ #include "CompositorChild.h" // for CompositorChild #include "GeckoProfiler.h" // for PROFILER_LABEL #include "gfxASurface.h" // for gfxASurface, etc -#include "ipc/AutoOpenSurface.h" // for AutoOpenSurface #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/Hal.h" #include "mozilla/dom/ScreenOrientation.h" // for ScreenOrientation @@ -289,10 +288,10 @@ ClientLayerManager::MakeSnapshotIfRequired() // it through |outSnapshot|, but if it doesn't, it's // responsible for freeing |snapshot|. remoteRenderer->SendMakeSnapshot(inSnapshot, &snapshot)) { - AutoOpenSurface opener(OPEN_READ_ONLY, snapshot); - gfxASurface* source = opener.Get(); - - mShadowTarget->DrawSurface(source, source->GetSize()); + RefPtr surf = GetSurfaceForDescriptor(snapshot); + mShadowTarget->GetDrawTarget()->CopySurface(surf, + IntRect(0, 0, bounds.Size().width, bounds.Size().height), + IntPoint(0, 0)); } if (IsSurfaceDescriptorValid(snapshot)) { mForwarder->DestroySharedSurface(&snapshot); diff --git a/gfx/layers/composite/ContentHost.cpp b/gfx/layers/composite/ContentHost.cpp index 5d59995d1265..5a06eaa17063 100644 --- a/gfx/layers/composite/ContentHost.cpp +++ b/gfx/layers/composite/ContentHost.cpp @@ -15,7 +15,6 @@ #include "nsAString.h" #include "nsPrintfCString.h" // for nsPrintfCString #include "nsString.h" // for nsAutoCString -#include "ipc/AutoOpenSurface.h" // for AutoOpenSurface #include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL namespace mozilla { @@ -622,19 +621,12 @@ ContentHostIncremental::TextureUpdateRequest::Execute(ContentHostIncremental* aH IntPoint offset = ToIntPoint(-mUpdated.GetBounds().TopLeft()); - AutoOpenSurface surf(OPEN_READ_ONLY, mDescriptor); - - nsRefPtr thebesSurf = surf.GetAsImage(); - RefPtr sourceSurf = - gfx::Factory::CreateWrappingDataSourceSurface(thebesSurf->Data(), - thebesSurf->Stride(), - ToIntSize(thebesSurf->GetSize()), - ImageFormatToSurfaceFormat(thebesSurf->Format())); + RefPtr surf = GetSurfaceForDescriptor(mDescriptor); if (mTextureId == TextureFront) { - aHost->mSource->Update(sourceSurf, &mUpdated, &offset); + aHost->mSource->Update(surf, &mUpdated, &offset); } else { - aHost->mSourceOnWhite->Update(sourceSurf, &mUpdated, &offset); + aHost->mSourceOnWhite->Update(surf, &mUpdated, &offset); } } diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index 9af240ede62e..57801746f5fb 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -8,7 +8,6 @@ #include "gfxContext.h" #include "gfxImageSurface.h" #include "Effects.h" -#include "ipc/AutoOpenSurface.h" #include "mozilla/layers/YCbCrImageDataSerializer.h" #include "gfxWindowsPlatform.h" #include "gfxD2DSurface.h" diff --git a/gfx/layers/d3d9/CanvasLayerD3D9.cpp b/gfx/layers/d3d9/CanvasLayerD3D9.cpp index 4110bf7697da..986aee452c4d 100644 --- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp +++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "ipc/AutoOpenSurface.h" #include "mozilla/layers/PLayerTransaction.h" #include "gfxImageSurface.h" diff --git a/gfx/layers/d3d9/ImageLayerD3D9.cpp b/gfx/layers/d3d9/ImageLayerD3D9.cpp index a1b49b6cf9a8..168a011d810d 100644 --- a/gfx/layers/d3d9/ImageLayerD3D9.cpp +++ b/gfx/layers/d3d9/ImageLayerD3D9.cpp @@ -3,7 +3,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "ipc/AutoOpenSurface.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/Point.h" #include "mozilla/RefPtr.h" diff --git a/gfx/layers/d3d9/TextureD3D9.cpp b/gfx/layers/d3d9/TextureD3D9.cpp index ca8f45828d6d..7d43721393f2 100644 --- a/gfx/layers/d3d9/TextureD3D9.cpp +++ b/gfx/layers/d3d9/TextureD3D9.cpp @@ -8,7 +8,6 @@ #include "gfxContext.h" #include "gfxImageSurface.h" #include "Effects.h" -#include "ipc/AutoOpenSurface.h" #include "mozilla/layers/YCbCrImageDataSerializer.h" #include "gfxWindowsPlatform.h" #include "gfx2DGlue.h" diff --git a/gfx/layers/d3d9/ThebesLayerD3D9.cpp b/gfx/layers/d3d9/ThebesLayerD3D9.cpp index 4dc5a4e73a5d..f7cb25abdc6a 100644 --- a/gfx/layers/d3d9/ThebesLayerD3D9.cpp +++ b/gfx/layers/d3d9/ThebesLayerD3D9.cpp @@ -9,8 +9,6 @@ // typedefs conflicts. #include "mozilla/ArrayUtils.h" -#include "ipc/AutoOpenSurface.h" - #include "ThebesLayerD3D9.h" #include "gfxPlatform.h" diff --git a/gfx/layers/ipc/AutoOpenSurface.h b/gfx/layers/ipc/AutoOpenSurface.h deleted file mode 100644 index 785f668d19ff..000000000000 --- a/gfx/layers/ipc/AutoOpenSurface.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=8 et : - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_layers_AutoOpenSurface_h -#define mozilla_layers_AutoOpenSurface_h 1 - -#include "base/basictypes.h" - -#include "gfxASurface.h" -#include "mozilla/layers/PLayerTransaction.h" -#include "ShadowLayers.h" - -namespace mozilla { -namespace layers { - -/** - * Some surface types can be fairly expensive to open. This helper - * tries to put off opening surfaces as long as it can, until - * ahsolutely necessary. And after being forced to open, it remembers - * the mapping so it doesn't need to be redone. - */ -class MOZ_STACK_CLASS AutoOpenSurface -{ -public: - - /** |aDescriptor| must be valid while AutoOpenSurface is - * in scope. */ - AutoOpenSurface(OpenMode aMode, const SurfaceDescriptor& aDescriptor); - - ~AutoOpenSurface(); - - /** - * These helpers do not necessarily need to open the descriptor to - * return an answer. - */ - gfxContentType ContentType(); - gfxImageFormat ImageFormat(); - gfx::IntSize Size(); - - /** This can't escape the scope of AutoOpenSurface. */ - gfxASurface* Get(); - - /** - * This can't escape the scope of AutoOpenSurface. - * - * This method is currently just a convenience wrapper around - * gfxASurface::GetAsImageSurface() --- it returns a valid surface - * exactly when this->Get()->GetAsImageSurface() would. Clients - * that need guaranteed (fast) ImageSurfaces should allocate the - * underlying descriptor with capability MAP_AS_IMAGE_SURFACE, in - * which case this helper is guaranteed to succeed. - */ - gfxImageSurface* GetAsImage(); - - -private: - SurfaceDescriptor mDescriptor; - nsRefPtr mSurface; - nsRefPtr mSurfaceAsImage; - OpenMode mMode; - - AutoOpenSurface(const AutoOpenSurface&) MOZ_DELETE; - AutoOpenSurface& operator=(const AutoOpenSurface&) MOZ_DELETE; -}; - -} // namespace layers -} // namespace mozilla - -#endif // ifndef mozilla_layers_AutoOpenSurface_h diff --git a/gfx/layers/ipc/CompositableForwarder.h b/gfx/layers/ipc/CompositableForwarder.h index 108f2c7c2920..409a13f74b66 100644 --- a/gfx/layers/ipc/CompositableForwarder.h +++ b/gfx/layers/ipc/CompositableForwarder.h @@ -42,7 +42,6 @@ class PTextureChild; */ class CompositableForwarder : public ISurfaceAllocator { - friend class AutoOpenSurface; public: CompositableForwarder() diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 21afd296e770..b3bf35ec6d9b 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -9,7 +9,6 @@ #include // for uint64_t #include // for _Rb_tree_iterator, etc #include // for pair -#include "AutoOpenSurface.h" // for AutoOpenSurface #include "LayerTransactionParent.h" // for LayerTransactionParent #include "RenderTrace.h" // for RenderTraceLayers #include "base/message_loop.h" // for MessageLoop @@ -313,12 +312,7 @@ bool CompositorParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, SurfaceDescriptor* aOutSnapshot) { - AutoOpenSurface opener(OPEN_READ_WRITE, aInSnapshot); - gfx::IntSize size = opener.Size(); - // XXX CreateDrawTargetForSurface will always give us a Cairo surface, we can - // do better if AutoOpenSurface uses Moz2D directly. - RefPtr target = - gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(opener.Get(), size); + RefPtr target = GetDrawTargetForDescriptor(aInSnapshot); ForceComposeToTarget(target); *aOutSnapshot = aInSnapshot; return true; diff --git a/gfx/layers/ipc/ISurfaceAllocator.cpp b/gfx/layers/ipc/ISurfaceAllocator.cpp index 082e010726fe..0ed39a636d04 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.cpp +++ b/gfx/layers/ipc/ISurfaceAllocator.cpp @@ -20,6 +20,8 @@ #include "nsAutoPtr.h" // for nsRefPtr, getter_AddRefs, etc #include "nsDebug.h" // for NS_RUNTIMEABORT #include "nsXULAppAPI.h" // for XRE_GetProcessType, etc +#include "mozilla/ipc/Shmem.h" +#include "mozilla/layers/ImageDataSerializer.h" #ifdef DEBUG #include "prenv.h" #endif @@ -57,6 +59,41 @@ ISurfaceAllocator::Finalize() ShrinkShmemSectionHeap(); } +static inline uint8_t* +GetAddressFromDescriptor(const SurfaceDescriptor& aDescriptor, size_t& aSize) +{ + MOZ_ASSERT(IsSurfaceDescriptorValid(aDescriptor)); + MOZ_ASSERT(aDescriptor.type() == SurfaceDescriptor::TShmem || + aDescriptor.type() == SurfaceDescriptor::TMemoryImage); + if (aDescriptor.type() == SurfaceDescriptor::TShmem) { + Shmem shmem(aDescriptor.get_Shmem()); + aSize = shmem.Size(); + return shmem.get(); + } else { + const MemoryImage& image = aDescriptor.get_MemoryImage(); + aSize = std::numeric_limits::max(); + return reinterpret_cast(image.data()); + } +} + +TemporaryRef +GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor) +{ + size_t size; + uint8_t* data = GetAddressFromDescriptor(aDescriptor, size); + ImageDataDeserializer image(data, size); + return image.GetAsDrawTarget(gfx::BackendType::CAIRO); +} + +TemporaryRef +GetSurfaceForDescriptor(const SurfaceDescriptor& aDescriptor) +{ + size_t size; + uint8_t* data = GetAddressFromDescriptor(aDescriptor, size); + ImageDataDeserializer image(data, size); + return image.GetAsSurface(); +} + bool ISurfaceAllocator::AllocSharedImageSurface(const gfx::IntSize& aSize, gfxContentType aContent, diff --git a/gfx/layers/ipc/ISurfaceAllocator.h b/gfx/layers/ipc/ISurfaceAllocator.h index 5e2d18766803..0852533bfd31 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.h +++ b/gfx/layers/ipc/ISurfaceAllocator.h @@ -40,6 +40,9 @@ namespace mozilla { namespace ipc { class Shmem; } +namespace gfx { +class DataSourceSurface; +} namespace layers { @@ -68,6 +71,9 @@ mozilla::ipc::SharedMemory::SharedMemoryType OptimalShmemType(); bool IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface); bool IsSurfaceDescriptorOwned(const SurfaceDescriptor& aDescriptor); bool ReleaseOwnedSurfaceDescriptor(const SurfaceDescriptor& aDescriptor); + +TemporaryRef GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor); +TemporaryRef GetSurfaceForDescriptor(const SurfaceDescriptor& aDescriptor); /** * An interface used to create and destroy surfaces that are shared with the * Compositor process (using shmem, or gralloc, or other platform specific memory) diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index 03f981dfb0c9..9fc5a5318cb5 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -8,7 +8,6 @@ #include "ShadowLayers.h" #include // for _Rb_tree_const_iterator, etc #include // for vector -#include "AutoOpenSurface.h" // for AutoOpenSurface, etc #include "GeckoProfiler.h" // for PROFILER_LABEL #include "ISurfaceAllocator.h" // for IsSurfaceDescriptorValid #include "Layers.h" // for Layer @@ -781,78 +780,6 @@ ISurfaceAllocator::PlatformDestroySharedSurface(SurfaceDescriptor*) #endif // !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS) -AutoOpenSurface::AutoOpenSurface(OpenMode aMode, - const SurfaceDescriptor& aDescriptor) - : mDescriptor(aDescriptor) - , mMode(aMode) -{ - MOZ_ASSERT(IsSurfaceDescriptorValid(mDescriptor)); -} - -AutoOpenSurface::~AutoOpenSurface() -{ - if (mSurface) { - mSurface = nullptr; - ShadowLayerForwarder::CloseDescriptor(mDescriptor); - } -} - -gfxContentType -AutoOpenSurface::ContentType() -{ - if (mSurface) { - return mSurface->GetContentType(); - } - return ShadowLayerForwarder::GetDescriptorSurfaceContentType( - mDescriptor, mMode, getter_AddRefs(mSurface)); -} - -gfxImageFormat -AutoOpenSurface::ImageFormat() -{ - if (mSurface) { - nsRefPtr img = mSurface->GetAsImageSurface(); - if (img) { - gfxImageFormat format = img->Format(); - NS_ASSERTION(format != gfxImageFormat::Unknown, - "ImageSurface RGB format should be known"); - - return format; - } - } - - return ShadowLayerForwarder::GetDescriptorSurfaceImageFormat( - mDescriptor, mMode, getter_AddRefs(mSurface)); -} - -gfx::IntSize -AutoOpenSurface::Size() -{ - if (mSurface) { - return mSurface->GetSize().ToIntSize(); - } - return ShadowLayerForwarder::GetDescriptorSurfaceSize( - mDescriptor, mMode, getter_AddRefs(mSurface)); -} - -gfxASurface* -AutoOpenSurface::Get() -{ - if (!mSurface) { - mSurface = ShadowLayerForwarder::OpenDescriptor(mMode, mDescriptor); - } - return mSurface.get(); -} - -gfxImageSurface* -AutoOpenSurface::GetAsImage() -{ - if (!mSurfaceAsImage) { - mSurfaceAsImage = Get()->GetAsImageSurface(); - } - return mSurfaceAsImage.get(); -} - void ShadowLayerForwarder::Connect(CompositableClient* aCompositable) { diff --git a/gfx/layers/ipc/ShadowLayers.h b/gfx/layers/ipc/ShadowLayers.h index f226bfd95d7f..2fe524acfeff 100644 --- a/gfx/layers/ipc/ShadowLayers.h +++ b/gfx/layers/ipc/ShadowLayers.h @@ -48,7 +48,6 @@ class PLayerTransactionParent; class LayerTransactionChild; class RefLayerComposite; class ShadowableLayer; -class Shmem; class ShmemTextureClient; class SurfaceDescriptor; class TextureClient; @@ -134,7 +133,6 @@ class Transaction; class ShadowLayerForwarder : public CompositableForwarder { - friend class AutoOpenSurface; friend class ContentClientIncremental; friend class ClientLayerManager; diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 10208132eee9..f2d9cb9c1e1b 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -17,7 +17,6 @@ #include "gfx2DGlue.h" // for ContentForFormat, etc #include "gfxImageSurface.h" // for gfxImageSurface #include "gfxReusableSurfaceWrapper.h" // for gfxReusableSurfaceWrapper -#include "ipc/AutoOpenSurface.h" // for AutoOpenSurface #include "mozilla/gfx/2D.h" // for DataSourceSurface #include "mozilla/gfx/BaseSize.h" // for BaseSize #include "mozilla/layers/CompositorOGL.h" // for CompositorOGL