Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/ImageBitmap.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp |
| index c3cd961a5b12b29186bb1a6b3c37db276e19f1b6..99f397e45a00abb621a6411cd5bc971fe79569ac 100644 |
| --- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp |
| +++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp |
| @@ -591,6 +591,46 @@ ImageBitmap::ImageBitmap(HTMLImageElement* image, |
| m_image->setPremultiplied(parsedOptions.premultiplyAlpha); |
| } |
| +ImageBitmap::ImageBitmap(SVGImageElement* image, |
| + Optional<IntRect> cropRect, |
| + Document* document, |
| + const ImageBitmapOptions& options) { |
| + RefPtr<Image> input = image->cachedImage()->getImage(); |
| + ParsedOptions parsedOptions = |
| + parseOptions(options, cropRect, image->bitmapSourceSize()); |
|
fs
2017/04/06 16:48:12
Given all the interfaces that's defined for this,
fserb
2017/04/06 20:06:16
fixed
|
| + if (dstBufferSizeHasOverflow(parsedOptions)) |
| + return; |
| + |
| + if (options.colorSpaceConversion() == kImageBitmapOptionNone) { |
| + m_image = cropImageAndApplyColorSpaceConversion( |
| + input.get(), parsedOptions, PremultiplyAlpha, ColorBehavior::ignore()); |
| + } else { |
| + m_image = cropImageAndApplyColorSpaceConversion( |
| + input.get(), parsedOptions, PremultiplyAlpha, |
| + ColorBehavior::transformToGlobalTarget()); |
| + } |
| + |
| + if (!m_image) |
| + return; |
| + // In the case where the source image is lazy-decoded, m_image may not be in |
| + // a decoded state, we trigger it here. |
| + sk_sp<SkImage> skImage = m_image->imageForCurrentFrame(); |
| + SkPixmap pixmap; |
| + if (!skImage->isTextureBacked() && !skImage->peekPixels(&pixmap)) { |
| + SkImageInfo imageInfo = SkImageInfo::Make( |
| + skImage->width(), skImage->height(), parsedOptions.dstColorType, |
| + kPremul_SkAlphaType, parsedOptions.dstColorSpace); |
| + sk_sp<SkSurface> surface = SkSurface::MakeRaster(imageInfo); |
| + surface->getCanvas()->drawImage(skImage, 0, 0); |
| + m_image = StaticBitmapImage::create(surface->makeImageSnapshot()); |
| + } |
| + if (!m_image) |
| + return; |
| + m_image->setOriginClean( |
| + !image->wouldTaintOrigin(document->getSecurityOrigin())); |
| + m_image->setPremultiplied(parsedOptions.premultiplyAlpha); |
| +} |
| + |
| ImageBitmap::ImageBitmap(HTMLVideoElement* video, |
| Optional<IntRect> cropRect, |
| Document* document, |
| @@ -990,6 +1030,13 @@ ImageBitmap* ImageBitmap::create(HTMLImageElement* image, |
| return new ImageBitmap(image, cropRect, document, options); |
| } |
| +ImageBitmap* ImageBitmap::create(SVGImageElement* image, |
| + Optional<IntRect> cropRect, |
| + Document* document, |
| + const ImageBitmapOptions& options) { |
| + return new ImageBitmap(image, cropRect, document, options); |
| +} |
| + |
| ImageBitmap* ImageBitmap::create(HTMLVideoElement* video, |
| Optional<IntRect> cropRect, |
| Document* document, |