| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 9 #include "base/memory/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 "ppapi/shared_impl/image_data_impl.h" |
| 12 #include "ppapi/shared_impl/resource.h" | 12 #include "ppapi/shared_impl/resource.h" |
| 13 #include "ppapi/thunk/ppb_image_data_api.h" | 13 #include "ppapi/thunk/ppb_image_data_api.h" |
| 14 #include "webkit/plugins/ppapi/plugin_delegate.h" | 14 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 15 | 15 |
| 16 namespace skia { | 16 namespace skia { |
| 17 class PlatformCanvas; | 17 class PlatformCanvas; |
| 18 } | 18 } |
| 19 | 19 |
| 20 struct PPB_ImageDataTrusted; | |
| 21 class SkBitmap; | 20 class SkBitmap; |
| 22 | 21 |
| 23 namespace webkit { | 22 namespace webkit { |
| 24 namespace ppapi { | 23 namespace ppapi { |
| 25 | 24 |
| 26 class PPB_ImageData_Impl : public ::ppapi::Resource, | 25 class PPB_ImageData_Impl : public ::ppapi::Resource, |
| 27 public ::ppapi::ImageDataImpl, | 26 public ::ppapi::ImageDataImpl, |
| 28 public ::ppapi::thunk::PPB_ImageData_API { | 27 public ::ppapi::thunk::PPB_ImageData_API { |
| 29 public: | 28 public: |
| 30 // If you call this constructor, you must also call Init before use. Normally | 29 // If you call this constructor, you must also call Init before use. Normally |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // state. You must check is_valid() to make sure the image was successfully | 90 // state. You must check is_valid() to make sure the image was successfully |
| 92 // mapped before using it. | 91 // mapped before using it. |
| 93 // | 92 // |
| 94 // Example: | 93 // Example: |
| 95 // ImageDataAutoMapper mapper(image_data); | 94 // ImageDataAutoMapper mapper(image_data); |
| 96 // if (!mapper.is_valid()) | 95 // if (!mapper.is_valid()) |
| 97 // return utter_failure; | 96 // return utter_failure; |
| 98 // image_data->mapped_canvas()->blah(); // Guaranteed valid. | 97 // image_data->mapped_canvas()->blah(); // Guaranteed valid. |
| 99 class ImageDataAutoMapper { | 98 class ImageDataAutoMapper { |
| 100 public: | 99 public: |
| 101 ImageDataAutoMapper(PPB_ImageData_Impl* image_data) | 100 explicit ImageDataAutoMapper(PPB_ImageData_Impl* image_data) |
| 102 : image_data_(image_data) { | 101 : image_data_(image_data) { |
| 103 if (image_data_->is_mapped()) { | 102 if (image_data_->is_mapped()) { |
| 104 is_valid_ = true; | 103 is_valid_ = true; |
| 105 needs_unmap_ = false; | 104 needs_unmap_ = false; |
| 106 } else { | 105 } else { |
| 107 is_valid_ = needs_unmap_ = !!image_data_->Map(); | 106 is_valid_ = needs_unmap_ = !!image_data_->Map(); |
| 108 } | 107 } |
| 109 } | 108 } |
| 110 | 109 |
| 111 ~ImageDataAutoMapper() { | 110 ~ImageDataAutoMapper() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 122 bool is_valid_; | 121 bool is_valid_; |
| 123 bool needs_unmap_; | 122 bool needs_unmap_; |
| 124 | 123 |
| 125 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); | 124 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 } // namespace ppapi | 127 } // namespace ppapi |
| 129 } // namespace webkit | 128 } // namespace webkit |
| 130 | 129 |
| 131 #endif // WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_ | 130 #endif // WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_ |
| OLD | NEW |