OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ |
6 #define CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 virtual ~Backend() {}; | 39 virtual ~Backend() {}; |
40 virtual bool Init(PPB_ImageData_Impl* impl, | 40 virtual bool Init(PPB_ImageData_Impl* impl, |
41 PP_ImageDataFormat format, | 41 PP_ImageDataFormat format, |
42 int width, | 42 int width, |
43 int height, | 43 int height, |
44 bool init_to_zero) = 0; | 44 bool init_to_zero) = 0; |
45 virtual bool IsMapped() const = 0; | 45 virtual bool IsMapped() const = 0; |
46 virtual TransportDIB* GetTransportDIB() const = 0; | 46 virtual TransportDIB* GetTransportDIB() const = 0; |
47 virtual void* Map() = 0; | 47 virtual void* Map() = 0; |
48 virtual void Unmap() = 0; | 48 virtual void Unmap() = 0; |
49 virtual int32_t GetSharedMemory(base::SharedMemoryHandle* handle, | 49 virtual int32_t GetSharedMemory(base::SharedMemory** shm, |
50 uint32_t* byte_count) = 0; | 50 uint32_t* byte_count) = 0; |
51 virtual SkCanvas* GetPlatformCanvas() = 0; | 51 virtual SkCanvas* GetPlatformCanvas() = 0; |
52 virtual SkCanvas* GetCanvas() = 0; | 52 virtual SkCanvas* GetCanvas() = 0; |
53 virtual const SkBitmap* GetMappedBitmap() const = 0; | 53 virtual const SkBitmap* GetMappedBitmap() const = 0; |
54 }; | 54 }; |
55 | 55 |
56 // If you call this constructor, you must also call Init before use. Normally | 56 // If you call this constructor, you must also call Init before use. Normally |
57 // you should use the static Create function, but this constructor is needed | 57 // you should use the static Create function, but this constructor is needed |
58 // for some internal uses of ImageData (like Graphics2D). | 58 // for some internal uses of ImageData (like Graphics2D). |
59 PPB_ImageData_Impl(PP_Instance instance, | 59 PPB_ImageData_Impl(PP_Instance instance, |
(...skipping 25 matching lines...) Expand all Loading... |
85 bool IsMapped() const; | 85 bool IsMapped() const; |
86 TransportDIB* GetTransportDIB() const; | 86 TransportDIB* GetTransportDIB() const; |
87 | 87 |
88 // Resource override. | 88 // Resource override. |
89 ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() override; | 89 ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() override; |
90 | 90 |
91 // PPB_ImageData_API implementation. | 91 // PPB_ImageData_API implementation. |
92 PP_Bool Describe(PP_ImageDataDesc* desc) override; | 92 PP_Bool Describe(PP_ImageDataDesc* desc) override; |
93 void* Map() override; | 93 void* Map() override; |
94 void Unmap() override; | 94 void Unmap() override; |
95 int32_t GetSharedMemory(base::SharedMemoryHandle* handle, | 95 int32_t GetSharedMemory(base::SharedMemory** shm, |
96 uint32_t* byte_count) override; | 96 uint32_t* byte_count) override; |
97 SkCanvas* GetPlatformCanvas() override; | 97 SkCanvas* GetPlatformCanvas() override; |
98 SkCanvas* GetCanvas() override; | 98 SkCanvas* GetCanvas() override; |
99 void SetIsCandidateForReuse() override; | 99 void SetIsCandidateForReuse() override; |
100 | 100 |
101 const SkBitmap* GetMappedBitmap() const; | 101 const SkBitmap* GetMappedBitmap() const; |
102 | 102 |
103 private: | 103 private: |
104 ~PPB_ImageData_Impl() override; | 104 ~PPB_ImageData_Impl() override; |
105 | 105 |
(...skipping 15 matching lines...) Expand all Loading... |
121 // PPB_ImageData_Impl::Backend implementation. | 121 // PPB_ImageData_Impl::Backend implementation. |
122 bool Init(PPB_ImageData_Impl* impl, | 122 bool Init(PPB_ImageData_Impl* impl, |
123 PP_ImageDataFormat format, | 123 PP_ImageDataFormat format, |
124 int width, | 124 int width, |
125 int height, | 125 int height, |
126 bool init_to_zero) override; | 126 bool init_to_zero) override; |
127 bool IsMapped() const override; | 127 bool IsMapped() const override; |
128 TransportDIB* GetTransportDIB() const override; | 128 TransportDIB* GetTransportDIB() const override; |
129 void* Map() override; | 129 void* Map() override; |
130 void Unmap() override; | 130 void Unmap() override; |
131 int32_t GetSharedMemory(base::SharedMemoryHandle* handle, | 131 int32_t GetSharedMemory(base::SharedMemory** shm, |
132 uint32_t* byte_count) override; | 132 uint32_t* byte_count) override; |
133 SkCanvas* GetPlatformCanvas() override; | 133 SkCanvas* GetPlatformCanvas() override; |
134 SkCanvas* GetCanvas() override; | 134 SkCanvas* GetCanvas() override; |
135 const SkBitmap* GetMappedBitmap() const override; | 135 const SkBitmap* GetMappedBitmap() const override; |
136 | 136 |
137 private: | 137 private: |
138 // This will be NULL before initialization, and if this PPB_ImageData_Impl is | 138 // This will be NULL before initialization, and if this PPB_ImageData_Impl is |
139 // swapped with another. | 139 // swapped with another. |
140 int width_; | 140 int width_; |
141 int height_; | 141 int height_; |
(...skipping 13 matching lines...) Expand all Loading... |
155 // PPB_ImageData_Impl::Backend implementation. | 155 // PPB_ImageData_Impl::Backend implementation. |
156 bool Init(PPB_ImageData_Impl* impl, | 156 bool Init(PPB_ImageData_Impl* impl, |
157 PP_ImageDataFormat format, | 157 PP_ImageDataFormat format, |
158 int width, | 158 int width, |
159 int height, | 159 int height, |
160 bool init_to_zero) override; | 160 bool init_to_zero) override; |
161 bool IsMapped() const override; | 161 bool IsMapped() const override; |
162 TransportDIB* GetTransportDIB() const override; | 162 TransportDIB* GetTransportDIB() const override; |
163 void* Map() override; | 163 void* Map() override; |
164 void Unmap() override; | 164 void Unmap() override; |
165 int32_t GetSharedMemory(base::SharedMemoryHandle* handle, | 165 int32_t GetSharedMemory(base::SharedMemory** shm, |
166 uint32_t* byte_count) override; | 166 uint32_t* byte_count) override; |
167 SkCanvas* GetPlatformCanvas() override; | 167 SkCanvas* GetPlatformCanvas() override; |
168 SkCanvas* GetCanvas() override; | 168 SkCanvas* GetCanvas() override; |
169 const SkBitmap* GetMappedBitmap() const override; | 169 const SkBitmap* GetMappedBitmap() const override; |
170 | 170 |
171 private: | 171 private: |
172 scoped_ptr<base::SharedMemory> shared_memory_; | 172 scoped_ptr<base::SharedMemory> shared_memory_; |
173 // skia_bitmap_ is backed by shared_memory_. | 173 // skia_bitmap_ is backed by shared_memory_. |
174 SkBitmap skia_bitmap_; | 174 SkBitmap skia_bitmap_; |
175 scoped_ptr<SkCanvas> skia_canvas_; | 175 scoped_ptr<SkCanvas> skia_canvas_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 PPB_ImageData_Impl* image_data_; | 213 PPB_ImageData_Impl* image_data_; |
214 bool is_valid_; | 214 bool is_valid_; |
215 bool needs_unmap_; | 215 bool needs_unmap_; |
216 | 216 |
217 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); | 217 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); |
218 }; | 218 }; |
219 | 219 |
220 } // namespace content | 220 } // namespace content |
221 | 221 |
222 #endif // CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ | 222 #endif // CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ |
OLD | NEW |