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