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 "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 // Returns the image format. | 78 // Returns the image format. |
79 PP_ImageDataFormat format() const { return format_; } | 79 PP_ImageDataFormat format() const { return format_; } |
80 | 80 |
81 // Returns true if this image is mapped. False means that the image is either | 81 // Returns true if this image is mapped. False means that the image is either |
82 // invalid or not mapped. See ImageDataAutoMapper below. | 82 // invalid or not mapped. See ImageDataAutoMapper below. |
83 bool IsMapped() const; | 83 bool IsMapped() const; |
84 TransportDIB* GetTransportDIB() const; | 84 TransportDIB* GetTransportDIB() const; |
85 | 85 |
86 // Resource override. | 86 // Resource override. |
87 virtual ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE; | 87 virtual ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() override; |
88 | 88 |
89 // PPB_ImageData_API implementation. | 89 // PPB_ImageData_API implementation. |
90 virtual PP_Bool Describe(PP_ImageDataDesc* desc) OVERRIDE; | 90 virtual PP_Bool Describe(PP_ImageDataDesc* desc) override; |
91 virtual void* Map() OVERRIDE; | 91 virtual void* Map() override; |
92 virtual void Unmap() OVERRIDE; | 92 virtual void Unmap() override; |
93 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE; | 93 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) override; |
94 virtual SkCanvas* GetPlatformCanvas() OVERRIDE; | 94 virtual SkCanvas* GetPlatformCanvas() override; |
95 virtual SkCanvas* GetCanvas() OVERRIDE; | 95 virtual SkCanvas* GetCanvas() override; |
96 virtual void SetIsCandidateForReuse() OVERRIDE; | 96 virtual void SetIsCandidateForReuse() override; |
97 | 97 |
98 const SkBitmap* GetMappedBitmap() const; | 98 const SkBitmap* GetMappedBitmap() const; |
99 | 99 |
100 private: | 100 private: |
101 virtual ~PPB_ImageData_Impl(); | 101 virtual ~PPB_ImageData_Impl(); |
102 | 102 |
103 PP_ImageDataFormat format_; | 103 PP_ImageDataFormat format_; |
104 int width_; | 104 int width_; |
105 int height_; | 105 int height_; |
106 scoped_ptr<Backend> backend_; | 106 scoped_ptr<Backend> backend_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Impl); | 108 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Impl); |
109 }; | 109 }; |
110 | 110 |
111 class ImageDataPlatformBackend : public PPB_ImageData_Impl::Backend { | 111 class ImageDataPlatformBackend : public PPB_ImageData_Impl::Backend { |
112 public: | 112 public: |
113 // |is_browser_allocated| indicates whether the backing shared memory should | 113 // |is_browser_allocated| indicates whether the backing shared memory should |
114 // be allocated by the browser process. | 114 // be allocated by the browser process. |
115 ImageDataPlatformBackend(bool is_browser_allocated); | 115 ImageDataPlatformBackend(bool is_browser_allocated); |
116 virtual ~ImageDataPlatformBackend(); | 116 virtual ~ImageDataPlatformBackend(); |
117 | 117 |
118 // PPB_ImageData_Impl::Backend implementation. | 118 // PPB_ImageData_Impl::Backend implementation. |
119 virtual bool Init(PPB_ImageData_Impl* impl, | 119 virtual bool Init(PPB_ImageData_Impl* impl, |
120 PP_ImageDataFormat format, | 120 PP_ImageDataFormat format, |
121 int width, | 121 int width, |
122 int height, | 122 int height, |
123 bool init_to_zero) OVERRIDE; | 123 bool init_to_zero) override; |
124 virtual bool IsMapped() const OVERRIDE; | 124 virtual bool IsMapped() const override; |
125 virtual TransportDIB* GetTransportDIB() const OVERRIDE; | 125 virtual TransportDIB* GetTransportDIB() const override; |
126 virtual void* Map() OVERRIDE; | 126 virtual void* Map() override; |
127 virtual void Unmap() OVERRIDE; | 127 virtual void Unmap() override; |
128 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE; | 128 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) override; |
129 virtual SkCanvas* GetPlatformCanvas() OVERRIDE; | 129 virtual SkCanvas* GetPlatformCanvas() override; |
130 virtual SkCanvas* GetCanvas() OVERRIDE; | 130 virtual SkCanvas* GetCanvas() override; |
131 virtual const SkBitmap* GetMappedBitmap() const OVERRIDE; | 131 virtual const SkBitmap* GetMappedBitmap() const override; |
132 | 132 |
133 private: | 133 private: |
134 // This will be NULL before initialization, and if this PPB_ImageData_Impl is | 134 // This will be NULL before initialization, and if this PPB_ImageData_Impl is |
135 // swapped with another. | 135 // swapped with another. |
136 int width_; | 136 int width_; |
137 int height_; | 137 int height_; |
138 scoped_ptr<TransportDIB> dib_; | 138 scoped_ptr<TransportDIB> dib_; |
139 | 139 |
140 bool is_browser_allocated_; | 140 bool is_browser_allocated_; |
141 | 141 |
142 // When the device is mapped, this is the image. Null when umapped. | 142 // When the device is mapped, this is the image. Null when umapped. |
143 scoped_ptr<SkCanvas> mapped_canvas_; | 143 scoped_ptr<SkCanvas> mapped_canvas_; |
144 | 144 |
145 DISALLOW_COPY_AND_ASSIGN(ImageDataPlatformBackend); | 145 DISALLOW_COPY_AND_ASSIGN(ImageDataPlatformBackend); |
146 }; | 146 }; |
147 | 147 |
148 class ImageDataSimpleBackend : public PPB_ImageData_Impl::Backend { | 148 class ImageDataSimpleBackend : public PPB_ImageData_Impl::Backend { |
149 public: | 149 public: |
150 ImageDataSimpleBackend(); | 150 ImageDataSimpleBackend(); |
151 virtual ~ImageDataSimpleBackend(); | 151 virtual ~ImageDataSimpleBackend(); |
152 | 152 |
153 // PPB_ImageData_Impl::Backend implementation. | 153 // PPB_ImageData_Impl::Backend implementation. |
154 virtual bool Init(PPB_ImageData_Impl* impl, | 154 virtual bool Init(PPB_ImageData_Impl* impl, |
155 PP_ImageDataFormat format, | 155 PP_ImageDataFormat format, |
156 int width, | 156 int width, |
157 int height, | 157 int height, |
158 bool init_to_zero) OVERRIDE; | 158 bool init_to_zero) override; |
159 virtual bool IsMapped() const OVERRIDE; | 159 virtual bool IsMapped() const override; |
160 virtual TransportDIB* GetTransportDIB() const OVERRIDE; | 160 virtual TransportDIB* GetTransportDIB() const override; |
161 virtual void* Map() OVERRIDE; | 161 virtual void* Map() override; |
162 virtual void Unmap() OVERRIDE; | 162 virtual void Unmap() override; |
163 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE; | 163 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) override; |
164 virtual SkCanvas* GetPlatformCanvas() OVERRIDE; | 164 virtual SkCanvas* GetPlatformCanvas() override; |
165 virtual SkCanvas* GetCanvas() OVERRIDE; | 165 virtual SkCanvas* GetCanvas() override; |
166 virtual const SkBitmap* GetMappedBitmap() const OVERRIDE; | 166 virtual const SkBitmap* GetMappedBitmap() const override; |
167 | 167 |
168 private: | 168 private: |
169 scoped_ptr<base::SharedMemory> shared_memory_; | 169 scoped_ptr<base::SharedMemory> shared_memory_; |
170 // skia_bitmap_ is backed by shared_memory_. | 170 // skia_bitmap_ is backed by shared_memory_. |
171 SkBitmap skia_bitmap_; | 171 SkBitmap skia_bitmap_; |
172 scoped_ptr<SkCanvas> skia_canvas_; | 172 scoped_ptr<SkCanvas> skia_canvas_; |
173 uint32 map_count_; | 173 uint32 map_count_; |
174 | 174 |
175 DISALLOW_COPY_AND_ASSIGN(ImageDataSimpleBackend); | 175 DISALLOW_COPY_AND_ASSIGN(ImageDataSimpleBackend); |
176 }; | 176 }; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 PPB_ImageData_Impl* image_data_; | 210 PPB_ImageData_Impl* image_data_; |
211 bool is_valid_; | 211 bool is_valid_; |
212 bool needs_unmap_; | 212 bool needs_unmap_; |
213 | 213 |
214 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); | 214 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); |
215 }; | 215 }; |
216 | 216 |
217 } // namespace content | 217 } // namespace content |
218 | 218 |
219 #endif // CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ | 219 #endif // CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ |
OLD | NEW |