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

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

Issue 2547813002: Remove WebGLObject maps from WebGLRenderingContextBase and WebGLContextGroup. (Closed)
Patch Set: Fixed WebGLContextObject::validate. Made WebGLExtension non-finalized. Created 4 years 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 "modules/webgl/WebGL2RenderingContextBase.h" 5 #include "modules/webgl/WebGL2RenderingContextBase.h"
6 6
7 #include "bindings/modules/v8/WebGLAny.h" 7 #include "bindings/modules/v8/WebGLAny.h"
8 #include "core/dom/DOMException.h" 8 #include "core/dom/DOMException.h"
9 #include "core/frame/ImageBitmap.h" 9 #include "core/frame/ImageBitmap.h"
10 #include "core/html/HTMLCanvasElement.h" 10 #include "core/html/HTMLCanvasElement.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 m_boundUniformBuffer(this, nullptr), 265 m_boundUniformBuffer(this, nullptr),
266 m_currentBooleanOcclusionQuery(this, nullptr), 266 m_currentBooleanOcclusionQuery(this, nullptr),
267 m_currentTransformFeedbackPrimitivesWrittenQuery(this, nullptr), 267 m_currentTransformFeedbackPrimitivesWrittenQuery(this, nullptr),
268 m_currentElapsedQuery(this, nullptr) { 268 m_currentElapsedQuery(this, nullptr) {
269 m_supportedInternalFormatsStorage.insert( 269 m_supportedInternalFormatsStorage.insert(
270 kSupportedInternalFormatsStorage, 270 kSupportedInternalFormatsStorage,
271 kSupportedInternalFormatsStorage + 271 kSupportedInternalFormatsStorage +
272 WTF_ARRAY_LENGTH(kSupportedInternalFormatsStorage)); 272 WTF_ARRAY_LENGTH(kSupportedInternalFormatsStorage));
273 } 273 }
274 274
275 WebGL2RenderingContextBase::~WebGL2RenderingContextBase() {
276 m_readFramebufferBinding = nullptr;
277
278 m_boundCopyReadBuffer = nullptr;
279 m_boundCopyWriteBuffer = nullptr;
280 m_boundPixelPackBuffer = nullptr;
281 m_boundPixelUnpackBuffer = nullptr;
282 m_boundTransformFeedbackBuffer = nullptr;
283 m_boundUniformBuffer = nullptr;
284
285 m_currentBooleanOcclusionQuery = nullptr;
286 m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr;
287 m_currentElapsedQuery = nullptr;
288 }
289
290 void WebGL2RenderingContextBase::destroyContext() { 275 void WebGL2RenderingContextBase::destroyContext() {
291 for (auto& callback : m_getBufferSubDataAsyncCallbacks) { 276 for (auto& callback : m_getBufferSubDataAsyncCallbacks) {
292 callback->destroy(); 277 callback->destroy();
293 } 278 }
294 m_getBufferSubDataAsyncCallbacks.clear(); 279 m_getBufferSubDataAsyncCallbacks.clear();
295 280
296 WebGLRenderingContextBase::destroyContext(); 281 WebGLRenderingContextBase::destroyContext();
297 } 282 }
298 283
299 void WebGL2RenderingContextBase::initializeNewContext() { 284 void WebGL2RenderingContextBase::initializeNewContext() {
(...skipping 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2785 GLint stencil) { 2770 GLint stencil) {
2786 if (isContextLost()) 2771 if (isContextLost())
2787 return; 2772 return;
2788 2773
2789 contextGL()->ClearBufferfi(buffer, drawbuffer, depth, stencil); 2774 contextGL()->ClearBufferfi(buffer, drawbuffer, depth, stencil);
2790 } 2775 }
2791 2776
2792 WebGLQuery* WebGL2RenderingContextBase::createQuery() { 2777 WebGLQuery* WebGL2RenderingContextBase::createQuery() {
2793 if (isContextLost()) 2778 if (isContextLost())
2794 return nullptr; 2779 return nullptr;
2795 WebGLQuery* o = WebGLQuery::create(this); 2780 return WebGLQuery::create(this);
2796 addSharedObject(o);
2797 return o;
2798 } 2781 }
2799 2782
2800 void WebGL2RenderingContextBase::deleteQuery(WebGLQuery* query) { 2783 void WebGL2RenderingContextBase::deleteQuery(WebGLQuery* query) {
2801 if (isContextLost() || !query) 2784 if (isContextLost() || !query)
2802 return; 2785 return;
2803 2786
2804 if (m_currentBooleanOcclusionQuery == query) { 2787 if (m_currentBooleanOcclusionQuery == query) {
2805 contextGL()->EndQueryEXT(m_currentBooleanOcclusionQuery->getTarget()); 2788 contextGL()->EndQueryEXT(m_currentBooleanOcclusionQuery->getTarget());
2806 m_currentBooleanOcclusionQuery = nullptr; 2789 m_currentBooleanOcclusionQuery = nullptr;
2807 } 2790 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 default: 3008 default:
3026 synthesizeGLError(GL_INVALID_ENUM, "getQueryParameter", 3009 synthesizeGLError(GL_INVALID_ENUM, "getQueryParameter",
3027 "invalid parameter name"); 3010 "invalid parameter name");
3028 return ScriptValue::createNull(scriptState); 3011 return ScriptValue::createNull(scriptState);
3029 } 3012 }
3030 } 3013 }
3031 3014
3032 WebGLSampler* WebGL2RenderingContextBase::createSampler() { 3015 WebGLSampler* WebGL2RenderingContextBase::createSampler() {
3033 if (isContextLost()) 3016 if (isContextLost())
3034 return nullptr; 3017 return nullptr;
3035 WebGLSampler* o = WebGLSampler::create(this); 3018 return WebGLSampler::create(this);
3036 addSharedObject(o);
3037 return o;
3038 } 3019 }
3039 3020
3040 void WebGL2RenderingContextBase::deleteSampler(WebGLSampler* sampler) { 3021 void WebGL2RenderingContextBase::deleteSampler(WebGLSampler* sampler) {
3041 if (isContextLost()) 3022 if (isContextLost())
3042 return; 3023 return;
3043 3024
3044 for (size_t i = 0; i < m_samplerUnits.size(); ++i) { 3025 for (size_t i = 0; i < m_samplerUnits.size(); ++i) {
3045 if (sampler == m_samplerUnits[i]) { 3026 if (sampler == m_samplerUnits[i]) {
3046 m_samplerUnits[i] = nullptr; 3027 m_samplerUnits[i] = nullptr;
3047 contextGL()->BindSampler(i, 0); 3028 contextGL()->BindSampler(i, 0);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
3219 "invalid parameter name"); 3200 "invalid parameter name");
3220 return ScriptValue::createNull(scriptState); 3201 return ScriptValue::createNull(scriptState);
3221 } 3202 }
3222 } 3203 }
3223 3204
3224 WebGLSync* WebGL2RenderingContextBase::fenceSync(GLenum condition, 3205 WebGLSync* WebGL2RenderingContextBase::fenceSync(GLenum condition,
3225 GLbitfield flags) { 3206 GLbitfield flags) {
3226 if (isContextLost()) 3207 if (isContextLost())
3227 return nullptr; 3208 return nullptr;
3228 3209
3229 WebGLSync* o = WebGLFenceSync::create(this, condition, flags); 3210 return WebGLFenceSync::create(this, condition, flags);
3230 addSharedObject(o);
3231 return o;
3232 } 3211 }
3233 3212
3234 GLboolean WebGL2RenderingContextBase::isSync(WebGLSync* sync) { 3213 GLboolean WebGL2RenderingContextBase::isSync(WebGLSync* sync) {
3235 if (isContextLost() || !sync) 3214 if (isContextLost() || !sync)
3236 return 0; 3215 return 0;
3237 3216
3238 return contextGL()->IsSync(sync->object()); 3217 return contextGL()->IsSync(sync->object());
3239 } 3218 }
3240 3219
3241 void WebGL2RenderingContextBase::deleteSync(WebGLSync* sync) { 3220 void WebGL2RenderingContextBase::deleteSync(WebGLSync* sync) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3296 default: 3275 default:
3297 synthesizeGLError(GL_INVALID_ENUM, "getSyncParameter", 3276 synthesizeGLError(GL_INVALID_ENUM, "getSyncParameter",
3298 "invalid parameter name"); 3277 "invalid parameter name");
3299 return ScriptValue::createNull(scriptState); 3278 return ScriptValue::createNull(scriptState);
3300 } 3279 }
3301 } 3280 }
3302 3281
3303 WebGLTransformFeedback* WebGL2RenderingContextBase::createTransformFeedback() { 3282 WebGLTransformFeedback* WebGL2RenderingContextBase::createTransformFeedback() {
3304 if (isContextLost()) 3283 if (isContextLost())
3305 return nullptr; 3284 return nullptr;
3306 WebGLTransformFeedback* o = WebGLTransformFeedback::create(this); 3285 return WebGLTransformFeedback::create(this);
3307 addSharedObject(o);
3308 return o;
3309 } 3286 }
3310 3287
3311 void WebGL2RenderingContextBase::deleteTransformFeedback( 3288 void WebGL2RenderingContextBase::deleteTransformFeedback(
3312 WebGLTransformFeedback* feedback) { 3289 WebGLTransformFeedback* feedback) {
3313 if (feedback == m_transformFeedbackBinding) 3290 if (feedback == m_transformFeedbackBinding)
3314 m_transformFeedbackBinding = nullptr; 3291 m_transformFeedbackBinding = nullptr;
3315 3292
3316 deleteObject(feedback); 3293 deleteObject(feedback);
3317 } 3294 }
3318 3295
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
3806 return; 3783 return;
3807 3784
3808 contextGL()->UniformBlockBinding(objectOrZero(program), uniformBlockIndex, 3785 contextGL()->UniformBlockBinding(objectOrZero(program), uniformBlockIndex,
3809 uniformBlockBinding); 3786 uniformBlockBinding);
3810 } 3787 }
3811 3788
3812 WebGLVertexArrayObject* WebGL2RenderingContextBase::createVertexArray() { 3789 WebGLVertexArrayObject* WebGL2RenderingContextBase::createVertexArray() {
3813 if (isContextLost()) 3790 if (isContextLost())
3814 return nullptr; 3791 return nullptr;
3815 3792
3816 WebGLVertexArrayObject* o = WebGLVertexArrayObject::create( 3793 return WebGLVertexArrayObject::create(
3817 this, WebGLVertexArrayObjectBase::VaoTypeUser); 3794 this, WebGLVertexArrayObjectBase::VaoTypeUser);
3818 addContextObject(o);
3819 return o;
3820 } 3795 }
3821 3796
3822 void WebGL2RenderingContextBase::deleteVertexArray( 3797 void WebGL2RenderingContextBase::deleteVertexArray(
3823 WebGLVertexArrayObject* vertexArray) { 3798 WebGLVertexArrayObject* vertexArray) {
3824 if (isContextLost() || !vertexArray) 3799 if (isContextLost() || !vertexArray)
3825 return; 3800 return;
3826 3801
3827 if (!vertexArray->isDefaultObject() && 3802 if (!vertexArray->isDefaultObject() &&
3828 vertexArray == m_boundVertexArrayObject) 3803 vertexArray == m_boundVertexArrayObject)
3829 setBoundVertexArrayObject(nullptr); 3804 setBoundVertexArrayObject(nullptr);
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
4965 4940
4966 void WebGL2RenderingContextBase:: 4941 void WebGL2RenderingContextBase::
4967 DrawingBufferClientRestorePixelUnpackBufferBinding() { 4942 DrawingBufferClientRestorePixelUnpackBufferBinding() {
4968 if (!contextGL()) 4943 if (!contextGL())
4969 return; 4944 return;
4970 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 4945 contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER,
4971 objectOrZero(m_boundPixelUnpackBuffer.get())); 4946 objectOrZero(m_boundPixelUnpackBuffer.get()));
4972 } 4947 }
4973 4948
4974 } // namespace blink 4949 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698