Chromium Code Reviews| 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; | |
|
danakj
2013/07/16 02:57:02
This will be a leak. Should we refcount and clean
piman
2013/07/16 03:06:39
It is refcounted, and it cleans itself up :)
See T
danakj
2013/07/16 03:26:11
Oh right, cool.
| |
| 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) | |
|
danakj
2013/07/16 03:26:11
Do we need a lock for accessing the shared_namespa
piman
2013/07/16 04:50:55
Yes, we do! Thanks!
| |
| 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) { |
| 73 if (shared_namespace_) { | |
|
danakj
2013/07/16 03:26:11
can you DCHECK(attributes.shareResources) here so
piman
2013/07/16 04:50:55
Created helper function (made conditional).
| |
| 74 namespace_ = shared_namespace_; | |
| 75 } else { | |
| 76 namespace_ = new Namespace; | |
| 77 shared_namespace_ = namespace_; | |
|
danakj
2013/07/16 03:26:11
.get()
piman
2013/07/16 04:50:55
Done.
| |
| 78 } | |
| 61 } | 79 } |
| 62 | 80 |
| 63 TestWebGraphicsContext3D::TestWebGraphicsContext3D( | 81 TestWebGraphicsContext3D::TestWebGraphicsContext3D( |
| 64 const WebGraphicsContext3D::Attributes& attributes) | 82 const WebGraphicsContext3D::Attributes& attributes) |
| 65 : FakeWebGraphicsContext3D(), | 83 : FakeWebGraphicsContext3D(), |
| 66 context_id_(s_context_id++), | 84 context_id_(s_context_id++), |
| 67 next_buffer_id_(1), | |
| 68 next_image_id_(1), | |
| 69 next_texture_id_(1), | |
| 70 attributes_(attributes), | 85 attributes_(attributes), |
| 71 support_swapbuffers_complete_callback_(true), | 86 support_swapbuffers_complete_callback_(true), |
| 72 have_extension_io_surface_(false), | 87 have_extension_io_surface_(false), |
| 73 have_extension_egl_image_(false), | 88 have_extension_egl_image_(false), |
| 74 times_make_current_succeeds_(-1), | 89 times_make_current_succeeds_(-1), |
| 75 times_bind_texture_succeeds_(-1), | 90 times_bind_texture_succeeds_(-1), |
| 76 times_end_query_succeeds_(-1), | 91 times_end_query_succeeds_(-1), |
| 77 context_lost_(false), | 92 context_lost_(false), |
| 78 times_map_image_chromium_succeeds_(-1), | 93 times_map_image_chromium_succeeds_(-1), |
| 79 times_map_buffer_chromium_succeeds_(-1), | 94 times_map_buffer_chromium_succeeds_(-1), |
| 80 context_lost_callback_(NULL), | 95 context_lost_callback_(NULL), |
| 81 swap_buffers_callback_(NULL), | 96 swap_buffers_callback_(NULL), |
| 82 memory_allocation_changed_callback_(NULL), | 97 memory_allocation_changed_callback_(NULL), |
| 83 max_texture_size_(1024), | 98 max_texture_size_(1024), |
| 84 width_(0), | 99 width_(0), |
| 85 height_(0), | 100 height_(0), |
| 86 bound_buffer_(0), | 101 bound_buffer_(0), |
| 87 weak_ptr_factory_(this) { | 102 weak_ptr_factory_(this) { |
| 103 if (attributes.shareResources) { | |
| 104 if (shared_namespace_) { | |
| 105 namespace_ = shared_namespace_; | |
|
danakj
2013/07/16 03:26:11
cast from raw pointer to scoped_refptr is kinda ic
piman
2013/07/16 04:50:55
It's not a cast but an assignment.. What bothers y
danakj
2013/07/16 05:39:00
Yeh, I've seen this used in chromium before as wel
| |
| 106 } else { | |
| 107 namespace_ = new Namespace; | |
| 108 shared_namespace_ = namespace_; | |
|
danakj
2013/07/16 03:26:11
.get()
piman
2013/07/16 04:50:55
Done.
| |
| 109 } | |
| 110 } else { | |
| 111 namespace_ = new Namespace; | |
| 112 } | |
| 88 } | 113 } |
| 89 | 114 |
| 90 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { | 115 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { |
| 91 for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) { | 116 for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) { |
| 92 if (sync_point_callbacks_[i] != NULL) | 117 if (sync_point_callbacks_[i] != NULL) |
| 93 delete sync_point_callbacks_[i]; | 118 delete sync_point_callbacks_[i]; |
| 94 } | 119 } |
| 95 } | 120 } |
| 96 | 121 |
| 97 bool TestWebGraphicsContext3D::makeContextCurrent() { | 122 bool TestWebGraphicsContext3D::makeContextCurrent() { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 WGC3Dboolean TestWebGraphicsContext3D::isTexture( | 225 WGC3Dboolean TestWebGraphicsContext3D::isTexture( |
| 201 WebGLId texture) { | 226 WebGLId texture) { |
| 202 return false; | 227 return false; |
| 203 } | 228 } |
| 204 | 229 |
| 205 WebGLId TestWebGraphicsContext3D::createBuffer() { | 230 WebGLId TestWebGraphicsContext3D::createBuffer() { |
| 206 return NextBufferId(); | 231 return NextBufferId(); |
| 207 } | 232 } |
| 208 | 233 |
| 209 void TestWebGraphicsContext3D::deleteBuffer(WebGLId id) { | 234 void TestWebGraphicsContext3D::deleteBuffer(WebGLId id) { |
| 235 base::AutoLock lock(namespace_->lock); | |
| 210 unsigned context_id = id >> 17; | 236 unsigned context_id = id >> 17; |
| 211 unsigned buffer_id = id & 0x1ffff; | 237 unsigned buffer_id = id & 0x1ffff; |
| 212 DCHECK(buffer_id && buffer_id < next_buffer_id_); | 238 DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id); |
| 213 DCHECK_EQ(context_id, context_id_); | 239 DCHECK_EQ(context_id, context_id_); |
| 214 } | 240 } |
| 215 | 241 |
| 216 WebGLId TestWebGraphicsContext3D::createFramebuffer() { | 242 WebGLId TestWebGraphicsContext3D::createFramebuffer() { |
| 217 return kFramebufferId | context_id_ << 16; | 243 return kFramebufferId | context_id_ << 16; |
| 218 } | 244 } |
| 219 | 245 |
| 220 void TestWebGraphicsContext3D::deleteFramebuffer(WebGLId id) { | 246 void TestWebGraphicsContext3D::deleteFramebuffer(WebGLId id) { |
| 221 EXPECT_EQ(kFramebufferId | context_id_ << 16, id); | 247 EXPECT_EQ(kFramebufferId | context_id_ << 16, id); |
| 222 } | 248 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 241 return kShaderId | context_id_ << 16; | 267 return kShaderId | context_id_ << 16; |
| 242 } | 268 } |
| 243 | 269 |
| 244 void TestWebGraphicsContext3D::deleteShader(WebGLId id) { | 270 void TestWebGraphicsContext3D::deleteShader(WebGLId id) { |
| 245 EXPECT_EQ(kShaderId | context_id_ << 16, id); | 271 EXPECT_EQ(kShaderId | context_id_ << 16, id); |
| 246 } | 272 } |
| 247 | 273 |
| 248 WebGLId TestWebGraphicsContext3D::createTexture() { | 274 WebGLId TestWebGraphicsContext3D::createTexture() { |
| 249 WebGLId texture_id = NextTextureId(); | 275 WebGLId texture_id = NextTextureId(); |
| 250 DCHECK_NE(texture_id, kExternalTextureId); | 276 DCHECK_NE(texture_id, kExternalTextureId); |
| 251 textures_.push_back(texture_id); | 277 base::AutoLock lock(namespace_->lock); |
| 278 namespace_->textures.push_back(texture_id); | |
| 252 return texture_id; | 279 return texture_id; |
| 253 } | 280 } |
| 254 | 281 |
| 255 void TestWebGraphicsContext3D::deleteTexture(WebGLId texture_id) { | 282 void TestWebGraphicsContext3D::deleteTexture(WebGLId texture_id) { |
| 256 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != | 283 base::AutoLock lock(namespace_->lock); |
| 257 textures_.end()); | 284 std::vector<WebKit::WebGLId>& textures = namespace_->textures; |
| 258 textures_.erase(std::find(textures_.begin(), textures_.end(), texture_id)); | 285 DCHECK(std::find(textures.begin(), textures.end(), texture_id) != |
| 286 textures.end()); | |
| 287 textures.erase(std::find(textures.begin(), textures.end(), texture_id)); | |
| 259 } | 288 } |
| 260 | 289 |
| 261 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) { | 290 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) { |
| 262 EXPECT_EQ(kProgramId | context_id_ << 16, program); | 291 EXPECT_EQ(kProgramId | context_id_ << 16, program); |
| 263 EXPECT_EQ(kShaderId | context_id_ << 16, shader); | 292 EXPECT_EQ(kShaderId | context_id_ << 16, shader); |
| 264 } | 293 } |
| 265 | 294 |
| 266 void TestWebGraphicsContext3D::useProgram(WebGLId program) { | 295 void TestWebGraphicsContext3D::useProgram(WebGLId program) { |
| 267 if (!program) | 296 if (!program) |
| 268 return; | 297 return; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 290 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 319 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 291 GL_INNOCENT_CONTEXT_RESET_ARB); | 320 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 292 } | 321 } |
| 293 --times_bind_texture_succeeds_; | 322 --times_bind_texture_succeeds_; |
| 294 } | 323 } |
| 295 | 324 |
| 296 if (!texture_id) | 325 if (!texture_id) |
| 297 return; | 326 return; |
| 298 if (texture_id == kExternalTextureId) | 327 if (texture_id == kExternalTextureId) |
| 299 return; | 328 return; |
| 300 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != | 329 base::AutoLock lock(namespace_->lock); |
| 301 textures_.end()); | 330 std::vector<WebKit::WebGLId>& textures = namespace_->textures; |
| 331 DCHECK(std::find(textures.begin(), textures.end(), texture_id) != | |
| 332 textures.end()); | |
| 302 used_textures_.insert(texture_id); | 333 used_textures_.insert(texture_id); |
| 303 } | 334 } |
| 304 | 335 |
| 305 void TestWebGraphicsContext3D::endQueryEXT(WGC3Denum target) { | 336 void TestWebGraphicsContext3D::endQueryEXT(WGC3Denum target) { |
| 306 if (times_end_query_succeeds_ >= 0) { | 337 if (times_end_query_succeeds_ >= 0) { |
| 307 if (!times_end_query_succeeds_) { | 338 if (!times_end_query_succeeds_) { |
| 308 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 339 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 309 GL_INNOCENT_CONTEXT_RESET_ARB); | 340 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 310 } | 341 } |
| 311 --times_end_query_succeeds_; | 342 --times_end_query_succeeds_; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 swap_buffers_callback_->onSwapBuffersComplete(); | 446 swap_buffers_callback_->onSwapBuffersComplete(); |
| 416 } | 447 } |
| 417 | 448 |
| 418 void TestWebGraphicsContext3D::bindBuffer(WebKit::WGC3Denum target, | 449 void TestWebGraphicsContext3D::bindBuffer(WebKit::WGC3Denum target, |
| 419 WebKit::WebGLId buffer) { | 450 WebKit::WebGLId buffer) { |
| 420 bound_buffer_ = buffer; | 451 bound_buffer_ = buffer; |
| 421 if (!bound_buffer_) | 452 if (!bound_buffer_) |
| 422 return; | 453 return; |
| 423 unsigned context_id = buffer >> 17; | 454 unsigned context_id = buffer >> 17; |
| 424 unsigned buffer_id = buffer & 0x1ffff; | 455 unsigned buffer_id = buffer & 0x1ffff; |
| 425 DCHECK(buffer_id && buffer_id < next_buffer_id_); | 456 base::AutoLock lock(namespace_->lock); |
| 457 DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id); | |
| 426 DCHECK_EQ(context_id, context_id_); | 458 DCHECK_EQ(context_id, context_id_); |
| 427 | 459 |
| 428 if (buffers_.count(bound_buffer_) == 0) | 460 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 429 buffers_.set(bound_buffer_, make_scoped_ptr(new Buffer).Pass()); | 461 if (buffers.count(bound_buffer_) == 0) |
| 462 buffers.set(bound_buffer_, make_scoped_ptr(new Buffer).Pass()); | |
| 430 | 463 |
| 431 buffers_.get(bound_buffer_)->target = target; | 464 buffers.get(bound_buffer_)->target = target; |
| 432 } | 465 } |
| 433 | 466 |
| 434 void TestWebGraphicsContext3D::bufferData(WebKit::WGC3Denum target, | 467 void TestWebGraphicsContext3D::bufferData(WebKit::WGC3Denum target, |
| 435 WebKit::WGC3Dsizeiptr size, | 468 WebKit::WGC3Dsizeiptr size, |
| 436 const void* data, | 469 const void* data, |
| 437 WebKit::WGC3Denum usage) { | 470 WebKit::WGC3Denum usage) { |
| 438 DCHECK_GT(buffers_.count(bound_buffer_), 0u); | 471 base::AutoLock lock(namespace_->lock); |
| 439 DCHECK_EQ(target, buffers_.get(bound_buffer_)->target); | 472 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 473 DCHECK_GT(buffers.count(bound_buffer_), 0u); | |
| 474 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | |
| 440 if (context_lost_) { | 475 if (context_lost_) { |
| 441 buffers_.get(bound_buffer_)->pixels.reset(); | 476 buffers.get(bound_buffer_)->pixels.reset(); |
| 442 return; | 477 return; |
| 443 } | 478 } |
| 444 buffers_.get(bound_buffer_)->pixels.reset(new uint8[size]); | 479 buffers.get(bound_buffer_)->pixels.reset(new uint8[size]); |
| 445 if (data != NULL) | 480 if (data != NULL) |
| 446 memcpy(buffers_.get(bound_buffer_)->pixels.get(), data, size); | 481 memcpy(buffers.get(bound_buffer_)->pixels.get(), data, size); |
| 447 } | 482 } |
| 448 | 483 |
| 449 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(WebKit::WGC3Denum target, | 484 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(WebKit::WGC3Denum target, |
| 450 WebKit::WGC3Denum access) { | 485 WebKit::WGC3Denum access) { |
| 451 DCHECK_GT(buffers_.count(bound_buffer_), 0u); | 486 base::AutoLock lock(namespace_->lock); |
| 452 DCHECK_EQ(target, buffers_.get(bound_buffer_)->target); | 487 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 488 DCHECK_GT(buffers.count(bound_buffer_), 0u); | |
| 489 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | |
| 453 if (times_map_buffer_chromium_succeeds_ >= 0) { | 490 if (times_map_buffer_chromium_succeeds_ >= 0) { |
| 454 if (!times_map_buffer_chromium_succeeds_) { | 491 if (!times_map_buffer_chromium_succeeds_) { |
| 455 return NULL; | 492 return NULL; |
| 456 } | 493 } |
| 457 --times_map_buffer_chromium_succeeds_; | 494 --times_map_buffer_chromium_succeeds_; |
| 458 } | 495 } |
| 459 return buffers_.get(bound_buffer_)->pixels.get(); | 496 return buffers.get(bound_buffer_)->pixels.get(); |
| 460 } | 497 } |
| 461 | 498 |
| 462 WebKit::WGC3Dboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( | 499 WebKit::WGC3Dboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( |
| 463 WebKit::WGC3Denum target) { | 500 WebKit::WGC3Denum target) { |
| 464 DCHECK_GT(buffers_.count(bound_buffer_), 0u); | 501 base::AutoLock lock(namespace_->lock); |
| 465 DCHECK_EQ(target, buffers_.get(bound_buffer_)->target); | 502 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 466 buffers_.get(bound_buffer_)->pixels.reset(); | 503 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
| 504 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | |
| 505 buffers.get(bound_buffer_)->pixels.reset(); | |
| 467 return true; | 506 return true; |
| 468 } | 507 } |
| 469 | 508 |
| 470 void TestWebGraphicsContext3D::bindTexImage2DCHROMIUM( | 509 void TestWebGraphicsContext3D::bindTexImage2DCHROMIUM( |
| 471 WebKit::WGC3Denum target, | 510 WebKit::WGC3Denum target, |
| 472 WebKit::WGC3Dint image_id) { | 511 WebKit::WGC3Dint image_id) { |
| 473 DCHECK_GT(images_.count(image_id), 0u); | 512 base::AutoLock lock(namespace_->lock); |
| 513 DCHECK_GT(namespace_->images.count(image_id), 0u); | |
| 474 } | 514 } |
| 475 | 515 |
| 476 WebKit::WGC3Duint TestWebGraphicsContext3D::createImageCHROMIUM( | 516 WebKit::WGC3Duint TestWebGraphicsContext3D::createImageCHROMIUM( |
| 477 WebKit::WGC3Dsizei width, WebKit::WGC3Dsizei height, | 517 WebKit::WGC3Dsizei width, WebKit::WGC3Dsizei height, |
| 478 WebKit::WGC3Denum internalformat) { | 518 WebKit::WGC3Denum internalformat) { |
| 479 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat)); | 519 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat)); |
| 480 WebKit::WGC3Duint image_id = NextImageId(); | 520 WebKit::WGC3Duint image_id = NextImageId(); |
| 481 images_.set(image_id, make_scoped_ptr(new Image).Pass()); | 521 base::AutoLock lock(namespace_->lock); |
| 482 images_.get(image_id)->pixels.reset(new uint8[width * height * 4]); | 522 ScopedPtrHashMap<unsigned, Image> &images = namespace_->images; |
|
danakj
2013/07/16 03:26:11
& images
(cpplint fail)
piman
2013/07/16 04:50:55
Done.
| |
| 523 images.set(image_id, make_scoped_ptr(new Image).Pass()); | |
| 524 images.get(image_id)->pixels.reset(new uint8[width * height * 4]); | |
| 483 return image_id; | 525 return image_id; |
| 484 } | 526 } |
| 485 | 527 |
| 486 void TestWebGraphicsContext3D::destroyImageCHROMIUM( | 528 void TestWebGraphicsContext3D::destroyImageCHROMIUM( |
| 487 WebKit::WGC3Duint id) { | 529 WebKit::WGC3Duint id) { |
| 530 base::AutoLock lock(namespace_->lock); | |
| 488 unsigned context_id = id >> 17; | 531 unsigned context_id = id >> 17; |
| 489 unsigned image_id = id & 0x1ffff; | 532 unsigned image_id = id & 0x1ffff; |
| 490 DCHECK(image_id && image_id < next_image_id_); | 533 DCHECK(image_id && image_id < namespace_->next_image_id); |
| 491 DCHECK_EQ(context_id, context_id_); | 534 DCHECK_EQ(context_id, context_id_); |
| 492 } | 535 } |
| 493 | 536 |
| 494 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM( | 537 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM( |
| 495 WebKit::WGC3Duint image_id, | 538 WebKit::WGC3Duint image_id, |
| 496 WebKit::WGC3Denum pname, | 539 WebKit::WGC3Denum pname, |
| 497 WebKit::WGC3Dint* params) { | 540 WebKit::WGC3Dint* params) { |
| 498 DCHECK_GT(images_.count(image_id), 0u); | 541 base::AutoLock lock(namespace_->lock); |
| 542 DCHECK_GT(namespace_->images.count(image_id), 0u); | |
| 499 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); | 543 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); |
| 500 *params = 0; | 544 *params = 0; |
| 501 } | 545 } |
| 502 | 546 |
| 503 void* TestWebGraphicsContext3D::mapImageCHROMIUM(WebKit::WGC3Duint image_id, | 547 void* TestWebGraphicsContext3D::mapImageCHROMIUM(WebKit::WGC3Duint image_id, |
| 504 WebKit::WGC3Denum access) { | 548 WebKit::WGC3Denum access) { |
| 505 DCHECK_GT(images_.count(image_id), 0u); | 549 base::AutoLock lock(namespace_->lock); |
| 550 ScopedPtrHashMap<unsigned, Image> &images = namespace_->images; | |
|
danakj
2013/07/16 03:26:11
& images
piman
2013/07/16 04:50:55
Done.
| |
| 551 DCHECK_GT(images.count(image_id), 0u); | |
| 506 if (times_map_image_chromium_succeeds_ >= 0) { | 552 if (times_map_image_chromium_succeeds_ >= 0) { |
| 507 if (!times_map_image_chromium_succeeds_) { | 553 if (!times_map_image_chromium_succeeds_) { |
| 508 return NULL; | 554 return NULL; |
| 509 } | 555 } |
| 510 --times_map_image_chromium_succeeds_; | 556 --times_map_image_chromium_succeeds_; |
| 511 } | 557 } |
| 512 return images_.get(image_id)->pixels.get(); | 558 return images.get(image_id)->pixels.get(); |
| 513 } | 559 } |
| 514 | 560 |
| 515 void TestWebGraphicsContext3D::unmapImageCHROMIUM( | 561 void TestWebGraphicsContext3D::unmapImageCHROMIUM( |
| 516 WebKit::WGC3Duint image_id) { | 562 WebKit::WGC3Duint image_id) { |
| 517 DCHECK_GT(images_.count(image_id), 0u); | 563 base::AutoLock lock(namespace_->lock); |
| 564 DCHECK_GT(namespace_->images.count(image_id), 0u); | |
| 565 } | |
| 566 | |
| 567 size_t TestWebGraphicsContext3D::NumTextures() const { | |
| 568 base::AutoLock lock(namespace_->lock); | |
| 569 return namespace_->textures.size(); | |
| 570 } | |
| 571 | |
| 572 WebKit::WebGLId TestWebGraphicsContext3D::TextureAt(int i) const { | |
| 573 base::AutoLock lock(namespace_->lock); | |
| 574 return namespace_->textures[i]; | |
| 518 } | 575 } |
| 519 | 576 |
| 520 WebGLId TestWebGraphicsContext3D::NextTextureId() { | 577 WebGLId TestWebGraphicsContext3D::NextTextureId() { |
| 521 WebGLId texture_id = next_texture_id_++; | 578 base::AutoLock lock(namespace_->lock); |
| 579 WebGLId texture_id = namespace_->next_texture_id++; | |
| 522 DCHECK(texture_id < (1 << 16)); | 580 DCHECK(texture_id < (1 << 16)); |
| 523 texture_id |= context_id_ << 16; | 581 texture_id |= context_id_ << 16; |
| 524 return texture_id; | 582 return texture_id; |
| 525 } | 583 } |
| 526 | 584 |
| 527 WebGLId TestWebGraphicsContext3D::NextBufferId() { | 585 WebGLId TestWebGraphicsContext3D::NextBufferId() { |
| 528 WebGLId buffer_id = next_buffer_id_++; | 586 base::AutoLock lock(namespace_->lock); |
| 587 WebGLId buffer_id = namespace_->next_buffer_id++; | |
| 529 DCHECK(buffer_id < (1 << 17)); | 588 DCHECK(buffer_id < (1 << 17)); |
| 530 buffer_id |= context_id_ << 17; | 589 buffer_id |= context_id_ << 17; |
| 531 return buffer_id; | 590 return buffer_id; |
| 532 } | 591 } |
| 533 | 592 |
| 534 WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() { | 593 WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() { |
| 535 WebKit::WGC3Duint image_id = next_image_id_++; | 594 base::AutoLock lock(namespace_->lock); |
| 595 WGC3Duint image_id = namespace_->next_image_id++; | |
| 536 DCHECK(image_id < (1 << 17)); | 596 DCHECK(image_id < (1 << 17)); |
| 537 image_id |= context_id_ << 17; | 597 image_id |= context_id_ << 17; |
| 538 return image_id; | 598 return image_id; |
| 539 } | 599 } |
| 540 | 600 |
| 541 void TestWebGraphicsContext3D::SetMemoryAllocation( | 601 void TestWebGraphicsContext3D::SetMemoryAllocation( |
| 542 WebKit::WebGraphicsMemoryAllocation allocation) { | 602 WebKit::WebGraphicsMemoryAllocation allocation) { |
| 543 if (!memory_allocation_changed_callback_) | 603 if (!memory_allocation_changed_callback_) |
| 544 return; | 604 return; |
| 545 memory_allocation_changed_callback_->onMemoryAllocationChanged(allocation); | 605 memory_allocation_changed_callback_->onMemoryAllocationChanged(allocation); |
| 546 } | 606 } |
| 547 | 607 |
| 548 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} | 608 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} |
| 549 | 609 |
| 550 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 610 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
| 551 | 611 |
| 552 TestWebGraphicsContext3D::Image::Image() {} | 612 TestWebGraphicsContext3D::Image::Image() {} |
| 553 | 613 |
| 554 TestWebGraphicsContext3D::Image::~Image() {} | 614 TestWebGraphicsContext3D::Image::~Image() {} |
| 555 | 615 |
| 556 } // namespace cc | 616 } // namespace cc |
| OLD | NEW |