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 "core/offscreencanvas/OffscreenCanvas.h" | 10 #include "core/offscreencanvas/OffscreenCanvas.h" |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 applyColorSpaceConversion(croppedSkImage, parsedOptions); | 499 applyColorSpaceConversion(croppedSkImage, parsedOptions); |
500 if (parsedOptions.flipY) { | 500 if (parsedOptions.flipY) { |
501 return StaticBitmapImage::create(flipSkImageVertically( | 501 return StaticBitmapImage::create(flipSkImageVertically( |
502 croppedSkImage.get(), DontEnforceAlphaPremultiply, parsedOptions)); | 502 croppedSkImage.get(), DontEnforceAlphaPremultiply, parsedOptions)); |
503 } | 503 } |
504 // Special case: The first parameter image is unpremul but we need to turn | 504 // Special case: The first parameter image is unpremul but we need to turn |
505 // it into premul. | 505 // it into premul. |
506 if (parsedOptions.premultiplyAlpha && imageFormat == DontPremultiplyAlpha) | 506 if (parsedOptions.premultiplyAlpha && imageFormat == DontPremultiplyAlpha) |
507 return StaticBitmapImage::create( | 507 return StaticBitmapImage::create( |
508 unPremulSkImageToPremul(croppedSkImage.get())); | 508 unPremulSkImageToPremul(croppedSkImage.get())); |
509 // Call preroll to trigger image decoding. | |
510 croppedSkImage->preroll(); | |
511 return StaticBitmapImage::create(std::move(croppedSkImage)); | 509 return StaticBitmapImage::create(std::move(croppedSkImage)); |
512 } | 510 } |
513 | 511 |
514 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( | 512 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( |
515 parsedOptions.resizeWidth, parsedOptions.resizeHeight); | 513 parsedOptions.resizeWidth, parsedOptions.resizeHeight); |
516 if (!surface) | 514 if (!surface) |
517 return nullptr; | 515 return nullptr; |
518 if (srcRect.isEmpty()) | 516 if (srcRect.isEmpty()) |
519 return StaticBitmapImage::create(surface->makeImageSnapshot()); | 517 return StaticBitmapImage::create(surface->makeImageSnapshot()); |
520 | 518 |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, | 1099 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, |
1102 FloatRect* dstRect) const {} | 1100 FloatRect* dstRect) const {} |
1103 | 1101 |
1104 FloatSize ImageBitmap::elementSize(const FloatSize&) const { | 1102 FloatSize ImageBitmap::elementSize(const FloatSize&) const { |
1105 return FloatSize(width(), height()); | 1103 return FloatSize(width(), height()); |
1106 } | 1104 } |
1107 | 1105 |
1108 DEFINE_TRACE(ImageBitmap) {} | 1106 DEFINE_TRACE(ImageBitmap) {} |
1109 | 1107 |
1110 } // namespace blink | 1108 } // namespace blink |
OLD | NEW |