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 |
(...skipping 25 matching lines...) Expand all Loading... |
36 ImageData::ImageData(PassRef, PP_Resource resource) | 36 ImageData::ImageData(PassRef, PP_Resource resource) |
37 : data_(NULL) { | 37 : data_(NULL) { |
38 memset(&desc_, 0, sizeof(PP_ImageDataDesc)); | 38 memset(&desc_, 0, sizeof(PP_ImageDataDesc)); |
39 | 39 |
40 if (!has_interface<PPB_ImageData>()) | 40 if (!has_interface<PPB_ImageData>()) |
41 return; | 41 return; |
42 | 42 |
43 PassRefAndInitData(resource); | 43 PassRefAndInitData(resource); |
44 } | 44 } |
45 | 45 |
46 ImageData::ImageData(PP_ImageDataFormat format, | 46 ImageData::ImageData(Instance* instance, |
| 47 PP_ImageDataFormat format, |
47 const Size& size, | 48 const Size& size, |
48 bool init_to_zero) | 49 bool init_to_zero) |
49 : data_(NULL) { | 50 : data_(NULL) { |
50 memset(&desc_, 0, sizeof(PP_ImageDataDesc)); | 51 memset(&desc_, 0, sizeof(PP_ImageDataDesc)); |
51 | 52 |
52 if (!has_interface<PPB_ImageData>()) | 53 if (!has_interface<PPB_ImageData>()) |
53 return; | 54 return; |
54 | 55 |
55 PassRefAndInitData(get_interface<PPB_ImageData>()->Create( | 56 PassRefAndInitData(get_interface<PPB_ImageData>()->Create( |
56 Module::Get()->pp_module(), format, &size.pp_size(), | 57 instance->pp_instance(), format, &size.pp_size(), |
57 BoolToPPBool(init_to_zero))); | 58 BoolToPPBool(init_to_zero))); |
58 } | 59 } |
59 | 60 |
60 ImageData& ImageData::operator=(const ImageData& other) { | 61 ImageData& ImageData::operator=(const ImageData& other) { |
61 Resource::operator=(other); | 62 Resource::operator=(other); |
62 desc_ = other.desc_; | 63 desc_ = other.desc_; |
63 data_ = other.data_; | 64 data_ = other.data_; |
64 return *this; | 65 return *this; |
65 } | 66 } |
66 | 67 |
(...skipping 17 matching lines...) Expand all Loading... |
84 } | 85 } |
85 | 86 |
86 void ImageData::PassRefAndInitData(PP_Resource resource) { | 87 void ImageData::PassRefAndInitData(PP_Resource resource) { |
87 PassRefFromConstructor(resource); | 88 PassRefFromConstructor(resource); |
88 if (!get_interface<PPB_ImageData>()->Describe(pp_resource(), &desc_) || | 89 if (!get_interface<PPB_ImageData>()->Describe(pp_resource(), &desc_) || |
89 !(data_ = get_interface<PPB_ImageData>()->Map(pp_resource()))) | 90 !(data_ = get_interface<PPB_ImageData>()->Map(pp_resource()))) |
90 *this = ImageData(); | 91 *this = ImageData(); |
91 } | 92 } |
92 | 93 |
93 } // namespace pp | 94 } // namespace pp |
OLD | NEW |