1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef GFXSHMCOWSURFACEWRAPPER 1.9 +#define GFXSHMCOWSURFACEWRAPPER 1.10 + 1.11 +#include "gfxReusableSurfaceWrapper.h" 1.12 +#include "mozilla/RefPtr.h" 1.13 + 1.14 +class gfxSharedImageSurface; 1.15 + 1.16 +namespace mozilla { 1.17 +namespace ipc { 1.18 +class Shmem; 1.19 +} 1.20 +namespace layers { 1.21 +class ISurfaceAllocator; 1.22 +} 1.23 +} 1.24 + 1.25 +/** 1.26 + * A cross-process capable implementation of gfxReusableSurfaceWrapper based 1.27 + * on gfxSharedImageSurface. 1.28 + */ 1.29 +class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper { 1.30 +public: 1.31 + gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator, 1.32 + gfxSharedImageSurface* aSurface); 1.33 + ~gfxReusableSharedImageSurfaceWrapper(); 1.34 + 1.35 + const unsigned char* GetReadOnlyData() const MOZ_OVERRIDE; 1.36 + gfxImageFormat Format() MOZ_OVERRIDE; 1.37 + gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) MOZ_OVERRIDE; 1.38 + void ReadLock() MOZ_OVERRIDE; 1.39 + void ReadUnlock() MOZ_OVERRIDE; 1.40 + 1.41 + Type GetType() 1.42 + { 1.43 + return TYPE_SHARED_IMAGE; 1.44 + } 1.45 + 1.46 + /** 1.47 + * Returns the shared memory segment that backs the shared image surface. 1.48 + */ 1.49 + mozilla::ipc::Shmem& GetShmem(); 1.50 + 1.51 + /** 1.52 + * Create a gfxReusableSurfaceWrapper from the shared memory segment of a 1.53 + * gfxSharedImageSurface. A ReadLock must be held, which will be adopted by 1.54 + * the returned gfxReusableSurfaceWrapper. 1.55 + */ 1.56 + static already_AddRefed<gfxReusableSharedImageSurfaceWrapper> 1.57 + Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem); 1.58 + 1.59 +private: 1.60 + mozilla::RefPtr<mozilla::layers::ISurfaceAllocator> mAllocator; 1.61 + nsRefPtr<gfxSharedImageSurface> mSurface; 1.62 +}; 1.63 + 1.64 +#endif // GFXSHMCOWSURFACEWRAPPER