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" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "skia/ext/platform_canvas.h" | 12 #include "skia/ext/platform_canvas.h" |
13 #include "third_party/ppapi/c/pp_instance.h" | 13 #include "third_party/ppapi/c/pp_instance.h" |
14 #include "third_party/ppapi/c/pp_module.h" | 14 #include "third_party/ppapi/c/pp_module.h" |
15 #include "third_party/ppapi/c/pp_resource.h" | 15 #include "third_party/ppapi/c/pp_resource.h" |
16 #include "third_party/ppapi/c/ppb_image_data.h" | 16 #include "third_party/ppapi/c/ppb_image_data.h" |
17 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 17 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
18 #include "webkit/glue/plugins/pepper_plugin_module.h" | 18 #include "webkit/glue/plugins/pepper_plugin_module.h" |
19 #include "webkit/glue/plugins/pepper_resource_tracker.h" | 19 #include "webkit/glue/plugins/pepper_resource_tracker.h" |
20 | 20 |
21 namespace pepper { | 21 namespace pepper { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 ImageData* ResourceAsImageData(PP_Resource resource) { | |
26 scoped_refptr<Resource> image_resource = | |
27 ResourceTracker::Get()->GetResource(resource); | |
28 if (!image_resource.get()) | |
29 return NULL; | |
30 return image_resource->AsImageData(); | |
31 } | |
32 | |
33 PP_ImageDataFormat GetNativeImageDataFormat() { | 25 PP_ImageDataFormat GetNativeImageDataFormat() { |
34 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; | 26 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; |
35 } | 27 } |
36 | 28 |
37 PP_Resource Create(PP_Module module_id, | 29 PP_Resource Create(PP_Module module_id, |
38 PP_ImageDataFormat format, | 30 PP_ImageDataFormat format, |
39 int32_t width, int32_t height, | 31 int32_t width, int32_t height, |
40 bool init_to_zero) { | 32 bool init_to_zero) { |
41 PluginModule* module = PluginModule::FromPPModule(module_id); | 33 PluginModule* module = PluginModule::FromPPModule(module_id); |
42 if (!module) | 34 if (!module) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 157 } |
166 | 158 |
167 void ImageData::Swap(ImageData* other) { | 159 void ImageData::Swap(ImageData* other) { |
168 swap(other->platform_image_, platform_image_); | 160 swap(other->platform_image_, platform_image_); |
169 swap(other->mapped_canvas_, mapped_canvas_); | 161 swap(other->mapped_canvas_, mapped_canvas_); |
170 std::swap(other->width_, width_); | 162 std::swap(other->width_, width_); |
171 std::swap(other->height_, height_); | 163 std::swap(other->height_, height_); |
172 } | 164 } |
173 | 165 |
174 } // namespace pepper | 166 } // namespace pepper |
OLD | NEW |