michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFXSHMCOWSURFACEWRAPPER michael@0: #define GFXSHMCOWSURFACEWRAPPER michael@0: michael@0: #include "gfxReusableSurfaceWrapper.h" michael@0: #include "mozilla/RefPtr.h" michael@0: michael@0: class gfxSharedImageSurface; michael@0: michael@0: namespace mozilla { michael@0: namespace ipc { michael@0: class Shmem; michael@0: } michael@0: namespace layers { michael@0: class ISurfaceAllocator; michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * A cross-process capable implementation of gfxReusableSurfaceWrapper based michael@0: * on gfxSharedImageSurface. michael@0: */ michael@0: class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper { michael@0: public: michael@0: gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator, michael@0: gfxSharedImageSurface* aSurface); michael@0: ~gfxReusableSharedImageSurfaceWrapper(); michael@0: michael@0: const unsigned char* GetReadOnlyData() const MOZ_OVERRIDE; michael@0: gfxImageFormat Format() MOZ_OVERRIDE; michael@0: gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) MOZ_OVERRIDE; michael@0: void ReadLock() MOZ_OVERRIDE; michael@0: void ReadUnlock() MOZ_OVERRIDE; michael@0: michael@0: Type GetType() michael@0: { michael@0: return TYPE_SHARED_IMAGE; michael@0: } michael@0: michael@0: /** michael@0: * Returns the shared memory segment that backs the shared image surface. michael@0: */ michael@0: mozilla::ipc::Shmem& GetShmem(); michael@0: michael@0: /** michael@0: * Create a gfxReusableSurfaceWrapper from the shared memory segment of a michael@0: * gfxSharedImageSurface. A ReadLock must be held, which will be adopted by michael@0: * the returned gfxReusableSurfaceWrapper. michael@0: */ michael@0: static already_AddRefed michael@0: Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem); michael@0: michael@0: private: michael@0: mozilla::RefPtr mAllocator; michael@0: nsRefPtr mSurface; michael@0: }; michael@0: michael@0: #endif // GFXSHMCOWSURFACEWRAPPER