| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 using WebKit::WGC3Dbyte; | 34 using WebKit::WGC3Dbyte; |
| 35 using WebKit::WGC3Denum; | 35 using WebKit::WGC3Denum; |
| 36 using WebKit::WGC3Dint; | 36 using WebKit::WGC3Dint; |
| 37 using WebKit::WGC3Dsizei; | 37 using WebKit::WGC3Dsizei; |
| 38 using WebKit::WGC3Duint; | 38 using WebKit::WGC3Duint; |
| 39 using WebKit::WebGLId; | 39 using WebKit::WebGLId; |
| 40 | 40 |
| 41 namespace cc { | 41 namespace cc { |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 size_t TextureSize(gfx::Size size, WGC3Denum format) { | 44 size_t TextureSize(gfx::Size size, ResourceFormat format) { |
| 45 unsigned int components_per_pixel = 4; | 45 unsigned int components_per_pixel = 4; |
| 46 unsigned int bytes_per_component = 1; | 46 unsigned int bytes_per_component = 1; |
| 47 return size.width() * size.height() * components_per_pixel * | 47 return size.width() * size.height() * components_per_pixel * |
| 48 bytes_per_component; | 48 bytes_per_component; |
| 49 } | 49 } |
| 50 | 50 |
| 51 class TextureStateTrackingContext : public TestWebGraphicsContext3D { | 51 class TextureStateTrackingContext : public TestWebGraphicsContext3D { |
| 52 public: | 52 public: |
| 53 MOCK_METHOD2(bindTexture, void(WGC3Denum target, WebGLId texture)); | 53 MOCK_METHOD2(bindTexture, void(WGC3Denum target, WebGLId texture)); |
| 54 MOCK_METHOD3(texParameteri, | 54 MOCK_METHOD3(texParameteri, |
| 55 void(WGC3Denum target, WGC3Denum pname, WGC3Dint param)); | 55 void(WGC3Denum target, WGC3Denum pname, WGC3Dint param)); |
| 56 MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point)); | 56 MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point)); |
| 57 MOCK_METHOD0(insertSyncPoint, unsigned(void)); | 57 MOCK_METHOD0(insertSyncPoint, unsigned(void)); |
| 58 MOCK_METHOD2(produceTextureCHROMIUM, void(WGC3Denum target, | 58 MOCK_METHOD2(produceTextureCHROMIUM, void(WGC3Denum target, |
| 59 const WGC3Dbyte* mailbox)); | 59 const WGC3Dbyte* mailbox)); |
| 60 MOCK_METHOD2(consumeTextureCHROMIUM, void(WGC3Denum target, | 60 MOCK_METHOD2(consumeTextureCHROMIUM, void(WGC3Denum target, |
| 61 const WGC3Dbyte* mailbox)); | 61 const WGC3Dbyte* mailbox)); |
| 62 | 62 |
| 63 // Force all textures to be "1" so we can test for them. | 63 // Force all textures to be "1" so we can test for them. |
| 64 virtual WebKit::WebGLId NextTextureId() OVERRIDE { return 1; } | 64 virtual WebKit::WebGLId NextTextureId() OVERRIDE { return 1; } |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 struct Texture : public base::RefCounted<Texture> { | 67 struct Texture : public base::RefCounted<Texture> { |
| 68 Texture() : format(0), filter(GL_NEAREST_MIPMAP_LINEAR) {} | 68 Texture() : format(RGBA_8888), |
| 69 filter(GL_NEAREST_MIPMAP_LINEAR) {} |
| 69 | 70 |
| 70 void Reallocate(gfx::Size size, WGC3Denum format) { | 71 void Reallocate(gfx::Size size, ResourceFormat format) { |
| 71 this->size = size; | 72 this->size = size; |
| 72 this->format = format; | 73 this->format = format; |
| 73 this->data.reset(new uint8_t[TextureSize(size, format)]); | 74 this->data.reset(new uint8_t[TextureSize(size, format)]); |
| 74 } | 75 } |
| 75 | 76 |
| 76 gfx::Size size; | 77 gfx::Size size; |
| 77 WGC3Denum format; | 78 ResourceFormat format; |
| 78 WGC3Denum filter; | 79 WGC3Denum filter; |
| 79 scoped_ptr<uint8_t[]> data; | 80 scoped_ptr<uint8_t[]> data; |
| 80 | 81 |
| 81 private: | 82 private: |
| 82 friend class base::RefCounted<Texture>; | 83 friend class base::RefCounted<Texture>; |
| 83 ~Texture() {} | 84 ~Texture() {} |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 // Shared data between multiple ResourceProviderContext. This contains mailbox | 87 // Shared data between multiple ResourceProviderContext. This contains mailbox |
| 87 // contents as well as information about sync points. | 88 // contents as well as information about sync points. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 WGC3Dint yoffset, | 231 WGC3Dint yoffset, |
| 231 WGC3Dsizei width, | 232 WGC3Dsizei width, |
| 232 WGC3Dsizei height, | 233 WGC3Dsizei height, |
| 233 WGC3Denum format, | 234 WGC3Denum format, |
| 234 WGC3Denum type, | 235 WGC3Denum type, |
| 235 const void* pixels) OVERRIDE { | 236 const void* pixels) OVERRIDE { |
| 236 ASSERT_TRUE(current_texture_); | 237 ASSERT_TRUE(current_texture_); |
| 237 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); | 238 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); |
| 238 ASSERT_FALSE(level); | 239 ASSERT_FALSE(level); |
| 239 ASSERT_TRUE(textures_[current_texture_].get()); | 240 ASSERT_TRUE(textures_[current_texture_].get()); |
| 240 ASSERT_EQ(textures_[current_texture_]->format, format); | 241 ASSERT_EQ( |
| 242 ResourceProvider::GetGLDataFormat(textures_[current_texture_]->format), |
| 243 format); |
| 241 ASSERT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); | 244 ASSERT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); |
| 242 ASSERT_TRUE(pixels); | 245 ASSERT_TRUE(pixels); |
| 243 SetPixels(xoffset, yoffset, width, height, pixels); | 246 SetPixels(xoffset, yoffset, width, height, pixels); |
| 244 } | 247 } |
| 245 | 248 |
| 246 virtual void texParameteri(WGC3Denum target, WGC3Denum param, WGC3Dint value) | 249 virtual void texParameteri(WGC3Denum target, WGC3Denum param, WGC3Dint value) |
| 247 OVERRIDE { | 250 OVERRIDE { |
| 248 ASSERT_TRUE(current_texture_); | 251 ASSERT_TRUE(current_texture_); |
| 249 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); | 252 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); |
| 250 scoped_refptr<Texture> texture = textures_[current_texture_]; | 253 scoped_refptr<Texture> texture = textures_[current_texture_]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 273 } | 276 } |
| 274 | 277 |
| 275 virtual void consumeTextureCHROMIUM(WGC3Denum target, | 278 virtual void consumeTextureCHROMIUM(WGC3Denum target, |
| 276 const WGC3Dbyte* mailbox) OVERRIDE { | 279 const WGC3Dbyte* mailbox) OVERRIDE { |
| 277 ASSERT_TRUE(current_texture_); | 280 ASSERT_TRUE(current_texture_); |
| 278 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); | 281 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); |
| 279 textures_[current_texture_] = shared_data_->ConsumeTexture( | 282 textures_[current_texture_] = shared_data_->ConsumeTexture( |
| 280 mailbox, last_waited_sync_point_); | 283 mailbox, last_waited_sync_point_); |
| 281 } | 284 } |
| 282 | 285 |
| 283 void GetPixels(gfx::Size size, WGC3Denum format, uint8_t* pixels) { | 286 void GetPixels(gfx::Size size, ResourceFormat format, uint8_t* pixels) { |
| 284 ASSERT_TRUE(current_texture_); | 287 ASSERT_TRUE(current_texture_); |
| 285 scoped_refptr<Texture> texture = textures_[current_texture_]; | 288 scoped_refptr<Texture> texture = textures_[current_texture_]; |
| 286 ASSERT_TRUE(texture.get()); | 289 ASSERT_TRUE(texture.get()); |
| 287 ASSERT_EQ(texture->size, size); | 290 ASSERT_EQ(texture->size, size); |
| 288 ASSERT_EQ(texture->format, format); | 291 ASSERT_EQ(texture->format, format); |
| 289 memcpy(pixels, texture->data.get(), TextureSize(size, format)); | 292 memcpy(pixels, texture->data.get(), TextureSize(size, format)); |
| 290 } | 293 } |
| 291 | 294 |
| 292 WGC3Denum GetTextureFilter() { | 295 WGC3Denum GetTextureFilter() { |
| 293 DCHECK(current_texture_); | 296 DCHECK(current_texture_); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 304 : TestWebGraphicsContext3D(attrs), | 307 : TestWebGraphicsContext3D(attrs), |
| 305 shared_data_(shared_data), | 308 shared_data_(shared_data), |
| 306 current_texture_(0), | 309 current_texture_(0), |
| 307 last_waited_sync_point_(0) {} | 310 last_waited_sync_point_(0) {} |
| 308 | 311 |
| 309 private: | 312 private: |
| 310 void AllocateTexture(gfx::Size size, WGC3Denum format) { | 313 void AllocateTexture(gfx::Size size, WGC3Denum format) { |
| 311 ASSERT_TRUE(current_texture_); | 314 ASSERT_TRUE(current_texture_); |
| 312 scoped_refptr<Texture> texture = textures_[current_texture_]; | 315 scoped_refptr<Texture> texture = textures_[current_texture_]; |
| 313 ASSERT_TRUE(texture.get()); | 316 ASSERT_TRUE(texture.get()); |
| 314 texture->Reallocate(size, format); | 317 ResourceFormat texture_format = RGBA_8888; |
| 318 switch (format) { |
| 319 case GL_RGBA: |
| 320 texture_format = RGBA_8888; |
| 321 break; |
| 322 case GL_BGRA_EXT: |
| 323 texture_format = BGRA_8888; |
| 324 break; |
| 325 } |
| 326 texture->Reallocate(size, texture_format); |
| 315 } | 327 } |
| 316 | 328 |
| 317 void SetPixels(int xoffset, | 329 void SetPixels(int xoffset, |
| 318 int yoffset, | 330 int yoffset, |
| 319 int width, | 331 int width, |
| 320 int height, | 332 int height, |
| 321 const void* pixels) { | 333 const void* pixels) { |
| 322 ASSERT_TRUE(current_texture_); | 334 ASSERT_TRUE(current_texture_); |
| 323 scoped_refptr<Texture> texture = textures_[current_texture_]; | 335 scoped_refptr<Texture> texture = textures_[current_texture_]; |
| 324 ASSERT_TRUE(texture.get()); | 336 ASSERT_TRUE(texture.get()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 349 WebGLId current_texture_; | 361 WebGLId current_texture_; |
| 350 TextureMap textures_; | 362 TextureMap textures_; |
| 351 unsigned last_waited_sync_point_; | 363 unsigned last_waited_sync_point_; |
| 352 PendingProduceTextureList pending_produce_textures_; | 364 PendingProduceTextureList pending_produce_textures_; |
| 353 }; | 365 }; |
| 354 | 366 |
| 355 void GetResourcePixels(ResourceProvider* resource_provider, | 367 void GetResourcePixels(ResourceProvider* resource_provider, |
| 356 ResourceProviderContext* context, | 368 ResourceProviderContext* context, |
| 357 ResourceProvider::ResourceId id, | 369 ResourceProvider::ResourceId id, |
| 358 gfx::Size size, | 370 gfx::Size size, |
| 359 WGC3Denum format, | 371 ResourceFormat format, |
| 360 uint8_t* pixels) { | 372 uint8_t* pixels) { |
| 361 switch (resource_provider->default_resource_type()) { | 373 switch (resource_provider->default_resource_type()) { |
| 362 case ResourceProvider::GLTexture: { | 374 case ResourceProvider::GLTexture: { |
| 363 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); | 375 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); |
| 364 ASSERT_NE(0U, lock_gl.texture_id()); | 376 ASSERT_NE(0U, lock_gl.texture_id()); |
| 365 context->bindTexture(GL_TEXTURE_2D, lock_gl.texture_id()); | 377 context->bindTexture(GL_TEXTURE_2D, lock_gl.texture_id()); |
| 366 context->GetPixels(size, format, pixels); | 378 context->GetPixels(size, format, pixels); |
| 367 break; | 379 break; |
| 368 } | 380 } |
| 369 case ResourceProvider::Bitmap: { | 381 case ResourceProvider::Bitmap: { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 413 } |
| 402 case ResourceProvider::Bitmap: | 414 case ResourceProvider::Bitmap: |
| 403 output_surface_ = FakeOutputSurface::CreateSoftware( | 415 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 404 make_scoped_ptr(new SoftwareOutputDevice)); | 416 make_scoped_ptr(new SoftwareOutputDevice)); |
| 405 break; | 417 break; |
| 406 case ResourceProvider::InvalidType: | 418 case ResourceProvider::InvalidType: |
| 407 NOTREACHED(); | 419 NOTREACHED(); |
| 408 break; | 420 break; |
| 409 } | 421 } |
| 410 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 422 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 411 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); | 423 resource_provider_ = ResourceProvider::Create( |
| 424 output_surface_.get(), 0, false); |
| 412 } | 425 } |
| 413 | 426 |
| 414 static void SetResourceFilter(ResourceProvider* resource_provider, | 427 static void SetResourceFilter(ResourceProvider* resource_provider, |
| 415 ResourceProvider::ResourceId id, | 428 ResourceProvider::ResourceId id, |
| 416 WGC3Denum filter) { | 429 WGC3Denum filter) { |
| 417 ResourceProvider::ScopedSamplerGL sampler( | 430 ResourceProvider::ScopedSamplerGL sampler( |
| 418 resource_provider, id, GL_TEXTURE_2D, filter); | 431 resource_provider, id, GL_TEXTURE_2D, filter); |
| 419 } | 432 } |
| 420 | 433 |
| 421 ResourceProviderContext* context() { return context3d_; } | 434 ResourceProviderContext* context() { return context3d_; } |
| 422 | 435 |
| 423 protected: | 436 protected: |
| 424 scoped_ptr<ContextSharedData> shared_data_; | 437 scoped_ptr<ContextSharedData> shared_data_; |
| 425 ResourceProviderContext* context3d_; | 438 ResourceProviderContext* context3d_; |
| 426 FakeOutputSurfaceClient output_surface_client_; | 439 FakeOutputSurfaceClient output_surface_client_; |
| 427 scoped_ptr<OutputSurface> output_surface_; | 440 scoped_ptr<OutputSurface> output_surface_; |
| 428 scoped_ptr<ResourceProvider> resource_provider_; | 441 scoped_ptr<ResourceProvider> resource_provider_; |
| 429 }; | 442 }; |
| 430 | 443 |
| 431 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, | 444 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, |
| 432 ResourceProvider* resource_provider, | 445 ResourceProvider* resource_provider, |
| 433 ResourceProviderContext* context) { | 446 ResourceProviderContext* context) { |
| 434 DCHECK_EQ(expected_default_type, resource_provider->default_resource_type()); | 447 DCHECK_EQ(expected_default_type, resource_provider->default_resource_type()); |
| 435 | 448 |
| 436 gfx::Size size(1, 1); | 449 gfx::Size size(1, 1); |
| 437 WGC3Denum format = GL_RGBA; | 450 ResourceFormat format = RGBA_8888; |
| 438 size_t pixel_size = TextureSize(size, format); | 451 size_t pixel_size = TextureSize(size, format); |
| 439 ASSERT_EQ(4U, pixel_size); | 452 ASSERT_EQ(4U, pixel_size); |
| 440 | 453 |
| 441 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 454 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
| 442 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 455 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 443 EXPECT_EQ(1, static_cast<int>(resource_provider->num_resources())); | 456 EXPECT_EQ(1, static_cast<int>(resource_provider->num_resources())); |
| 444 if (expected_default_type == ResourceProvider::GLTexture) | 457 if (expected_default_type == ResourceProvider::GLTexture) |
| 445 EXPECT_EQ(0, context->texture_count()); | 458 EXPECT_EQ(0, context->texture_count()); |
| 446 | 459 |
| 447 uint8_t data[4] = { 1, 2, 3, 4 }; | 460 uint8_t data[4] = { 1, 2, 3, 4 }; |
| 448 gfx::Rect rect(size); | 461 gfx::Rect rect(size); |
| 449 resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); | 462 resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); |
| 450 if (expected_default_type == ResourceProvider::GLTexture) | 463 if (expected_default_type == ResourceProvider::GLTexture) |
| 451 EXPECT_EQ(1, context->texture_count()); | 464 EXPECT_EQ(1, context->texture_count()); |
| 452 | 465 |
| 453 uint8_t result[4] = { 0 }; | 466 uint8_t result[4] = { 0 }; |
| 454 GetResourcePixels(resource_provider, context, id, size, format, result); | 467 GetResourcePixels(resource_provider, context, id, size, format, result); |
| 455 EXPECT_EQ(0, memcmp(data, result, pixel_size)); | 468 EXPECT_EQ(0, memcmp(data, result, pixel_size)); |
| 456 | 469 |
| 457 resource_provider->DeleteResource(id); | 470 resource_provider->DeleteResource(id); |
| 458 EXPECT_EQ(0, static_cast<int>(resource_provider->num_resources())); | 471 EXPECT_EQ(0, static_cast<int>(resource_provider->num_resources())); |
| 459 if (expected_default_type == ResourceProvider::GLTexture) | 472 if (expected_default_type == ResourceProvider::GLTexture) |
| 460 EXPECT_EQ(0, context->texture_count()); | 473 EXPECT_EQ(0, context->texture_count()); |
| 461 } | 474 } |
| 462 | 475 |
| 463 TEST_P(ResourceProviderTest, Basic) { | 476 TEST_P(ResourceProviderTest, Basic) { |
| 464 CheckCreateResource(GetParam(), resource_provider_.get(), context()); | 477 CheckCreateResource(GetParam(), resource_provider_.get(), context()); |
| 465 } | 478 } |
| 466 | 479 |
| 467 TEST_P(ResourceProviderTest, Upload) { | 480 TEST_P(ResourceProviderTest, Upload) { |
| 468 gfx::Size size(2, 2); | 481 gfx::Size size(2, 2); |
| 469 WGC3Denum format = GL_RGBA; | 482 ResourceFormat format = RGBA_8888; |
| 470 size_t pixel_size = TextureSize(size, format); | 483 size_t pixel_size = TextureSize(size, format); |
| 471 ASSERT_EQ(16U, pixel_size); | 484 ASSERT_EQ(16U, pixel_size); |
| 472 | 485 |
| 473 ResourceProvider::ResourceId id = resource_provider_->CreateResource( | 486 ResourceProvider::ResourceId id = resource_provider_->CreateResource( |
| 474 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 487 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 475 | 488 |
| 476 uint8_t image[16] = { 0 }; | 489 uint8_t image[16] = { 0 }; |
| 477 gfx::Rect image_rect(size); | 490 gfx::Rect image_rect(size); |
| 478 resource_provider_->SetPixels( | 491 resource_provider_->SetPixels( |
| 479 id, image, image_rect, image_rect, gfx::Vector2d()); | 492 id, image, image_rect, image_rect, gfx::Vector2d()); |
| 480 | 493 |
| 481 for (uint8_t i = 0; i < pixel_size; ++i) | 494 for (uint8_t i = 0; i < pixel_size; ++i) |
| 482 image[i] = i; | 495 image[i] = i; |
| 483 | 496 |
| 484 uint8_t result[16] = { 0 }; | 497 uint8_t result[16] = { 0 }; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 ResourceProviderContext::Create(shared_data_.get())); | 553 ResourceProviderContext::Create(shared_data_.get())); |
| 541 ResourceProviderContext* child_context = child_context_owned.get(); | 554 ResourceProviderContext* child_context = child_context_owned.get(); |
| 542 | 555 |
| 543 FakeOutputSurfaceClient child_output_surface_client; | 556 FakeOutputSurfaceClient child_output_surface_client; |
| 544 scoped_ptr<OutputSurface> child_output_surface( | 557 scoped_ptr<OutputSurface> child_output_surface( |
| 545 FakeOutputSurface::Create3d( | 558 FakeOutputSurface::Create3d( |
| 546 child_context_owned.PassAs<TestWebGraphicsContext3D>())); | 559 child_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 547 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); | 560 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); |
| 548 | 561 |
| 549 scoped_ptr<ResourceProvider> child_resource_provider( | 562 scoped_ptr<ResourceProvider> child_resource_provider( |
| 550 ResourceProvider::Create(child_output_surface.get(), 0)); | 563 ResourceProvider::Create(child_output_surface.get(), 0, false)); |
| 551 | 564 |
| 552 gfx::Size size(1, 1); | 565 gfx::Size size(1, 1); |
| 553 WGC3Denum format = GL_RGBA; | 566 ResourceFormat format = RGBA_8888; |
| 554 size_t pixel_size = TextureSize(size, format); | 567 size_t pixel_size = TextureSize(size, format); |
| 555 ASSERT_EQ(4U, pixel_size); | 568 ASSERT_EQ(4U, pixel_size); |
| 556 | 569 |
| 557 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( | 570 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( |
| 558 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 571 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 559 uint8_t data1[4] = { 1, 2, 3, 4 }; | 572 uint8_t data1[4] = { 1, 2, 3, 4 }; |
| 560 gfx::Rect rect(size); | 573 gfx::Rect rect(size); |
| 561 child_resource_provider->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); | 574 child_resource_provider->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); |
| 562 | 575 |
| 563 ResourceProvider::ResourceId id2 = child_resource_provider->CreateResource( | 576 ResourceProvider::ResourceId id2 = child_resource_provider->CreateResource( |
| 564 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 577 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 565 uint8_t data2[4] = { 5, 5, 5, 5 }; | 578 uint8_t data2[4] = { 5, 5, 5, 5 }; |
| 566 child_resource_provider->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); | 579 child_resource_provider->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); |
| 567 | 580 |
| 568 int child_id = resource_provider_->CreateChild(); | 581 int child_id = resource_provider_->CreateChild(); |
| 569 { | 582 { |
| 570 // Transfer some resources to the parent. | 583 // Transfer some resources to the parent. |
| 571 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 584 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 572 resource_ids_to_transfer.push_back(id1); | 585 resource_ids_to_transfer.push_back(id1); |
| 573 resource_ids_to_transfer.push_back(id2); | 586 resource_ids_to_transfer.push_back(id2); |
| 574 TransferableResourceArray list; | 587 TransferableResourceArray list; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 scoped_ptr<ResourceProviderContext> child_context_owned( | 689 scoped_ptr<ResourceProviderContext> child_context_owned( |
| 677 ResourceProviderContext::Create(shared_data_.get())); | 690 ResourceProviderContext::Create(shared_data_.get())); |
| 678 | 691 |
| 679 FakeOutputSurfaceClient child_output_surface_client; | 692 FakeOutputSurfaceClient child_output_surface_client; |
| 680 scoped_ptr<OutputSurface> child_output_surface( | 693 scoped_ptr<OutputSurface> child_output_surface( |
| 681 FakeOutputSurface::Create3d( | 694 FakeOutputSurface::Create3d( |
| 682 child_context_owned.PassAs<TestWebGraphicsContext3D>())); | 695 child_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 683 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); | 696 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); |
| 684 | 697 |
| 685 scoped_ptr<ResourceProvider> child_resource_provider( | 698 scoped_ptr<ResourceProvider> child_resource_provider( |
| 686 ResourceProvider::Create(child_output_surface.get(), 0)); | 699 ResourceProvider::Create(child_output_surface.get(), 0, false)); |
| 687 | 700 |
| 688 gfx::Size size(1, 1); | 701 gfx::Size size(1, 1); |
| 689 WGC3Denum format = GL_RGBA; | 702 ResourceFormat format = RGBA_8888; |
| 690 size_t pixel_size = TextureSize(size, format); | 703 size_t pixel_size = TextureSize(size, format); |
| 691 ASSERT_EQ(4U, pixel_size); | 704 ASSERT_EQ(4U, pixel_size); |
| 692 | 705 |
| 693 ResourceProvider::ResourceId id = child_resource_provider->CreateResource( | 706 ResourceProvider::ResourceId id = child_resource_provider->CreateResource( |
| 694 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 707 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 695 uint8_t data[4] = { 1, 2, 3, 4 }; | 708 uint8_t data[4] = { 1, 2, 3, 4 }; |
| 696 gfx::Rect rect(size); | 709 gfx::Rect rect(size); |
| 697 child_resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); | 710 child_resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); |
| 698 | 711 |
| 699 int child_id = resource_provider_->CreateChild(); | 712 int child_id = resource_provider_->CreateChild(); |
| 700 { | 713 { |
| 701 // Transfer some resource to the parent. | 714 // Transfer some resource to the parent. |
| 702 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 715 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 703 resource_ids_to_transfer.push_back(id); | 716 resource_ids_to_transfer.push_back(id); |
| 704 TransferableResourceArray list; | 717 TransferableResourceArray list; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 scoped_ptr<TextureStateTrackingContext> child_context_owned( | 750 scoped_ptr<TextureStateTrackingContext> child_context_owned( |
| 738 new TextureStateTrackingContext); | 751 new TextureStateTrackingContext); |
| 739 TextureStateTrackingContext* child_context = child_context_owned.get(); | 752 TextureStateTrackingContext* child_context = child_context_owned.get(); |
| 740 | 753 |
| 741 FakeOutputSurfaceClient child_output_surface_client; | 754 FakeOutputSurfaceClient child_output_surface_client; |
| 742 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( | 755 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( |
| 743 child_context_owned.PassAs<TestWebGraphicsContext3D>())); | 756 child_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 744 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); | 757 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); |
| 745 | 758 |
| 746 scoped_ptr<ResourceProvider> child_resource_provider( | 759 scoped_ptr<ResourceProvider> child_resource_provider( |
| 747 ResourceProvider::Create(child_output_surface.get(), 0)); | 760 ResourceProvider::Create(child_output_surface.get(), 0, false)); |
| 748 | 761 |
| 749 scoped_ptr<TextureStateTrackingContext> parent_context_owned( | 762 scoped_ptr<TextureStateTrackingContext> parent_context_owned( |
| 750 new TextureStateTrackingContext); | 763 new TextureStateTrackingContext); |
| 751 TextureStateTrackingContext* parent_context = parent_context_owned.get(); | 764 TextureStateTrackingContext* parent_context = parent_context_owned.get(); |
| 752 | 765 |
| 753 FakeOutputSurfaceClient parent_output_surface_client; | 766 FakeOutputSurfaceClient parent_output_surface_client; |
| 754 scoped_ptr<OutputSurface> parent_output_surface(FakeOutputSurface::Create3d( | 767 scoped_ptr<OutputSurface> parent_output_surface(FakeOutputSurface::Create3d( |
| 755 parent_context_owned.PassAs<TestWebGraphicsContext3D>())); | 768 parent_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 756 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); | 769 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); |
| 757 | 770 |
| 758 scoped_ptr<ResourceProvider> parent_resource_provider( | 771 scoped_ptr<ResourceProvider> parent_resource_provider( |
| 759 ResourceProvider::Create(parent_output_surface.get(), 0)); | 772 ResourceProvider::Create(parent_output_surface.get(), 0, false)); |
| 760 | 773 |
| 761 gfx::Size size(1, 1); | 774 gfx::Size size(1, 1); |
| 762 WGC3Denum format = GL_RGBA; | 775 ResourceFormat format = RGBA_8888; |
| 763 int texture_id = 1; | 776 int texture_id = 1; |
| 764 | 777 |
| 765 size_t pixel_size = TextureSize(size, format); | 778 size_t pixel_size = TextureSize(size, format); |
| 766 ASSERT_EQ(4U, pixel_size); | 779 ASSERT_EQ(4U, pixel_size); |
| 767 | 780 |
| 768 ResourceProvider::ResourceId id = child_resource_provider->CreateResource( | 781 ResourceProvider::ResourceId id = child_resource_provider->CreateResource( |
| 769 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 782 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 770 | 783 |
| 771 // The new texture is created with GL_LINEAR. | 784 // The new texture is created with GL_LINEAR. |
| 772 EXPECT_CALL(*child_context, bindTexture(GL_TEXTURE_2D, texture_id)) | 785 EXPECT_CALL(*child_context, bindTexture(GL_TEXTURE_2D, texture_id)) |
| 773 .Times(2); // Once to create and once to allocate. | 786 .Times(2); // Once to create and once to allocate. |
| 774 EXPECT_CALL(*child_context, | 787 EXPECT_CALL(*child_context, |
| 775 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 788 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 776 EXPECT_CALL(*child_context, | 789 EXPECT_CALL(*child_context, |
| 777 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 790 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 778 EXPECT_CALL( | 791 EXPECT_CALL( |
| 779 *child_context, | 792 *child_context, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 EXPECT_LE(sync_point, list[0].sync_point); | 950 EXPECT_LE(sync_point, list[0].sync_point); |
| 938 EXPECT_EQ(0, | 951 EXPECT_EQ(0, |
| 939 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); | 952 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); |
| 940 EXPECT_EQ(0u, release_sync_point); | 953 EXPECT_EQ(0u, release_sync_point); |
| 941 | 954 |
| 942 context()->waitSyncPoint(list[0].sync_point); | 955 context()->waitSyncPoint(list[0].sync_point); |
| 943 unsigned other_texture = context()->createTexture(); | 956 unsigned other_texture = context()->createTexture(); |
| 944 context()->bindTexture(GL_TEXTURE_2D, other_texture); | 957 context()->bindTexture(GL_TEXTURE_2D, other_texture); |
| 945 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 958 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 946 uint8_t test_data[4] = { 0 }; | 959 uint8_t test_data[4] = { 0 }; |
| 947 context()->GetPixels(gfx::Size(1, 1), GL_RGBA, test_data); | 960 context()->GetPixels( |
| 961 gfx::Size(1, 1), RGBA_8888, test_data); |
| 948 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); | 962 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); |
| 949 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 963 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 950 context()->deleteTexture(other_texture); | 964 context()->deleteTexture(other_texture); |
| 951 list[0].sync_point = context()->insertSyncPoint(); | 965 list[0].sync_point = context()->insertSyncPoint(); |
| 952 EXPECT_LT(0u, list[0].sync_point); | 966 EXPECT_LT(0u, list[0].sync_point); |
| 953 | 967 |
| 954 // Receive the resource, then delete it, expect the sync points to be | 968 // Receive the resource, then delete it, expect the sync points to be |
| 955 // consistent. | 969 // consistent. |
| 956 ReturnedResourceArray returned; | 970 ReturnedResourceArray returned; |
| 957 TransferableResource::ReturnResources(list, &returned); | 971 TransferableResource::ReturnResources(list, &returned); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 984 EXPECT_LE(sync_point, list[0].sync_point); | 998 EXPECT_LE(sync_point, list[0].sync_point); |
| 985 EXPECT_EQ(0, | 999 EXPECT_EQ(0, |
| 986 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); | 1000 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); |
| 987 EXPECT_EQ(0u, release_sync_point); | 1001 EXPECT_EQ(0u, release_sync_point); |
| 988 | 1002 |
| 989 context()->waitSyncPoint(list[0].sync_point); | 1003 context()->waitSyncPoint(list[0].sync_point); |
| 990 unsigned other_texture = context()->createTexture(); | 1004 unsigned other_texture = context()->createTexture(); |
| 991 context()->bindTexture(GL_TEXTURE_2D, other_texture); | 1005 context()->bindTexture(GL_TEXTURE_2D, other_texture); |
| 992 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1006 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 993 uint8_t test_data[4] = { 0 }; | 1007 uint8_t test_data[4] = { 0 }; |
| 994 context()->GetPixels(gfx::Size(1, 1), GL_RGBA, test_data); | 1008 context()->GetPixels( |
| 1009 gfx::Size(1, 1), RGBA_8888, test_data); |
| 995 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); | 1010 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); |
| 996 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1011 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 997 context()->deleteTexture(other_texture); | 1012 context()->deleteTexture(other_texture); |
| 998 list[0].sync_point = context()->insertSyncPoint(); | 1013 list[0].sync_point = context()->insertSyncPoint(); |
| 999 EXPECT_LT(0u, list[0].sync_point); | 1014 EXPECT_LT(0u, list[0].sync_point); |
| 1000 | 1015 |
| 1001 // Delete the resource, which shouldn't do anything. | 1016 // Delete the resource, which shouldn't do anything. |
| 1002 resource_provider_->DeleteResource(resource); | 1017 resource_provider_->DeleteResource(resource); |
| 1003 EXPECT_EQ(1, context()->texture_count()); | 1018 EXPECT_EQ(1, context()->texture_count()); |
| 1004 EXPECT_EQ(0u, release_sync_point); | 1019 EXPECT_EQ(0u, release_sync_point); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 scoped_ptr<TextureStateTrackingContext> context_owned( | 1176 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 1162 new TextureStateTrackingContext); | 1177 new TextureStateTrackingContext); |
| 1163 TextureStateTrackingContext* context = context_owned.get(); | 1178 TextureStateTrackingContext* context = context_owned.get(); |
| 1164 | 1179 |
| 1165 FakeOutputSurfaceClient output_surface_client; | 1180 FakeOutputSurfaceClient output_surface_client; |
| 1166 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1181 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1167 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1182 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1168 CHECK(output_surface->BindToClient(&output_surface_client)); | 1183 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1169 | 1184 |
| 1170 scoped_ptr<ResourceProvider> resource_provider( | 1185 scoped_ptr<ResourceProvider> resource_provider( |
| 1171 ResourceProvider::Create(output_surface.get(), 0)); | 1186 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1172 | 1187 |
| 1173 gfx::Size size(1, 1); | 1188 gfx::Size size(1, 1); |
| 1174 WGC3Denum format = GL_RGBA; | 1189 ResourceFormat format = RGBA_8888; |
| 1175 int texture_id = 1; | 1190 int texture_id = 1; |
| 1176 | 1191 |
| 1177 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 1192 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
| 1178 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1193 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1179 | 1194 |
| 1180 // Check that the texture gets created with the right sampler settings. | 1195 // Check that the texture gets created with the right sampler settings. |
| 1181 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) | 1196 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) |
| 1182 .Times(2); // Once to create and once to allocate. | 1197 .Times(2); // Once to create and once to allocate. |
| 1183 EXPECT_CALL(*context, | 1198 EXPECT_CALL(*context, |
| 1184 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 1199 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 1185 EXPECT_CALL(*context, | 1200 EXPECT_CALL(*context, |
| 1186 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 1201 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 1187 EXPECT_CALL( | 1202 EXPECT_CALL( |
| 1188 *context, | 1203 *context, |
| 1189 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 1204 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
| 1190 EXPECT_CALL( | 1205 EXPECT_CALL( |
| 1191 *context, | 1206 *context, |
| 1192 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); | 1207 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
| 1193 EXPECT_CALL(*context, | 1208 EXPECT_CALL(*context, |
| 1194 texParameteri(GL_TEXTURE_2D, | 1209 texParameteri(GL_TEXTURE_2D, |
| 1195 GL_TEXTURE_POOL_CHROMIUM, | 1210 GL_TEXTURE_POOL_CHROMIUM, |
| 1196 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); | 1211 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); |
| 1212 |
| 1197 resource_provider->AllocateForTesting(id); | 1213 resource_provider->AllocateForTesting(id); |
| 1198 Mock::VerifyAndClearExpectations(context); | 1214 Mock::VerifyAndClearExpectations(context); |
| 1199 | 1215 |
| 1200 // Creating a sampler with the default filter should not change any texture | 1216 // Creating a sampler with the default filter should not change any texture |
| 1201 // parameters. | 1217 // parameters. |
| 1202 { | 1218 { |
| 1203 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 1219 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
| 1204 ResourceProvider::ScopedSamplerGL sampler( | 1220 ResourceProvider::ScopedSamplerGL sampler( |
| 1205 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); | 1221 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); |
| 1206 Mock::VerifyAndClearExpectations(context); | 1222 Mock::VerifyAndClearExpectations(context); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 scoped_ptr<TextureStateTrackingContext> context_owned( | 1257 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 1242 new TextureStateTrackingContext); | 1258 new TextureStateTrackingContext); |
| 1243 TextureStateTrackingContext* context = context_owned.get(); | 1259 TextureStateTrackingContext* context = context_owned.get(); |
| 1244 | 1260 |
| 1245 FakeOutputSurfaceClient output_surface_client; | 1261 FakeOutputSurfaceClient output_surface_client; |
| 1246 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1262 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1247 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1263 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1248 CHECK(output_surface->BindToClient(&output_surface_client)); | 1264 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1249 | 1265 |
| 1250 scoped_ptr<ResourceProvider> resource_provider( | 1266 scoped_ptr<ResourceProvider> resource_provider( |
| 1251 ResourceProvider::Create(output_surface.get(), 0)); | 1267 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1252 | 1268 |
| 1253 gfx::Size size(1, 1); | 1269 gfx::Size size(1, 1); |
| 1254 WGC3Denum format = GL_RGBA; | 1270 ResourceFormat format = RGBA_8888; |
| 1255 int texture_id = 1; | 1271 int texture_id = 1; |
| 1256 | 1272 |
| 1257 // Check that the texture gets created with the right sampler settings. | 1273 // Check that the texture gets created with the right sampler settings. |
| 1258 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( | 1274 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( |
| 1259 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1275 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1260 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 1276 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
| 1261 EXPECT_CALL(*context, | 1277 EXPECT_CALL(*context, |
| 1262 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 1278 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 1263 EXPECT_CALL(*context, | 1279 EXPECT_CALL(*context, |
| 1264 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 1280 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 1265 EXPECT_CALL( | 1281 EXPECT_CALL( |
| 1266 *context, | 1282 *context, |
| 1267 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 1283 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
| 1268 EXPECT_CALL( | 1284 EXPECT_CALL( |
| 1269 *context, | 1285 *context, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1286 scoped_ptr<TextureStateTrackingContext> context_owned( | 1302 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 1287 new TextureStateTrackingContext); | 1303 new TextureStateTrackingContext); |
| 1288 TextureStateTrackingContext* context = context_owned.get(); | 1304 TextureStateTrackingContext* context = context_owned.get(); |
| 1289 | 1305 |
| 1290 FakeOutputSurfaceClient output_surface_client; | 1306 FakeOutputSurfaceClient output_surface_client; |
| 1291 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1307 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1292 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1308 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1293 CHECK(output_surface->BindToClient(&output_surface_client)); | 1309 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1294 | 1310 |
| 1295 scoped_ptr<ResourceProvider> resource_provider( | 1311 scoped_ptr<ResourceProvider> resource_provider( |
| 1296 ResourceProvider::Create(output_surface.get(), 0)); | 1312 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1297 | 1313 |
| 1298 gfx::Size size(1, 1); | 1314 gfx::Size size(1, 1); |
| 1299 WGC3Denum format = GL_RGBA; | 1315 ResourceFormat format = RGBA_8888; |
| 1300 int texture_id = 1; | 1316 int texture_id = 1; |
| 1301 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; | 1317 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; |
| 1302 | 1318 |
| 1303 for (int i = 0; i < 2; ++i) { | 1319 for (int i = 0; i < 2; ++i) { |
| 1304 GLint wrap_mode = i ? GL_CLAMP_TO_EDGE : GL_REPEAT; | 1320 GLint wrap_mode = i ? GL_CLAMP_TO_EDGE : GL_REPEAT; |
| 1305 // Check that the texture gets created with the right sampler settings. | 1321 // Check that the texture gets created with the right sampler settings. |
| 1306 ResourceProvider::ResourceId id = resource_provider->CreateGLTexture( | 1322 ResourceProvider::ResourceId id = |
| 1307 size, format, texture_pool, wrap_mode, | 1323 resource_provider->CreateGLTexture(size, |
| 1308 ResourceProvider::TextureUsageAny); | 1324 texture_pool, |
| 1325 wrap_mode, |
| 1326 ResourceProvider::TextureUsageAny, |
| 1327 format); |
| 1309 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 1328 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
| 1310 EXPECT_CALL(*context, | 1329 EXPECT_CALL(*context, |
| 1311 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 1330 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 1312 EXPECT_CALL(*context, | 1331 EXPECT_CALL(*context, |
| 1313 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 1332 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 1314 EXPECT_CALL( | 1333 EXPECT_CALL( |
| 1315 *context, | 1334 *context, |
| 1316 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode)); | 1335 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode)); |
| 1317 EXPECT_CALL( | 1336 EXPECT_CALL( |
| 1318 *context, | 1337 *context, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1339 scoped_ptr<base::SharedMemory> shared_memory( | 1358 scoped_ptr<base::SharedMemory> shared_memory( |
| 1340 CreateAndFillSharedMemory(size, kBadBeef)); | 1359 CreateAndFillSharedMemory(size, kBadBeef)); |
| 1341 | 1360 |
| 1342 FakeOutputSurfaceClient output_surface_client; | 1361 FakeOutputSurfaceClient output_surface_client; |
| 1343 scoped_ptr<OutputSurface> output_surface( | 1362 scoped_ptr<OutputSurface> output_surface( |
| 1344 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 1363 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
| 1345 new SoftwareOutputDevice))); | 1364 new SoftwareOutputDevice))); |
| 1346 CHECK(output_surface->BindToClient(&output_surface_client)); | 1365 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1347 | 1366 |
| 1348 scoped_ptr<ResourceProvider> resource_provider( | 1367 scoped_ptr<ResourceProvider> resource_provider( |
| 1349 ResourceProvider::Create(output_surface.get(), 0)); | 1368 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1350 | 1369 |
| 1351 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 1370 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 1352 base::Bind(&EmptyReleaseCallback)); | 1371 base::Bind(&EmptyReleaseCallback)); |
| 1353 TextureMailbox mailbox(shared_memory.get(), size); | 1372 TextureMailbox mailbox(shared_memory.get(), size); |
| 1354 | 1373 |
| 1355 ResourceProvider::ResourceId id = | 1374 ResourceProvider::ResourceId id = |
| 1356 resource_provider->CreateResourceFromTextureMailbox( | 1375 resource_provider->CreateResourceFromTextureMailbox( |
| 1357 mailbox, callback.Pass()); | 1376 mailbox, callback.Pass()); |
| 1358 EXPECT_NE(0u, id); | 1377 EXPECT_NE(0u, id); |
| 1359 | 1378 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1374 scoped_ptr<TextureStateTrackingContext> context_owned( | 1393 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 1375 new TextureStateTrackingContext); | 1394 new TextureStateTrackingContext); |
| 1376 TextureStateTrackingContext* context = context_owned.get(); | 1395 TextureStateTrackingContext* context = context_owned.get(); |
| 1377 | 1396 |
| 1378 FakeOutputSurfaceClient output_surface_client; | 1397 FakeOutputSurfaceClient output_surface_client; |
| 1379 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1398 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1380 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1399 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1381 CHECK(output_surface->BindToClient(&output_surface_client)); | 1400 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1382 | 1401 |
| 1383 scoped_ptr<ResourceProvider> resource_provider( | 1402 scoped_ptr<ResourceProvider> resource_provider( |
| 1384 ResourceProvider::Create(output_surface.get(), 0)); | 1403 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1385 | 1404 |
| 1386 unsigned texture_id = 1; | 1405 unsigned texture_id = 1; |
| 1387 unsigned sync_point = 30; | 1406 unsigned sync_point = 30; |
| 1388 unsigned target = GL_TEXTURE_2D; | 1407 unsigned target = GL_TEXTURE_2D; |
| 1389 | 1408 |
| 1390 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 1409 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| 1391 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 1410 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 1392 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 1411 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
| 1393 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 1412 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 1394 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 1413 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 scoped_ptr<TextureStateTrackingContext> context_owned( | 1457 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 1439 new TextureStateTrackingContext); | 1458 new TextureStateTrackingContext); |
| 1440 TextureStateTrackingContext* context = context_owned.get(); | 1459 TextureStateTrackingContext* context = context_owned.get(); |
| 1441 | 1460 |
| 1442 FakeOutputSurfaceClient output_surface_client; | 1461 FakeOutputSurfaceClient output_surface_client; |
| 1443 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1462 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1444 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1463 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1445 CHECK(output_surface->BindToClient(&output_surface_client)); | 1464 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1446 | 1465 |
| 1447 scoped_ptr<ResourceProvider> resource_provider( | 1466 scoped_ptr<ResourceProvider> resource_provider( |
| 1448 ResourceProvider::Create(output_surface.get(), 0)); | 1467 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1449 | 1468 |
| 1450 unsigned texture_id = 1; | 1469 unsigned texture_id = 1; |
| 1451 unsigned sync_point = 30; | 1470 unsigned sync_point = 30; |
| 1452 unsigned target = GL_TEXTURE_EXTERNAL_OES; | 1471 unsigned target = GL_TEXTURE_EXTERNAL_OES; |
| 1453 | 1472 |
| 1454 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 1473 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| 1455 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 1474 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 1456 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 1475 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
| 1457 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 1476 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 1458 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 1477 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 scoped_ptr<AllocationTrackingContext3D> context_owned( | 1577 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 1559 new StrictMock<AllocationTrackingContext3D>); | 1578 new StrictMock<AllocationTrackingContext3D>); |
| 1560 AllocationTrackingContext3D* context = context_owned.get(); | 1579 AllocationTrackingContext3D* context = context_owned.get(); |
| 1561 | 1580 |
| 1562 FakeOutputSurfaceClient output_surface_client; | 1581 FakeOutputSurfaceClient output_surface_client; |
| 1563 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1582 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1564 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1583 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1565 CHECK(output_surface->BindToClient(&output_surface_client)); | 1584 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1566 | 1585 |
| 1567 scoped_ptr<ResourceProvider> resource_provider( | 1586 scoped_ptr<ResourceProvider> resource_provider( |
| 1568 ResourceProvider::Create(output_surface.get(), 0)); | 1587 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1569 | 1588 |
| 1570 gfx::Size size(2, 2); | 1589 gfx::Size size(2, 2); |
| 1571 gfx::Vector2d offset(0, 0); | 1590 gfx::Vector2d offset(0, 0); |
| 1572 gfx::Rect rect(0, 0, 2, 2); | 1591 gfx::Rect rect(0, 0, 2, 2); |
| 1573 WGC3Denum format = GL_RGBA; | 1592 ResourceFormat format = RGBA_8888; |
| 1574 ResourceProvider::ResourceId id = 0; | 1593 ResourceProvider::ResourceId id = 0; |
| 1575 uint8_t pixels[16] = { 0 }; | 1594 uint8_t pixels[16] = { 0 }; |
| 1576 int texture_id = 123; | 1595 int texture_id = 123; |
| 1577 | 1596 |
| 1578 // Lazy allocation. Don't allocate when creating the resource. | 1597 // Lazy allocation. Don't allocate when creating the resource. |
| 1579 id = resource_provider->CreateResource( | 1598 id = resource_provider->CreateResource( |
| 1580 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1599 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1581 | 1600 |
| 1582 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1601 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
| 1583 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); | 1602 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); |
| 1584 resource_provider->CreateForTesting(id); | 1603 resource_provider->CreateForTesting(id); |
| 1585 | 1604 |
| 1586 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); | 1605 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); |
| 1587 resource_provider->DeleteResource(id); | 1606 resource_provider->DeleteResource(id); |
| 1588 | 1607 |
| 1589 Mock::VerifyAndClearExpectations(context); | 1608 Mock::VerifyAndClearExpectations(context); |
| 1590 | 1609 |
| 1591 // Do allocate when we set the pixels. | 1610 // Do allocate when we set the pixels. |
| 1592 id = resource_provider->CreateResource( | 1611 id = resource_provider->CreateResource( |
| 1593 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1612 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1594 | 1613 |
| 1595 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1614 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
| 1596 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); | 1615 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); |
| 1597 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); | 1616 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); |
| 1598 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); | 1617 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); |
| 1599 resource_provider->SetPixels(id, pixels, rect, rect, offset); | 1618 resource_provider->SetPixels(id, pixels, rect, rect, offset); |
| 1600 | 1619 |
| 1601 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); | 1620 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); |
| 1602 resource_provider->DeleteResource(id); | 1621 resource_provider->DeleteResource(id); |
| 1603 | 1622 |
| 1604 Mock::VerifyAndClearExpectations(context); | 1623 Mock::VerifyAndClearExpectations(context); |
| 1605 | 1624 |
| 1606 // Same for async version. | 1625 // Same for async version. |
| 1607 id = resource_provider->CreateResource( | 1626 id = resource_provider->CreateResource( |
| 1608 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1627 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1609 resource_provider->AcquirePixelBuffer(id); | 1628 resource_provider->AcquirePixelBuffer(id); |
| 1610 | 1629 |
| 1611 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1630 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
| 1612 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 1631 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 1613 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 1632 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
| 1614 .Times(1); | 1633 .Times(1); |
| 1615 resource_provider->BeginSetPixels(id); | 1634 resource_provider->BeginSetPixels(id); |
| 1616 ASSERT_TRUE(resource_provider->DidSetPixelsComplete(id)); | 1635 ASSERT_TRUE(resource_provider->DidSetPixelsComplete(id)); |
| 1617 | 1636 |
| 1618 resource_provider->ReleasePixelBuffer(id); | 1637 resource_provider->ReleasePixelBuffer(id); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1629 scoped_ptr<AllocationTrackingContext3D> context_owned( | 1648 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 1630 new StrictMock<AllocationTrackingContext3D>); | 1649 new StrictMock<AllocationTrackingContext3D>); |
| 1631 AllocationTrackingContext3D* context = context_owned.get(); | 1650 AllocationTrackingContext3D* context = context_owned.get(); |
| 1632 | 1651 |
| 1633 FakeOutputSurfaceClient output_surface_client; | 1652 FakeOutputSurfaceClient output_surface_client; |
| 1634 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1653 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1635 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1654 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1636 CHECK(output_surface->BindToClient(&output_surface_client)); | 1655 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1637 | 1656 |
| 1638 gfx::Size size(2, 2); | 1657 gfx::Size size(2, 2); |
| 1639 WGC3Denum format = GL_RGBA; | 1658 ResourceFormat format = RGBA_8888; |
| 1640 ResourceProvider::ResourceId id = 0; | 1659 ResourceProvider::ResourceId id = 0; |
| 1641 int texture_id = 123; | 1660 int texture_id = 123; |
| 1642 | 1661 |
| 1643 scoped_ptr<ResourceProvider> resource_provider( | 1662 scoped_ptr<ResourceProvider> resource_provider( |
| 1644 ResourceProvider::Create(output_surface.get(), 0)); | 1663 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1645 | 1664 |
| 1646 id = resource_provider->CreateResource( | 1665 id = resource_provider->CreateResource( |
| 1647 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1666 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1648 resource_provider->AcquirePixelBuffer(id); | 1667 resource_provider->AcquirePixelBuffer(id); |
| 1649 | 1668 |
| 1650 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1669 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
| 1651 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 1670 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 1652 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 1671 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
| 1653 .Times(1); | 1672 .Times(1); |
| 1654 resource_provider->BeginSetPixels(id); | 1673 resource_provider->BeginSetPixels(id); |
| 1655 | 1674 |
| 1656 EXPECT_TRUE(resource_provider->DidSetPixelsComplete(id)); | 1675 EXPECT_TRUE(resource_provider->DidSetPixelsComplete(id)); |
| 1657 | 1676 |
| 1658 resource_provider->ReleasePixelBuffer(id); | 1677 resource_provider->ReleasePixelBuffer(id); |
| 1659 | 1678 |
| 1660 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); | 1679 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); |
| 1661 resource_provider->DeleteResource(id); | 1680 resource_provider->DeleteResource(id); |
| 1662 | 1681 |
| 1663 Mock::VerifyAndClearExpectations(context); | 1682 Mock::VerifyAndClearExpectations(context); |
| 1664 } | 1683 } |
| 1665 | 1684 |
| 1666 TEST_P(ResourceProviderTest, PixelBuffer_Bitmap) { | 1685 TEST_P(ResourceProviderTest, PixelBuffer_Bitmap) { |
| 1667 if (GetParam() != ResourceProvider::Bitmap) | 1686 if (GetParam() != ResourceProvider::Bitmap) |
| 1668 return; | 1687 return; |
| 1669 FakeOutputSurfaceClient output_surface_client; | 1688 FakeOutputSurfaceClient output_surface_client; |
| 1670 scoped_ptr<OutputSurface> output_surface( | 1689 scoped_ptr<OutputSurface> output_surface( |
| 1671 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 1690 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
| 1672 new SoftwareOutputDevice))); | 1691 new SoftwareOutputDevice))); |
| 1673 CHECK(output_surface->BindToClient(&output_surface_client)); | 1692 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1674 | 1693 |
| 1675 gfx::Size size(1, 1); | 1694 gfx::Size size(1, 1); |
| 1676 WGC3Denum format = GL_RGBA; | 1695 ResourceFormat format = RGBA_8888; |
| 1677 ResourceProvider::ResourceId id = 0; | 1696 ResourceProvider::ResourceId id = 0; |
| 1678 const uint32_t kBadBeef = 0xbadbeef; | 1697 const uint32_t kBadBeef = 0xbadbeef; |
| 1679 | 1698 |
| 1680 scoped_ptr<ResourceProvider> resource_provider( | 1699 scoped_ptr<ResourceProvider> resource_provider( |
| 1681 ResourceProvider::Create(output_surface.get(), 0)); | 1700 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1682 | 1701 |
| 1683 id = resource_provider->CreateResource( | 1702 id = resource_provider->CreateResource( |
| 1684 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1703 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1685 resource_provider->AcquirePixelBuffer(id); | 1704 resource_provider->AcquirePixelBuffer(id); |
| 1686 | 1705 |
| 1687 void* data = resource_provider->MapPixelBuffer(id); | 1706 void* data = resource_provider->MapPixelBuffer(id); |
| 1688 ASSERT_TRUE(!!data); | 1707 ASSERT_TRUE(!!data); |
| 1689 memcpy(data, &kBadBeef, sizeof(kBadBeef)); | 1708 memcpy(data, &kBadBeef, sizeof(kBadBeef)); |
| 1690 resource_provider->UnmapPixelBuffer(id); | 1709 resource_provider->UnmapPixelBuffer(id); |
| 1691 | 1710 |
| 1692 resource_provider->BeginSetPixels(id); | 1711 resource_provider->BeginSetPixels(id); |
| 1693 EXPECT_TRUE(resource_provider->DidSetPixelsComplete(id)); | 1712 EXPECT_TRUE(resource_provider->DidSetPixelsComplete(id)); |
| 1694 | 1713 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1712 scoped_ptr<AllocationTrackingContext3D> context_owned( | 1731 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 1713 new StrictMock<AllocationTrackingContext3D>); | 1732 new StrictMock<AllocationTrackingContext3D>); |
| 1714 AllocationTrackingContext3D* context = context_owned.get(); | 1733 AllocationTrackingContext3D* context = context_owned.get(); |
| 1715 | 1734 |
| 1716 FakeOutputSurfaceClient output_surface_client; | 1735 FakeOutputSurfaceClient output_surface_client; |
| 1717 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1736 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1718 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1737 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1719 CHECK(output_surface->BindToClient(&output_surface_client)); | 1738 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1720 | 1739 |
| 1721 gfx::Size size(2, 2); | 1740 gfx::Size size(2, 2); |
| 1722 WGC3Denum format = GL_RGBA; | 1741 ResourceFormat format = RGBA_8888; |
| 1723 ResourceProvider::ResourceId id = 0; | 1742 ResourceProvider::ResourceId id = 0; |
| 1724 int texture_id = 123; | 1743 int texture_id = 123; |
| 1725 | 1744 |
| 1726 scoped_ptr<ResourceProvider> resource_provider( | 1745 scoped_ptr<ResourceProvider> resource_provider( |
| 1727 ResourceProvider::Create(output_surface.get(), 0)); | 1746 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1728 | 1747 |
| 1729 id = resource_provider->CreateResource( | 1748 id = resource_provider->CreateResource( |
| 1730 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1749 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1731 resource_provider->AcquirePixelBuffer(id); | 1750 resource_provider->AcquirePixelBuffer(id); |
| 1732 | 1751 |
| 1733 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1752 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
| 1734 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 1753 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 1735 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 1754 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
| 1736 .Times(1); | 1755 .Times(1); |
| 1737 resource_provider->BeginSetPixels(id); | 1756 resource_provider->BeginSetPixels(id); |
| 1738 | 1757 |
| 1739 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); | 1758 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); |
| 1740 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); | 1759 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1753 scoped_ptr<AllocationTrackingContext3D> context_owned( | 1772 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 1754 new NiceMock<AllocationTrackingContext3D>); | 1773 new NiceMock<AllocationTrackingContext3D>); |
| 1755 AllocationTrackingContext3D* context = context_owned.get(); | 1774 AllocationTrackingContext3D* context = context_owned.get(); |
| 1756 | 1775 |
| 1757 FakeOutputSurfaceClient output_surface_client; | 1776 FakeOutputSurfaceClient output_surface_client; |
| 1758 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1777 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1759 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1778 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1760 CHECK(output_surface->BindToClient(&output_surface_client)); | 1779 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1761 | 1780 |
| 1762 gfx::Size size(2, 2); | 1781 gfx::Size size(2, 2); |
| 1763 WGC3Denum format = GL_RGBA; | 1782 ResourceFormat format = RGBA_8888; |
| 1764 ResourceProvider::ResourceId id = 0; | 1783 ResourceProvider::ResourceId id = 0; |
| 1765 int texture_id = 123; | 1784 int texture_id = 123; |
| 1766 | 1785 |
| 1767 scoped_ptr<ResourceProvider> resource_provider( | 1786 scoped_ptr<ResourceProvider> resource_provider( |
| 1768 ResourceProvider::Create(output_surface.get(), 0)); | 1787 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1769 | 1788 |
| 1770 EXPECT_CALL(*context, createTexture()).WillRepeatedly(Return(texture_id)); | 1789 EXPECT_CALL(*context, createTexture()).WillRepeatedly(Return(texture_id)); |
| 1771 | 1790 |
| 1772 id = resource_provider->CreateResource( | 1791 id = resource_provider->CreateResource( |
| 1773 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1792 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1774 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 1793 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 1775 GL_INNOCENT_CONTEXT_RESET_ARB); | 1794 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 1776 resource_provider->AcquirePixelBuffer(id); | 1795 resource_provider->AcquirePixelBuffer(id); |
| 1777 uint8_t* buffer = resource_provider->MapPixelBuffer(id); | 1796 uint8_t* buffer = resource_provider->MapPixelBuffer(id); |
| 1778 EXPECT_TRUE(buffer == NULL); | 1797 EXPECT_TRUE(buffer == NULL); |
| 1779 resource_provider->UnmapPixelBuffer(id); | 1798 resource_provider->UnmapPixelBuffer(id); |
| 1780 resource_provider->ReleasePixelBuffer(id); | 1799 resource_provider->ReleasePixelBuffer(id); |
| 1781 Mock::VerifyAndClearExpectations(context); | 1800 Mock::VerifyAndClearExpectations(context); |
| 1782 } | 1801 } |
| 1783 | 1802 |
| 1784 TEST_P(ResourceProviderTest, Image_GLTexture) { | 1803 TEST_P(ResourceProviderTest, Image_GLTexture) { |
| 1785 // Only for GL textures. | 1804 // Only for GL textures. |
| 1786 if (GetParam() != ResourceProvider::GLTexture) | 1805 if (GetParam() != ResourceProvider::GLTexture) |
| 1787 return; | 1806 return; |
| 1788 scoped_ptr<AllocationTrackingContext3D> context_owned( | 1807 scoped_ptr<AllocationTrackingContext3D> context_owned( |
| 1789 new StrictMock<AllocationTrackingContext3D>); | 1808 new StrictMock<AllocationTrackingContext3D>); |
| 1790 AllocationTrackingContext3D* context = context_owned.get(); | 1809 AllocationTrackingContext3D* context = context_owned.get(); |
| 1791 | 1810 |
| 1792 FakeOutputSurfaceClient output_surface_client; | 1811 FakeOutputSurfaceClient output_surface_client; |
| 1793 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1812 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1794 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1813 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1795 CHECK(output_surface->BindToClient(&output_surface_client)); | 1814 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1796 | 1815 |
| 1797 const int kWidth = 2; | 1816 const int kWidth = 2; |
| 1798 const int kHeight = 2; | 1817 const int kHeight = 2; |
| 1799 gfx::Size size(kWidth, kHeight); | 1818 gfx::Size size(kWidth, kHeight); |
| 1800 WGC3Denum format = GL_RGBA; | 1819 ResourceFormat format = RGBA_8888; |
| 1801 ResourceProvider::ResourceId id = 0; | 1820 ResourceProvider::ResourceId id = 0; |
| 1802 const unsigned kTextureId = 123u; | 1821 const unsigned kTextureId = 123u; |
| 1803 const unsigned kImageId = 234u; | 1822 const unsigned kImageId = 234u; |
| 1804 | 1823 |
| 1805 scoped_ptr<ResourceProvider> resource_provider( | 1824 scoped_ptr<ResourceProvider> resource_provider( |
| 1806 ResourceProvider::Create(output_surface.get(), 0)); | 1825 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1807 | 1826 |
| 1808 id = resource_provider->CreateResource( | 1827 id = resource_provider->CreateResource( |
| 1809 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1828 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1810 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) | 1829 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) |
| 1811 .WillOnce(Return(kImageId)) | 1830 .WillOnce(Return(kImageId)) |
| 1812 .RetiresOnSaturation(); | 1831 .RetiresOnSaturation(); |
| 1813 resource_provider->AcquireImage(id); | 1832 resource_provider->AcquireImage(id); |
| 1814 | 1833 |
| 1815 void* dummy_mapped_buffer_address = NULL; | 1834 void* dummy_mapped_buffer_address = NULL; |
| 1816 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId, GL_READ_WRITE)) | 1835 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId, GL_READ_WRITE)) |
| 1817 .WillOnce(Return(dummy_mapped_buffer_address)) | 1836 .WillOnce(Return(dummy_mapped_buffer_address)) |
| 1818 .RetiresOnSaturation(); | 1837 .RetiresOnSaturation(); |
| 1819 resource_provider->MapImage(id); | 1838 resource_provider->MapImage(id); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 TEST_P(ResourceProviderTest, Image_Bitmap) { | 1881 TEST_P(ResourceProviderTest, Image_Bitmap) { |
| 1863 if (GetParam() != ResourceProvider::Bitmap) | 1882 if (GetParam() != ResourceProvider::Bitmap) |
| 1864 return; | 1883 return; |
| 1865 FakeOutputSurfaceClient output_surface_client; | 1884 FakeOutputSurfaceClient output_surface_client; |
| 1866 scoped_ptr<OutputSurface> output_surface( | 1885 scoped_ptr<OutputSurface> output_surface( |
| 1867 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 1886 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
| 1868 new SoftwareOutputDevice))); | 1887 new SoftwareOutputDevice))); |
| 1869 CHECK(output_surface->BindToClient(&output_surface_client)); | 1888 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1870 | 1889 |
| 1871 gfx::Size size(1, 1); | 1890 gfx::Size size(1, 1); |
| 1872 WGC3Denum format = GL_RGBA; | 1891 ResourceFormat format = RGBA_8888; |
| 1873 ResourceProvider::ResourceId id = 0; | 1892 ResourceProvider::ResourceId id = 0; |
| 1874 const uint32_t kBadBeef = 0xbadbeef; | 1893 const uint32_t kBadBeef = 0xbadbeef; |
| 1875 | 1894 |
| 1876 scoped_ptr<ResourceProvider> resource_provider( | 1895 scoped_ptr<ResourceProvider> resource_provider( |
| 1877 ResourceProvider::Create(output_surface.get(), 0)); | 1896 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1878 | 1897 |
| 1879 id = resource_provider->CreateResource( | 1898 id = resource_provider->CreateResource( |
| 1880 size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); | 1899 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); |
| 1881 resource_provider->AcquireImage(id); | 1900 resource_provider->AcquireImage(id); |
| 1882 | 1901 |
| 1883 const int kStride = 0; | 1902 const int kStride = 0; |
| 1884 int stride = resource_provider->GetImageStride(id); | 1903 int stride = resource_provider->GetImageStride(id); |
| 1885 EXPECT_EQ(kStride, stride); | 1904 EXPECT_EQ(kStride, stride); |
| 1886 | 1905 |
| 1887 void* data = resource_provider->MapImage(id); | 1906 void* data = resource_provider->MapImage(id); |
| 1888 ASSERT_TRUE(!!data); | 1907 ASSERT_TRUE(!!data); |
| 1889 memcpy(data, &kBadBeef, sizeof(kBadBeef)); | 1908 memcpy(data, &kBadBeef, sizeof(kBadBeef)); |
| 1890 resource_provider->UnmapImage(id); | 1909 resource_provider->UnmapImage(id); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1918 } | 1937 } |
| 1919 | 1938 |
| 1920 TEST(ResourceProviderTest, BasicInitializeGLSoftware) { | 1939 TEST(ResourceProviderTest, BasicInitializeGLSoftware) { |
| 1921 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create(); | 1940 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create(); |
| 1922 FakeOutputSurfaceClient client; | 1941 FakeOutputSurfaceClient client; |
| 1923 scoped_ptr<FakeOutputSurface> output_surface( | 1942 scoped_ptr<FakeOutputSurface> output_surface( |
| 1924 FakeOutputSurface::CreateDeferredGL( | 1943 FakeOutputSurface::CreateDeferredGL( |
| 1925 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice))); | 1944 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice))); |
| 1926 EXPECT_TRUE(output_surface->BindToClient(&client)); | 1945 EXPECT_TRUE(output_surface->BindToClient(&client)); |
| 1927 scoped_ptr<ResourceProvider> resource_provider( | 1946 scoped_ptr<ResourceProvider> resource_provider( |
| 1928 ResourceProvider::Create(output_surface.get(), 0)); | 1947 ResourceProvider::Create(output_surface.get(), 0, false)); |
| 1929 | 1948 |
| 1930 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); | 1949 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); |
| 1931 | 1950 |
| 1932 InitializeGLAndCheck(shared_data.get(), | 1951 InitializeGLAndCheck(shared_data.get(), |
| 1933 resource_provider.get(), | 1952 resource_provider.get(), |
| 1934 output_surface.get()); | 1953 output_surface.get()); |
| 1935 | 1954 |
| 1936 resource_provider->InitializeSoftware(); | 1955 resource_provider->InitializeSoftware(); |
| 1937 output_surface->ReleaseGL(); | 1956 output_surface->ReleaseGL(); |
| 1938 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); | 1957 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); |
| 1939 | 1958 |
| 1940 InitializeGLAndCheck(shared_data.get(), | 1959 InitializeGLAndCheck(shared_data.get(), |
| 1941 resource_provider.get(), | 1960 resource_provider.get(), |
| 1942 output_surface.get()); | 1961 output_surface.get()); |
| 1943 } | 1962 } |
| 1944 | 1963 |
| 1945 INSTANTIATE_TEST_CASE_P( | 1964 INSTANTIATE_TEST_CASE_P( |
| 1946 ResourceProviderTests, | 1965 ResourceProviderTests, |
| 1947 ResourceProviderTest, | 1966 ResourceProviderTest, |
| 1948 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); | 1967 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); |
| 1949 | 1968 |
| 1950 } // namespace | 1969 } // namespace |
| 1951 } // namespace cc | 1970 } // namespace cc |
| OLD | NEW |