Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 2802813002: Adds SVGImageElement as a ImageBitmapSource (Closed)
Patch Set: test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698