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

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

Issue 894143002: Adding Blink bindings for WebGL 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed accidentally added scratch file Created 5 years, 10 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
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/html/canvas/WebGL2RenderingContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLCanvasElement.cpp
diff --git a/Source/core/html/HTMLCanvasElement.cpp b/Source/core/html/HTMLCanvasElement.cpp
index 227a1476edc32f937410fde7ec2c35da21b8f0f4..a4dcc991917028029c9db75fa8c1f25d658ebfdc 100644
--- a/Source/core/html/HTMLCanvasElement.cpp
+++ b/Source/core/html/HTMLCanvasElement.cpp
@@ -40,6 +40,7 @@
#include "core/html/ImageData.h"
#include "core/html/canvas/Canvas2DContextAttributes.h"
#include "core/html/canvas/CanvasRenderingContext2D.h"
+#include "core/html/canvas/WebGL2RenderingContext.h"
#include "core/html/canvas/WebGLContextAttributes.h"
#include "core/html/canvas/WebGLContextEvent.h"
#include "core/html/canvas/WebGLRenderingContext.h"
@@ -209,6 +210,7 @@ void HTMLCanvasElement::getContext(const String& type, const CanvasContextCreati
Context2d = 0,
ContextExperimentalWebgl = 2,
ContextWebgl = 3,
+ ContextWebgl2 = 4,
ContextTypeCount,
};
@@ -229,11 +231,25 @@ void HTMLCanvasElement::getContext(const String& type, const CanvasContextCreati
}
// Accept the the provisional "experimental-webgl" or official "webgl" context ID.
- if (type == "webgl" || type == "experimental-webgl") {
- ContextType contextType = (type == "webgl") ? ContextWebgl : ContextExperimentalWebgl;
+ ContextType contextType = Context2d;
+ bool is3dContext = true;
+ if (type == "experimental-webgl")
+ contextType = ContextExperimentalWebgl;
+ else if (type == "webgl")
+ contextType = ContextWebgl;
+ else if (type == "webgl2")
+ contextType = ContextWebgl2;
+ else
+ is3dContext = false;
+
+ if (is3dContext) {
if (!m_context) {
blink::Platform::current()->histogramEnumeration("Canvas.ContextType", contextType, ContextTypeCount);
- m_context = WebGLRenderingContext::create(this, attributes);
+ if (contextType == ContextWebgl2) {
+ m_context = WebGL2RenderingContext::create(this, attributes);
+ } else {
+ m_context = WebGLRenderingContext::create(this, attributes);
+ }
LayoutStyle* style = computedStyle();
if (style && m_context)
toWebGLRenderingContext(m_context.get())->setFilterLevel(style->imageRendering() == ImageRenderingPixelated ? SkPaint::kNone_FilterLevel : SkPaint::kLow_FilterLevel);
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/html/canvas/WebGL2RenderingContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698