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

Side by Side Diff: Source/core/html/canvas/WebGL2RenderingContext.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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/html/canvas/WebGL2RenderingContext.h"
7
8 #include "core/frame/LocalFrame.h"
9 #include "core/frame/Settings.h"
10 #include "core/html/canvas/ContextAttributeHelpers.h"
11 #include "core/html/canvas/WebGLContextAttributes.h"
12 #include "core/html/canvas/WebGLContextEvent.h"
13 #include "core/html/canvas/WebGLDebugRendererInfo.h"
14 #include "core/html/canvas/WebGLDebugShaders.h"
15 #include "core/loader/FrameLoader.h"
16 #include "core/loader/FrameLoaderClient.h"
17 #include "platform/graphics/gpu/DrawingBuffer.h"
18 #include "public/platform/Platform.h"
19
20 namespace blink {
21
22 PassOwnPtrWillBeRawPtr<WebGL2RenderingContext> WebGL2RenderingContext::create(HT MLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs)
23 {
24 if (!RuntimeEnabledFeatures::unsafeES3APIsEnabled()) {
25 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Creation of WebGL2 contexts disabled."));
26 return nullptr;
27 }
28
29 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs);
30 OwnPtr<blink::WebGraphicsContext3D> context(createWebGraphicsContext3D(canva s, attributes, 2));
31 if (!context)
32 return nullptr;
33 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g et());
34 if (!extensionsUtil)
35 return nullptr;
36 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) {
37 String contextLabel(String::format("WebGL2RenderingContext-%p", context. get()));
38 context->pushGroupMarkerEXT(contextLabel.ascii().data());
39 }
40
41 OwnPtrWillBeRawPtr<WebGL2RenderingContext> renderingContext = adoptPtrWillBe Noop(new WebGL2RenderingContext(canvas, context.release(), attributes));
42 renderingContext->registerContextExtensions();
43 renderingContext->suspendIfNeeded();
44
45 if (!renderingContext->drawingBuffer()) {
46 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Could not create a WebGL2 context."));
47 return nullptr;
48 }
49
50 return renderingContext.release();
51 }
52
53 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, PassOwnPtr<blink::WebGraphicsContext3D> context, const WebGLContextAttributes& r equestedAttributes)
54 : WebGL2RenderingContextBase(passedCanvas, context, requestedAttributes)
55 {
56 }
57
58 WebGL2RenderingContext::~WebGL2RenderingContext()
59 {
60
61 }
62
63 void WebGL2RenderingContext::registerContextExtensions()
64 {
65 // Register privileged extensions.
66 registerExtension<WebGLDebugRendererInfo>(m_webglDebugRendererInfo);
67 registerExtension<WebGLDebugShaders>(m_webglDebugShaders);
68 }
69
70 void WebGL2RenderingContext::trace(Visitor* visitor)
71 {
72 visitor->trace(m_webglDebugRendererInfo);
73 visitor->trace(m_webglDebugShaders);
74 WebGL2RenderingContextBase::trace(visitor);
75 }
76
77 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGL2RenderingContext.h ('k') | Source/core/html/canvas/WebGL2RenderingContext.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698