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/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/bind.h" | 10 #include "base/bind.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 static const WebGLId kFramebufferId = 1; | 29 static const WebGLId kFramebufferId = 1; |
30 static const WebGLId kProgramId = 2; | 30 static const WebGLId kProgramId = 2; |
31 static const WebGLId kRenderbufferId = 3; | 31 static const WebGLId kRenderbufferId = 3; |
32 static const WebGLId kShaderId = 4; | 32 static const WebGLId kShaderId = 4; |
33 | 33 |
34 static unsigned s_context_id = 1; | 34 static unsigned s_context_id = 1; |
35 | 35 |
36 const WebGLId TestWebGraphicsContext3D::kExternalTextureId = 1337; | 36 const WebGLId TestWebGraphicsContext3D::kExternalTextureId = 1337; |
37 | 37 |
| 38 TestWebGraphicsContext3D::Namespace* |
| 39 TestWebGraphicsContext3D::shared_namespace_ = NULL; |
| 40 |
| 41 TestWebGraphicsContext3D::Namespace::Namespace() |
| 42 : next_buffer_id(1), |
| 43 next_image_id(1), |
| 44 next_texture_id(1) { |
| 45 } |
| 46 |
| 47 TestWebGraphicsContext3D::Namespace::~Namespace() { |
| 48 if (shared_namespace_ == this) |
| 49 shared_namespace_ = NULL; |
| 50 } |
| 51 |
38 TestWebGraphicsContext3D::TestWebGraphicsContext3D() | 52 TestWebGraphicsContext3D::TestWebGraphicsContext3D() |
39 : FakeWebGraphicsContext3D(), | 53 : FakeWebGraphicsContext3D(), |
40 context_id_(s_context_id++), | 54 context_id_(s_context_id++), |
41 next_buffer_id_(1), | |
42 next_image_id_(1), | |
43 next_texture_id_(1), | |
44 support_swapbuffers_complete_callback_(true), | 55 support_swapbuffers_complete_callback_(true), |
45 have_extension_io_surface_(false), | 56 have_extension_io_surface_(false), |
46 have_extension_egl_image_(false), | 57 have_extension_egl_image_(false), |
47 times_make_current_succeeds_(-1), | 58 times_make_current_succeeds_(-1), |
48 times_bind_texture_succeeds_(-1), | 59 times_bind_texture_succeeds_(-1), |
49 times_end_query_succeeds_(-1), | 60 times_end_query_succeeds_(-1), |
50 context_lost_(false), | 61 context_lost_(false), |
51 times_map_image_chromium_succeeds_(-1), | 62 times_map_image_chromium_succeeds_(-1), |
52 times_map_buffer_chromium_succeeds_(-1), | 63 times_map_buffer_chromium_succeeds_(-1), |
53 context_lost_callback_(NULL), | 64 context_lost_callback_(NULL), |
54 swap_buffers_callback_(NULL), | 65 swap_buffers_callback_(NULL), |
55 memory_allocation_changed_callback_(NULL), | 66 memory_allocation_changed_callback_(NULL), |
56 max_texture_size_(1024), | 67 max_texture_size_(1024), |
57 width_(0), | 68 width_(0), |
58 height_(0), | 69 height_(0), |
59 bound_buffer_(0), | 70 bound_buffer_(0), |
| 71 namespace_(new Namespace), |
60 weak_ptr_factory_(this) { | 72 weak_ptr_factory_(this) { |
61 } | 73 } |
62 | 74 |
63 TestWebGraphicsContext3D::TestWebGraphicsContext3D( | 75 TestWebGraphicsContext3D::TestWebGraphicsContext3D( |
64 const WebGraphicsContext3D::Attributes& attributes) | 76 const WebGraphicsContext3D::Attributes& attributes) |
65 : FakeWebGraphicsContext3D(), | 77 : FakeWebGraphicsContext3D(), |
66 context_id_(s_context_id++), | 78 context_id_(s_context_id++), |
67 next_buffer_id_(1), | |
68 next_image_id_(1), | |
69 next_texture_id_(1), | |
70 attributes_(attributes), | 79 attributes_(attributes), |
71 support_swapbuffers_complete_callback_(true), | 80 support_swapbuffers_complete_callback_(true), |
72 have_extension_io_surface_(false), | 81 have_extension_io_surface_(false), |
73 have_extension_egl_image_(false), | 82 have_extension_egl_image_(false), |
74 times_make_current_succeeds_(-1), | 83 times_make_current_succeeds_(-1), |
75 times_bind_texture_succeeds_(-1), | 84 times_bind_texture_succeeds_(-1), |
76 times_end_query_succeeds_(-1), | 85 times_end_query_succeeds_(-1), |
77 context_lost_(false), | 86 context_lost_(false), |
78 times_map_image_chromium_succeeds_(-1), | 87 times_map_image_chromium_succeeds_(-1), |
79 times_map_buffer_chromium_succeeds_(-1), | 88 times_map_buffer_chromium_succeeds_(-1), |
80 context_lost_callback_(NULL), | 89 context_lost_callback_(NULL), |
81 swap_buffers_callback_(NULL), | 90 swap_buffers_callback_(NULL), |
82 memory_allocation_changed_callback_(NULL), | 91 memory_allocation_changed_callback_(NULL), |
83 max_texture_size_(1024), | 92 max_texture_size_(1024), |
84 width_(0), | 93 width_(0), |
85 height_(0), | 94 height_(0), |
86 bound_buffer_(0), | 95 bound_buffer_(0), |
87 weak_ptr_factory_(this) { | 96 weak_ptr_factory_(this) { |
| 97 if (attributes.shareResources) { |
| 98 if (shared_namespace_) { |
| 99 namespace_ = shared_namespace_; |
| 100 } else { |
| 101 namespace_ = new Namespace; |
| 102 shared_namespace_ = namespace_; |
| 103 } |
| 104 } else { |
| 105 namespace_ = new Namespace; |
| 106 } |
88 } | 107 } |
89 | 108 |
90 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { | 109 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { |
91 for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) { | 110 for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) { |
92 if (sync_point_callbacks_[i] != NULL) | 111 if (sync_point_callbacks_[i] != NULL) |
93 delete sync_point_callbacks_[i]; | 112 delete sync_point_callbacks_[i]; |
94 } | 113 } |
95 } | 114 } |
96 | 115 |
97 bool TestWebGraphicsContext3D::makeContextCurrent() { | 116 bool TestWebGraphicsContext3D::makeContextCurrent() { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 WGC3Dboolean TestWebGraphicsContext3D::isTexture( | 219 WGC3Dboolean TestWebGraphicsContext3D::isTexture( |
201 WebGLId texture) { | 220 WebGLId texture) { |
202 return false; | 221 return false; |
203 } | 222 } |
204 | 223 |
205 WebGLId TestWebGraphicsContext3D::createBuffer() { | 224 WebGLId TestWebGraphicsContext3D::createBuffer() { |
206 return NextBufferId(); | 225 return NextBufferId(); |
207 } | 226 } |
208 | 227 |
209 void TestWebGraphicsContext3D::deleteBuffer(WebGLId id) { | 228 void TestWebGraphicsContext3D::deleteBuffer(WebGLId id) { |
| 229 base::AutoLock lock(namespace_->lock); |
210 unsigned context_id = id >> 17; | 230 unsigned context_id = id >> 17; |
211 unsigned buffer_id = id & 0x1ffff; | 231 unsigned buffer_id = id & 0x1ffff; |
212 DCHECK(buffer_id && buffer_id < next_buffer_id_); | 232 DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id); |
213 DCHECK_EQ(context_id, context_id_); | 233 DCHECK_EQ(context_id, context_id_); |
214 } | 234 } |
215 | 235 |
216 WebGLId TestWebGraphicsContext3D::createFramebuffer() { | 236 WebGLId TestWebGraphicsContext3D::createFramebuffer() { |
217 return kFramebufferId | context_id_ << 16; | 237 return kFramebufferId | context_id_ << 16; |
218 } | 238 } |
219 | 239 |
220 void TestWebGraphicsContext3D::deleteFramebuffer(WebGLId id) { | 240 void TestWebGraphicsContext3D::deleteFramebuffer(WebGLId id) { |
221 EXPECT_EQ(kFramebufferId | context_id_ << 16, id); | 241 EXPECT_EQ(kFramebufferId | context_id_ << 16, id); |
222 } | 242 } |
(...skipping 18 matching lines...) Expand all Loading... |
241 return kShaderId | context_id_ << 16; | 261 return kShaderId | context_id_ << 16; |
242 } | 262 } |
243 | 263 |
244 void TestWebGraphicsContext3D::deleteShader(WebGLId id) { | 264 void TestWebGraphicsContext3D::deleteShader(WebGLId id) { |
245 EXPECT_EQ(kShaderId | context_id_ << 16, id); | 265 EXPECT_EQ(kShaderId | context_id_ << 16, id); |
246 } | 266 } |
247 | 267 |
248 WebGLId TestWebGraphicsContext3D::createTexture() { | 268 WebGLId TestWebGraphicsContext3D::createTexture() { |
249 WebGLId texture_id = NextTextureId(); | 269 WebGLId texture_id = NextTextureId(); |
250 DCHECK_NE(texture_id, kExternalTextureId); | 270 DCHECK_NE(texture_id, kExternalTextureId); |
251 textures_.push_back(texture_id); | 271 base::AutoLock lock(namespace_->lock); |
| 272 namespace_->textures.push_back(texture_id); |
252 return texture_id; | 273 return texture_id; |
253 } | 274 } |
254 | 275 |
255 void TestWebGraphicsContext3D::deleteTexture(WebGLId texture_id) { | 276 void TestWebGraphicsContext3D::deleteTexture(WebGLId texture_id) { |
256 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != | 277 base::AutoLock lock(namespace_->lock); |
257 textures_.end()); | 278 std::vector<WebKit::WebGLId>& textures = namespace_->textures; |
258 textures_.erase(std::find(textures_.begin(), textures_.end(), texture_id)); | 279 DCHECK(std::find(textures.begin(), textures.end(), texture_id) != |
| 280 textures.end()); |
| 281 textures.erase(std::find(textures.begin(), textures.end(), texture_id)); |
259 } | 282 } |
260 | 283 |
261 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) { | 284 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) { |
262 EXPECT_EQ(kProgramId | context_id_ << 16, program); | 285 EXPECT_EQ(kProgramId | context_id_ << 16, program); |
263 EXPECT_EQ(kShaderId | context_id_ << 16, shader); | 286 EXPECT_EQ(kShaderId | context_id_ << 16, shader); |
264 } | 287 } |
265 | 288 |
266 void TestWebGraphicsContext3D::useProgram(WebGLId program) { | 289 void TestWebGraphicsContext3D::useProgram(WebGLId program) { |
267 if (!program) | 290 if (!program) |
268 return; | 291 return; |
(...skipping 21 matching lines...) Expand all Loading... |
290 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 313 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
291 GL_INNOCENT_CONTEXT_RESET_ARB); | 314 GL_INNOCENT_CONTEXT_RESET_ARB); |
292 } | 315 } |
293 --times_bind_texture_succeeds_; | 316 --times_bind_texture_succeeds_; |
294 } | 317 } |
295 | 318 |
296 if (!texture_id) | 319 if (!texture_id) |
297 return; | 320 return; |
298 if (texture_id == kExternalTextureId) | 321 if (texture_id == kExternalTextureId) |
299 return; | 322 return; |
300 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != | 323 base::AutoLock lock(namespace_->lock); |
301 textures_.end()); | 324 std::vector<WebKit::WebGLId>& textures = namespace_->textures; |
| 325 DCHECK(std::find(textures.begin(), textures.end(), texture_id) != |
| 326 textures.end()); |
302 used_textures_.insert(texture_id); | 327 used_textures_.insert(texture_id); |
303 } | 328 } |
304 | 329 |
305 void TestWebGraphicsContext3D::endQueryEXT(WGC3Denum target) { | 330 void TestWebGraphicsContext3D::endQueryEXT(WGC3Denum target) { |
306 if (times_end_query_succeeds_ >= 0) { | 331 if (times_end_query_succeeds_ >= 0) { |
307 if (!times_end_query_succeeds_) { | 332 if (!times_end_query_succeeds_) { |
308 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 333 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
309 GL_INNOCENT_CONTEXT_RESET_ARB); | 334 GL_INNOCENT_CONTEXT_RESET_ARB); |
310 } | 335 } |
311 --times_end_query_succeeds_; | 336 --times_end_query_succeeds_; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 swap_buffers_callback_->onSwapBuffersComplete(); | 440 swap_buffers_callback_->onSwapBuffersComplete(); |
416 } | 441 } |
417 | 442 |
418 void TestWebGraphicsContext3D::bindBuffer(WebKit::WGC3Denum target, | 443 void TestWebGraphicsContext3D::bindBuffer(WebKit::WGC3Denum target, |
419 WebKit::WebGLId buffer) { | 444 WebKit::WebGLId buffer) { |
420 bound_buffer_ = buffer; | 445 bound_buffer_ = buffer; |
421 if (!bound_buffer_) | 446 if (!bound_buffer_) |
422 return; | 447 return; |
423 unsigned context_id = buffer >> 17; | 448 unsigned context_id = buffer >> 17; |
424 unsigned buffer_id = buffer & 0x1ffff; | 449 unsigned buffer_id = buffer & 0x1ffff; |
425 DCHECK(buffer_id && buffer_id < next_buffer_id_); | 450 base::AutoLock lock(namespace_->lock); |
| 451 DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id); |
426 DCHECK_EQ(context_id, context_id_); | 452 DCHECK_EQ(context_id, context_id_); |
427 | 453 |
428 if (buffers_.count(bound_buffer_) == 0) | 454 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
429 buffers_.set(bound_buffer_, make_scoped_ptr(new Buffer).Pass()); | 455 if (buffers.count(bound_buffer_) == 0) |
| 456 buffers.set(bound_buffer_, make_scoped_ptr(new Buffer).Pass()); |
430 | 457 |
431 buffers_.get(bound_buffer_)->target = target; | 458 buffers.get(bound_buffer_)->target = target; |
432 } | 459 } |
433 | 460 |
434 void TestWebGraphicsContext3D::bufferData(WebKit::WGC3Denum target, | 461 void TestWebGraphicsContext3D::bufferData(WebKit::WGC3Denum target, |
435 WebKit::WGC3Dsizeiptr size, | 462 WebKit::WGC3Dsizeiptr size, |
436 const void* data, | 463 const void* data, |
437 WebKit::WGC3Denum usage) { | 464 WebKit::WGC3Denum usage) { |
438 DCHECK_GT(buffers_.count(bound_buffer_), 0u); | 465 base::AutoLock lock(namespace_->lock); |
439 DCHECK_EQ(target, buffers_.get(bound_buffer_)->target); | 466 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 467 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
| 468 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
440 if (context_lost_) { | 469 if (context_lost_) { |
441 buffers_.get(bound_buffer_)->pixels.reset(); | 470 buffers.get(bound_buffer_)->pixels.reset(); |
442 return; | 471 return; |
443 } | 472 } |
444 buffers_.get(bound_buffer_)->pixels.reset(new uint8[size]); | 473 buffers.get(bound_buffer_)->pixels.reset(new uint8[size]); |
445 if (data != NULL) | 474 if (data != NULL) |
446 memcpy(buffers_.get(bound_buffer_)->pixels.get(), data, size); | 475 memcpy(buffers.get(bound_buffer_)->pixels.get(), data, size); |
447 } | 476 } |
448 | 477 |
449 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(WebKit::WGC3Denum target, | 478 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(WebKit::WGC3Denum target, |
450 WebKit::WGC3Denum access) { | 479 WebKit::WGC3Denum access) { |
451 DCHECK_GT(buffers_.count(bound_buffer_), 0u); | 480 base::AutoLock lock(namespace_->lock); |
452 DCHECK_EQ(target, buffers_.get(bound_buffer_)->target); | 481 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 482 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
| 483 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
453 if (times_map_buffer_chromium_succeeds_ >= 0) { | 484 if (times_map_buffer_chromium_succeeds_ >= 0) { |
454 if (!times_map_buffer_chromium_succeeds_) { | 485 if (!times_map_buffer_chromium_succeeds_) { |
455 return NULL; | 486 return NULL; |
456 } | 487 } |
457 --times_map_buffer_chromium_succeeds_; | 488 --times_map_buffer_chromium_succeeds_; |
458 } | 489 } |
459 return buffers_.get(bound_buffer_)->pixels.get(); | 490 return buffers.get(bound_buffer_)->pixels.get(); |
460 } | 491 } |
461 | 492 |
462 WebKit::WGC3Dboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( | 493 WebKit::WGC3Dboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( |
463 WebKit::WGC3Denum target) { | 494 WebKit::WGC3Denum target) { |
464 DCHECK_GT(buffers_.count(bound_buffer_), 0u); | 495 base::AutoLock lock(namespace_->lock); |
465 DCHECK_EQ(target, buffers_.get(bound_buffer_)->target); | 496 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
466 buffers_.get(bound_buffer_)->pixels.reset(); | 497 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
| 498 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
| 499 buffers.get(bound_buffer_)->pixels.reset(); |
467 return true; | 500 return true; |
468 } | 501 } |
469 | 502 |
470 void TestWebGraphicsContext3D::bindTexImage2DCHROMIUM( | 503 void TestWebGraphicsContext3D::bindTexImage2DCHROMIUM( |
471 WebKit::WGC3Denum target, | 504 WebKit::WGC3Denum target, |
472 WebKit::WGC3Dint image_id) { | 505 WebKit::WGC3Dint image_id) { |
473 DCHECK_GT(images_.count(image_id), 0u); | 506 base::AutoLock lock(namespace_->lock); |
| 507 DCHECK_GT(namespace_->images.count(image_id), 0u); |
474 } | 508 } |
475 | 509 |
476 WebKit::WGC3Duint TestWebGraphicsContext3D::createImageCHROMIUM( | 510 WebKit::WGC3Duint TestWebGraphicsContext3D::createImageCHROMIUM( |
477 WebKit::WGC3Dsizei width, WebKit::WGC3Dsizei height, | 511 WebKit::WGC3Dsizei width, WebKit::WGC3Dsizei height, |
478 WebKit::WGC3Denum internalformat) { | 512 WebKit::WGC3Denum internalformat) { |
479 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat)); | 513 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat)); |
480 WebKit::WGC3Duint image_id = NextImageId(); | 514 WebKit::WGC3Duint image_id = NextImageId(); |
481 images_.set(image_id, make_scoped_ptr(new Image).Pass()); | 515 base::AutoLock lock(namespace_->lock); |
482 images_.get(image_id)->pixels.reset(new uint8[width * height * 4]); | 516 ScopedPtrHashMap<unsigned, Image> &images = namespace_->images; |
| 517 images.set(image_id, make_scoped_ptr(new Image).Pass()); |
| 518 images.get(image_id)->pixels.reset(new uint8[width * height * 4]); |
483 return image_id; | 519 return image_id; |
484 } | 520 } |
485 | 521 |
486 void TestWebGraphicsContext3D::destroyImageCHROMIUM( | 522 void TestWebGraphicsContext3D::destroyImageCHROMIUM( |
487 WebKit::WGC3Duint id) { | 523 WebKit::WGC3Duint id) { |
| 524 base::AutoLock lock(namespace_->lock); |
488 unsigned context_id = id >> 17; | 525 unsigned context_id = id >> 17; |
489 unsigned image_id = id & 0x1ffff; | 526 unsigned image_id = id & 0x1ffff; |
490 DCHECK(image_id && image_id < next_image_id_); | 527 DCHECK(image_id && image_id < namespace_->next_image_id); |
491 DCHECK_EQ(context_id, context_id_); | 528 DCHECK_EQ(context_id, context_id_); |
492 } | 529 } |
493 | 530 |
494 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM( | 531 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM( |
495 WebKit::WGC3Duint image_id, | 532 WebKit::WGC3Duint image_id, |
496 WebKit::WGC3Denum pname, | 533 WebKit::WGC3Denum pname, |
497 WebKit::WGC3Dint* params) { | 534 WebKit::WGC3Dint* params) { |
498 DCHECK_GT(images_.count(image_id), 0u); | 535 base::AutoLock lock(namespace_->lock); |
| 536 DCHECK_GT(namespace_->images.count(image_id), 0u); |
499 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); | 537 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); |
500 *params = 0; | 538 *params = 0; |
501 } | 539 } |
502 | 540 |
503 void* TestWebGraphicsContext3D::mapImageCHROMIUM(WebKit::WGC3Duint image_id, | 541 void* TestWebGraphicsContext3D::mapImageCHROMIUM(WebKit::WGC3Duint image_id, |
504 WebKit::WGC3Denum access) { | 542 WebKit::WGC3Denum access) { |
505 DCHECK_GT(images_.count(image_id), 0u); | 543 base::AutoLock lock(namespace_->lock); |
| 544 ScopedPtrHashMap<unsigned, Image> &images = namespace_->images; |
| 545 DCHECK_GT(images.count(image_id), 0u); |
506 if (times_map_image_chromium_succeeds_ >= 0) { | 546 if (times_map_image_chromium_succeeds_ >= 0) { |
507 if (!times_map_image_chromium_succeeds_) { | 547 if (!times_map_image_chromium_succeeds_) { |
508 return NULL; | 548 return NULL; |
509 } | 549 } |
510 --times_map_image_chromium_succeeds_; | 550 --times_map_image_chromium_succeeds_; |
511 } | 551 } |
512 return images_.get(image_id)->pixels.get(); | 552 return images.get(image_id)->pixels.get(); |
513 } | 553 } |
514 | 554 |
515 void TestWebGraphicsContext3D::unmapImageCHROMIUM( | 555 void TestWebGraphicsContext3D::unmapImageCHROMIUM( |
516 WebKit::WGC3Duint image_id) { | 556 WebKit::WGC3Duint image_id) { |
517 DCHECK_GT(images_.count(image_id), 0u); | 557 base::AutoLock lock(namespace_->lock); |
| 558 DCHECK_GT(namespace_->images.count(image_id), 0u); |
| 559 } |
| 560 |
| 561 size_t TestWebGraphicsContext3D::NumTextures() const { |
| 562 base::AutoLock lock(namespace_->lock); |
| 563 return namespace_->textures.size(); |
| 564 } |
| 565 |
| 566 WebKit::WebGLId TestWebGraphicsContext3D::TextureAt(int i) const { |
| 567 base::AutoLock lock(namespace_->lock); |
| 568 return namespace_->textures[i]; |
518 } | 569 } |
519 | 570 |
520 WebGLId TestWebGraphicsContext3D::NextTextureId() { | 571 WebGLId TestWebGraphicsContext3D::NextTextureId() { |
521 WebGLId texture_id = next_texture_id_++; | 572 base::AutoLock lock(namespace_->lock); |
| 573 WebGLId texture_id = namespace_->next_texture_id++; |
522 DCHECK(texture_id < (1 << 16)); | 574 DCHECK(texture_id < (1 << 16)); |
523 texture_id |= context_id_ << 16; | 575 texture_id |= context_id_ << 16; |
524 return texture_id; | 576 return texture_id; |
525 } | 577 } |
526 | 578 |
527 WebGLId TestWebGraphicsContext3D::NextBufferId() { | 579 WebGLId TestWebGraphicsContext3D::NextBufferId() { |
528 WebGLId buffer_id = next_buffer_id_++; | 580 base::AutoLock lock(namespace_->lock); |
| 581 WebGLId buffer_id = namespace_->next_buffer_id++; |
529 DCHECK(buffer_id < (1 << 17)); | 582 DCHECK(buffer_id < (1 << 17)); |
530 buffer_id |= context_id_ << 17; | 583 buffer_id |= context_id_ << 17; |
531 return buffer_id; | 584 return buffer_id; |
532 } | 585 } |
533 | 586 |
534 WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() { | 587 WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() { |
535 WebKit::WGC3Duint image_id = next_image_id_++; | 588 base::AutoLock lock(namespace_->lock); |
| 589 WGC3Duint image_id = namespace_->next_image_id++; |
536 DCHECK(image_id < (1 << 17)); | 590 DCHECK(image_id < (1 << 17)); |
537 image_id |= context_id_ << 17; | 591 image_id |= context_id_ << 17; |
538 return image_id; | 592 return image_id; |
539 } | 593 } |
540 | 594 |
541 void TestWebGraphicsContext3D::SetMemoryAllocation( | 595 void TestWebGraphicsContext3D::SetMemoryAllocation( |
542 WebKit::WebGraphicsMemoryAllocation allocation) { | 596 WebKit::WebGraphicsMemoryAllocation allocation) { |
543 if (!memory_allocation_changed_callback_) | 597 if (!memory_allocation_changed_callback_) |
544 return; | 598 return; |
545 memory_allocation_changed_callback_->onMemoryAllocationChanged(allocation); | 599 memory_allocation_changed_callback_->onMemoryAllocationChanged(allocation); |
546 } | 600 } |
547 | 601 |
548 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} | 602 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} |
549 | 603 |
550 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 604 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
551 | 605 |
552 TestWebGraphicsContext3D::Image::Image() {} | 606 TestWebGraphicsContext3D::Image::Image() {} |
553 | 607 |
554 TestWebGraphicsContext3D::Image::~Image() {} | 608 TestWebGraphicsContext3D::Image::~Image() {} |
555 | 609 |
556 } // namespace cc | 610 } // namespace cc |
OLD | NEW |