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

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

Issue 798233005: Merge 185069 "Enforce context refrence guards in WebGL extensions." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2214/
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return OESVertexArrayObjectName; 48 return OESVertexArrayObjectName;
49 } 49 }
50 50
51 PassRefPtrWillBeRawPtr<OESVertexArrayObject> OESVertexArrayObject::create(WebGLR enderingContextBase* context) 51 PassRefPtrWillBeRawPtr<OESVertexArrayObject> OESVertexArrayObject::create(WebGLR enderingContextBase* context)
52 { 52 {
53 return adoptRefWillBeNoop(new OESVertexArrayObject(context)); 53 return adoptRefWillBeNoop(new OESVertexArrayObject(context));
54 } 54 }
55 55
56 PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> OESVertexArrayObject::createVe rtexArrayOES() 56 PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> OESVertexArrayObject::createVe rtexArrayOES()
57 { 57 {
58 if (isLost()) 58 WebGLExtensionScopedContext scoped(this);
59 if (scoped.isLost())
59 return nullptr; 60 return nullptr;
60 61
61 RefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> o = WebGLVertexArrayObjectOES: :create(m_context, WebGLVertexArrayObjectOES::VaoTypeUser); 62 RefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> o = WebGLVertexArrayObjectOES: :create(scoped.context(), WebGLVertexArrayObjectOES::VaoTypeUser);
62 m_context->addContextObject(o.get()); 63 scoped.context()->addContextObject(o.get());
63 return o.release(); 64 return o.release();
64 } 65 }
65 66
66 void OESVertexArrayObject::deleteVertexArrayOES(WebGLVertexArrayObjectOES* array Object) 67 void OESVertexArrayObject::deleteVertexArrayOES(WebGLVertexArrayObjectOES* array Object)
67 { 68 {
68 if (!arrayObject || isLost()) 69 WebGLExtensionScopedContext scoped(this);
70 if (!arrayObject || scoped.isLost())
69 return; 71 return;
70 72
71 if (!arrayObject->isDefaultObject() && arrayObject == m_context->m_boundVert exArrayObject) 73 if (!arrayObject->isDefaultObject() && arrayObject == scoped.context()->m_bo undVertexArrayObject)
72 m_context->setBoundVertexArrayObject(nullptr); 74 scoped.context()->setBoundVertexArrayObject(nullptr);
73 75
74 arrayObject->deleteObject(m_context->webContext()); 76 arrayObject->deleteObject(scoped.context()->webContext());
75 } 77 }
76 78
77 GLboolean OESVertexArrayObject::isVertexArrayOES(WebGLVertexArrayObjectOES* arra yObject) 79 GLboolean OESVertexArrayObject::isVertexArrayOES(WebGLVertexArrayObjectOES* arra yObject)
78 { 80 {
79 if (!arrayObject || isLost()) 81 WebGLExtensionScopedContext scoped(this);
82 if (!arrayObject || scoped.isLost())
80 return 0; 83 return 0;
81 84
82 if (!arrayObject->hasEverBeenBound()) 85 if (!arrayObject->hasEverBeenBound())
83 return 0; 86 return 0;
84 87
85 return m_context->webContext()->isVertexArrayOES(arrayObject->object()); 88 return scoped.context()->webContext()->isVertexArrayOES(arrayObject->object( ));
86 } 89 }
87 90
88 void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayOb ject) 91 void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayOb ject)
89 { 92 {
90 if (isLost()) 93 WebGLExtensionScopedContext scoped(this);
94 if (scoped.isLost())
91 return; 95 return;
92 96
93 if (arrayObject && (arrayObject->isDeleted() || !arrayObject->validate(0, co ntext()))) { 97 if (arrayObject && (arrayObject->isDeleted() || !arrayObject->validate(0, sc oped.context()))) {
94 m_context->webContext()->synthesizeGLError(GL_INVALID_OPERATION); 98 scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION);
95 return; 99 return;
96 } 100 }
97 101
98 if (arrayObject && !arrayObject->isDefaultObject() && arrayObject->object()) { 102 if (arrayObject && !arrayObject->isDefaultObject() && arrayObject->object()) {
99 m_context->webContext()->bindVertexArrayOES(arrayObject->object()); 103 scoped.context()->webContext()->bindVertexArrayOES(arrayObject->object() );
100 104
101 arrayObject->setHasEverBeenBound(); 105 arrayObject->setHasEverBeenBound();
102 m_context->setBoundVertexArrayObject(arrayObject); 106 scoped.context()->setBoundVertexArrayObject(arrayObject);
103 } else { 107 } else {
104 m_context->webContext()->bindVertexArrayOES(0); 108 scoped.context()->webContext()->bindVertexArrayOES(0);
105 m_context->setBoundVertexArrayObject(nullptr); 109 scoped.context()->setBoundVertexArrayObject(nullptr);
106 } 110 }
107 } 111 }
108 112
109 bool OESVertexArrayObject::supported(WebGLRenderingContextBase* context) 113 bool OESVertexArrayObject::supported(WebGLRenderingContextBase* context)
110 { 114 {
111 return context->extensionsUtil()->supportsExtension("GL_OES_vertex_array_obj ect"); 115 return context->extensionsUtil()->supportsExtension("GL_OES_vertex_array_obj ect");
112 } 116 }
113 117
114 const char* OESVertexArrayObject::extensionName() 118 const char* OESVertexArrayObject::extensionName()
115 { 119 {
116 return "OES_vertex_array_object"; 120 return "OES_vertex_array_object";
117 } 121 }
118 122
119 } // namespace blink 123 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/ANGLEInstancedArrays.cpp ('k') | Source/core/html/canvas/WebGLDebugShaders.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698