| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 PP_ImageDataFormat format, | 44 PP_ImageDataFormat format, |
| 45 int width, | 45 int width, |
| 46 int height, | 46 int height, |
| 47 bool init_to_zero) = 0; | 47 bool init_to_zero) = 0; |
| 48 virtual bool IsMapped() const = 0; | 48 virtual bool IsMapped() const = 0; |
| 49 virtual TransportDIB* GetTransportDIB() const = 0; | 49 virtual TransportDIB* GetTransportDIB() const = 0; |
| 50 virtual void* Map() = 0; | 50 virtual void* Map() = 0; |
| 51 virtual void Unmap() = 0; | 51 virtual void Unmap() = 0; |
| 52 virtual int32_t GetSharedMemory(base::SharedMemory** shm, | 52 virtual int32_t GetSharedMemory(base::SharedMemory** shm, |
| 53 uint32_t* byte_count) = 0; | 53 uint32_t* byte_count) = 0; |
| 54 virtual SkCanvas* GetPlatformCanvas() = 0; | |
| 55 virtual SkCanvas* GetCanvas() = 0; | 54 virtual SkCanvas* GetCanvas() = 0; |
| 56 virtual SkBitmap GetMappedBitmap() const = 0; | 55 virtual SkBitmap GetMappedBitmap() const = 0; |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 // If you call this constructor, you must also call Init before use. Normally | 58 // If you call this constructor, you must also call Init before use. Normally |
| 60 // you should use the static Create function, but this constructor is needed | 59 // you should use the static Create function, but this constructor is needed |
| 61 // for some internal uses of ImageData (like Graphics2D). | 60 // for some internal uses of ImageData (like Graphics2D). |
| 62 PPB_ImageData_Impl(PP_Instance instance, | 61 PPB_ImageData_Impl(PP_Instance instance, |
| 63 PPB_ImageData_Shared::ImageDataType type); | 62 PPB_ImageData_Shared::ImageDataType type); |
| 64 | 63 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 | 89 |
| 91 // Resource override. | 90 // Resource override. |
| 92 ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() override; | 91 ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() override; |
| 93 | 92 |
| 94 // PPB_ImageData_API implementation. | 93 // PPB_ImageData_API implementation. |
| 95 PP_Bool Describe(PP_ImageDataDesc* desc) override; | 94 PP_Bool Describe(PP_ImageDataDesc* desc) override; |
| 96 void* Map() override; | 95 void* Map() override; |
| 97 void Unmap() override; | 96 void Unmap() override; |
| 98 int32_t GetSharedMemory(base::SharedMemory** shm, | 97 int32_t GetSharedMemory(base::SharedMemory** shm, |
| 99 uint32_t* byte_count) override; | 98 uint32_t* byte_count) override; |
| 100 SkCanvas* GetPlatformCanvas() override; | |
| 101 SkCanvas* GetCanvas() override; | 99 SkCanvas* GetCanvas() override; |
| 102 void SetIsCandidateForReuse() override; | 100 void SetIsCandidateForReuse() override; |
| 103 | 101 |
| 104 // Returns an *empty* bitmap on error. | 102 // Returns an *empty* bitmap on error. |
| 105 // Users must call SkBitmap::lockPixels() before SkBitmap::getPixels(); | 103 // Users must call SkBitmap::lockPixels() before SkBitmap::getPixels(); |
| 106 // unlockPixels() will be automatically invoked if necessary when the | 104 // unlockPixels() will be automatically invoked if necessary when the |
| 107 // bitmap goes out of scope. | 105 // bitmap goes out of scope. |
| 108 SkBitmap GetMappedBitmap() const; | 106 SkBitmap GetMappedBitmap() const; |
| 109 | 107 |
| 110 private: | 108 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 130 PP_ImageDataFormat format, | 128 PP_ImageDataFormat format, |
| 131 int width, | 129 int width, |
| 132 int height, | 130 int height, |
| 133 bool init_to_zero) override; | 131 bool init_to_zero) override; |
| 134 bool IsMapped() const override; | 132 bool IsMapped() const override; |
| 135 TransportDIB* GetTransportDIB() const override; | 133 TransportDIB* GetTransportDIB() const override; |
| 136 void* Map() override; | 134 void* Map() override; |
| 137 void Unmap() override; | 135 void Unmap() override; |
| 138 int32_t GetSharedMemory(base::SharedMemory** shm, | 136 int32_t GetSharedMemory(base::SharedMemory** shm, |
| 139 uint32_t* byte_count) override; | 137 uint32_t* byte_count) override; |
| 140 SkCanvas* GetPlatformCanvas() override; | |
| 141 SkCanvas* GetCanvas() override; | 138 SkCanvas* GetCanvas() override; |
| 142 SkBitmap GetMappedBitmap() const override; | 139 SkBitmap GetMappedBitmap() const override; |
| 143 | 140 |
| 144 private: | 141 private: |
| 145 // This will be NULL before initialization, and if this PPB_ImageData_Impl is | 142 // This will be NULL before initialization, and if this PPB_ImageData_Impl is |
| 146 // swapped with another. | 143 // swapped with another. |
| 147 int width_; | 144 int width_; |
| 148 int height_; | 145 int height_; |
| 149 std::unique_ptr<TransportDIB> dib_; | 146 std::unique_ptr<TransportDIB> dib_; |
| 150 | 147 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 164 PP_ImageDataFormat format, | 161 PP_ImageDataFormat format, |
| 165 int width, | 162 int width, |
| 166 int height, | 163 int height, |
| 167 bool init_to_zero) override; | 164 bool init_to_zero) override; |
| 168 bool IsMapped() const override; | 165 bool IsMapped() const override; |
| 169 TransportDIB* GetTransportDIB() const override; | 166 TransportDIB* GetTransportDIB() const override; |
| 170 void* Map() override; | 167 void* Map() override; |
| 171 void Unmap() override; | 168 void Unmap() override; |
| 172 int32_t GetSharedMemory(base::SharedMemory** shm, | 169 int32_t GetSharedMemory(base::SharedMemory** shm, |
| 173 uint32_t* byte_count) override; | 170 uint32_t* byte_count) override; |
| 174 SkCanvas* GetPlatformCanvas() override; | |
| 175 SkCanvas* GetCanvas() override; | 171 SkCanvas* GetCanvas() override; |
| 176 SkBitmap GetMappedBitmap() const override; | 172 SkBitmap GetMappedBitmap() const override; |
| 177 | 173 |
| 178 private: | 174 private: |
| 179 std::unique_ptr<base::SharedMemory> shared_memory_; | 175 std::unique_ptr<base::SharedMemory> shared_memory_; |
| 180 // skia_bitmap_ is backed by shared_memory_. | 176 // skia_bitmap_ is backed by shared_memory_. |
| 181 SkBitmap skia_bitmap_; | 177 SkBitmap skia_bitmap_; |
| 182 std::unique_ptr<SkCanvas> skia_canvas_; | 178 std::unique_ptr<SkCanvas> skia_canvas_; |
| 183 uint32_t map_count_; | 179 uint32_t map_count_; |
| 184 | 180 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 PPB_ImageData_Impl* image_data_; | 216 PPB_ImageData_Impl* image_data_; |
| 221 bool is_valid_; | 217 bool is_valid_; |
| 222 bool needs_unmap_; | 218 bool needs_unmap_; |
| 223 | 219 |
| 224 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); | 220 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); |
| 225 }; | 221 }; |
| 226 | 222 |
| 227 } // namespace content | 223 } // namespace content |
| 228 | 224 |
| 229 #endif // CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ | 225 #endif // CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ |
| OLD | NEW |