OLD | NEW |
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/fake_web_graphics_context_3d.h" | 5 #include "cc/test/fake_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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 context_lost_callback_(NULL), | 57 context_lost_callback_(NULL), |
58 width_(0), | 58 width_(0), |
59 height_(0) { | 59 height_(0) { |
60 } | 60 } |
61 | 61 |
62 FakeWebGraphicsContext3D::~FakeWebGraphicsContext3D() { | 62 FakeWebGraphicsContext3D::~FakeWebGraphicsContext3D() { |
63 } | 63 } |
64 | 64 |
65 bool FakeWebGraphicsContext3D::makeContextCurrent() { | 65 bool FakeWebGraphicsContext3D::makeContextCurrent() { |
66 if (times_make_current_succeeds_ >= 0) { | 66 if (times_make_current_succeeds_ >= 0) { |
67 if (!times_make_current_succeeds_) | 67 if (!times_make_current_succeeds_) { |
68 loseContextCHROMIUM(); | 68 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 69 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 70 } |
69 --times_make_current_succeeds_; | 71 --times_make_current_succeeds_; |
70 } | 72 } |
71 return !context_lost_; | 73 return !context_lost_; |
72 } | 74 } |
73 | 75 |
74 int FakeWebGraphicsContext3D::width() { | 76 int FakeWebGraphicsContext3D::width() { |
75 return width_; | 77 return width_; |
76 } | 78 } |
77 | 79 |
78 int FakeWebGraphicsContext3D::height() { | 80 int FakeWebGraphicsContext3D::height() { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 void FakeWebGraphicsContext3D::bindRenderbuffer( | 350 void FakeWebGraphicsContext3D::bindRenderbuffer( |
349 WGC3Denum target, WebGLId renderbuffer) { | 351 WGC3Denum target, WebGLId renderbuffer) { |
350 if (!renderbuffer) | 352 if (!renderbuffer) |
351 return; | 353 return; |
352 EXPECT_EQ(kRenderbufferId | context_id_ << 16, renderbuffer); | 354 EXPECT_EQ(kRenderbufferId | context_id_ << 16, renderbuffer); |
353 } | 355 } |
354 | 356 |
355 void FakeWebGraphicsContext3D::bindTexture( | 357 void FakeWebGraphicsContext3D::bindTexture( |
356 WGC3Denum target, WebGLId texture_id) { | 358 WGC3Denum target, WebGLId texture_id) { |
357 if (times_bind_texture_succeeds_ >= 0) { | 359 if (times_bind_texture_succeeds_ >= 0) { |
358 if (!times_bind_texture_succeeds_) | 360 if (!times_bind_texture_succeeds_) { |
359 loseContextCHROMIUM(); | 361 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 362 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 363 } |
360 --times_bind_texture_succeeds_; | 364 --times_bind_texture_succeeds_; |
361 } | 365 } |
362 | 366 |
363 if (!texture_id) | 367 if (!texture_id) |
364 return; | 368 return; |
365 if (texture_id == kExternalTextureId) | 369 if (texture_id == kExternalTextureId) |
366 return; | 370 return; |
367 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != | 371 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != |
368 textures_.end()); | 372 textures_.end()); |
369 used_textures_.insert(texture_id); | 373 used_textures_.insert(texture_id); |
370 } | 374 } |
371 | 375 |
372 WebGLId FakeWebGraphicsContext3D::createQueryEXT() { | 376 WebGLId FakeWebGraphicsContext3D::createQueryEXT() { |
373 return 1; | 377 return 1; |
374 } | 378 } |
375 | 379 |
376 WGC3Dboolean FakeWebGraphicsContext3D::isQueryEXT(WebGLId query) { | 380 WGC3Dboolean FakeWebGraphicsContext3D::isQueryEXT(WebGLId query) { |
377 return true; | 381 return true; |
378 } | 382 } |
379 | 383 |
380 void FakeWebGraphicsContext3D::endQueryEXT(WebKit::WGC3Denum target) { | 384 void FakeWebGraphicsContext3D::endQueryEXT(WebKit::WGC3Denum target) { |
381 if (times_end_query_succeeds_ >= 0) { | 385 if (times_end_query_succeeds_ >= 0) { |
382 if (!times_end_query_succeeds_) | 386 if (!times_end_query_succeeds_) { |
383 loseContextCHROMIUM(); | 387 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 388 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 389 } |
384 --times_end_query_succeeds_; | 390 --times_end_query_succeeds_; |
385 } | 391 } |
386 } | 392 } |
387 | 393 |
388 void FakeWebGraphicsContext3D::getQueryObjectuivEXT( | 394 void FakeWebGraphicsContext3D::getQueryObjectuivEXT( |
389 WebKit::WebGLId query, | 395 WebKit::WebGLId query, |
390 WebKit::WGC3Denum pname, | 396 WebKit::WGC3Denum pname, |
391 WebKit::WGC3Duint* params) { | 397 WebKit::WGC3Duint* params) { |
392 // If the context is lost, behave as if result is available. | 398 // If the context is lost, behave as if result is available. |
393 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) | 399 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) |
394 *params = 1; | 400 *params = 1; |
395 } | 401 } |
396 | 402 |
397 void FakeWebGraphicsContext3D::setContextLostCallback( | 403 void FakeWebGraphicsContext3D::setContextLostCallback( |
398 WebGraphicsContextLostCallback* callback) { | 404 WebGraphicsContextLostCallback* callback) { |
399 context_lost_callback_ = callback; | 405 context_lost_callback_ = callback; |
400 } | 406 } |
401 | 407 |
402 void FakeWebGraphicsContext3D::loseContextCHROMIUM() { | 408 void FakeWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current, |
| 409 WGC3Denum other) { |
403 if (context_lost_) | 410 if (context_lost_) |
404 return; | 411 return; |
405 context_lost_ = true; | 412 context_lost_ = true; |
406 if (context_lost_callback_) | 413 if (context_lost_callback_) |
407 context_lost_callback_->onContextLost(); | 414 context_lost_callback_->onContextLost(); |
408 } | 415 } |
409 | 416 |
410 WebKit::WebGLId FakeWebGraphicsContext3D::NextTextureId() { | 417 WebKit::WebGLId FakeWebGraphicsContext3D::NextTextureId() { |
411 WebGLId texture_id = next_texture_id_++; | 418 WebGLId texture_id = next_texture_id_++; |
412 DCHECK(texture_id < (1 << 16)); | 419 DCHECK(texture_id < (1 << 16)); |
413 texture_id |= context_id_ << 16; | 420 texture_id |= context_id_ << 16; |
414 return texture_id; | 421 return texture_id; |
415 } | 422 } |
416 | 423 |
417 } // namespace cc | 424 } // namespace cc |
OLD | NEW |