| 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/Float32ImageData.h" | 7 #include "core/html/Float32ImageData.h" |
| 8 #include "core/html/HTMLCanvasElement.h" | 8 #include "core/html/HTMLCanvasElement.h" |
| 9 #include "core/html/HTMLVideoElement.h" | 9 #include "core/html/HTMLVideoElement.h" |
| 10 #include "core/html/ImageData.h" | 10 #include "core/html/ImageData.h" |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 DoNotInitializeImagePixels); | 615 DoNotInitializeImagePixels); |
| 616 if (!buffer) | 616 if (!buffer) |
| 617 return; | 617 return; |
| 618 | 618 |
| 619 IntPoint dstPoint = | 619 IntPoint dstPoint = |
| 620 IntPoint(-parsedOptions.cropRect.x(), -parsedOptions.cropRect.y()); | 620 IntPoint(-parsedOptions.cropRect.x(), -parsedOptions.cropRect.y()); |
| 621 if (parsedOptions.flipY) { | 621 if (parsedOptions.flipY) { |
| 622 buffer->canvas()->translate(0, buffer->size().height()); | 622 buffer->canvas()->translate(0, buffer->size().height()); |
| 623 buffer->canvas()->scale(1, -1); | 623 buffer->canvas()->scale(1, -1); |
| 624 } | 624 } |
| 625 SkPaint paint; | 625 PaintFlags flags; |
| 626 if (parsedOptions.shouldScaleInput) { | 626 if (parsedOptions.shouldScaleInput) { |
| 627 float scaleRatioX = static_cast<float>(parsedOptions.resizeWidth) / | 627 float scaleRatioX = static_cast<float>(parsedOptions.resizeWidth) / |
| 628 parsedOptions.cropRect.width(); | 628 parsedOptions.cropRect.width(); |
| 629 float scaleRatioY = static_cast<float>(parsedOptions.resizeHeight) / | 629 float scaleRatioY = static_cast<float>(parsedOptions.resizeHeight) / |
| 630 parsedOptions.cropRect.height(); | 630 parsedOptions.cropRect.height(); |
| 631 buffer->canvas()->scale(scaleRatioX, scaleRatioY); | 631 buffer->canvas()->scale(scaleRatioX, scaleRatioY); |
| 632 paint.setFilterQuality(parsedOptions.resizeQuality); | 632 flags.setFilterQuality(parsedOptions.resizeQuality); |
| 633 } | 633 } |
| 634 buffer->canvas()->translate(dstPoint.x(), dstPoint.y()); | 634 buffer->canvas()->translate(dstPoint.x(), dstPoint.y()); |
| 635 video->paintCurrentFrame( | 635 video->paintCurrentFrame( |
| 636 buffer->canvas(), | 636 buffer->canvas(), |
| 637 IntRect(IntPoint(), IntSize(video->videoWidth(), video->videoHeight())), | 637 IntRect(IntPoint(), IntSize(video->videoWidth(), video->videoHeight())), |
| 638 parsedOptions.shouldScaleInput ? &paint : nullptr); | 638 parsedOptions.shouldScaleInput ? &flags : nullptr); |
| 639 | 639 |
| 640 sk_sp<SkImage> skiaImage = | 640 sk_sp<SkImage> skiaImage = |
| 641 buffer->newSkImageSnapshot(PreferNoAcceleration, SnapshotReasonUnknown); | 641 buffer->newSkImageSnapshot(PreferNoAcceleration, SnapshotReasonUnknown); |
| 642 if (!parsedOptions.premultiplyAlpha) | 642 if (!parsedOptions.premultiplyAlpha) |
| 643 skiaImage = premulSkImageToUnPremul(skiaImage.get()); | 643 skiaImage = premulSkImageToUnPremul(skiaImage.get()); |
| 644 if (!skiaImage) | 644 if (!skiaImage) |
| 645 return; | 645 return; |
| 646 m_image = StaticBitmapImage::create(std::move(skiaImage)); | 646 m_image = StaticBitmapImage::create(std::move(skiaImage)); |
| 647 m_image->setOriginClean( | 647 m_image->setOriginClean( |
| 648 !video->wouldTaintOrigin(document->getSecurityOrigin())); | 648 !video->wouldTaintOrigin(document->getSecurityOrigin())); |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, | 1152 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, |
| 1153 FloatRect* dstRect) const {} | 1153 FloatRect* dstRect) const {} |
| 1154 | 1154 |
| 1155 FloatSize ImageBitmap::elementSize(const FloatSize&) const { | 1155 FloatSize ImageBitmap::elementSize(const FloatSize&) const { |
| 1156 return FloatSize(width(), height()); | 1156 return FloatSize(width(), height()); |
| 1157 } | 1157 } |
| 1158 | 1158 |
| 1159 DEFINE_TRACE(ImageBitmap) {} | 1159 DEFINE_TRACE(ImageBitmap) {} |
| 1160 | 1160 |
| 1161 } // namespace blink | 1161 } // namespace blink |
| OLD | NEW |