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, uint32_t* byte_count) { | 82 int32_t GetSharedMemory(PP_Resource resource, |
| 83 int* handle, |
| 84 uint32_t* byte_count) { |
83 scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource)); | 85 scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource)); |
84 if (image_data) | 86 if (image_data) { |
85 return image_data->GetNativeMemoryHandle(byte_count); | 87 *handle = image_data->GetSharedMemoryHandle(byte_count); |
86 return 0; | 88 return PP_OK; |
| 89 } |
| 90 return PP_ERROR_BADRESOURCE; |
87 } | 91 } |
88 | 92 |
89 const PPB_ImageData ppb_imagedata = { | 93 const PPB_ImageData ppb_imagedata = { |
90 &GetNativeImageDataFormat, | 94 &GetNativeImageDataFormat, |
91 &IsImageDataFormatSupported, | 95 &IsImageDataFormatSupported, |
92 &Create, | 96 &Create, |
93 &IsImageData, | 97 &IsImageData, |
94 &Describe, | 98 &Describe, |
95 &Map, | 99 &Map, |
96 &Unmap, | 100 &Unmap, |
97 }; | 101 }; |
98 | 102 |
99 const PPB_ImageDataTrusted ppb_imagedata_trusted = { | 103 const PPB_ImageDataTrusted ppb_imagedata_trusted = { |
100 &GetNativeMemoryHandle2, | 104 &GetSharedMemory, |
101 }; | 105 }; |
102 | 106 |
103 } // namespace | 107 } // namespace |
104 | 108 |
105 ImageData::ImageData(PluginModule* module) | 109 ImageData::ImageData(PluginModule* module) |
106 : Resource(module), | 110 : Resource(module), |
107 format_(PP_IMAGEDATAFORMAT_BGRA_PREMUL), | 111 format_(PP_IMAGEDATAFORMAT_BGRA_PREMUL), |
108 width_(0), | 112 width_(0), |
109 height_(0) { | 113 height_(0) { |
110 } | 114 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return bitmap.getAddr32(0, 0); | 186 return bitmap.getAddr32(0, 0); |
183 } | 187 } |
184 | 188 |
185 void ImageData::Unmap() { | 189 void ImageData::Unmap() { |
186 // This is currently unimplemented, which is OK. The data will just always | 190 // 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 | 191 // 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 | 192 // unmappable without freeing it, but this may be something we want to support |
189 // in the future to save some memory. | 193 // in the future to save some memory. |
190 } | 194 } |
191 | 195 |
192 uint64 ImageData::GetNativeMemoryHandle(uint32* byte_count) const { | 196 int ImageData::GetSharedMemoryHandle(uint32* byte_count) const { |
193 return platform_image_->GetSharedMemoryHandle(byte_count); | 197 return platform_image_->GetSharedMemoryHandle(byte_count); |
194 } | 198 } |
195 | 199 |
196 const SkBitmap* ImageData::GetMappedBitmap() const { | 200 const SkBitmap* ImageData::GetMappedBitmap() const { |
197 if (!mapped_canvas_.get()) | 201 if (!mapped_canvas_.get()) |
198 return NULL; | 202 return NULL; |
199 return &mapped_canvas_->getTopPlatformDevice().accessBitmap(false); | 203 return &mapped_canvas_->getTopPlatformDevice().accessBitmap(false); |
200 } | 204 } |
201 | 205 |
202 void ImageData::Swap(ImageData* other) { | 206 void ImageData::Swap(ImageData* other) { |
203 swap(other->platform_image_, platform_image_); | 207 swap(other->platform_image_, platform_image_); |
204 swap(other->mapped_canvas_, mapped_canvas_); | 208 swap(other->mapped_canvas_, mapped_canvas_); |
205 std::swap(other->format_, format_); | 209 std::swap(other->format_, format_); |
206 std::swap(other->width_, width_); | 210 std::swap(other->width_, width_); |
207 std::swap(other->height_, height_); | 211 std::swap(other->height_, height_); |
208 } | 212 } |
209 | 213 |
210 } // namespace pepper | 214 } // namespace pepper |
OLD | NEW |