| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugins/ppapi/ppb_image_data_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_image_data_impl.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format, | 49 bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format, |
| 50 int width, int height, | 50 int width, int height, |
| 51 bool init_to_zero) { | 51 bool init_to_zero) { |
| 52 // TODO(brettw) this should be called only on the main thread! | 52 // TODO(brettw) this should be called only on the main thread! |
| 53 if (!IsImageDataFormatSupported(format)) | 53 if (!IsImageDataFormatSupported(format)) |
| 54 return false; // Only support this one format for now. | 54 return false; // Only support this one format for now. |
| 55 if (width <= 0 || height <= 0) | 55 if (width <= 0 || height <= 0) |
| 56 return false; | 56 return false; |
| 57 if (static_cast<int64>(width) * static_cast<int64>(height) * 4 >= | 57 if (static_cast<int64>(width) * static_cast<int64>(height) >= |
| 58 std::numeric_limits<int32>::max()) | 58 std::numeric_limits<int32>::max() / 4) |
| 59 return false; // Prevent overflow of signed 32-bit ints. | 59 return false; // Prevent overflow of signed 32-bit ints. |
| 60 | 60 |
| 61 format_ = format; | 61 format_ = format; |
| 62 width_ = width; | 62 width_ = width; |
| 63 height_ = height; | 63 height_ = height; |
| 64 return backend_->Init(this, format, width, height, init_to_zero); | 64 return backend_->Init(this, format, width, height, init_to_zero); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // static | 67 // static |
| 68 PP_Resource PPB_ImageData_Impl::CreatePlatform(PP_Instance instance, | 68 PP_Resource PPB_ImageData_Impl::CreatePlatform(PP_Instance instance, |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 278 } |
| 279 | 279 |
| 280 const SkBitmap* ImageDataNaClBackend::GetMappedBitmap() const { | 280 const SkBitmap* ImageDataNaClBackend::GetMappedBitmap() const { |
| 281 if (!IsMapped()) | 281 if (!IsMapped()) |
| 282 return NULL; | 282 return NULL; |
| 283 return &skia_bitmap_; | 283 return &skia_bitmap_; |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace ppapi | 286 } // namespace ppapi |
| 287 } // namespace webkit | 287 } // namespace webkit |
| 288 | |
| OLD | NEW |