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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp

Issue 1387743002: Fixed expando-loss.html test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cache ScriptState and use it to wrap m_defaultVertexArrayObject. Created 5 years, 2 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/webgl/WebGL2RenderingContext.h" 6 #include "modules/webgl/WebGL2RenderingContext.h"
7 7
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/loader/FrameLoader.h" 10 #include "core/loader/FrameLoader.h"
11 #include "core/loader/FrameLoaderClient.h" 11 #include "core/loader/FrameLoaderClient.h"
12 #include "modules/webgl/CHROMIUMSubscribeUniform.h" 12 #include "modules/webgl/CHROMIUMSubscribeUniform.h"
13 #include "modules/webgl/EXTTextureFilterAnisotropic.h" 13 #include "modules/webgl/EXTTextureFilterAnisotropic.h"
14 #include "modules/webgl/OESTextureFloatLinear.h" 14 #include "modules/webgl/OESTextureFloatLinear.h"
15 #include "modules/webgl/WebGLCompressedTextureASTC.h" 15 #include "modules/webgl/WebGLCompressedTextureASTC.h"
16 #include "modules/webgl/WebGLCompressedTextureATC.h" 16 #include "modules/webgl/WebGLCompressedTextureATC.h"
17 #include "modules/webgl/WebGLCompressedTextureETC1.h" 17 #include "modules/webgl/WebGLCompressedTextureETC1.h"
18 #include "modules/webgl/WebGLCompressedTexturePVRTC.h" 18 #include "modules/webgl/WebGLCompressedTexturePVRTC.h"
19 #include "modules/webgl/WebGLCompressedTextureS3TC.h" 19 #include "modules/webgl/WebGLCompressedTextureS3TC.h"
20 #include "modules/webgl/WebGLContextAttributeHelpers.h" 20 #include "modules/webgl/WebGLContextAttributeHelpers.h"
21 #include "modules/webgl/WebGLContextEvent.h" 21 #include "modules/webgl/WebGLContextEvent.h"
22 #include "modules/webgl/WebGLDebugRendererInfo.h" 22 #include "modules/webgl/WebGLDebugRendererInfo.h"
23 #include "modules/webgl/WebGLDebugShaders.h" 23 #include "modules/webgl/WebGLDebugShaders.h"
24 #include "modules/webgl/WebGLLoseContext.h" 24 #include "modules/webgl/WebGLLoseContext.h"
25 #include "platform/graphics/gpu/DrawingBuffer.h" 25 #include "platform/graphics/gpu/DrawingBuffer.h"
26 #include "public/platform/Platform.h" 26 #include "public/platform/Platform.h"
27 27
28 namespace blink { 28 namespace blink {
29 29
30 PassOwnPtrWillBeRawPtr<CanvasRenderingContext> WebGL2RenderingContext::Factory:: create(HTMLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs, Document&) 30 PassOwnPtrWillBeRawPtr<CanvasRenderingContext> WebGL2RenderingContext::Factory:: create(HTMLCanvasElement* canvas, ScriptState* scriptState, const CanvasContextC reationAttributes& attrs, Document&)
31 { 31 {
32 if (!RuntimeEnabledFeatures::unsafeES3APIsEnabled()) { 32 if (!RuntimeEnabledFeatures::unsafeES3APIsEnabled()) {
33 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Creation of WebGL2 contexts disabled.")); 33 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Creation of WebGL2 contexts disabled."));
34 return nullptr; 34 return nullptr;
35 } 35 }
36 36
37 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); 37 WebGLContextAttributes attributes = toWebGLContextAttributes(attrs);
38 OwnPtr<WebGraphicsContext3D> context(createWebGraphicsContext3D(canvas, attr ibutes, 2)); 38 OwnPtr<WebGraphicsContext3D> context(createWebGraphicsContext3D(canvas, attr ibutes, 2));
39 if (!context) 39 if (!context)
40 return nullptr; 40 return nullptr;
41 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g et()); 41 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g et());
42 if (!extensionsUtil) 42 if (!extensionsUtil)
43 return nullptr; 43 return nullptr;
44 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { 44 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) {
45 String contextLabel(String::format("WebGL2RenderingContext-%p", context. get())); 45 String contextLabel(String::format("WebGL2RenderingContext-%p", context. get()));
46 context->pushGroupMarkerEXT(contextLabel.ascii().data()); 46 context->pushGroupMarkerEXT(contextLabel.ascii().data());
47 } 47 }
48 48
49 OwnPtrWillBeRawPtr<WebGL2RenderingContext> renderingContext = adoptPtrWillBe Noop(new WebGL2RenderingContext(canvas, context.release(), attributes)); 49 OwnPtrWillBeRawPtr<WebGL2RenderingContext> renderingContext = adoptPtrWillBe Noop(new WebGL2RenderingContext(canvas, scriptState, context.release(), attribut es));
50 50
51 if (!renderingContext->drawingBuffer()) { 51 if (!renderingContext->drawingBuffer()) {
52 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Could not create a WebGL2 context.")); 52 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Could not create a WebGL2 context."));
53 return nullptr; 53 return nullptr;
54 } 54 }
55 55
56 renderingContext->initializeNewContext(); 56 renderingContext->initializeNewContext();
57 renderingContext->registerContextExtensions(); 57 renderingContext->registerContextExtensions();
58 58
59 return renderingContext.release(); 59 return renderingContext.release();
60 } 60 }
61 61
62 void WebGL2RenderingContext::Factory::onError(HTMLCanvasElement* canvas, const S tring& error) 62 void WebGL2RenderingContext::Factory::onError(HTMLCanvasElement* canvas, const S tring& error)
63 { 63 {
64 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext creationerror, false, true, error)); 64 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontext creationerror, false, true, error));
65 } 65 }
66 66
67 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requeste dAttributes) 67 WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, ScriptState* scriptState, PassOwnPtr<WebGraphicsContext3D> context, const WebGLC ontextAttributes& requestedAttributes)
68 : WebGL2RenderingContextBase(passedCanvas, context, requestedAttributes) 68 : WebGL2RenderingContextBase(passedCanvas, scriptState, context, requestedAt tributes)
69 { 69 {
70 } 70 }
71 71
72 WebGL2RenderingContext::~WebGL2RenderingContext() 72 WebGL2RenderingContext::~WebGL2RenderingContext()
73 { 73 {
74 74
75 } 75 }
76 76
77 void WebGL2RenderingContext::registerContextExtensions() 77 void WebGL2RenderingContext::registerContextExtensions()
78 { 78 {
(...skipping 21 matching lines...) Expand all
100 visitor->trace(m_webglCompressedTextureETC1); 100 visitor->trace(m_webglCompressedTextureETC1);
101 visitor->trace(m_webglCompressedTexturePVRTC); 101 visitor->trace(m_webglCompressedTexturePVRTC);
102 visitor->trace(m_webglCompressedTextureS3TC); 102 visitor->trace(m_webglCompressedTextureS3TC);
103 visitor->trace(m_webglDebugRendererInfo); 103 visitor->trace(m_webglDebugRendererInfo);
104 visitor->trace(m_webglDebugShaders); 104 visitor->trace(m_webglDebugShaders);
105 visitor->trace(m_webglLoseContext); 105 visitor->trace(m_webglLoseContext);
106 WebGL2RenderingContextBase::trace(visitor); 106 WebGL2RenderingContextBase::trace(visitor);
107 } 107 }
108 108
109 } // namespace blink 109 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698