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
;
18 class ISurfaceAllocator
;
23 * A cross-process capable implementation of gfxReusableSurfaceWrapper based
24 * on gfxSharedImageSurface.
26 class gfxReusableSharedImageSurfaceWrapper
: public gfxReusableSurfaceWrapper
{
28 gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator
* aAllocator
,
29 gfxSharedImageSurface
* aSurface
);
31 ~gfxReusableSharedImageSurfaceWrapper();
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
;
42 return TYPE_SHARED_IMAGE
;
46 * Returns the shared memory segment that backs the shared image surface.
48 mozilla::ipc::Shmem
& GetShmem();
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
);
59 mozilla::RefPtr
<mozilla::layers::ISurfaceAllocator
> mAllocator
;
60 nsRefPtr
<gfxSharedImageSurface
> mSurface
;
63 #endif // GFXSHMCOWSURFACEWRAPPER