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 |