Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "core/frame/ImageBitmap.h" | 5 #include "core/frame/ImageBitmap.h" |
| 6 | 6 |
| 7 #include "core/html/HTMLCanvasElement.h" | 7 #include "core/html/HTMLCanvasElement.h" |
| 8 #include "core/html/HTMLVideoElement.h" | 8 #include "core/html/HTMLVideoElement.h" |
| 9 #include "core/html/ImageData.h" | 9 #include "core/html/ImageData.h" |
| 10 #include "platform/graphics/skia/SkiaUtils.h" | 10 #include "platform/graphics/skia/SkiaUtils.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 return nullptr; | 140 return nullptr; |
| 141 decoder->setData(image->data(), true); | 141 decoder->setData(image->data(), true); |
| 142 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); | 142 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); |
| 143 if (!skiaImage) | 143 if (!skiaImage) |
| 144 return nullptr; | 144 return nullptr; |
| 145 } | 145 } |
| 146 | 146 |
| 147 if (cropRect == srcRect) { | 147 if (cropRect == srcRect) { |
| 148 if (flipY) | 148 if (flipY) |
| 149 return StaticBitmapImage::create(flipSkImageVertically(skiaImage->ne wSubset(srcRect), premultiplyAlpha ? PremultiplyAlpha : DontPremultiplyAlpha)); | 149 return StaticBitmapImage::create(flipSkImageVertically(skiaImage->ne wSubset(srcRect), premultiplyAlpha ? PremultiplyAlpha : DontPremultiplyAlpha)); |
| 150 SkImage* croppedSkImage = skiaImage->newSubset(srcRect); | 150 RefPtr<SkImage> croppedSkImage = fromSkSp(skiaImage->makeSubset(srcRect) ); |
| 151 // Special case: The first parameter image is unpremul but we need to tu rn it into premul. | 151 // Special case: The first parameter image is unpremul but we need to tu rn it into premul. |
| 152 if (premultiplyAlpha && imageFormat == DontPremultiplyAlpha) | 152 if (premultiplyAlpha && imageFormat == DontPremultiplyAlpha) |
| 153 return StaticBitmapImage::create(unPremulSkImageToPremul(croppedSkIm age)); | 153 return StaticBitmapImage::create(unPremulSkImageToPremul(croppedSkIm age.get())); |
| 154 // Call preroll to trigger image decoding. | 154 // Call preroll to trigger image decoding. |
| 155 croppedSkImage->preroll(); | 155 croppedSkImage->preroll(); |
|
f(malita)
2016/06/15 08:41:54
Unrelated to this CL: I think I understand why we
xidachen
2016/06/15 08:56:11
The problem is that ImageBitmapLoader is not alway
xidachen
2016/06/15 08:57:29
sorry, I meant is there a way to check whether the
| |
| 156 return StaticBitmapImage::create(adoptRef(croppedSkImage)); | 156 return StaticBitmapImage::create(croppedSkImage.release()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(cropRect.width(), cropRect.height()); | 159 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(cropRect.width(), cropRect.height()); |
| 160 if (!surface) | 160 if (!surface) |
| 161 return nullptr; | 161 return nullptr; |
| 162 if (srcRect.isEmpty()) | 162 if (srcRect.isEmpty()) |
| 163 return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot())); | 163 return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot())); |
| 164 | 164 |
| 165 SkScalar dstLeft = std::min(0, -cropRect.x()); | 165 SkScalar dstLeft = std::min(0, -cropRect.x()); |
| 166 SkScalar dstTop = std::min(0, -cropRect.y()); | 166 SkScalar dstTop = std::min(0, -cropRect.y()); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 FloatSize ImageBitmap::elementSize(const FloatSize&) const | 512 FloatSize ImageBitmap::elementSize(const FloatSize&) const |
| 513 { | 513 { |
| 514 return FloatSize(width(), height()); | 514 return FloatSize(width(), height()); |
| 515 } | 515 } |
| 516 | 516 |
| 517 DEFINE_TRACE(ImageBitmap) | 517 DEFINE_TRACE(ImageBitmap) |
| 518 { | 518 { |
| 519 } | 519 } |
| 520 | 520 |
| 521 } // namespace blink | 521 } // namespace blink |
| OLD | NEW |