|
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 |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef SHAREDRGBIMAGE_H_ |
|
6 #define SHAREDRGBIMAGE_H_ |
|
7 |
|
8 #include <stddef.h> // for size_t |
|
9 #include <stdint.h> // for uint8_t |
|
10 #include "ImageContainer.h" // for ISharedImage, Image, etc |
|
11 #include "gfxTypes.h" |
|
12 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE |
|
13 #include "mozilla/RefPtr.h" // for RefPtr |
|
14 #include "mozilla/gfx/Point.h" // for IntSize |
|
15 #include "mozilla/gfx/Types.h" // for SurfaceFormat |
|
16 #include "nsCOMPtr.h" // for already_AddRefed |
|
17 |
|
18 namespace mozilla { |
|
19 namespace ipc { |
|
20 class Shmem; |
|
21 } |
|
22 |
|
23 namespace layers { |
|
24 |
|
25 class BufferTextureClient; |
|
26 class ImageClient; |
|
27 class ISurfaceAllocator; |
|
28 class TextureClient; |
|
29 class SurfaceDescriptor; |
|
30 |
|
31 already_AddRefed<Image> CreateSharedRGBImage(ImageContainer* aImageContainer, |
|
32 nsIntSize aSize, |
|
33 gfxImageFormat aImageFormat); |
|
34 |
|
35 /** |
|
36 * Stores RGB data in shared memory |
|
37 * It is assumed that the image width and stride are equal |
|
38 */ |
|
39 class SharedRGBImage : public Image |
|
40 , public ISharedImage |
|
41 { |
|
42 public: |
|
43 SharedRGBImage(ImageClient* aCompositable); |
|
44 ~SharedRGBImage(); |
|
45 |
|
46 virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; } |
|
47 |
|
48 virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE; |
|
49 |
|
50 virtual uint8_t* GetBuffer() MOZ_OVERRIDE; |
|
51 |
|
52 gfx::IntSize GetSize(); |
|
53 |
|
54 size_t GetBufferSize(); |
|
55 |
|
56 TemporaryRef<gfx::SourceSurface> GetAsSourceSurface(); |
|
57 |
|
58 bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat); |
|
59 private: |
|
60 gfx::IntSize mSize; |
|
61 RefPtr<ImageClient> mCompositable; |
|
62 RefPtr<BufferTextureClient> mTextureClient; |
|
63 }; |
|
64 |
|
65 } // namespace layers |
|
66 } // namespace mozilla |
|
67 |
|
68 #endif |