|
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/. */ |
|
4 |
|
5 #ifndef GFXSHMCOWSURFACEWRAPPER |
|
6 #define GFXSHMCOWSURFACEWRAPPER |
|
7 |
|
8 #include "gfxReusableSurfaceWrapper.h" |
|
9 #include "mozilla/RefPtr.h" |
|
10 |
|
11 class gfxSharedImageSurface; |
|
12 |
|
13 namespace mozilla { |
|
14 namespace ipc { |
|
15 class Shmem; |
|
16 } |
|
17 namespace layers { |
|
18 class ISurfaceAllocator; |
|
19 } |
|
20 } |
|
21 |
|
22 /** |
|
23 * A cross-process capable implementation of gfxReusableSurfaceWrapper based |
|
24 * on gfxSharedImageSurface. |
|
25 */ |
|
26 class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper { |
|
27 public: |
|
28 gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator, |
|
29 gfxSharedImageSurface* aSurface); |
|
30 ~gfxReusableSharedImageSurfaceWrapper(); |
|
31 |
|
32 const unsigned char* GetReadOnlyData() const MOZ_OVERRIDE; |
|
33 gfxImageFormat Format() MOZ_OVERRIDE; |
|
34 gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) MOZ_OVERRIDE; |
|
35 void ReadLock() MOZ_OVERRIDE; |
|
36 void ReadUnlock() MOZ_OVERRIDE; |
|
37 |
|
38 Type GetType() |
|
39 { |
|
40 return TYPE_SHARED_IMAGE; |
|
41 } |
|
42 |
|
43 /** |
|
44 * Returns the shared memory segment that backs the shared image surface. |
|
45 */ |
|
46 mozilla::ipc::Shmem& GetShmem(); |
|
47 |
|
48 /** |
|
49 * Create a gfxReusableSurfaceWrapper from the shared memory segment of a |
|
50 * gfxSharedImageSurface. A ReadLock must be held, which will be adopted by |
|
51 * the returned gfxReusableSurfaceWrapper. |
|
52 */ |
|
53 static already_AddRefed<gfxReusableSharedImageSurfaceWrapper> |
|
54 Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem); |
|
55 |
|
56 private: |
|
57 mozilla::RefPtr<mozilla::layers::ISurfaceAllocator> mAllocator; |
|
58 nsRefPtr<gfxSharedImageSurface> mSurface; |
|
59 }; |
|
60 |
|
61 #endif // GFXSHMCOWSURFACEWRAPPER |