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

Unified Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2496013002: Make a bitmaprenderer canvas an ImageSource (Closed)
Patch Set: remove the expected.txt because the test is passing Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
index fbae8739478899e73a50fbdd7910a19c98595335..d0fc4b34e27098f2d57292870f1392d27cc7f112 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -1124,6 +1124,18 @@ PassRefPtr<Image> HTMLCanvasElement::copiedImage(
if (!m_context)
return createTransparentImage(size());
+ if (m_context->getContextType() ==
+ CanvasRenderingContext::ContextImageBitmap) {
+ RefPtr<Image> image =
+ m_context->getImage(hint, SnapshotReasonGetCopiedImage);
+ if (image)
+ return m_context->getImage(hint, SnapshotReasonGetCopiedImage);
+ // Special case: transferFromImageBitmap is not yet called.
+ sk_sp<SkSurface> surface =
+ SkSurface::MakeRasterN32Premul(width(), height());
+ return StaticBitmapImage::create(surface->makeImageSnapshot());
+ }
+
bool needToUpdate = !m_copiedImage;
// The concept of SourceDrawingBuffer is valid on only WebGL.
if (m_context->is3d())
@@ -1205,6 +1217,9 @@ PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(
return createTransparentImage(size());
}
+ if (m_context->getContextType() == CanvasRenderingContext::ContextImageBitmap)
+ return m_context->getImage(hint, reason);
+
sk_sp<SkImage> skImage;
if (m_context->is3d()) {
// Because WebGL sources always require making a copy of the back buffer, we
@@ -1240,6 +1255,15 @@ bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const {
}
FloatSize HTMLCanvasElement::elementSize(const FloatSize&) const {
+ if (m_context &&
+ m_context->getContextType() ==
+ CanvasRenderingContext::ContextImageBitmap) {
+ RefPtr<Image> image =
+ m_context->getImage(PreferNoAcceleration, SnapshotReasonDrawImage);
+ if (image)
+ return FloatSize(image->width(), image->height());
+ return FloatSize(0, 0);
+ }
return FloatSize(width(), height());
}
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698