| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "platform/graphics/skia/ImagePixelLocker.h" | 5 #include "platform/graphics/skia/ImagePixelLocker.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkImage.h" | 7 #include "third_party/skia/include/core/SkImage.h" |
| 8 #include "third_party/skia/include/core/SkImageInfo.h" | 8 #include "third_party/skia/include/core/SkImageInfo.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 bool InfoIsCompatible(const SkImageInfo& info, | 14 bool InfoIsCompatible(const SkImageInfo& info, |
| 15 SkAlphaType alpha_type, | 15 SkAlphaType alpha_type, |
| 16 SkColorType color_type) { | 16 SkColorType color_type) { |
| 17 ASSERT(alpha_type != kUnknown_SkAlphaType); | 17 DCHECK_NE(alpha_type, kUnknown_SkAlphaType); |
| 18 | 18 |
| 19 if (info.colorType() != color_type) | 19 if (info.colorType() != color_type) |
| 20 return false; | 20 return false; |
| 21 | 21 |
| 22 // kOpaque_SkAlphaType works regardless of the requested alphaType. | 22 // kOpaque_SkAlphaType works regardless of the requested alphaType. |
| 23 return info.alphaType() == alpha_type || | 23 return info.alphaType() == alpha_type || |
| 24 info.alphaType() == kOpaque_SkAlphaType; | 24 info.alphaType() == kOpaque_SkAlphaType; |
| 25 } | 25 } |
| 26 | 26 |
| 27 } // anonymous namespace | 27 } // anonymous namespace |
| (...skipping 26 matching lines...) Expand all Loading... |
| 54 pixel_storage_.Resize(size); // this will throw on failure | 54 pixel_storage_.Resize(size); // this will throw on failure |
| 55 pixmap.reset(info, pixel_storage_.Data(), row_bytes); | 55 pixmap.reset(info, pixel_storage_.Data(), row_bytes); |
| 56 | 56 |
| 57 if (!image_->readPixels(pixmap, 0, 0)) | 57 if (!image_->readPixels(pixmap, 0, 0)) |
| 58 return; | 58 return; |
| 59 | 59 |
| 60 pixels_ = pixel_storage_.Data(); | 60 pixels_ = pixel_storage_.Data(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |