OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "webkit/glue/plugins/pepper_image_data.h" | 5 #include "webkit/glue/plugins/pepper_image_data.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 return NULL; | 72 return NULL; |
73 return image_data->Map(); | 73 return image_data->Map(); |
74 } | 74 } |
75 | 75 |
76 void Unmap(PP_Resource resource) { | 76 void Unmap(PP_Resource resource) { |
77 scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource)); | 77 scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource)); |
78 if (image_data) | 78 if (image_data) |
79 image_data->Unmap(); | 79 image_data->Unmap(); |
80 } | 80 } |
81 | 81 |
82 uint64_t GetNativeMemoryHandle2(PP_Resource resource) { | 82 uint64_t GetNativeMemoryHandle2(PP_Resource resource, uint32_t* byte_count) { |
83 scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource)); | 83 scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource)); |
84 if (image_data) | 84 if (image_data) |
85 return image_data->GetNativeMemoryHandle(); | 85 return image_data->GetNativeMemoryHandle(byte_count); |
86 return 0; | 86 return 0; |
87 } | 87 } |
88 | 88 |
89 const PPB_ImageData ppb_imagedata = { | 89 const PPB_ImageData ppb_imagedata = { |
90 &GetNativeImageDataFormat, | 90 &GetNativeImageDataFormat, |
91 &IsImageDataFormatSupported, | 91 &IsImageDataFormatSupported, |
92 &Create, | 92 &Create, |
93 &IsImageData, | 93 &IsImageData, |
94 &Describe, | 94 &Describe, |
95 &Map, | 95 &Map, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return bitmap.getAddr32(0, 0); | 182 return bitmap.getAddr32(0, 0); |
183 } | 183 } |
184 | 184 |
185 void ImageData::Unmap() { | 185 void ImageData::Unmap() { |
186 // This is currently unimplemented, which is OK. The data will just always | 186 // This is currently unimplemented, which is OK. The data will just always |
187 // be around once it's mapped. Chrome's TransportDIB isn't currently | 187 // be around once it's mapped. Chrome's TransportDIB isn't currently |
188 // unmappable without freeing it, but this may be something we want to support | 188 // unmappable without freeing it, but this may be something we want to support |
189 // in the future to save some memory. | 189 // in the future to save some memory. |
190 } | 190 } |
191 | 191 |
192 uint64 ImageData::GetNativeMemoryHandle() const { | 192 uint64 ImageData::GetNativeMemoryHandle(uint32* byte_count) const { |
193 return platform_image_->GetSharedMemoryHandle(); | 193 return platform_image_->GetSharedMemoryHandle(byte_count); |
194 } | 194 } |
195 | 195 |
196 const SkBitmap* ImageData::GetMappedBitmap() const { | 196 const SkBitmap* ImageData::GetMappedBitmap() const { |
197 if (!mapped_canvas_.get()) | 197 if (!mapped_canvas_.get()) |
198 return NULL; | 198 return NULL; |
199 return &mapped_canvas_->getTopPlatformDevice().accessBitmap(false); | 199 return &mapped_canvas_->getTopPlatformDevice().accessBitmap(false); |
200 } | 200 } |
201 | 201 |
202 void ImageData::Swap(ImageData* other) { | 202 void ImageData::Swap(ImageData* other) { |
203 swap(other->platform_image_, platform_image_); | 203 swap(other->platform_image_, platform_image_); |
204 swap(other->mapped_canvas_, mapped_canvas_); | 204 swap(other->mapped_canvas_, mapped_canvas_); |
205 std::swap(other->format_, format_); | 205 std::swap(other->format_, format_); |
206 std::swap(other->width_, width_); | 206 std::swap(other->width_, width_); |
207 std::swap(other->height_, height_); | 207 std::swap(other->height_, height_); |
208 } | 208 } |
209 | 209 |
210 } // namespace pepper | 210 } // namespace pepper |
OLD | NEW |