| 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 "ppapi/cpp/image_data.h" | 5 #include "ppapi/cpp/image_data.h" |
| 6 | 6 |
| 7 #include <string.h> // Needed for memset. | 7 #include <string.h> // Needed for memset. |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "ppapi/cpp/common.h" | |
| 12 #include "ppapi/cpp/instance.h" | 11 #include "ppapi/cpp/instance.h" |
| 13 #include "ppapi/cpp/module.h" | 12 #include "ppapi/cpp/module.h" |
| 14 #include "ppapi/cpp/module_impl.h" | 13 #include "ppapi/cpp/module_impl.h" |
| 15 | 14 |
| 16 namespace pp { | 15 namespace pp { |
| 17 | 16 |
| 18 namespace { | 17 namespace { |
| 19 | 18 |
| 20 template <> const char* interface_name<PPB_ImageData>() { | 19 template <> const char* interface_name<PPB_ImageData>() { |
| 21 return PPB_IMAGEDATA_INTERFACE; | 20 return PPB_IMAGEDATA_INTERFACE; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 48 const Size& size, | 47 const Size& size, |
| 49 bool init_to_zero) | 48 bool init_to_zero) |
| 50 : data_(NULL) { | 49 : data_(NULL) { |
| 51 memset(&desc_, 0, sizeof(PP_ImageDataDesc)); | 50 memset(&desc_, 0, sizeof(PP_ImageDataDesc)); |
| 52 | 51 |
| 53 if (!has_interface<PPB_ImageData>()) | 52 if (!has_interface<PPB_ImageData>()) |
| 54 return; | 53 return; |
| 55 | 54 |
| 56 PassRefAndInitData(get_interface<PPB_ImageData>()->Create( | 55 PassRefAndInitData(get_interface<PPB_ImageData>()->Create( |
| 57 instance->pp_instance(), format, &size.pp_size(), | 56 instance->pp_instance(), format, &size.pp_size(), |
| 58 BoolToPPBool(init_to_zero))); | 57 PP_FromBool(init_to_zero))); |
| 59 } | 58 } |
| 60 | 59 |
| 61 ImageData& ImageData::operator=(const ImageData& other) { | 60 ImageData& ImageData::operator=(const ImageData& other) { |
| 62 Resource::operator=(other); | 61 Resource::operator=(other); |
| 63 desc_ = other.desc_; | 62 desc_ = other.desc_; |
| 64 data_ = other.data_; | 63 data_ = other.data_; |
| 65 return *this; | 64 return *this; |
| 66 } | 65 } |
| 67 | 66 |
| 68 const uint32_t* ImageData::GetAddr32(const Point& coord) const { | 67 const uint32_t* ImageData::GetAddr32(const Point& coord) const { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 } | 84 } |
| 86 | 85 |
| 87 void ImageData::PassRefAndInitData(PP_Resource resource) { | 86 void ImageData::PassRefAndInitData(PP_Resource resource) { |
| 88 PassRefFromConstructor(resource); | 87 PassRefFromConstructor(resource); |
| 89 if (!get_interface<PPB_ImageData>()->Describe(pp_resource(), &desc_) || | 88 if (!get_interface<PPB_ImageData>()->Describe(pp_resource(), &desc_) || |
| 90 !(data_ = get_interface<PPB_ImageData>()->Map(pp_resource()))) | 89 !(data_ = get_interface<PPB_ImageData>()->Map(pp_resource()))) |
| 91 *this = ImageData(); | 90 *this = ImageData(); |
| 92 } | 91 } |
| 93 | 92 |
| 94 } // namespace pp | 93 } // namespace pp |
| OLD | NEW |