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

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

Issue 2570613002: Add OffscreenCanvas to ImageBitmapSource union typedef (Closed)
Patch Set: build fix Created 4 years 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 feaa25995291526cdc0937ba73b09dacdba9bd2e..7003e7b59ffa9bce99238dc88d36d2193e50ee93 100644
--- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
+++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
@@ -7,6 +7,7 @@
#include "core/html/HTMLCanvasElement.h"
#include "core/html/HTMLVideoElement.h"
#include "core/html/ImageData.h"
+#include "core/offscreencanvas/OffscreenCanvas.h"
#include "platform/graphics/skia/SkiaUtils.h"
#include "platform/image-decoders/ImageDecoder.h"
#include "third_party/skia/include/core/SkCanvas.h"
@@ -687,6 +688,42 @@ ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas,
m_image->setPremultiplied(parsedOptions.premultiplyAlpha);
}
+ImageBitmap::ImageBitmap(OffscreenCanvas* offscreenCanvas,
+ Optional<IntRect> cropRect,
+ const ImageBitmapOptions& options) {
+ SourceImageStatus status;
+ RefPtr<Image> input = offscreenCanvas->getSourceImageForCanvas(
+ &status, PreferNoAcceleration, SnapshotReasonCreateImageBitmap,
+ FloatSize(offscreenCanvas->size()));
+ if (status != NormalSourceImageStatus)
+ return;
+ ParsedOptions parsedOptions =
+ parseOptions(options, cropRect, IntSize(input->width(), input->height()));
+ if (dstBufferSizeHasOverflow(parsedOptions))
+ return;
+
+ bool isPremultiplyAlphaReverted = false;
+ if (!parsedOptions.premultiplyAlpha) {
+ parsedOptions.premultiplyAlpha = true;
+ isPremultiplyAlphaReverted = true;
+ }
+ m_image = cropImageAndApplyColorSpaceConversion(
+ input.get(), parsedOptions, PremultiplyAlpha,
+ ColorBehavior::transformToGlobalTarget());
+ if (!m_image)
+ return;
+ if (isPremultiplyAlphaReverted) {
+ parsedOptions.premultiplyAlpha = false;
+ m_image = StaticBitmapImage::create(premulSkImageToUnPremul(
+ m_image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget())
+ .get()));
+ }
+ if (!m_image)
+ return;
+ m_image->setOriginClean(offscreenCanvas->originClean());
+ m_image->setPremultiplied(parsedOptions.premultiplyAlpha);
+}
+
ImageBitmap::ImageBitmap(const void* pixelData,
uint32_t width,
uint32_t height,
@@ -946,6 +983,12 @@ ImageBitmap* ImageBitmap::create(HTMLCanvasElement* canvas,
return new ImageBitmap(canvas, cropRect, options);
}
+ImageBitmap* ImageBitmap::create(OffscreenCanvas* offscreenCanvas,
+ Optional<IntRect> cropRect,
+ const ImageBitmapOptions& options) {
+ return new ImageBitmap(offscreenCanvas, cropRect, options);
+}
+
ImageBitmap* ImageBitmap::create(ImageData* data,
Optional<IntRect> cropRect,
const ImageBitmapOptions& options) {
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.h ('k') | third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698