Bumping manifests a=b2g-bump
[gecko.git] / gfx / thebes / gfxReusableSharedImageSurfaceWrapper.h
blobb6d49b9a3adfd437a26f2eb721fdec2755d5e863
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef GFXSHMCOWSURFACEWRAPPER
6 #define GFXSHMCOWSURFACEWRAPPER
8 #include "gfxReusableSurfaceWrapper.h"
9 #include "mozilla/RefPtr.h"
11 class gfxSharedImageSurface;
13 namespace mozilla {
14 namespace ipc {
15 class Shmem;
17 namespace layers {
18 class ISurfaceAllocator;
22 /**
23 * A cross-process capable implementation of gfxReusableSurfaceWrapper based
24 * on gfxSharedImageSurface.
26 class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper {
27 public:
28 gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator,
29 gfxSharedImageSurface* aSurface);
30 protected:
31 ~gfxReusableSharedImageSurfaceWrapper();
33 public:
34 const unsigned char* GetReadOnlyData() const MOZ_OVERRIDE;
35 gfxImageFormat Format() MOZ_OVERRIDE;
36 gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) MOZ_OVERRIDE;
37 void ReadLock() MOZ_OVERRIDE;
38 void ReadUnlock() MOZ_OVERRIDE;
40 Type GetType()
42 return TYPE_SHARED_IMAGE;
45 /**
46 * Returns the shared memory segment that backs the shared image surface.
48 mozilla::ipc::Shmem& GetShmem();
50 /**
51 * Create a gfxReusableSurfaceWrapper from the shared memory segment of a
52 * gfxSharedImageSurface. A ReadLock must be held, which will be adopted by
53 * the returned gfxReusableSurfaceWrapper.
55 static already_AddRefed<gfxReusableSharedImageSurfaceWrapper>
56 Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem);
58 private:
59 mozilla::RefPtr<mozilla::layers::ISurfaceAllocator> mAllocator;
60 nsRefPtr<gfxSharedImageSurface> mSurface;
63 #endif // GFXSHMCOWSURFACEWRAPPER