| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 sk_sp<SkData> data(SkData::MakeWithoutCopy(&dstPixels, size)); | 358 sk_sp<SkData> data(SkData::MakeWithoutCopy(&dstPixels, size)); |
| 359 sk_sp<SkImage> coloredImage = SkImage::MakeRasterData( | 359 sk_sp<SkImage> coloredImage = SkImage::MakeRasterData( |
| 360 dstInfo, data, image->width() * dstInfo.bytesPerPixel()); | 360 dstInfo, data, image->width() * dstInfo.bytesPerPixel()); |
| 361 if (coloredImage) { | 361 if (coloredImage) { |
| 362 updateLatestColorInformation(options); | 362 updateLatestColorInformation(options); |
| 363 image = coloredImage; | 363 image = coloredImage; |
| 364 return; | 364 return; |
| 365 } | 365 } |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 | |
| 369 // Skia does not support drawing to unpremul surfaces/canvases. | 368 // Skia does not support drawing to unpremul surfaces/canvases. |
| 370 sk_sp<SkImage> unPremulImage = nullptr; | 369 sk_sp<SkImage> unPremulImage = nullptr; |
| 371 if (image->alphaType() == kUnpremul_SkAlphaType) | 370 if (image->alphaType() == kUnpremul_SkAlphaType) |
| 372 unPremulImage = unPremulSkImageToPremul(image.get(), options); | 371 unPremulImage = unPremulSkImageToPremul(image.get(), options); |
| 373 | 372 |
| 374 // If the color space of the source SkImage is null, the following code | 373 // If the color space of the source SkImage is null, the following code |
| 375 // does not do any color conversion even thought the new SkImage will be | 374 // does not do any color conversion even thought the new SkImage will be |
| 376 // tagged by the new color space. If this is the case, the following code | 375 // tagged by the new color space. If this is the case, the following code |
| 377 // will tag a wrong color space to the SkImage. However, this cannot be | 376 // will tag a wrong color space to the SkImage. However, this cannot be |
| 378 // addressed here and the code that creates the SkImage must tag the | 377 // addressed here and the code that creates the SkImage must tag the |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 return ImageBitmapSource::fulfillImageBitmap(scriptState, | 1094 return ImageBitmapSource::fulfillImageBitmap(scriptState, |
| 1096 create(this, cropRect, options)); | 1095 create(this, cropRect, options)); |
| 1097 } | 1096 } |
| 1098 | 1097 |
| 1099 PassRefPtr<Image> ImageBitmap::getSourceImageForCanvas( | 1098 PassRefPtr<Image> ImageBitmap::getSourceImageForCanvas( |
| 1100 SourceImageStatus* status, | 1099 SourceImageStatus* status, |
| 1101 AccelerationHint, | 1100 AccelerationHint, |
| 1102 SnapshotReason, | 1101 SnapshotReason, |
| 1103 const FloatSize&) const { | 1102 const FloatSize&) const { |
| 1104 *status = NormalSourceImageStatus; | 1103 *status = NormalSourceImageStatus; |
| 1105 return m_image ? m_image : nullptr; | 1104 if (!m_image) |
| 1105 return nullptr; |
| 1106 if (m_image->isPremultiplied()) |
| 1107 return m_image; |
| 1108 // Skia does not support drawing unpremul SkImage on SkCanvas. |
| 1109 // Premultiply and return. |
| 1110 sk_sp<SkImage> premulSkImage = unPremulSkImageToPremul( |
| 1111 m_image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()) |
| 1112 .get()); |
| 1113 return StaticBitmapImage::create(premulSkImage); |
| 1106 } | 1114 } |
| 1107 | 1115 |
| 1108 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, | 1116 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, |
| 1109 FloatRect* dstRect) const {} | 1117 FloatRect* dstRect) const {} |
| 1110 | 1118 |
| 1111 FloatSize ImageBitmap::elementSize(const FloatSize&) const { | 1119 FloatSize ImageBitmap::elementSize(const FloatSize&) const { |
| 1112 return FloatSize(width(), height()); | 1120 return FloatSize(width(), height()); |
| 1113 } | 1121 } |
| 1114 | 1122 |
| 1115 DEFINE_TRACE(ImageBitmap) {} | 1123 DEFINE_TRACE(ImageBitmap) {} |
| 1116 | 1124 |
| 1117 } // namespace blink | 1125 } // namespace blink |
| OLD | NEW |