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

Unified Diff: third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvasModules.cpp

Issue 2255683005: Determine if OffscreenCanvas is paintable in different rendering contexts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Canvas2DTypecast
Patch Set: Created 4 years, 4 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/modules/offscreencanvas/OffscreenCanvasModules.cpp
diff --git a/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvasModules.cpp b/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvasModules.cpp
index 0585db0a307aec55af413181a0509c43cd695ced..b33456de79c200a46fac37d6704608d60be575f0 100644
--- a/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvasModules.cpp
+++ b/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvasModules.cpp
@@ -6,7 +6,10 @@
#include "core/html/canvas/CanvasContextCreationAttributes.h"
#include "core/offscreencanvas/OffscreenCanvas.h"
+#include "modules/imagebitmap/ImageBitmapRenderingContext.h"
#include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h"
+#include "modules/webgl/WebGLRenderingContextBase.h"
+#include "platform/graphics/ImageBuffer.h"
namespace blink {
@@ -22,4 +25,21 @@ void OffscreenCanvasModules::getContext(ScriptState* scriptState, OffscreenCanva
context->setOffscreenCanvasGetContextResult(result);
}
+bool OffscreenCanvasModules::isPaintable(OffscreenCanvas& offscreenCanvas)
Justin Novosad 2016/08/19 14:55:47 There is a cleaner way to implement this: put a pu
+{
+ CanvasRenderingContext* context = offscreenCanvas.renderingContext();
+ if (!context)
+ return ImageBuffer::canCreateImageBuffer(offscreenCanvas.size());
+
+ if (context->is2d())
+ return toOffscreenCanvasRenderingContext2D(context)->imageBuffer();
+ if (context->is3d())
+ return toWebGLRenderingContextBase(context)->drawingBuffer();
+ if (context->getContextType() == CanvasRenderingContext::ContextImageBitmap)
+ return toImageBitmapRenderingContext(context)->image();
+
+ NOTREACHED();
+ return false;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698