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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // We immediately return a transparent black image with cropRect.size() | 213 // We immediately return a transparent black image with cropRect.size() |
214 if (srcRect.isEmpty() && !parsedOptions.premultiplyAlpha) { | 214 if (srcRect.isEmpty() && !parsedOptions.premultiplyAlpha) { |
215 SkImageInfo info = SkImageInfo::Make(parsedOptions.cropRect.width(), par
sedOptions.cropRect.height(), kN32_SkColorType, kUnpremul_SkAlphaType); | 215 SkImageInfo info = SkImageInfo::Make(parsedOptions.cropRect.width(), par
sedOptions.cropRect.height(), kN32_SkColorType, kUnpremul_SkAlphaType); |
216 std::unique_ptr<uint8_t[]> dstPixels = wrapArrayUnique(new uint8_t[parse
dOptions.cropRect.width() * parsedOptions.cropRect.height() * info.bytesPerPixel
()]()); | 216 std::unique_ptr<uint8_t[]> dstPixels = wrapArrayUnique(new uint8_t[parse
dOptions.cropRect.width() * parsedOptions.cropRect.height() * info.bytesPerPixel
()]()); |
217 return StaticBitmapImage::create(newSkImageFromRaster(info, std::move(ds
tPixels), parsedOptions.cropRect.width() * info.bytesPerPixel())); | 217 return StaticBitmapImage::create(newSkImageFromRaster(info, std::move(ds
tPixels), parsedOptions.cropRect.width() * info.bytesPerPixel())); |
218 } | 218 } |
219 | 219 |
220 RefPtr<SkImage> skiaImage = image->imageForCurrentFrame(); | 220 RefPtr<SkImage> skiaImage = image->imageForCurrentFrame(); |
221 // Attempt to get raw unpremultiplied image data, executed only when skiaIma
ge is premultiplied. | 221 // Attempt to get raw unpremultiplied image data, executed only when skiaIma
ge is premultiplied. |
222 if ((((!parsedOptions.premultiplyAlpha && !skiaImage->isOpaque()) || !skiaIm
age) && image->data() && imageFormat == PremultiplyAlpha) || colorSpaceOp == Ima
geDecoder::GammaAndColorProfileIgnored) { | 222 if ((((!parsedOptions.premultiplyAlpha && !skiaImage->isOpaque()) || !skiaIm
age) && image->data() && imageFormat == PremultiplyAlpha) || colorSpaceOp == Ima
geDecoder::GammaAndColorProfileIgnored) { |
223 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create( | 223 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create(*(image->data
()), |
224 ImageDecoder::determineImageType(*(image->data())), | |
225 parsedOptions.premultiplyAlpha ? ImageDecoder::AlphaPremultiplied :
ImageDecoder::AlphaNotPremultiplied, | 224 parsedOptions.premultiplyAlpha ? ImageDecoder::AlphaPremultiplied :
ImageDecoder::AlphaNotPremultiplied, |
226 colorSpaceOp)); | 225 colorSpaceOp)); |
227 if (!decoder) | 226 if (!decoder) |
228 return nullptr; | 227 return nullptr; |
229 decoder->setData(image->data(), true); | 228 decoder->setData(image->data(), true); |
230 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); | 229 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); |
231 if (!skiaImage) | 230 if (!skiaImage) |
232 return nullptr; | 231 return nullptr; |
233 } | 232 } |
234 | 233 |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 FloatSize ImageBitmap::elementSize(const FloatSize&) const | 605 FloatSize ImageBitmap::elementSize(const FloatSize&) const |
607 { | 606 { |
608 return FloatSize(width(), height()); | 607 return FloatSize(width(), height()); |
609 } | 608 } |
610 | 609 |
611 DEFINE_TRACE(ImageBitmap) | 610 DEFINE_TRACE(ImageBitmap) |
612 { | 611 { |
613 } | 612 } |
614 | 613 |
615 } // namespace blink | 614 } // namespace blink |
OLD | NEW |