| 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 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "ppapi/c/ppb_image_data.h" | 10 #include "ppapi/c/ppb_image_data.h" |
| 11 #include "ppapi/shared_impl/image_data_impl.h" |
| 11 #include "webkit/plugins/ppapi/plugin_delegate.h" | 12 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 12 #include "webkit/plugins/ppapi/resource.h" | 13 #include "webkit/plugins/ppapi/resource.h" |
| 13 | 14 |
| 14 namespace skia { | 15 namespace skia { |
| 15 class PlatformCanvas; | 16 class PlatformCanvas; |
| 16 } | 17 } |
| 17 | 18 |
| 18 struct PPB_ImageDataTrusted; | 19 struct PPB_ImageDataTrusted; |
| 19 class SkBitmap; | 20 class SkBitmap; |
| 20 | 21 |
| 21 namespace webkit { | 22 namespace webkit { |
| 22 namespace ppapi { | 23 namespace ppapi { |
| 23 | 24 |
| 24 class PPB_ImageData_Impl : public Resource { | 25 class PPB_ImageData_Impl : public Resource, |
| 26 public pp::shared_impl::ImageDataImpl { |
| 25 public: | 27 public: |
| 26 explicit PPB_ImageData_Impl(PluginInstance* instance); | 28 explicit PPB_ImageData_Impl(PluginInstance* instance); |
| 27 virtual ~PPB_ImageData_Impl(); | 29 virtual ~PPB_ImageData_Impl(); |
| 28 | 30 |
| 29 int width() const { return width_; } | 31 int width() const { return width_; } |
| 30 int height() const { return height_; } | 32 int height() const { return height_; } |
| 31 | 33 |
| 32 // Returns the image format. | 34 // Returns the image format. |
| 33 PP_ImageDataFormat format() const { return format_; } | 35 PP_ImageDataFormat format() const { return format_; } |
| 34 | 36 |
| 35 // Returns true if this image is mapped. False means that the image is either | 37 // Returns true if this image is mapped. False means that the image is either |
| 36 // invalid or not mapped. See ImageDataAutoMapper below. | 38 // invalid or not mapped. See ImageDataAutoMapper below. |
| 37 bool is_mapped() const { return !!mapped_canvas_.get(); } | 39 bool is_mapped() const { return !!mapped_canvas_.get(); } |
| 38 | 40 |
| 39 PluginDelegate::PlatformImage2D* platform_image() const { | 41 PluginDelegate::PlatformImage2D* platform_image() const { |
| 40 return platform_image_.get(); | 42 return platform_image_.get(); |
| 41 } | 43 } |
| 42 | 44 |
| 43 // Returns a pointer to the interface implementing PPB_ImageData that is | 45 // Returns a pointer to the interface implementing PPB_ImageData that is |
| 44 // exposed to the plugin. | 46 // exposed to the plugin. |
| 45 static const PPB_ImageData* GetInterface(); | 47 static const PPB_ImageData* GetInterface(); |
| 46 static const PPB_ImageDataTrusted* GetTrustedInterface(); | 48 static const PPB_ImageDataTrusted* GetTrustedInterface(); |
| 47 | 49 |
| 48 // Returns the image data format used by the browser. If the plugin uses the | |
| 49 // same format, there is no conversion. Otherwise the browser will be in | |
| 50 // charge of converting from a supported format to its native format. | |
| 51 static PP_ImageDataFormat GetNativeImageDataFormat(); | |
| 52 | |
| 53 // Returns true if the format is supported by the browser. | |
| 54 static bool IsImageDataFormatSupported(PP_ImageDataFormat format); | |
| 55 | |
| 56 // Resource overrides. | 50 // Resource overrides. |
| 57 virtual PPB_ImageData_Impl* AsPPB_ImageData_Impl(); | 51 virtual PPB_ImageData_Impl* AsPPB_ImageData_Impl(); |
| 58 | 52 |
| 59 // PPB_ImageData implementation. | 53 // PPB_ImageData implementation. |
| 60 bool Init(PP_ImageDataFormat format, | 54 bool Init(PP_ImageDataFormat format, |
| 61 int width, int height, | 55 int width, int height, |
| 62 bool init_to_zero); | 56 bool init_to_zero); |
| 63 void Describe(PP_ImageDataDesc* desc) const; | 57 void Describe(PP_ImageDataDesc* desc) const; |
| 64 void* Map(); | 58 void* Map(); |
| 65 void Unmap(); | 59 void Unmap(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 bool is_valid_; | 119 bool is_valid_; |
| 126 bool needs_unmap_; | 120 bool needs_unmap_; |
| 127 | 121 |
| 128 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); | 122 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); |
| 129 }; | 123 }; |
| 130 | 124 |
| 131 } // namespace ppapi | 125 } // namespace ppapi |
| 132 } // namespace webkit | 126 } // namespace webkit |
| 133 | 127 |
| 134 #endif // WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_ | 128 #endif // WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_ |
| OLD | NEW |