| 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(*(image->data
()), | 223 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create( |
| 224 ImageDecoder::determineImageType(*(image->data())), |
| 224 parsedOptions.premultiplyAlpha ? ImageDecoder::AlphaPremultiplied :
ImageDecoder::AlphaNotPremultiplied, | 225 parsedOptions.premultiplyAlpha ? ImageDecoder::AlphaPremultiplied :
ImageDecoder::AlphaNotPremultiplied, |
| 225 colorSpaceOp)); | 226 colorSpaceOp)); |
| 226 if (!decoder) | 227 if (!decoder) |
| 227 return nullptr; | 228 return nullptr; |
| 228 decoder->setData(image->data(), true); | 229 decoder->setData(image->data(), true); |
| 229 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); | 230 skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); |
| 230 if (!skiaImage) | 231 if (!skiaImage) |
| 231 return nullptr; | 232 return nullptr; |
| 232 } | 233 } |
| 233 | 234 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 FloatSize ImageBitmap::elementSize(const FloatSize&) const | 606 FloatSize ImageBitmap::elementSize(const FloatSize&) const |
| 606 { | 607 { |
| 607 return FloatSize(width(), height()); | 608 return FloatSize(width(), height()); |
| 608 } | 609 } |
| 609 | 610 |
| 610 DEFINE_TRACE(ImageBitmap) | 611 DEFINE_TRACE(ImageBitmap) |
| 611 { | 612 { |
| 612 } | 613 } |
| 613 | 614 |
| 614 } // namespace blink | 615 } // namespace blink |
| OLD | NEW |