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" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 else | 135 else |
136 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; // Default to something on failure. | 136 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; // Default to something on failure. |
137 } | 137 } |
138 | 138 |
139 // static | 139 // static |
140 bool ImageData::IsImageDataFormatSupported(PP_ImageDataFormat format) { | 140 bool ImageData::IsImageDataFormatSupported(PP_ImageDataFormat format) { |
141 return format == PP_IMAGEDATAFORMAT_BGRA_PREMUL || | 141 return format == PP_IMAGEDATAFORMAT_BGRA_PREMUL || |
142 format == PP_IMAGEDATAFORMAT_RGBA_PREMUL; | 142 format == PP_IMAGEDATAFORMAT_RGBA_PREMUL; |
143 } | 143 } |
144 | 144 |
| 145 ImageData* ImageData::AsImageData() { |
| 146 return this; |
| 147 } |
| 148 |
145 bool ImageData::Init(PP_ImageDataFormat format, | 149 bool ImageData::Init(PP_ImageDataFormat format, |
146 int width, int height, | 150 int width, int height, |
147 bool init_to_zero) { | 151 bool init_to_zero) { |
148 // TODO(brettw) this should be called only on the main thread! | 152 // TODO(brettw) this should be called only on the main thread! |
149 // TODO(brettw) use init_to_zero when we implement caching. | 153 // TODO(brettw) use init_to_zero when we implement caching. |
150 if (!IsImageDataFormatSupported(format)) | 154 if (!IsImageDataFormatSupported(format)) |
151 return false; // Only support this one format for now. | 155 return false; // Only support this one format for now. |
152 if (width <= 0 || height <= 0) | 156 if (width <= 0 || height <= 0) |
153 return false; | 157 return false; |
154 if (static_cast<int64>(width) * static_cast<int64>(height) >= | 158 if (static_cast<int64>(width) * static_cast<int64>(height) >= |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 209 |
206 void ImageData::Swap(ImageData* other) { | 210 void ImageData::Swap(ImageData* other) { |
207 swap(other->platform_image_, platform_image_); | 211 swap(other->platform_image_, platform_image_); |
208 swap(other->mapped_canvas_, mapped_canvas_); | 212 swap(other->mapped_canvas_, mapped_canvas_); |
209 std::swap(other->format_, format_); | 213 std::swap(other->format_, format_); |
210 std::swap(other->width_, width_); | 214 std::swap(other->width_, width_); |
211 std::swap(other->height_, height_); | 215 std::swap(other->height_, height_); |
212 } | 216 } |
213 | 217 |
214 } // namespace pepper | 218 } // namespace pepper |
OLD | NEW |