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

Side by Side Diff: cc/test/test_web_graphics_context_3d.cc

Issue 12545014: Implement EXT_draw_buffers WebGL extention support in command buffer. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/test/test_web_graphics_context_3d.h" 5 #include "cc/test/test_web_graphics_context_3d.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "gpu/GLES2/gl2extchromium.h" 11 #include "gpu/GLES2/gl2extchromium.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/khronos/GLES2/gl2ext.h" 13 #include "third_party/khronos/GLES2/gl2ext.h"
14 14
15 using WebKit::WGC3Dboolean; 15 using WebKit::WGC3Dboolean;
16 using WebKit::WGC3Dchar;
16 using WebKit::WGC3Denum; 17 using WebKit::WGC3Denum;
18 using WebKit::WGC3Dint;
19 using WebKit::WGC3Dsizei;
20 using WebKit::WGC3Dsizeiptr;
21 using WebKit::WGC3Duint;
17 using WebKit::WebGLId; 22 using WebKit::WebGLId;
18 using WebKit::WebGraphicsContext3D; 23 using WebKit::WebGraphicsContext3D;
19 24
20 namespace cc { 25 namespace cc {
21 26
22 static const WebGLId kBufferId = 1; 27 static const WebGLId kBufferId = 1;
23 static const WebGLId kFramebufferId = 2; 28 static const WebGLId kFramebufferId = 2;
24 static const WebGLId kProgramId = 3; 29 static const WebGLId kProgramId = 3;
25 static const WebGLId kRenderbufferId = 4; 30 static const WebGLId kRenderbufferId = 4;
26 static const WebGLId kShaderId = 5; 31 static const WebGLId kShaderId = 5;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if (name == GL_EXTENSIONS) { 119 if (name == GL_EXTENSIONS) {
115 if (have_extension_io_surface_) 120 if (have_extension_io_surface_)
116 string += "GL_CHROMIUM_iosurface GL_ARB_texture_rectangle "; 121 string += "GL_CHROMIUM_iosurface GL_ARB_texture_rectangle ";
117 if (have_extension_egl_image_) 122 if (have_extension_egl_image_)
118 string += "GL_OES_EGL_image_external"; 123 string += "GL_OES_EGL_image_external";
119 } 124 }
120 125
121 return WebKit::WebString::fromUTF8(string.c_str()); 126 return WebKit::WebString::fromUTF8(string.c_str());
122 } 127 }
123 128
124 WebKit::WGC3Dint TestWebGraphicsContext3D::getUniformLocation( 129 WGC3Dint TestWebGraphicsContext3D::getUniformLocation(
125 WebGLId program, 130 WebGLId program,
126 const WebKit::WGC3Dchar* name) { 131 const WGC3Dchar* name) {
127 return 0; 132 return 0;
128 } 133 }
129 134
130 WebKit::WGC3Dsizeiptr TestWebGraphicsContext3D::getVertexAttribOffset( 135 WGC3Dsizeiptr TestWebGraphicsContext3D::getVertexAttribOffset(
131 WebKit::WGC3Duint index, 136 WGC3Duint index,
132 WGC3Denum pname) { 137 WGC3Denum pname) {
133 return 0; 138 return 0;
134 } 139 }
135 140
136 WGC3Dboolean TestWebGraphicsContext3D::isBuffer( 141 WGC3Dboolean TestWebGraphicsContext3D::isBuffer(
137 WebGLId buffer) { 142 WebGLId buffer) {
138 return false; 143 return false;
139 } 144 }
140 145
141 WGC3Dboolean TestWebGraphicsContext3D::isEnabled( 146 WGC3Dboolean TestWebGraphicsContext3D::isEnabled(
(...skipping 23 matching lines...) Expand all
165 170
166 WGC3Dboolean TestWebGraphicsContext3D::isTexture( 171 WGC3Dboolean TestWebGraphicsContext3D::isTexture(
167 WebGLId texture) { 172 WebGLId texture) {
168 return false; 173 return false;
169 } 174 }
170 175
171 WebGLId TestWebGraphicsContext3D::createBuffer() { 176 WebGLId TestWebGraphicsContext3D::createBuffer() {
172 return kBufferId | context_id_ << 16; 177 return kBufferId | context_id_ << 16;
173 } 178 }
174 179
175 void TestWebGraphicsContext3D::deleteBuffer(WebKit::WebGLId id) { 180 void TestWebGraphicsContext3D::deleteBuffer(WebGLId id) {
176 EXPECT_EQ(kBufferId | context_id_ << 16, id); 181 EXPECT_EQ(kBufferId | context_id_ << 16, id);
177 } 182 }
178 183
179 WebGLId TestWebGraphicsContext3D::createFramebuffer() { 184 WebGLId TestWebGraphicsContext3D::createFramebuffer() {
180 return kFramebufferId | context_id_ << 16; 185 return kFramebufferId | context_id_ << 16;
181 } 186 }
182 187
183 void TestWebGraphicsContext3D::deleteFramebuffer(WebKit::WebGLId id) { 188 void TestWebGraphicsContext3D::deleteFramebuffer(WebGLId id) {
184 EXPECT_EQ(kFramebufferId | context_id_ << 16, id); 189 EXPECT_EQ(kFramebufferId | context_id_ << 16, id);
185 } 190 }
186 191
187 WebGLId TestWebGraphicsContext3D::createProgram() { 192 WebGLId TestWebGraphicsContext3D::createProgram() {
188 return kProgramId | context_id_ << 16; 193 return kProgramId | context_id_ << 16;
189 } 194 }
190 195
191 void TestWebGraphicsContext3D::deleteProgram(WebKit::WebGLId id) { 196 void TestWebGraphicsContext3D::deleteProgram(WebGLId id) {
192 EXPECT_EQ(kProgramId | context_id_ << 16, id); 197 EXPECT_EQ(kProgramId | context_id_ << 16, id);
193 } 198 }
194 199
195 WebGLId TestWebGraphicsContext3D::createRenderbuffer() { 200 WebGLId TestWebGraphicsContext3D::createRenderbuffer() {
196 return kRenderbufferId | context_id_ << 16; 201 return kRenderbufferId | context_id_ << 16;
197 } 202 }
198 203
199 void TestWebGraphicsContext3D::deleteRenderbuffer(WebKit::WebGLId id) { 204 void TestWebGraphicsContext3D::deleteRenderbuffer(WebGLId id) {
200 EXPECT_EQ(kRenderbufferId | context_id_ << 16, id); 205 EXPECT_EQ(kRenderbufferId | context_id_ << 16, id);
201 } 206 }
202 207
203 WebGLId TestWebGraphicsContext3D::createShader(WGC3Denum) { 208 WebGLId TestWebGraphicsContext3D::createShader(WGC3Denum) {
204 return kShaderId | context_id_ << 16; 209 return kShaderId | context_id_ << 16;
205 } 210 }
206 211
207 void TestWebGraphicsContext3D::deleteShader(WebKit::WebGLId id) { 212 void TestWebGraphicsContext3D::deleteShader(WebGLId id) {
208 EXPECT_EQ(kShaderId | context_id_ << 16, id); 213 EXPECT_EQ(kShaderId | context_id_ << 16, id);
209 } 214 }
210 215
211 WebGLId TestWebGraphicsContext3D::createTexture() { 216 WebGLId TestWebGraphicsContext3D::createTexture() {
212 WebGLId texture_id = NextTextureId(); 217 WebGLId texture_id = NextTextureId();
213 DCHECK_NE(texture_id, kExternalTextureId); 218 DCHECK_NE(texture_id, kExternalTextureId);
214 textures_.push_back(texture_id); 219 textures_.push_back(texture_id);
215 return texture_id; 220 return texture_id;
216 } 221 }
217 222
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 269
265 if (!texture_id) 270 if (!texture_id)
266 return; 271 return;
267 if (texture_id == kExternalTextureId) 272 if (texture_id == kExternalTextureId)
268 return; 273 return;
269 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != 274 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) !=
270 textures_.end()); 275 textures_.end());
271 used_textures_.insert(texture_id); 276 used_textures_.insert(texture_id);
272 } 277 }
273 278
274 void TestWebGraphicsContext3D::endQueryEXT(WebKit::WGC3Denum target) { 279 void TestWebGraphicsContext3D::endQueryEXT(WGC3Denum target) {
275 if (times_end_query_succeeds_ >= 0) { 280 if (times_end_query_succeeds_ >= 0) {
276 if (!times_end_query_succeeds_) { 281 if (!times_end_query_succeeds_) {
277 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 282 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
278 GL_INNOCENT_CONTEXT_RESET_ARB); 283 GL_INNOCENT_CONTEXT_RESET_ARB);
279 } 284 }
280 --times_end_query_succeeds_; 285 --times_end_query_succeeds_;
281 } 286 }
282 } 287 }
283 288
284 void TestWebGraphicsContext3D::getQueryObjectuivEXT( 289 void TestWebGraphicsContext3D::getQueryObjectuivEXT(
285 WebKit::WebGLId query, 290 WebGLId query,
286 WebKit::WGC3Denum pname, 291 WGC3Denum pname,
287 WebKit::WGC3Duint* params) { 292 WGC3Duint* params) {
288 // If the context is lost, behave as if result is available. 293 // If the context is lost, behave as if result is available.
289 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) 294 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT)
290 *params = 1; 295 *params = 1;
291 } 296 }
292 297
293 void TestWebGraphicsContext3D::setContextLostCallback( 298 void TestWebGraphicsContext3D::setContextLostCallback(
294 WebGraphicsContextLostCallback* callback) { 299 WebGraphicsContextLostCallback* callback) {
295 context_lost_callback_ = callback; 300 context_lost_callback_ = callback;
296 } 301 }
297 302
298 void TestWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current, 303 void TestWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current,
299 WGC3Denum other) { 304 WGC3Denum other) {
300 if (context_lost_) 305 if (context_lost_)
301 return; 306 return;
302 context_lost_ = true; 307 context_lost_ = true;
303 if (context_lost_callback_) 308 if (context_lost_callback_)
304 context_lost_callback_->onContextLost(); 309 context_lost_callback_->onContextLost();
305 310
306 for (size_t i = 0; i < shared_contexts_.size(); ++i) 311 for (size_t i = 0; i < shared_contexts_.size(); ++i)
307 shared_contexts_[i]->loseContextCHROMIUM(current, other); 312 shared_contexts_[i]->loseContextCHROMIUM(current, other);
308 shared_contexts_.clear(); 313 shared_contexts_.clear();
309 } 314 }
310 315
311 WebKit::WebGLId TestWebGraphicsContext3D::NextTextureId() { 316 WebGLId TestWebGraphicsContext3D::NextTextureId() {
312 WebGLId texture_id = next_texture_id_++; 317 WebGLId texture_id = next_texture_id_++;
313 DCHECK(texture_id < (1 << 16)); 318 DCHECK(texture_id < (1 << 16));
314 texture_id |= context_id_ << 16; 319 texture_id |= context_id_ << 16;
315 return texture_id; 320 return texture_id;
316 } 321 }
317 322
318 } // namespace cc 323 } // namespace cc
OLDNEW
« no previous file with comments | « cc/fake_web_graphics_context_3d.h ('k') | content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698