Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef GFXSHMCOWSURFACEWRAPPER |
michael@0 | 6 | #define GFXSHMCOWSURFACEWRAPPER |
michael@0 | 7 | |
michael@0 | 8 | #include "gfxReusableSurfaceWrapper.h" |
michael@0 | 9 | #include "mozilla/RefPtr.h" |
michael@0 | 10 | |
michael@0 | 11 | class gfxSharedImageSurface; |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | namespace ipc { |
michael@0 | 15 | class Shmem; |
michael@0 | 16 | } |
michael@0 | 17 | namespace layers { |
michael@0 | 18 | class ISurfaceAllocator; |
michael@0 | 19 | } |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * A cross-process capable implementation of gfxReusableSurfaceWrapper based |
michael@0 | 24 | * on gfxSharedImageSurface. |
michael@0 | 25 | */ |
michael@0 | 26 | class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper { |
michael@0 | 27 | public: |
michael@0 | 28 | gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator, |
michael@0 | 29 | gfxSharedImageSurface* aSurface); |
michael@0 | 30 | ~gfxReusableSharedImageSurfaceWrapper(); |
michael@0 | 31 | |
michael@0 | 32 | const unsigned char* GetReadOnlyData() const MOZ_OVERRIDE; |
michael@0 | 33 | gfxImageFormat Format() MOZ_OVERRIDE; |
michael@0 | 34 | gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) MOZ_OVERRIDE; |
michael@0 | 35 | void ReadLock() MOZ_OVERRIDE; |
michael@0 | 36 | void ReadUnlock() MOZ_OVERRIDE; |
michael@0 | 37 | |
michael@0 | 38 | Type GetType() |
michael@0 | 39 | { |
michael@0 | 40 | return TYPE_SHARED_IMAGE; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | /** |
michael@0 | 44 | * Returns the shared memory segment that backs the shared image surface. |
michael@0 | 45 | */ |
michael@0 | 46 | mozilla::ipc::Shmem& GetShmem(); |
michael@0 | 47 | |
michael@0 | 48 | /** |
michael@0 | 49 | * Create a gfxReusableSurfaceWrapper from the shared memory segment of a |
michael@0 | 50 | * gfxSharedImageSurface. A ReadLock must be held, which will be adopted by |
michael@0 | 51 | * the returned gfxReusableSurfaceWrapper. |
michael@0 | 52 | */ |
michael@0 | 53 | static already_AddRefed<gfxReusableSharedImageSurfaceWrapper> |
michael@0 | 54 | Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem); |
michael@0 | 55 | |
michael@0 | 56 | private: |
michael@0 | 57 | mozilla::RefPtr<mozilla::layers::ISurfaceAllocator> mAllocator; |
michael@0 | 58 | nsRefPtr<gfxSharedImageSurface> mSurface; |
michael@0 | 59 | }; |
michael@0 | 60 | |
michael@0 | 61 | #endif // GFXSHMCOWSURFACEWRAPPER |