author | Jeff Muizelaar <jmuizelaar@mozilla.com> |
Tue, 19 Apr 2016 19:41:15 -0400 | |
changeset 294048 | 2d966e084cdd4ae510dff1f3ce4d538dafc6cd5d |
parent 294047 | d6655d9a086b8850cfe8fb16f11af87f879e59be |
child 294049 | c7c25fa27b435024a5a29f8a63a2d14540f040d7 |
push id | 30196 |
push user | kwierso@gmail.com |
push date | Wed, 20 Apr 2016 20:55:01 +0000 |
treeherder | mozilla-central@93090fa30653 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Bas |
bugs | 1265960 |
milestone | 48.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -44,23 +44,16 @@ #endif #endif #ifdef MOZ_WIDGET_GONK #include <cutils/properties.h> #include "mozilla/layers/GrallocTextureClient.h" #endif -#ifdef MOZ_WIDGET_ANDROID -# include "gfxReusableImageSurfaceWrapper.h" -#else -# include "gfxReusableSharedImageSurfaceWrapper.h" -# include "gfxSharedImageSurface.h" -#endif - #if 0 #define RECYCLE_LOG(...) printf_stderr(__VA_ARGS__) #else #define RECYCLE_LOG(...) do { } while (0) #endif namespace mozilla { namespace layers {
--- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -19,17 +19,16 @@ #include "mozilla/gfx/Tools.h" // for BytesPerPixel #include "mozilla/layers/CompositableForwarder.h" #include "mozilla/layers/CompositorBridgeChild.h" // for CompositorBridgeChild #include "mozilla/layers/LayerMetricsWrapper.h" #include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder #include "TextureClientPool.h" #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for gfxContext::AddRef, etc -#include "gfxReusableSharedImageSurfaceWrapper.h" #include "nsExpirationTracker.h" // for nsExpirationTracker #include "nsMathUtils.h" // for NS_lroundf #include "LayersLogging.h" #include "UnitTransforms.h" // for TransformTo #include "mozilla/UniquePtr.h" // This is the minimum area that we deem reasonable to copy from the front buffer to the // back buffer on tile updates. If the valid region is smaller than this, we just
--- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -30,17 +30,16 @@ #include "nsAutoPtr.h" // for nsRefPtr #include "nsISupportsImpl.h" // for MOZ_COUNT_DTOR #include "nsPoint.h" // for nsIntPoint #include "nsRect.h" // for mozilla::gfx::IntRect #include "nsRegion.h" // for nsIntRegion #include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc #include "nsExpirationTracker.h" #include "mozilla/layers/ISurfaceAllocator.h" -#include "gfxReusableSurfaceWrapper.h" #include "pratom.h" // For PR_ATOMIC_INCREMENT/DECREMENT namespace mozilla { namespace layers { class ClientTiledPaintedLayer; class ClientLayerManager;
--- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -15,18 +15,16 @@ #include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL #include "nsAString.h" #include "nsDebug.h" // for NS_WARNING #include "nsPoint.h" // for IntPoint #include "nsPrintfCString.h" // for nsPrintfCString #include "nsRect.h" // for IntRect #include "mozilla/layers/TiledContentClient.h" -class gfxReusableSurfaceWrapper; - namespace mozilla { using namespace gfx; namespace layers { class Layer; TiledLayerBufferComposite::TiledLayerBufferComposite() : mFrameResolution()
--- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -6,17 +6,16 @@ #include "TextureHostOGL.h" #include "EGLUtils.h" #include "GLContext.h" // for GLContext, etc #include "GLLibraryEGL.h" // for GLLibraryEGL #include "GLUploadHelpers.h" #include "GLReadTexImageHelper.h" #include "gfx2DGlue.h" // for ContentForFormat, etc -#include "gfxReusableSurfaceWrapper.h" // for gfxReusableSurfaceWrapper #include "mozilla/gfx/2D.h" // for DataSourceSurface #include "mozilla/gfx/BaseSize.h" // for BaseSize #include "mozilla/gfx/Logging.h" // for gfxCriticalError #include "mozilla/layers/ISurfaceAllocator.h" #include "mozilla/layers/GrallocTextureHost.h" #include "nsRegion.h" // for nsIntRegion #include "AndroidSurfaceTexture.h" #include "GfxTexturesReporter.h" // for GfxTexturesReporter
--- a/gfx/thebes/gfxBaseSharedMemorySurface.h +++ b/gfx/thebes/gfxBaseSharedMemorySurface.h @@ -31,17 +31,16 @@ GetShmInfoPtr(const mozilla::ipc::Shmem& } extern const cairo_user_data_key_t SHM_KEY; template <typename Base, typename Sub> class gfxBaseSharedMemorySurface : public Base { typedef mozilla::ipc::SharedMemory SharedMemory; typedef mozilla::ipc::Shmem Shmem; - friend class gfxReusableSharedImageSurfaceWrapper; protected: virtual ~gfxBaseSharedMemorySurface() { MOZ_COUNT_DTOR(gfxBaseSharedMemorySurface); } public:
deleted file mode 100644 --- a/gfx/thebes/gfxReusableImageSurfaceWrapper.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* 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/. */ - -#include "gfxReusableImageSurfaceWrapper.h" -#include "gfxImageSurface.h" - -gfxReusableImageSurfaceWrapper::gfxReusableImageSurfaceWrapper(gfxImageSurface* aSurface) - : mSurface(aSurface) -{ - MOZ_COUNT_CTOR(gfxReusableImageSurfaceWrapper); -} - -gfxReusableImageSurfaceWrapper::~gfxReusableImageSurfaceWrapper() -{ - MOZ_COUNT_DTOR(gfxReusableImageSurfaceWrapper); -} - -void -gfxReusableImageSurfaceWrapper::ReadLock() -{ - NS_ASSERT_OWNINGTHREAD(gfxReusableImageSurfaceWrapper); - AddRef(); -} - -void -gfxReusableImageSurfaceWrapper::ReadUnlock() -{ - Release(); -} - -gfxReusableSurfaceWrapper* -gfxReusableImageSurfaceWrapper::GetWritable(gfxImageSurface** aSurface) -{ - NS_ASSERT_OWNINGTHREAD(gfxReusableImageSurfaceWrapper); - - if (mRefCnt == 1) { - *aSurface = mSurface; - return this; - } - - // Something else is reading the surface, copy it - gfxImageSurface* copySurface = new gfxImageSurface(mSurface->GetSize(), mSurface->Format(), false); - copySurface->CopyFrom(mSurface); - *aSurface = copySurface; - - return new gfxReusableImageSurfaceWrapper(copySurface); -} - -const unsigned char* -gfxReusableImageSurfaceWrapper::GetReadOnlyData() const -{ - return mSurface->Data(); -} - -gfxImageFormat -gfxReusableImageSurfaceWrapper::Format() -{ - return mSurface->Format(); -} -
deleted file mode 100644 --- a/gfx/thebes/gfxReusableImageSurfaceWrapper.h +++ /dev/null @@ -1,38 +0,0 @@ -/* 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 GFXMEMCOWSURFACEWRAPPER -#define GFXMEMCOWSURFACEWRAPPER - -#include "gfxReusableSurfaceWrapper.h" - -class gfxImageSurface; - -/** - * A cross-thread capable implementation of gfxReusableSurfaceWrapper based - * on gfxImageSurface. - */ -class gfxReusableImageSurfaceWrapper : public gfxReusableSurfaceWrapper { -public: - explicit gfxReusableImageSurfaceWrapper(gfxImageSurface* aSurface); -protected: - ~gfxReusableImageSurfaceWrapper(); - -public: - const unsigned char* GetReadOnlyData() const override; - gfxImageFormat Format() override; - gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) override; - void ReadLock() override; - void ReadUnlock() override; - - Type GetType() override - { - return TYPE_IMAGE; - } - -private: - RefPtr<gfxImageSurface> mSurface; -}; - -#endif // GFXMEMCOWSURFACEWRAPPER
deleted file mode 100644 --- a/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* 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/. */ - -#include "gfxReusableSharedImageSurfaceWrapper.h" -#include "gfxSharedImageSurface.h" -#include "mozilla/layers/ISurfaceAllocator.h" - -using mozilla::ipc::Shmem; -using mozilla::layers::ISurfaceAllocator; - -gfxReusableSharedImageSurfaceWrapper::gfxReusableSharedImageSurfaceWrapper(ISurfaceAllocator* aAllocator, - gfxSharedImageSurface* aSurface) - : mAllocator(aAllocator) - , mSurface(aSurface) -{ - MOZ_COUNT_CTOR(gfxReusableSharedImageSurfaceWrapper); - ReadLock(); -} - -gfxReusableSharedImageSurfaceWrapper::~gfxReusableSharedImageSurfaceWrapper() -{ - MOZ_COUNT_DTOR(gfxReusableSharedImageSurfaceWrapper); - ReadUnlock(); -} - -void -gfxReusableSharedImageSurfaceWrapper::ReadLock() -{ - NS_ASSERT_OWNINGTHREAD(gfxReusableSharedImageSurfaceWrapper); - mSurface->ReadLock(); -} - -void -gfxReusableSharedImageSurfaceWrapper::ReadUnlock() -{ - int32_t readCount = mSurface->ReadUnlock(); - MOZ_ASSERT(readCount >= 0, "Read count should not be negative"); - - if (readCount == 0) { - mAllocator->AsShmemAllocator()->DeallocShmem(mSurface->GetShmem()); - } -} - -gfxReusableSurfaceWrapper* -gfxReusableSharedImageSurfaceWrapper::GetWritable(gfxImageSurface** aSurface) -{ - NS_ASSERT_OWNINGTHREAD(gfxReusableSharedImageSurfaceWrapper); - - int32_t readCount = mSurface->GetReadCount(); - MOZ_ASSERT(readCount > 0, "A ReadLock must be held when calling GetWritable"); - if (readCount == 1) { - *aSurface = mSurface; - return this; - } - - // Something else is reading the surface, copy it - RefPtr<gfxSharedImageSurface> copySurface = - gfxSharedImageSurface::CreateUnsafe(mAllocator->AsShmemAllocator(), mSurface->GetSize(), mSurface->Format()); - copySurface->CopyFrom(mSurface); - *aSurface = copySurface; - - // We need to create a new wrapper since this wrapper has an external ReadLock - gfxReusableSurfaceWrapper* wrapper = new gfxReusableSharedImageSurfaceWrapper(mAllocator, copySurface); - - // No need to release the ReadLock on the surface, this will happen when - // the wrapper is destroyed. - - return wrapper; -} - -const unsigned char* -gfxReusableSharedImageSurfaceWrapper::GetReadOnlyData() const -{ - MOZ_ASSERT(mSurface->GetReadCount() > 0, "Should have read lock"); - return mSurface->Data(); -} - -gfxImageFormat -gfxReusableSharedImageSurfaceWrapper::Format() -{ - return mSurface->Format(); -} - -Shmem& -gfxReusableSharedImageSurfaceWrapper::GetShmem() -{ - return mSurface->GetShmem(); -} - -/* static */ already_AddRefed<gfxReusableSharedImageSurfaceWrapper> -gfxReusableSharedImageSurfaceWrapper::Open(ISurfaceAllocator* aAllocator, const Shmem& aShmem) -{ - RefPtr<gfxSharedImageSurface> sharedImage = gfxSharedImageSurface::Open(aShmem); - RefPtr<gfxReusableSharedImageSurfaceWrapper> wrapper = new gfxReusableSharedImageSurfaceWrapper(aAllocator, sharedImage); - wrapper->ReadUnlock(); - return wrapper.forget(); -}
deleted file mode 100644 --- a/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h +++ /dev/null @@ -1,63 +0,0 @@ -/* 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 GFXSHMCOWSURFACEWRAPPER -#define GFXSHMCOWSURFACEWRAPPER - -#include "gfxReusableSurfaceWrapper.h" -#include "mozilla/RefPtr.h" - -class gfxSharedImageSurface; - -namespace mozilla { -namespace ipc { -class Shmem; -} // namespace ipc -namespace layers { -class ISurfaceAllocator; -} // namespace layers -} // namespace mozilla - -/** - * A cross-process capable implementation of gfxReusableSurfaceWrapper based - * on gfxSharedImageSurface. - */ -class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper { -public: - gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator, - gfxSharedImageSurface* aSurface); -protected: - ~gfxReusableSharedImageSurfaceWrapper(); - -public: - const unsigned char* GetReadOnlyData() const override; - gfxImageFormat Format() override; - gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) override; - void ReadLock() override; - void ReadUnlock() override; - - Type GetType() override - { - return TYPE_SHARED_IMAGE; - } - - /** - * Returns the shared memory segment that backs the shared image surface. - */ - mozilla::ipc::Shmem& GetShmem(); - - /** - * Create a gfxReusableSurfaceWrapper from the shared memory segment of a - * gfxSharedImageSurface. A ReadLock must be held, which will be adopted by - * the returned gfxReusableSurfaceWrapper. - */ - static already_AddRefed<gfxReusableSharedImageSurfaceWrapper> - Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem); - -private: - RefPtr<mozilla::layers::ISurfaceAllocator> mAllocator; - RefPtr<gfxSharedImageSurface> mSurface; -}; - -#endif // GFXSHMCOWSURFACEWRAPPER
deleted file mode 100644 --- a/gfx/thebes/gfxReusableSurfaceWrapper.h +++ /dev/null @@ -1,88 +0,0 @@ -/* 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 GFXCOWSURFACEWRAPPER -#define GFXCOWSURFACEWRAPPER - -#include "gfxImageSurface.h" -#include "nsISupportsImpl.h" - - -/** - * Provides an interface to implement a cross thread/process wrapper for a - * gfxImageSurface that has copy-on-write semantics. - * - * Only the owner thread can write to the surface and acquire - * read locks. Destroying a gfxReusableSurfaceWrapper releases - * a read lock. - * - * OMTC Usage: - * 1) Content creates a writable copy of this surface - * wrapper which will be optimized to the same wrapper if there - * are no readers. - * 2) The surface is sent from content to the compositor once - * or potentially many times, each increasing a read lock. - * 3) When the compositor receives the surface, it adopts the - * read lock. - * 4) Once the compositor has processed the surface and uploaded - * the content, it then releases the read lock by dereferencing - * its wrapper. - */ -class gfxReusableSurfaceWrapper { - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxReusableSurfaceWrapper) -public: - - /** - * Returns a read-only pointer to the image data. - */ - virtual const unsigned char* GetReadOnlyData() const = 0; - - /** - * Returns the image surface format. - */ - virtual gfxImageFormat Format() = 0; - - /** - * Returns a writable copy of the image. - * If necessary this will copy the wrapper. If there are no contention - * the same wrapper will be returned. A ReadLock must be held when - * calling this function, and calling it will give up this lock. - */ - virtual gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) = 0; - - /** - * A read only lock count is recorded, any attempts to - * call GetWritable() while this count is greater than one will - * create a new surface/wrapper pair. - * - * When a surface's read count falls to zero, its memory will be - * deallocated. It is the responsibility of the user to make sure - * that all locks are matched with an equal number of unlocks. - */ - virtual void ReadLock() = 0; - virtual void ReadUnlock() = 0; - - /** - * Types for each implementation of gfxReusableSurfaceWrapper. - */ - enum Type { - TYPE_SHARED_IMAGE, - TYPE_IMAGE, - - TYPE_MAX - }; - - /** - * Returns a unique ID for each implementation of gfxReusableSurfaceWrapper. - */ - virtual Type GetType() = 0; - -protected: - // Protected destructor, to discourage deletion outside of Release(): - virtual ~gfxReusableSurfaceWrapper() {} - - NS_DECL_OWNINGTHREAD -}; - -#endif // GFXCOWSURFACEWRAPPER
--- a/gfx/thebes/moz.build +++ b/gfx/thebes/moz.build @@ -33,19 +33,16 @@ EXPORTS += [ 'gfxMatrix.h', 'gfxPattern.h', 'gfxPlatform.h', 'gfxPoint.h', 'gfxPrefs.h', 'gfxQuad.h', 'gfxQuaternion.h', 'gfxRect.h', - 'gfxReusableImageSurfaceWrapper.h', - 'gfxReusableSharedImageSurfaceWrapper.h', - 'gfxReusableSurfaceWrapper.h', 'gfxSharedImageSurface.h', 'gfxSharedQuartzSurface.h', 'gfxSkipChars.h', 'gfxSVGGlyphs.h', 'gfxTeeSurface.h', 'gfxTextRun.h', 'gfxTypes.h', 'gfxUserFontSet.h', @@ -227,18 +224,16 @@ UNIFIED_SOURCES += [ 'gfxGraphiteShaper.cpp', 'gfxHarfBuzzShaper.cpp', 'gfxImageSurface.cpp', 'gfxMathTable.cpp', 'gfxMatrix.cpp', 'gfxPattern.cpp', 'gfxPlatformFontList.cpp', 'gfxRect.cpp', - 'gfxReusableImageSurfaceWrapper.cpp', - 'gfxReusableSharedImageSurfaceWrapper.cpp', 'gfxScriptItemizer.cpp', 'gfxSkipChars.cpp', 'gfxSVGGlyphs.cpp', 'gfxTeeSurface.cpp', 'gfxTextRun.cpp', 'gfxUserFontSet.cpp', 'gfxUtils.cpp', 'nsUnicodeRange.cpp', @@ -310,9 +305,9 @@ LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES' DEFINES['GRAPHITE2_STATIC'] = True if CONFIG['CLANG_CXX']: # Suppress warnings from Skia header files. SOURCES['gfxPlatform.cpp'].flags += ['-Wno-implicit-fallthrough'] if CONFIG['_MSC_VER']: # This is intended as a temporary hack to support building with VS2015. - CXXFLAGS += ['-wd4577'] \ No newline at end of file + CXXFLAGS += ['-wd4577']