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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContext.cpp

Issue 365653002: Oilpan: move 2D Canvas and WebGL objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Smaller adjustments Created 6 years, 5 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 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 Settings* settings = frame->settings(); 72 Settings* settings = frame->settings();
73 73
74 // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in 74 // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in
75 // particular, if WebGL contexts were lost one or more times via the GL_ARB_ robustness extension. 75 // particular, if WebGL contexts were lost one or more times via the GL_ARB_ robustness extension.
76 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) { 76 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) {
77 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext.")); 77 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext."));
78 return nullptr; 78 return nullptr;
79 } 79 }
80 80
81 // The only situation that attrs is null is through Document::getCSSCanvasCo ntext(). 81 // The only situation that attrs is null is through Document::getCSSCanvasCo ntext().
82 RefPtr<WebGLContextAttributes> defaultAttrs; 82 RefPtrWillBeRawPtr<WebGLContextAttributes> defaultAttrs = nullptr;
83 if (!attrs) { 83 if (!attrs) {
84 defaultAttrs = WebGLContextAttributes::create(); 84 defaultAttrs = WebGLContextAttributes::create();
85 attrs = defaultAttrs.get(); 85 attrs = defaultAttrs.get();
86 } 86 }
87 blink::WebGraphicsContext3D::Attributes attributes = attrs->attributes(docum ent.topDocument().url().string(), settings, 1); 87 blink::WebGraphicsContext3D::Attributes attributes = attrs->attributes(docum ent.topDocument().url().string(), settings, 1);
88 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes, 0)); 88 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes, 0));
89 if (!context || !context->makeContextCurrent()) { 89 if (!context || !context->makeContextCurrent()) {
90 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Could not create a WebGL context.")); 90 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Could not create a WebGL context."));
91 return nullptr; 91 return nullptr;
92 } 92 }
93 93
94 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g et()); 94 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g et());
95 if (!extensionsUtil) 95 if (!extensionsUtil)
96 return nullptr; 96 return nullptr;
97 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) 97 if (extensionsUtil->supportsExtension("GL_EXT_debug_marker"))
98 context->pushGroupMarkerEXT("WebGLRenderingContext"); 98 context->pushGroupMarkerEXT("WebGLRenderingContext");
99 99
100 OwnPtrWillBeRawPtr<WebGLRenderingContext> renderingContext = adoptPtrWillBeN oop(new WebGLRenderingContext(canvas, context.release(), attrs)); 100 OwnPtrWillBeRawPtr<WebGLRenderingContext> renderingContext = adoptPtrWillBeN oop(new WebGLRenderingContext(canvas, context.release(), attrs));
101 renderingContext->registerContextExtensions(); 101 renderingContext->registerContextExtensions();
102 renderingContext->suspendIfNeeded(); 102 renderingContext->suspendIfNeeded();
103 103
104 if (!renderingContext->m_drawingBuffer) { 104 if (!renderingContext->drawingBuffer()) {
105 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Could not create a WebGL context.")); 105 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Could not create a WebGL context."));
106 return nullptr; 106 return nullptr;
107 } 107 }
108 108
109 return renderingContext.release(); 109 return renderingContext.release();
110 } 110 }
111 111
112 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa ssOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* requested Attributes) 112 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa ssOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* requested Attributes)
113 : WebGLRenderingContextBase(passedCanvas, context, requestedAttributes) 113 : WebGLRenderingContextBase(passedCanvas, context, requestedAttributes)
114 { 114 {
115 ScriptWrappable::init(this); 115 ScriptWrappable::init(this);
116 } 116 }
117 117
118 WebGLRenderingContext::~WebGLRenderingContext() 118 WebGLRenderingContext::~WebGLRenderingContext()
119 { 119 {
120
121 } 120 }
122 121
123 void WebGLRenderingContext::registerContextExtensions() 122 void WebGLRenderingContext::registerContextExtensions()
124 { 123 {
125 // Register extensions. 124 // Register extensions.
126 static const char* const bothPrefixes[] = { "", "WEBKIT_", 0, }; 125 static const char* const bothPrefixes[] = { "", "WEBKIT_", 0, };
127 126
128 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays); 127 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays);
129 registerExtension<EXTBlendMinMax>(m_extBlendMinMax); 128 registerExtension<EXTBlendMinMax>(m_extBlendMinMax);
130 registerExtension<EXTFragDepth>(m_extFragDepth); 129 registerExtension<EXTFragDepth>(m_extFragDepth);
(...skipping 10 matching lines...) Expand all
141 registerExtension<WebGLCompressedTextureETC1>(m_webglCompressedTextureETC1); 140 registerExtension<WebGLCompressedTextureETC1>(m_webglCompressedTextureETC1);
142 registerExtension<WebGLCompressedTexturePVRTC>(m_webglCompressedTexturePVRTC , ApprovedExtension, bothPrefixes); 141 registerExtension<WebGLCompressedTexturePVRTC>(m_webglCompressedTexturePVRTC , ApprovedExtension, bothPrefixes);
143 registerExtension<WebGLCompressedTextureS3TC>(m_webglCompressedTextureS3TC, ApprovedExtension, bothPrefixes); 142 registerExtension<WebGLCompressedTextureS3TC>(m_webglCompressedTextureS3TC, ApprovedExtension, bothPrefixes);
144 registerExtension<WebGLDebugRendererInfo>(m_webglDebugRendererInfo); 143 registerExtension<WebGLDebugRendererInfo>(m_webglDebugRendererInfo);
145 registerExtension<WebGLDebugShaders>(m_webglDebugShaders); 144 registerExtension<WebGLDebugShaders>(m_webglDebugShaders);
146 registerExtension<WebGLDepthTexture>(m_webglDepthTexture, ApprovedExtension, bothPrefixes); 145 registerExtension<WebGLDepthTexture>(m_webglDepthTexture, ApprovedExtension, bothPrefixes);
147 registerExtension<WebGLDrawBuffers>(m_webglDrawBuffers); 146 registerExtension<WebGLDrawBuffers>(m_webglDrawBuffers);
148 registerExtension<WebGLLoseContext>(m_webglLoseContext, ApprovedExtension, b othPrefixes); 147 registerExtension<WebGLLoseContext>(m_webglLoseContext, ApprovedExtension, b othPrefixes);
149 } 148 }
150 149
150 void WebGLRenderingContext::trace(Visitor* visitor)
151 {
152 visitor->trace(m_angleInstancedArrays);
153 visitor->trace(m_extBlendMinMax);
154 visitor->trace(m_extFragDepth);
155 visitor->trace(m_extShaderTextureLOD);
156 visitor->trace(m_extTextureFilterAnisotropic);
157 visitor->trace(m_oesTextureFloat);
158 visitor->trace(m_oesTextureFloatLinear);
159 visitor->trace(m_oesTextureHalfFloat);
160 visitor->trace(m_oesTextureHalfFloatLinear);
161 visitor->trace(m_oesStandardDerivatives);
162 visitor->trace(m_oesVertexArrayObject);
163 visitor->trace(m_oesElementIndexUint);
164 visitor->trace(m_webglLoseContext);
165 visitor->trace(m_webglDebugRendererInfo);
166 visitor->trace(m_webglDebugShaders);
167 visitor->trace(m_webglDrawBuffers);
168 visitor->trace(m_webglCompressedTextureATC);
169 visitor->trace(m_webglCompressedTextureETC1);
170 visitor->trace(m_webglCompressedTexturePVRTC);
171 visitor->trace(m_webglCompressedTextureS3TC);
172 visitor->trace(m_webglDepthTexture);
173 WebGLRenderingContextBase::trace(visitor);
174 }
175
151 } // namespace blink 176 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698