Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: cc/resources/resource_provider_unittest.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/scoped_resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <deque> 11 #include <deque>
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 #include <unordered_map> 14 #include <unordered_map>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/ptr_util.h"
19 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
20 #include "cc/output/output_surface.h" 21 #include "cc/output/output_surface.h"
21 #include "cc/resources/returned_resource.h" 22 #include "cc/resources/returned_resource.h"
22 #include "cc/resources/shared_bitmap_manager.h" 23 #include "cc/resources/shared_bitmap_manager.h"
23 #include "cc/resources/single_release_callback.h" 24 #include "cc/resources/single_release_callback.h"
24 #include "cc/test/fake_output_surface.h" 25 #include "cc/test/fake_output_surface.h"
25 #include "cc/test/fake_output_surface_client.h" 26 #include "cc/test/fake_output_surface_client.h"
26 #include "cc/test/test_gpu_memory_buffer_manager.h" 27 #include "cc/test/test_gpu_memory_buffer_manager.h"
27 #include "cc/test/test_shared_bitmap_manager.h" 28 #include "cc/test/test_shared_bitmap_manager.h"
28 #include "cc/test/test_texture.h" 29 #include "cc/test/test_texture.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 BlockingTaskRunner** release_main_thread_task_runner, 62 BlockingTaskRunner** release_main_thread_task_runner,
62 const gpu::SyncToken& sync_token, 63 const gpu::SyncToken& sync_token,
63 bool lost_resource, 64 bool lost_resource,
64 BlockingTaskRunner* main_thread_task_runner) { 65 BlockingTaskRunner* main_thread_task_runner) {
65 *release_sync_token = sync_token; 66 *release_sync_token = sync_token;
66 *release_lost_resource = lost_resource; 67 *release_lost_resource = lost_resource;
67 *release_main_thread_task_runner = main_thread_task_runner; 68 *release_main_thread_task_runner = main_thread_task_runner;
68 } 69 }
69 70
70 static void SharedBitmapReleaseCallback( 71 static void SharedBitmapReleaseCallback(
71 scoped_ptr<SharedBitmap> bitmap, 72 std::unique_ptr<SharedBitmap> bitmap,
72 const gpu::SyncToken& sync_token, 73 const gpu::SyncToken& sync_token,
73 bool lost_resource, 74 bool lost_resource,
74 BlockingTaskRunner* main_thread_task_runner) {} 75 BlockingTaskRunner* main_thread_task_runner) {}
75 76
76 static void ReleaseSharedBitmapCallback( 77 static void ReleaseSharedBitmapCallback(
77 scoped_ptr<SharedBitmap> shared_bitmap, 78 std::unique_ptr<SharedBitmap> shared_bitmap,
78 bool* release_called, 79 bool* release_called,
79 gpu::SyncToken* release_sync_token, 80 gpu::SyncToken* release_sync_token,
80 bool* lost_resource_result, 81 bool* lost_resource_result,
81 const gpu::SyncToken& sync_token, 82 const gpu::SyncToken& sync_token,
82 bool lost_resource, 83 bool lost_resource,
83 BlockingTaskRunner* main_thread_task_runner) { 84 BlockingTaskRunner* main_thread_task_runner) {
84 *release_called = true; 85 *release_called = true;
85 *release_sync_token = sync_token; 86 *release_sync_token = sync_token;
86 *lost_resource_result = lost_resource; 87 *lost_resource_result = lost_resource;
87 } 88 }
88 89
89 static scoped_ptr<SharedBitmap> CreateAndFillSharedBitmap( 90 static std::unique_ptr<SharedBitmap> CreateAndFillSharedBitmap(
90 SharedBitmapManager* manager, 91 SharedBitmapManager* manager,
91 const gfx::Size& size, 92 const gfx::Size& size,
92 uint32_t value) { 93 uint32_t value) {
93 scoped_ptr<SharedBitmap> shared_bitmap = manager->AllocateSharedBitmap(size); 94 std::unique_ptr<SharedBitmap> shared_bitmap =
95 manager->AllocateSharedBitmap(size);
94 CHECK(shared_bitmap); 96 CHECK(shared_bitmap);
95 uint32_t* pixels = reinterpret_cast<uint32_t*>(shared_bitmap->pixels()); 97 uint32_t* pixels = reinterpret_cast<uint32_t*>(shared_bitmap->pixels());
96 CHECK(pixels); 98 CHECK(pixels);
97 std::fill_n(pixels, size.GetArea(), value); 99 std::fill_n(pixels, size.GetArea(), value);
98 return shared_bitmap; 100 return shared_bitmap;
99 } 101 }
100 102
101 class TextureStateTrackingContext : public TestWebGraphicsContext3D { 103 class TextureStateTrackingContext : public TestWebGraphicsContext3D {
102 public: 104 public:
103 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); 105 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture));
(...skipping 25 matching lines...) Expand all
129 131
130 GLuint64 GetNextFenceSync() const { return next_fence_sync_; } 132 GLuint64 GetNextFenceSync() const { return next_fence_sync_; }
131 133
132 GLuint64 next_fence_sync_ = 1; 134 GLuint64 next_fence_sync_ = 1;
133 }; 135 };
134 136
135 // Shared data between multiple ResourceProviderContext. This contains mailbox 137 // Shared data between multiple ResourceProviderContext. This contains mailbox
136 // contents as well as information about sync points. 138 // contents as well as information about sync points.
137 class ContextSharedData { 139 class ContextSharedData {
138 public: 140 public:
139 static scoped_ptr<ContextSharedData> Create() { 141 static std::unique_ptr<ContextSharedData> Create() {
140 return make_scoped_ptr(new ContextSharedData()); 142 return base::WrapUnique(new ContextSharedData());
141 } 143 }
142 144
143 uint32_t InsertFenceSync() { return next_fence_sync_++; } 145 uint32_t InsertFenceSync() { return next_fence_sync_++; }
144 146
145 void GenMailbox(GLbyte* mailbox) { 147 void GenMailbox(GLbyte* mailbox) {
146 memset(mailbox, 0, GL_MAILBOX_SIZE_CHROMIUM); 148 memset(mailbox, 0, GL_MAILBOX_SIZE_CHROMIUM);
147 memcpy(mailbox, &next_mailbox_, sizeof(next_mailbox_)); 149 memcpy(mailbox, &next_mailbox_, sizeof(next_mailbox_));
148 ++next_mailbox_; 150 ++next_mailbox_;
149 } 151 }
150 152
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 184
183 uint64_t next_fence_sync_; 185 uint64_t next_fence_sync_;
184 unsigned next_mailbox_; 186 unsigned next_mailbox_;
185 using TextureMap = std::unordered_map<unsigned, scoped_refptr<TestTexture>>; 187 using TextureMap = std::unordered_map<unsigned, scoped_refptr<TestTexture>>;
186 TextureMap textures_; 188 TextureMap textures_;
187 std::unordered_map<unsigned, uint32_t> sync_point_for_mailbox_; 189 std::unordered_map<unsigned, uint32_t> sync_point_for_mailbox_;
188 }; 190 };
189 191
190 class ResourceProviderContext : public TestWebGraphicsContext3D { 192 class ResourceProviderContext : public TestWebGraphicsContext3D {
191 public: 193 public:
192 static scoped_ptr<ResourceProviderContext> Create( 194 static std::unique_ptr<ResourceProviderContext> Create(
193 ContextSharedData* shared_data) { 195 ContextSharedData* shared_data) {
194 return make_scoped_ptr(new ResourceProviderContext(shared_data)); 196 return base::WrapUnique(new ResourceProviderContext(shared_data));
195 } 197 }
196 198
197 GLuint64 insertFenceSync() override { 199 GLuint64 insertFenceSync() override {
198 return shared_data_->InsertFenceSync(); 200 return shared_data_->InsertFenceSync();
199 } 201 }
200 202
201 void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token) override { 203 void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token) override {
202 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0, 204 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0,
203 gpu::CommandBufferId::FromUnsafeValue(0x123), 205 gpu::CommandBufferId::FromUnsafeValue(0x123),
204 fence_sync); 206 fence_sync);
205 sync_token_data.SetVerifyFlush(); 207 sync_token_data.SetVerifyFlush();
206 // Commit the produceTextureCHROMIUM calls at this point, so that 208 // Commit the produceTextureCHROMIUM calls at this point, so that
207 // they're associated with the sync point. 209 // they're associated with the sync point.
208 for (const scoped_ptr<PendingProduceTexture>& pending_texture : 210 for (const std::unique_ptr<PendingProduceTexture>& pending_texture :
209 pending_produce_textures_) { 211 pending_produce_textures_) {
210 shared_data_->ProduceTexture(pending_texture->mailbox, sync_token_data, 212 shared_data_->ProduceTexture(pending_texture->mailbox, sync_token_data,
211 pending_texture->texture); 213 pending_texture->texture);
212 } 214 }
213 pending_produce_textures_.clear(); 215 pending_produce_textures_.clear();
214 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); 216 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data));
215 } 217 }
216 218
217 void waitSyncToken(const GLbyte* sync_token) override { 219 void waitSyncToken(const GLbyte* sync_token) override {
218 gpu::SyncToken sync_token_data; 220 gpu::SyncToken sync_token_data;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 void genMailboxCHROMIUM(GLbyte* mailbox) override { 296 void genMailboxCHROMIUM(GLbyte* mailbox) override {
295 return shared_data_->GenMailbox(mailbox); 297 return shared_data_->GenMailbox(mailbox);
296 } 298 }
297 299
298 void produceTextureDirectCHROMIUM(GLuint texture, 300 void produceTextureDirectCHROMIUM(GLuint texture,
299 GLenum target, 301 GLenum target,
300 const GLbyte* mailbox) override { 302 const GLbyte* mailbox) override {
301 // Delay moving the texture into the mailbox until the next 303 // Delay moving the texture into the mailbox until the next
302 // sync token, so that it is not visible to other contexts that 304 // sync token, so that it is not visible to other contexts that
303 // haven't waited on that sync point. 305 // haven't waited on that sync point.
304 scoped_ptr<PendingProduceTexture> pending(new PendingProduceTexture); 306 std::unique_ptr<PendingProduceTexture> pending(new PendingProduceTexture);
305 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox)); 307 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox));
306 base::AutoLock lock_for_texture_access(namespace_->lock); 308 base::AutoLock lock_for_texture_access(namespace_->lock);
307 pending->texture = UnboundTexture(texture); 309 pending->texture = UnboundTexture(texture);
308 pending_produce_textures_.push_back(std::move(pending)); 310 pending_produce_textures_.push_back(std::move(pending));
309 } 311 }
310 312
311 GLuint createAndConsumeTextureCHROMIUM(GLenum target, 313 GLuint createAndConsumeTextureCHROMIUM(GLenum target,
312 const GLbyte* mailbox) override { 314 const GLbyte* mailbox) override {
313 GLuint texture_id = createTexture(); 315 GLuint texture_id = createTexture();
314 base::AutoLock lock_for_texture_access(namespace_->lock); 316 base::AutoLock lock_for_texture_access(namespace_->lock);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 src += in_pitch; 375 src += in_pitch;
374 } 376 }
375 } 377 }
376 378
377 struct PendingProduceTexture { 379 struct PendingProduceTexture {
378 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; 380 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM];
379 scoped_refptr<TestTexture> texture; 381 scoped_refptr<TestTexture> texture;
380 }; 382 };
381 ContextSharedData* shared_data_; 383 ContextSharedData* shared_data_;
382 gpu::SyncToken last_waited_sync_token_; 384 gpu::SyncToken last_waited_sync_token_;
383 std::deque<scoped_ptr<PendingProduceTexture>> pending_produce_textures_; 385 std::deque<std::unique_ptr<PendingProduceTexture>> pending_produce_textures_;
384 }; 386 };
385 387
386 void GetResourcePixels(ResourceProvider* resource_provider, 388 void GetResourcePixels(ResourceProvider* resource_provider,
387 ResourceProviderContext* context, 389 ResourceProviderContext* context,
388 ResourceId id, 390 ResourceId id,
389 const gfx::Size& size, 391 const gfx::Size& size,
390 ResourceFormat format, 392 ResourceFormat format,
391 uint8_t* pixels) { 393 uint8_t* pixels) {
392 resource_provider->WaitSyncTokenIfNeeded(id); 394 resource_provider->WaitSyncTokenIfNeeded(id);
393 switch (resource_provider->default_resource_type()) { 395 switch (resource_provider->default_resource_type()) {
(...skipping 20 matching lines...) Expand all
414 : public testing::TestWithParam<ResourceProvider::ResourceType> { 416 : public testing::TestWithParam<ResourceProvider::ResourceType> {
415 public: 417 public:
416 explicit ResourceProviderTest(bool child_needs_sync_token) 418 explicit ResourceProviderTest(bool child_needs_sync_token)
417 : shared_data_(ContextSharedData::Create()), 419 : shared_data_(ContextSharedData::Create()),
418 context3d_(NULL), 420 context3d_(NULL),
419 child_context_(NULL), 421 child_context_(NULL),
420 main_thread_task_runner_(BlockingTaskRunner::Create(NULL)) { 422 main_thread_task_runner_(BlockingTaskRunner::Create(NULL)) {
421 switch (GetParam()) { 423 switch (GetParam()) {
422 case ResourceProvider::RESOURCE_TYPE_GPU_MEMORY_BUFFER: 424 case ResourceProvider::RESOURCE_TYPE_GPU_MEMORY_BUFFER:
423 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: { 425 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: {
424 scoped_ptr<ResourceProviderContext> context3d( 426 std::unique_ptr<ResourceProviderContext> context3d(
425 ResourceProviderContext::Create(shared_data_.get())); 427 ResourceProviderContext::Create(shared_data_.get()));
426 context3d_ = context3d.get(); 428 context3d_ = context3d.get();
427 429
428 scoped_refptr<TestContextProvider> context_provider = 430 scoped_refptr<TestContextProvider> context_provider =
429 TestContextProvider::Create(std::move(context3d)); 431 TestContextProvider::Create(std::move(context3d));
430 432
431 output_surface_ = FakeOutputSurface::Create3d(context_provider); 433 output_surface_ = FakeOutputSurface::Create3d(context_provider);
432 434
433 scoped_ptr<ResourceProviderContext> child_context_owned = 435 std::unique_ptr<ResourceProviderContext> child_context_owned =
434 ResourceProviderContext::Create(shared_data_.get()); 436 ResourceProviderContext::Create(shared_data_.get());
435 child_context_ = child_context_owned.get(); 437 child_context_ = child_context_owned.get();
436 if (child_needs_sync_token) { 438 if (child_needs_sync_token) {
437 child_output_surface_ = 439 child_output_surface_ =
438 FakeOutputSurface::Create3d(std::move(child_context_owned)); 440 FakeOutputSurface::Create3d(std::move(child_context_owned));
439 } else { 441 } else {
440 child_output_surface_ = FakeOutputSurface::CreateNoRequireSyncPoint( 442 child_output_surface_ = FakeOutputSurface::CreateNoRequireSyncPoint(
441 std::move(child_context_owned)); 443 std::move(child_context_owned));
442 } 444 }
443 break; 445 break;
444 } 446 }
445 case ResourceProvider::RESOURCE_TYPE_BITMAP: 447 case ResourceProvider::RESOURCE_TYPE_BITMAP:
446 output_surface_ = FakeOutputSurface::CreateSoftware( 448 output_surface_ = FakeOutputSurface::CreateSoftware(
447 make_scoped_ptr(new SoftwareOutputDevice)); 449 base::WrapUnique(new SoftwareOutputDevice));
448 child_output_surface_ = FakeOutputSurface::CreateSoftware( 450 child_output_surface_ = FakeOutputSurface::CreateSoftware(
449 make_scoped_ptr(new SoftwareOutputDevice)); 451 base::WrapUnique(new SoftwareOutputDevice));
450 break; 452 break;
451 } 453 }
452 CHECK(output_surface_->BindToClient(&output_surface_client_)); 454 CHECK(output_surface_->BindToClient(&output_surface_client_));
453 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_)); 455 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_));
454 456
455 shared_bitmap_manager_.reset(new TestSharedBitmapManager); 457 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
456 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); 458 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
457 459
458 resource_provider_ = ResourceProvider::Create( 460 resource_provider_ = ResourceProvider::Create(
459 output_surface_.get(), shared_bitmap_manager_.get(), 461 output_surface_.get(), shared_bitmap_manager_.get(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { 495 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) {
494 unsigned texture = child_context_->createTexture(); 496 unsigned texture = child_context_->createTexture();
495 gpu::Mailbox gpu_mailbox; 497 gpu::Mailbox gpu_mailbox;
496 child_context_->genMailboxCHROMIUM(gpu_mailbox.name); 498 child_context_->genMailboxCHROMIUM(gpu_mailbox.name);
497 child_context_->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, 499 child_context_->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D,
498 gpu_mailbox.name); 500 gpu_mailbox.name);
499 child_context_->genSyncToken(child_context_->insertFenceSync(), 501 child_context_->genSyncToken(child_context_->insertFenceSync(),
500 sync_token->GetData()); 502 sync_token->GetData());
501 EXPECT_TRUE(sync_token->HasData()); 503 EXPECT_TRUE(sync_token->HasData());
502 504
503 scoped_ptr<SharedBitmap> shared_bitmap; 505 std::unique_ptr<SharedBitmap> shared_bitmap;
504 scoped_ptr<SingleReleaseCallbackImpl> callback = 506 std::unique_ptr<SingleReleaseCallbackImpl> callback =
505 SingleReleaseCallbackImpl::Create(base::Bind( 507 SingleReleaseCallbackImpl::Create(base::Bind(
506 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap), 508 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap),
507 release_called, release_sync_token, lost_resource)); 509 release_called, release_sync_token, lost_resource));
508 return child_resource_provider_->CreateResourceFromTextureMailbox( 510 return child_resource_provider_->CreateResourceFromTextureMailbox(
509 TextureMailbox(gpu_mailbox, *sync_token, GL_TEXTURE_2D), 511 TextureMailbox(gpu_mailbox, *sync_token, GL_TEXTURE_2D),
510 std::move(callback)); 512 std::move(callback));
511 } else { 513 } else {
512 gfx::Size size(64, 64); 514 gfx::Size size(64, 64);
513 scoped_ptr<SharedBitmap> shared_bitmap( 515 std::unique_ptr<SharedBitmap> shared_bitmap(
514 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, 0)); 516 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, 0));
515 517
516 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get(); 518 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get();
517 scoped_ptr<SingleReleaseCallbackImpl> callback = 519 std::unique_ptr<SingleReleaseCallbackImpl> callback =
518 SingleReleaseCallbackImpl::Create(base::Bind( 520 SingleReleaseCallbackImpl::Create(base::Bind(
519 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap), 521 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap),
520 release_called, release_sync_token, lost_resource)); 522 release_called, release_sync_token, lost_resource));
521 return child_resource_provider_->CreateResourceFromTextureMailbox( 523 return child_resource_provider_->CreateResourceFromTextureMailbox(
522 TextureMailbox(shared_bitmap_ptr, size), std::move(callback)); 524 TextureMailbox(shared_bitmap_ptr, size), std::move(callback));
523 } 525 }
524 } 526 }
525 527
526 public: 528 public:
527 static bool use_gpu_memory_buffer_resources() { 529 static bool use_gpu_memory_buffer_resources() {
528 return use_gpu_memory_buffer_resources_; 530 return use_gpu_memory_buffer_resources_;
529 } 531 }
530 static std::vector<unsigned> use_image_texture_targets() { 532 static std::vector<unsigned> use_image_texture_targets() {
531 return use_image_texture_targets_; 533 return use_image_texture_targets_;
532 } 534 }
533 535
534 protected: 536 protected:
535 static bool use_gpu_memory_buffer_resources_; 537 static bool use_gpu_memory_buffer_resources_;
536 static std::vector<unsigned> use_image_texture_targets_; 538 static std::vector<unsigned> use_image_texture_targets_;
537 scoped_ptr<ContextSharedData> shared_data_; 539 std::unique_ptr<ContextSharedData> shared_data_;
538 ResourceProviderContext* context3d_; 540 ResourceProviderContext* context3d_;
539 ResourceProviderContext* child_context_; 541 ResourceProviderContext* child_context_;
540 FakeOutputSurfaceClient output_surface_client_; 542 FakeOutputSurfaceClient output_surface_client_;
541 FakeOutputSurfaceClient child_output_surface_client_; 543 FakeOutputSurfaceClient child_output_surface_client_;
542 scoped_ptr<OutputSurface> output_surface_; 544 std::unique_ptr<OutputSurface> output_surface_;
543 scoped_ptr<OutputSurface> child_output_surface_; 545 std::unique_ptr<OutputSurface> child_output_surface_;
544 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; 546 std::unique_ptr<BlockingTaskRunner> main_thread_task_runner_;
545 scoped_ptr<ResourceProvider> resource_provider_; 547 std::unique_ptr<ResourceProvider> resource_provider_;
546 scoped_ptr<ResourceProvider> child_resource_provider_; 548 std::unique_ptr<ResourceProvider> child_resource_provider_;
547 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; 549 std::unique_ptr<TestSharedBitmapManager> shared_bitmap_manager_;
548 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; 550 std::unique_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_;
549 }; 551 };
550 552
551 bool ResourceProviderTest::use_gpu_memory_buffer_resources_ = false; 553 bool ResourceProviderTest::use_gpu_memory_buffer_resources_ = false;
552 554
553 std::vector<unsigned> ResourceProviderTest::use_image_texture_targets_ = 555 std::vector<unsigned> ResourceProviderTest::use_image_texture_targets_ =
554 std::vector<unsigned>(static_cast<size_t>(gfx::BufferFormat::LAST) + 1, 556 std::vector<unsigned>(static_cast<size_t>(gfx::BufferFormat::LAST) + 1,
555 GL_TEXTURE_2D); 557 GL_TEXTURE_2D);
556 558
557 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, 559 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type,
558 ResourceProvider* resource_provider, 560 ResourceProvider* resource_provider,
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 ResourceId id1 = child_resource_provider_->CreateResource( 1258 ResourceId id1 = child_resource_provider_->CreateResource(
1257 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 1259 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
1258 uint8_t data1[4] = { 1, 2, 3, 4 }; 1260 uint8_t data1[4] = { 1, 2, 3, 4 };
1259 child_resource_provider_->CopyToResource(id1, data1, size); 1261 child_resource_provider_->CopyToResource(id1, data1, size);
1260 1262
1261 ResourceId id2 = child_resource_provider_->CreateResource( 1263 ResourceId id2 = child_resource_provider_->CreateResource(
1262 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 1264 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
1263 uint8_t data2[4] = { 5, 5, 5, 5 }; 1265 uint8_t data2[4] = { 5, 5, 5, 5 };
1264 child_resource_provider_->CopyToResource(id2, data2, size); 1266 child_resource_provider_->CopyToResource(id2, data2, size);
1265 1267
1266 scoped_ptr<SharedBitmap> shared_bitmap(CreateAndFillSharedBitmap( 1268 std::unique_ptr<SharedBitmap> shared_bitmap(CreateAndFillSharedBitmap(
1267 shared_bitmap_manager_.get(), gfx::Size(1, 1), 0)); 1269 shared_bitmap_manager_.get(), gfx::Size(1, 1), 0));
1268 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get(); 1270 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get();
1269 ResourceId id3 = child_resource_provider_->CreateResourceFromTextureMailbox( 1271 ResourceId id3 = child_resource_provider_->CreateResourceFromTextureMailbox(
1270 TextureMailbox(shared_bitmap_ptr, gfx::Size(1, 1)), 1272 TextureMailbox(shared_bitmap_ptr, gfx::Size(1, 1)),
1271 SingleReleaseCallbackImpl::Create(base::Bind( 1273 SingleReleaseCallbackImpl::Create(base::Bind(
1272 &SharedBitmapReleaseCallback, base::Passed(&shared_bitmap)))); 1274 &SharedBitmapReleaseCallback, base::Passed(&shared_bitmap))));
1273 1275
1274 ReturnedResourceArray returned_to_child; 1276 ReturnedResourceArray returned_to_child;
1275 int child_id = 1277 int child_id =
1276 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 1278 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 EXPECT_EQ(expected_ids, returned_ids); 1446 EXPECT_EQ(expected_ids, returned_ids);
1445 EXPECT_FALSE(returned_to_child[0].lost); 1447 EXPECT_FALSE(returned_to_child[0].lost);
1446 EXPECT_FALSE(returned_to_child[1].lost); 1448 EXPECT_FALSE(returned_to_child[1].lost);
1447 EXPECT_FALSE(returned_to_child[2].lost); 1449 EXPECT_FALSE(returned_to_child[2].lost);
1448 } 1450 }
1449 1451
1450 TEST_P(ResourceProviderTest, TransferGLToSoftware) { 1452 TEST_P(ResourceProviderTest, TransferGLToSoftware) {
1451 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) 1453 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP)
1452 return; 1454 return;
1453 1455
1454 scoped_ptr<ResourceProviderContext> child_context_owned( 1456 std::unique_ptr<ResourceProviderContext> child_context_owned(
1455 ResourceProviderContext::Create(shared_data_.get())); 1457 ResourceProviderContext::Create(shared_data_.get()));
1456 1458
1457 FakeOutputSurfaceClient child_output_surface_client; 1459 FakeOutputSurfaceClient child_output_surface_client;
1458 scoped_ptr<OutputSurface> child_output_surface( 1460 std::unique_ptr<OutputSurface> child_output_surface(
1459 FakeOutputSurface::Create3d(std::move(child_context_owned))); 1461 FakeOutputSurface::Create3d(std::move(child_context_owned)));
1460 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1462 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1461 1463
1462 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create( 1464 std::unique_ptr<ResourceProvider> child_resource_provider(
1463 child_output_surface.get(), shared_bitmap_manager_.get(), 1465 ResourceProvider::Create(
1464 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 1466 child_output_surface.get(), shared_bitmap_manager_.get(),
1465 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 1467 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
1468 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
1466 1469
1467 gfx::Size size(1, 1); 1470 gfx::Size size(1, 1);
1468 ResourceFormat format = RGBA_8888; 1471 ResourceFormat format = RGBA_8888;
1469 size_t pixel_size = TextureSizeBytes(size, format); 1472 size_t pixel_size = TextureSizeBytes(size, format);
1470 ASSERT_EQ(4U, pixel_size); 1473 ASSERT_EQ(4U, pixel_size);
1471 1474
1472 ResourceId id1 = child_resource_provider->CreateResource( 1475 ResourceId id1 = child_resource_provider->CreateResource(
1473 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 1476 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
1474 uint8_t data1[4] = { 1, 2, 3, 4 }; 1477 uint8_t data1[4] = { 1, 2, 3, 4 };
1475 child_resource_provider->CopyToResource(id1, data1, size); 1478 child_resource_provider->CopyToResource(id1, data1, size);
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 EXPECT_EQ(2, returned_to_child[0].count); 1958 EXPECT_EQ(2, returned_to_child[0].count);
1956 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); 1959 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child);
1957 returned_to_child.clear(); 1960 returned_to_child.clear();
1958 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id)); 1961 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id));
1959 } 1962 }
1960 } 1963 }
1961 1964
1962 class ResourceProviderTestTextureFilters : public ResourceProviderTest { 1965 class ResourceProviderTestTextureFilters : public ResourceProviderTest {
1963 public: 1966 public:
1964 static void RunTest(GLenum child_filter, GLenum parent_filter) { 1967 static void RunTest(GLenum child_filter, GLenum parent_filter) {
1965 scoped_ptr<TextureStateTrackingContext> child_context_owned( 1968 std::unique_ptr<TextureStateTrackingContext> child_context_owned(
1966 new TextureStateTrackingContext); 1969 new TextureStateTrackingContext);
1967 TextureStateTrackingContext* child_context = child_context_owned.get(); 1970 TextureStateTrackingContext* child_context = child_context_owned.get();
1968 1971
1969 FakeOutputSurfaceClient child_output_surface_client; 1972 FakeOutputSurfaceClient child_output_surface_client;
1970 scoped_ptr<OutputSurface> child_output_surface( 1973 std::unique_ptr<OutputSurface> child_output_surface(
1971 FakeOutputSurface::Create3d(std::move(child_context_owned))); 1974 FakeOutputSurface::Create3d(std::move(child_context_owned)));
1972 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1975 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1973 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1976 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
1974 new TestSharedBitmapManager()); 1977 new TestSharedBitmapManager());
1975 1978
1976 scoped_ptr<ResourceProvider> child_resource_provider( 1979 std::unique_ptr<ResourceProvider> child_resource_provider(
1977 ResourceProvider::Create(child_output_surface.get(), 1980 ResourceProvider::Create(child_output_surface.get(),
1978 shared_bitmap_manager.get(), NULL, NULL, 0, 1, 1981 shared_bitmap_manager.get(), NULL, NULL, 0, 1,
1979 use_gpu_memory_buffer_resources_, 1982 use_gpu_memory_buffer_resources_,
1980 use_image_texture_targets_)); 1983 use_image_texture_targets_));
1981 1984
1982 scoped_ptr<TextureStateTrackingContext> parent_context_owned( 1985 std::unique_ptr<TextureStateTrackingContext> parent_context_owned(
1983 new TextureStateTrackingContext); 1986 new TextureStateTrackingContext);
1984 TextureStateTrackingContext* parent_context = parent_context_owned.get(); 1987 TextureStateTrackingContext* parent_context = parent_context_owned.get();
1985 1988
1986 FakeOutputSurfaceClient parent_output_surface_client; 1989 FakeOutputSurfaceClient parent_output_surface_client;
1987 scoped_ptr<OutputSurface> parent_output_surface( 1990 std::unique_ptr<OutputSurface> parent_output_surface(
1988 FakeOutputSurface::Create3d(std::move(parent_context_owned))); 1991 FakeOutputSurface::Create3d(std::move(parent_context_owned)));
1989 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); 1992 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
1990 1993
1991 scoped_ptr<ResourceProvider> parent_resource_provider( 1994 std::unique_ptr<ResourceProvider> parent_resource_provider(
1992 ResourceProvider::Create(parent_output_surface.get(), 1995 ResourceProvider::Create(parent_output_surface.get(),
1993 shared_bitmap_manager.get(), NULL, NULL, 0, 1, 1996 shared_bitmap_manager.get(), NULL, NULL, 0, 1,
1994 use_gpu_memory_buffer_resources_, 1997 use_gpu_memory_buffer_resources_,
1995 use_image_texture_targets_)); 1998 use_image_texture_targets_));
1996 1999
1997 gfx::Size size(1, 1); 2000 gfx::Size size(1, 1);
1998 ResourceFormat format = RGBA_8888; 2001 ResourceFormat format = RGBA_8888;
1999 int child_texture_id = 1; 2002 int child_texture_id = 1;
2000 int parent_texture_id = 2; 2003 int parent_texture_id = 2;
2001 2004
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
2584 context()->genMailboxCHROMIUM(mailbox.name); 2587 context()->genMailboxCHROMIUM(mailbox.name);
2585 context()->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, mailbox.name); 2588 context()->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, mailbox.name);
2586 gpu::SyncToken sync_token; 2589 gpu::SyncToken sync_token;
2587 context()->genSyncToken(context()->insertFenceSync(), sync_token.GetData()); 2590 context()->genSyncToken(context()->insertFenceSync(), sync_token.GetData());
2588 2591
2589 EXPECT_TRUE(sync_token.HasData()); 2592 EXPECT_TRUE(sync_token.HasData());
2590 2593
2591 gpu::SyncToken release_sync_token; 2594 gpu::SyncToken release_sync_token;
2592 bool lost_resource = false; 2595 bool lost_resource = false;
2593 BlockingTaskRunner* main_thread_task_runner = NULL; 2596 BlockingTaskRunner* main_thread_task_runner = NULL;
2594 scoped_ptr<SingleReleaseCallbackImpl> callback = 2597 std::unique_ptr<SingleReleaseCallbackImpl> callback =
2595 SingleReleaseCallbackImpl::Create( 2598 SingleReleaseCallbackImpl::Create(
2596 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource, 2599 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource,
2597 &main_thread_task_runner)); 2600 &main_thread_task_runner));
2598 resource_provider_->CreateResourceFromTextureMailbox( 2601 resource_provider_->CreateResourceFromTextureMailbox(
2599 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), std::move(callback)); 2602 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), std::move(callback));
2600 2603
2601 EXPECT_FALSE(release_sync_token.HasData()); 2604 EXPECT_FALSE(release_sync_token.HasData());
2602 EXPECT_FALSE(lost_resource); 2605 EXPECT_FALSE(lost_resource);
2603 EXPECT_EQ(NULL, main_thread_task_runner); 2606 EXPECT_EQ(NULL, main_thread_task_runner);
2604 2607
2605 resource_provider_->DidLoseOutputSurface(); 2608 resource_provider_->DidLoseOutputSurface();
2606 resource_provider_ = nullptr; 2609 resource_provider_ = nullptr;
2607 2610
2608 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count()); 2611 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count());
2609 EXPECT_TRUE(lost_resource); 2612 EXPECT_TRUE(lost_resource);
2610 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); 2613 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
2611 } 2614 }
2612 2615
2613 TEST_P(ResourceProviderTest, ScopedSampler) { 2616 TEST_P(ResourceProviderTest, ScopedSampler) {
2614 // Sampling is only supported for GL textures. 2617 // Sampling is only supported for GL textures.
2615 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2618 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2616 return; 2619 return;
2617 2620
2618 scoped_ptr<TextureStateTrackingContext> context_owned( 2621 std::unique_ptr<TextureStateTrackingContext> context_owned(
2619 new TextureStateTrackingContext); 2622 new TextureStateTrackingContext);
2620 TextureStateTrackingContext* context = context_owned.get(); 2623 TextureStateTrackingContext* context = context_owned.get();
2621 2624
2622 FakeOutputSurfaceClient output_surface_client; 2625 FakeOutputSurfaceClient output_surface_client;
2623 scoped_ptr<OutputSurface> output_surface( 2626 std::unique_ptr<OutputSurface> output_surface(
2624 FakeOutputSurface::Create3d(std::move(context_owned))); 2627 FakeOutputSurface::Create3d(std::move(context_owned)));
2625 CHECK(output_surface->BindToClient(&output_surface_client)); 2628 CHECK(output_surface->BindToClient(&output_surface_client));
2626 2629
2627 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2630 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2628 output_surface.get(), shared_bitmap_manager_.get(), 2631 output_surface.get(), shared_bitmap_manager_.get(),
2629 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 2632 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
2630 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2633 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2631 2634
2632 gfx::Size size(1, 1); 2635 gfx::Size size(1, 1);
2633 ResourceFormat format = RGBA_8888; 2636 ResourceFormat format = RGBA_8888;
2634 int texture_id = 1; 2637 int texture_id = 1;
2635 2638
2636 ResourceId id = resource_provider->CreateResource( 2639 ResourceId id = resource_provider->CreateResource(
2637 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 2640 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); 2690 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
2688 Mock::VerifyAndClearExpectations(context); 2691 Mock::VerifyAndClearExpectations(context);
2689 } 2692 }
2690 } 2693 }
2691 2694
2692 TEST_P(ResourceProviderTest, ManagedResource) { 2695 TEST_P(ResourceProviderTest, ManagedResource) {
2693 // Sampling is only supported for GL textures. 2696 // Sampling is only supported for GL textures.
2694 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2697 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2695 return; 2698 return;
2696 2699
2697 scoped_ptr<TextureStateTrackingContext> context_owned( 2700 std::unique_ptr<TextureStateTrackingContext> context_owned(
2698 new TextureStateTrackingContext); 2701 new TextureStateTrackingContext);
2699 TextureStateTrackingContext* context = context_owned.get(); 2702 TextureStateTrackingContext* context = context_owned.get();
2700 2703
2701 FakeOutputSurfaceClient output_surface_client; 2704 FakeOutputSurfaceClient output_surface_client;
2702 scoped_ptr<OutputSurface> output_surface( 2705 std::unique_ptr<OutputSurface> output_surface(
2703 FakeOutputSurface::Create3d(std::move(context_owned))); 2706 FakeOutputSurface::Create3d(std::move(context_owned)));
2704 CHECK(output_surface->BindToClient(&output_surface_client)); 2707 CHECK(output_surface->BindToClient(&output_surface_client));
2705 2708
2706 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2709 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2707 output_surface.get(), shared_bitmap_manager_.get(), 2710 output_surface.get(), shared_bitmap_manager_.get(),
2708 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 2711 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
2709 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2712 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2710 2713
2711 gfx::Size size(1, 1); 2714 gfx::Size size(1, 1);
2712 ResourceFormat format = RGBA_8888; 2715 ResourceFormat format = RGBA_8888;
2713 int texture_id = 1; 2716 int texture_id = 1;
2714 2717
2715 // Check that the texture gets created with the right sampler settings. 2718 // Check that the texture gets created with the right sampler settings.
2716 ResourceId id = resource_provider->CreateResource( 2719 ResourceId id = resource_provider->CreateResource(
(...skipping 13 matching lines...) Expand all
2730 EXPECT_NE(0u, id); 2733 EXPECT_NE(0u, id);
2731 2734
2732 Mock::VerifyAndClearExpectations(context); 2735 Mock::VerifyAndClearExpectations(context);
2733 } 2736 }
2734 2737
2735 TEST_P(ResourceProviderTest, TextureWrapMode) { 2738 TEST_P(ResourceProviderTest, TextureWrapMode) {
2736 // Sampling is only supported for GL textures. 2739 // Sampling is only supported for GL textures.
2737 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2740 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2738 return; 2741 return;
2739 2742
2740 scoped_ptr<TextureStateTrackingContext> context_owned( 2743 std::unique_ptr<TextureStateTrackingContext> context_owned(
2741 new TextureStateTrackingContext); 2744 new TextureStateTrackingContext);
2742 TextureStateTrackingContext* context = context_owned.get(); 2745 TextureStateTrackingContext* context = context_owned.get();
2743 2746
2744 FakeOutputSurfaceClient output_surface_client; 2747 FakeOutputSurfaceClient output_surface_client;
2745 scoped_ptr<OutputSurface> output_surface( 2748 std::unique_ptr<OutputSurface> output_surface(
2746 FakeOutputSurface::Create3d(std::move(context_owned))); 2749 FakeOutputSurface::Create3d(std::move(context_owned)));
2747 CHECK(output_surface->BindToClient(&output_surface_client)); 2750 CHECK(output_surface->BindToClient(&output_surface_client));
2748 2751
2749 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2752 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2750 output_surface.get(), shared_bitmap_manager_.get(), 2753 output_surface.get(), shared_bitmap_manager_.get(),
2751 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 2754 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
2752 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2755 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2753 2756
2754 gfx::Size size(1, 1); 2757 gfx::Size size(1, 1);
2755 ResourceFormat format = RGBA_8888; 2758 ResourceFormat format = RGBA_8888;
2756 2759
2757 for (int texture_id = 1; texture_id <= 2; ++texture_id) { 2760 for (int texture_id = 1; texture_id <= 2; ++texture_id) {
2758 // Check that the texture gets created with the right sampler settings. 2761 // Check that the texture gets created with the right sampler settings.
2759 ResourceId id = resource_provider->CreateResource( 2762 ResourceId id = resource_provider->CreateResource(
(...skipping 12 matching lines...) Expand all
2772 2775
2773 Mock::VerifyAndClearExpectations(context); 2776 Mock::VerifyAndClearExpectations(context);
2774 } 2777 }
2775 } 2778 }
2776 2779
2777 TEST_P(ResourceProviderTest, TextureHint) { 2780 TEST_P(ResourceProviderTest, TextureHint) {
2778 // Sampling is only supported for GL textures. 2781 // Sampling is only supported for GL textures.
2779 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2782 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2780 return; 2783 return;
2781 2784
2782 scoped_ptr<TextureStateTrackingContext> context_owned( 2785 std::unique_ptr<TextureStateTrackingContext> context_owned(
2783 new TextureStateTrackingContext); 2786 new TextureStateTrackingContext);
2784 TextureStateTrackingContext* context = context_owned.get(); 2787 TextureStateTrackingContext* context = context_owned.get();
2785 context->set_support_texture_storage(true); 2788 context->set_support_texture_storage(true);
2786 context->set_support_texture_usage(true); 2789 context->set_support_texture_usage(true);
2787 2790
2788 FakeOutputSurfaceClient output_surface_client; 2791 FakeOutputSurfaceClient output_surface_client;
2789 scoped_ptr<OutputSurface> output_surface( 2792 std::unique_ptr<OutputSurface> output_surface(
2790 FakeOutputSurface::Create3d(std::move(context_owned))); 2793 FakeOutputSurface::Create3d(std::move(context_owned)));
2791 CHECK(output_surface->BindToClient(&output_surface_client)); 2794 CHECK(output_surface->BindToClient(&output_surface_client));
2792 2795
2793 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2796 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2794 output_surface.get(), shared_bitmap_manager_.get(), 2797 output_surface.get(), shared_bitmap_manager_.get(),
2795 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 2798 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
2796 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2799 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2797 2800
2798 gfx::Size size(1, 1); 2801 gfx::Size size(1, 1);
2799 ResourceFormat format = RGBA_8888; 2802 ResourceFormat format = RGBA_8888;
2800 2803
2801 const ResourceProvider::TextureHint hints[4] = { 2804 const ResourceProvider::TextureHint hints[4] = {
2802 ResourceProvider::TEXTURE_HINT_DEFAULT, 2805 ResourceProvider::TEXTURE_HINT_DEFAULT,
2803 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 2806 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
(...skipping 29 matching lines...) Expand all
2833 Mock::VerifyAndClearExpectations(context); 2836 Mock::VerifyAndClearExpectations(context);
2834 } 2837 }
2835 } 2838 }
2836 2839
2837 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) { 2840 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) {
2838 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) 2841 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP)
2839 return; 2842 return;
2840 2843
2841 gfx::Size size(64, 64); 2844 gfx::Size size(64, 64);
2842 const uint32_t kBadBeef = 0xbadbeef; 2845 const uint32_t kBadBeef = 0xbadbeef;
2843 scoped_ptr<SharedBitmap> shared_bitmap( 2846 std::unique_ptr<SharedBitmap> shared_bitmap(
2844 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, kBadBeef)); 2847 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, kBadBeef));
2845 2848
2846 FakeOutputSurfaceClient output_surface_client; 2849 FakeOutputSurfaceClient output_surface_client;
2847 scoped_ptr<OutputSurface> output_surface( 2850 std::unique_ptr<OutputSurface> output_surface(
2848 FakeOutputSurface::CreateSoftware(make_scoped_ptr( 2851 FakeOutputSurface::CreateSoftware(
2849 new SoftwareOutputDevice))); 2852 base::WrapUnique(new SoftwareOutputDevice)));
2850 CHECK(output_surface->BindToClient(&output_surface_client)); 2853 CHECK(output_surface->BindToClient(&output_surface_client));
2851 2854
2852 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2855 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2853 output_surface.get(), shared_bitmap_manager_.get(), 2856 output_surface.get(), shared_bitmap_manager_.get(),
2854 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 1, 2857 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 1,
2855 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2858 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2856 2859
2857 gpu::SyncToken release_sync_token; 2860 gpu::SyncToken release_sync_token;
2858 bool lost_resource = false; 2861 bool lost_resource = false;
2859 BlockingTaskRunner* main_thread_task_runner = NULL; 2862 BlockingTaskRunner* main_thread_task_runner = NULL;
2860 scoped_ptr<SingleReleaseCallbackImpl> callback = 2863 std::unique_ptr<SingleReleaseCallbackImpl> callback =
2861 SingleReleaseCallbackImpl::Create( 2864 SingleReleaseCallbackImpl::Create(
2862 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource, 2865 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource,
2863 &main_thread_task_runner)); 2866 &main_thread_task_runner));
2864 TextureMailbox mailbox(shared_bitmap.get(), size); 2867 TextureMailbox mailbox(shared_bitmap.get(), size);
2865 2868
2866 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 2869 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
2867 mailbox, std::move(callback)); 2870 mailbox, std::move(callback));
2868 EXPECT_NE(0u, id); 2871 EXPECT_NE(0u, id);
2869 2872
2870 { 2873 {
(...skipping 11 matching lines...) Expand all
2882 } 2885 }
2883 2886
2884 class ResourceProviderTestTextureMailboxGLFilters 2887 class ResourceProviderTestTextureMailboxGLFilters
2885 : public ResourceProviderTest { 2888 : public ResourceProviderTest {
2886 public: 2889 public:
2887 static void RunTest(TestSharedBitmapManager* shared_bitmap_manager, 2890 static void RunTest(TestSharedBitmapManager* shared_bitmap_manager,
2888 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, 2891 TestGpuMemoryBufferManager* gpu_memory_buffer_manager,
2889 BlockingTaskRunner* main_thread_task_runner, 2892 BlockingTaskRunner* main_thread_task_runner,
2890 bool mailbox_nearest_neighbor, 2893 bool mailbox_nearest_neighbor,
2891 GLenum sampler_filter) { 2894 GLenum sampler_filter) {
2892 scoped_ptr<TextureStateTrackingContext> context_owned( 2895 std::unique_ptr<TextureStateTrackingContext> context_owned(
2893 new TextureStateTrackingContext); 2896 new TextureStateTrackingContext);
2894 TextureStateTrackingContext* context = context_owned.get(); 2897 TextureStateTrackingContext* context = context_owned.get();
2895 2898
2896 FakeOutputSurfaceClient output_surface_client; 2899 FakeOutputSurfaceClient output_surface_client;
2897 scoped_ptr<OutputSurface> output_surface( 2900 std::unique_ptr<OutputSurface> output_surface(
2898 FakeOutputSurface::Create3d(std::move(context_owned))); 2901 FakeOutputSurface::Create3d(std::move(context_owned)));
2899 CHECK(output_surface->BindToClient(&output_surface_client)); 2902 CHECK(output_surface->BindToClient(&output_surface_client));
2900 2903
2901 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2904 std::unique_ptr<ResourceProvider> resource_provider(
2902 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager, 2905 ResourceProvider::Create(
2903 main_thread_task_runner, 0, 1, use_gpu_memory_buffer_resources_, 2906 output_surface.get(), shared_bitmap_manager,
2904 use_image_texture_targets_)); 2907 gpu_memory_buffer_manager, main_thread_task_runner, 0, 1,
2908 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2905 2909
2906 unsigned texture_id = 1; 2910 unsigned texture_id = 1;
2907 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 2911 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
2908 gpu::CommandBufferId::FromUnsafeValue(0x12), 2912 gpu::CommandBufferId::FromUnsafeValue(0x12),
2909 0x34); 2913 0x34);
2910 unsigned target = GL_TEXTURE_2D; 2914 unsigned target = GL_TEXTURE_2D;
2911 const GLuint64 current_fence_sync = context->GetNextFenceSync(); 2915 const GLuint64 current_fence_sync = context->GetNextFenceSync();
2912 2916
2913 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2917 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2914 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 2918 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
2915 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 2919 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2916 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 2920 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
2917 2921
2918 gpu::Mailbox gpu_mailbox; 2922 gpu::Mailbox gpu_mailbox;
2919 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2923 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2920 gpu::SyncToken release_sync_token; 2924 gpu::SyncToken release_sync_token;
2921 bool lost_resource = false; 2925 bool lost_resource = false;
2922 BlockingTaskRunner* mailbox_task_runner = NULL; 2926 BlockingTaskRunner* mailbox_task_runner = NULL;
2923 scoped_ptr<SingleReleaseCallbackImpl> callback = 2927 std::unique_ptr<SingleReleaseCallbackImpl> callback =
2924 SingleReleaseCallbackImpl::Create( 2928 SingleReleaseCallbackImpl::Create(
2925 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource, 2929 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource,
2926 &mailbox_task_runner)); 2930 &mailbox_task_runner));
2927 2931
2928 TextureMailbox mailbox(gpu_mailbox, sync_token, target); 2932 TextureMailbox mailbox(gpu_mailbox, sync_token, target);
2929 mailbox.set_nearest_neighbor(mailbox_nearest_neighbor); 2933 mailbox.set_nearest_neighbor(mailbox_nearest_neighbor);
2930 2934
2931 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 2935 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
2932 mailbox, std::move(callback)); 2936 mailbox, std::move(callback));
2933 EXPECT_NE(0u, id); 2937 EXPECT_NE(0u, id);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3027 main_thread_task_runner_.get(), 3031 main_thread_task_runner_.get(),
3028 false, 3032 false,
3029 GL_NEAREST); 3033 GL_NEAREST);
3030 } 3034 }
3031 3035
3032 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) { 3036 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) {
3033 // Mailboxing is only supported for GL textures. 3037 // Mailboxing is only supported for GL textures.
3034 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3038 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3035 return; 3039 return;
3036 3040
3037 scoped_ptr<TextureStateTrackingContext> context_owned( 3041 std::unique_ptr<TextureStateTrackingContext> context_owned(
3038 new TextureStateTrackingContext); 3042 new TextureStateTrackingContext);
3039 TextureStateTrackingContext* context = context_owned.get(); 3043 TextureStateTrackingContext* context = context_owned.get();
3040 3044
3041 FakeOutputSurfaceClient output_surface_client; 3045 FakeOutputSurfaceClient output_surface_client;
3042 scoped_ptr<OutputSurface> output_surface( 3046 std::unique_ptr<OutputSurface> output_surface(
3043 FakeOutputSurface::Create3d(std::move(context_owned))); 3047 FakeOutputSurface::Create3d(std::move(context_owned)));
3044 CHECK(output_surface->BindToClient(&output_surface_client)); 3048 CHECK(output_surface->BindToClient(&output_surface_client));
3045 3049
3046 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3050 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3047 output_surface.get(), shared_bitmap_manager_.get(), 3051 output_surface.get(), shared_bitmap_manager_.get(),
3048 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3052 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3049 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3053 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3050 3054
3051 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 3055 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
3052 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); 3056 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34);
3053 const GLuint64 current_fence_sync = context->GetNextFenceSync(); 3057 const GLuint64 current_fence_sync = context->GetNextFenceSync();
3054 unsigned target = GL_TEXTURE_EXTERNAL_OES; 3058 unsigned target = GL_TEXTURE_EXTERNAL_OES;
3055 3059
3056 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3060 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3057 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 3061 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
3058 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3062 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3059 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3063 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
3060 3064
3061 gpu::Mailbox gpu_mailbox; 3065 gpu::Mailbox gpu_mailbox;
3062 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 3066 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
3063 scoped_ptr<SingleReleaseCallbackImpl> callback = 3067 std::unique_ptr<SingleReleaseCallbackImpl> callback =
3064 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); 3068 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
3065 3069
3066 TextureMailbox mailbox(gpu_mailbox, sync_token, target); 3070 TextureMailbox mailbox(gpu_mailbox, sync_token, target);
3067 3071
3068 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 3072 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
3069 mailbox, std::move(callback)); 3073 mailbox, std::move(callback));
3070 EXPECT_NE(0u, id); 3074 EXPECT_NE(0u, id);
3071 EXPECT_EQ(current_fence_sync, context->GetNextFenceSync()); 3075 EXPECT_EQ(current_fence_sync, context->GetNextFenceSync());
3072 3076
3073 Mock::VerifyAndClearExpectations(context); 3077 Mock::VerifyAndClearExpectations(context);
(...skipping 23 matching lines...) Expand all
3097 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3101 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
3098 } 3102 }
3099 } 3103 }
3100 3104
3101 TEST_P(ResourceProviderTest, 3105 TEST_P(ResourceProviderTest,
3102 TextureMailbox_WaitSyncTokenIfNeeded_WithSyncToken) { 3106 TextureMailbox_WaitSyncTokenIfNeeded_WithSyncToken) {
3103 // Mailboxing is only supported for GL textures. 3107 // Mailboxing is only supported for GL textures.
3104 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3108 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3105 return; 3109 return;
3106 3110
3107 scoped_ptr<TextureStateTrackingContext> context_owned( 3111 std::unique_ptr<TextureStateTrackingContext> context_owned(
3108 new TextureStateTrackingContext); 3112 new TextureStateTrackingContext);
3109 TextureStateTrackingContext* context = context_owned.get(); 3113 TextureStateTrackingContext* context = context_owned.get();
3110 3114
3111 FakeOutputSurfaceClient output_surface_client; 3115 FakeOutputSurfaceClient output_surface_client;
3112 scoped_ptr<OutputSurface> output_surface( 3116 std::unique_ptr<OutputSurface> output_surface(
3113 FakeOutputSurface::Create3d(std::move(context_owned))); 3117 FakeOutputSurface::Create3d(std::move(context_owned)));
3114 CHECK(output_surface->BindToClient(&output_surface_client)); 3118 CHECK(output_surface->BindToClient(&output_surface_client));
3115 3119
3116 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3120 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3117 output_surface.get(), shared_bitmap_manager_.get(), 3121 output_surface.get(), shared_bitmap_manager_.get(),
3118 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3122 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3119 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3123 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3120 3124
3121 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 3125 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
3122 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); 3126 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34);
3123 const GLuint64 current_fence_sync = context->GetNextFenceSync(); 3127 const GLuint64 current_fence_sync = context->GetNextFenceSync();
3124 unsigned target = GL_TEXTURE_2D; 3128 unsigned target = GL_TEXTURE_2D;
3125 3129
3126 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3130 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3127 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 3131 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
3128 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3132 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3129 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3133 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
3130 3134
3131 gpu::Mailbox gpu_mailbox; 3135 gpu::Mailbox gpu_mailbox;
3132 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 3136 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
3133 scoped_ptr<SingleReleaseCallbackImpl> callback = 3137 std::unique_ptr<SingleReleaseCallbackImpl> callback =
3134 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); 3138 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
3135 3139
3136 TextureMailbox mailbox(gpu_mailbox, sync_token, target); 3140 TextureMailbox mailbox(gpu_mailbox, sync_token, target);
3137 3141
3138 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 3142 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
3139 mailbox, std::move(callback)); 3143 mailbox, std::move(callback));
3140 EXPECT_NE(0u, id); 3144 EXPECT_NE(0u, id);
3141 EXPECT_EQ(current_fence_sync, context->GetNextFenceSync()); 3145 EXPECT_EQ(current_fence_sync, context->GetNextFenceSync());
3142 3146
3143 Mock::VerifyAndClearExpectations(context); 3147 Mock::VerifyAndClearExpectations(context);
3144 3148
3145 { 3149 {
3146 // First call to WaitSyncTokenIfNeeded should call waitSyncToken. 3150 // First call to WaitSyncTokenIfNeeded should call waitSyncToken.
3147 EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token))); 3151 EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token)));
3148 resource_provider->WaitSyncTokenIfNeeded(id); 3152 resource_provider->WaitSyncTokenIfNeeded(id);
3149 Mock::VerifyAndClearExpectations(context); 3153 Mock::VerifyAndClearExpectations(context);
3150 3154
3151 // Subsequent calls to WaitSyncTokenIfNeeded shouldn't call waitSyncToken. 3155 // Subsequent calls to WaitSyncTokenIfNeeded shouldn't call waitSyncToken.
3152 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 3156 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
3153 resource_provider->WaitSyncTokenIfNeeded(id); 3157 resource_provider->WaitSyncTokenIfNeeded(id);
3154 Mock::VerifyAndClearExpectations(context); 3158 Mock::VerifyAndClearExpectations(context);
3155 } 3159 }
3156 } 3160 }
3157 3161
3158 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncTokenIfNeeded_NoSyncToken) { 3162 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncTokenIfNeeded_NoSyncToken) {
3159 // Mailboxing is only supported for GL textures. 3163 // Mailboxing is only supported for GL textures.
3160 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3164 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3161 return; 3165 return;
3162 3166
3163 scoped_ptr<TextureStateTrackingContext> context_owned( 3167 std::unique_ptr<TextureStateTrackingContext> context_owned(
3164 new TextureStateTrackingContext); 3168 new TextureStateTrackingContext);
3165 TextureStateTrackingContext* context = context_owned.get(); 3169 TextureStateTrackingContext* context = context_owned.get();
3166 3170
3167 FakeOutputSurfaceClient output_surface_client; 3171 FakeOutputSurfaceClient output_surface_client;
3168 scoped_ptr<OutputSurface> output_surface( 3172 std::unique_ptr<OutputSurface> output_surface(
3169 FakeOutputSurface::Create3d(std::move(context_owned))); 3173 FakeOutputSurface::Create3d(std::move(context_owned)));
3170 CHECK(output_surface->BindToClient(&output_surface_client)); 3174 CHECK(output_surface->BindToClient(&output_surface_client));
3171 3175
3172 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3176 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3173 output_surface.get(), shared_bitmap_manager_.get(), 3177 output_surface.get(), shared_bitmap_manager_.get(),
3174 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3178 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3175 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3179 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3176 3180
3177 gpu::SyncToken sync_token; 3181 gpu::SyncToken sync_token;
3178 const GLuint64 current_fence_sync = context->GetNextFenceSync(); 3182 const GLuint64 current_fence_sync = context->GetNextFenceSync();
3179 unsigned target = GL_TEXTURE_2D; 3183 unsigned target = GL_TEXTURE_2D;
3180 3184
3181 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3185 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3182 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 3186 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
3183 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3187 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3184 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3188 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
3185 3189
3186 gpu::Mailbox gpu_mailbox; 3190 gpu::Mailbox gpu_mailbox;
3187 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 3191 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
3188 scoped_ptr<SingleReleaseCallbackImpl> callback = 3192 std::unique_ptr<SingleReleaseCallbackImpl> callback =
3189 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); 3193 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
3190 3194
3191 TextureMailbox mailbox(gpu_mailbox, sync_token, target); 3195 TextureMailbox mailbox(gpu_mailbox, sync_token, target);
3192 3196
3193 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 3197 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
3194 mailbox, std::move(callback)); 3198 mailbox, std::move(callback));
3195 EXPECT_NE(0u, id); 3199 EXPECT_NE(0u, id);
3196 EXPECT_EQ(current_fence_sync, context->GetNextFenceSync()); 3200 EXPECT_EQ(current_fence_sync, context->GetNextFenceSync());
3197 3201
3198 Mock::VerifyAndClearExpectations(context); 3202 Mock::VerifyAndClearExpectations(context);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 // We're mocking bindTexture, so we override 3279 // We're mocking bindTexture, so we override
3276 // TestWebGraphicsContext3D::texParameteri to avoid assertions related to the 3280 // TestWebGraphicsContext3D::texParameteri to avoid assertions related to the
3277 // currently bound texture. 3281 // currently bound texture.
3278 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {} 3282 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {}
3279 }; 3283 };
3280 3284
3281 TEST_P(ResourceProviderTest, TextureAllocation) { 3285 TEST_P(ResourceProviderTest, TextureAllocation) {
3282 // Only for GL textures. 3286 // Only for GL textures.
3283 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3287 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3284 return; 3288 return;
3285 scoped_ptr<AllocationTrackingContext3D> context_owned( 3289 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3286 new StrictMock<AllocationTrackingContext3D>); 3290 new StrictMock<AllocationTrackingContext3D>);
3287 AllocationTrackingContext3D* context = context_owned.get(); 3291 AllocationTrackingContext3D* context = context_owned.get();
3288 3292
3289 FakeOutputSurfaceClient output_surface_client; 3293 FakeOutputSurfaceClient output_surface_client;
3290 scoped_ptr<OutputSurface> output_surface( 3294 std::unique_ptr<OutputSurface> output_surface(
3291 FakeOutputSurface::Create3d(std::move(context_owned))); 3295 FakeOutputSurface::Create3d(std::move(context_owned)));
3292 CHECK(output_surface->BindToClient(&output_surface_client)); 3296 CHECK(output_surface->BindToClient(&output_surface_client));
3293 3297
3294 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3298 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3295 output_surface.get(), shared_bitmap_manager_.get(), 3299 output_surface.get(), shared_bitmap_manager_.get(),
3296 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3300 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3297 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3301 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3298 3302
3299 gfx::Size size(2, 2); 3303 gfx::Size size(2, 2);
3300 gfx::Vector2d offset(0, 0); 3304 gfx::Vector2d offset(0, 0);
3301 ResourceFormat format = RGBA_8888; 3305 ResourceFormat format = RGBA_8888;
3302 ResourceId id = 0; 3306 ResourceId id = 0;
3303 uint8_t pixels[16] = { 0 }; 3307 uint8_t pixels[16] = { 0 };
3304 int texture_id = 123; 3308 int texture_id = 123;
(...skipping 24 matching lines...) Expand all
3329 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); 3333 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
3330 resource_provider->DeleteResource(id); 3334 resource_provider->DeleteResource(id);
3331 3335
3332 Mock::VerifyAndClearExpectations(context); 3336 Mock::VerifyAndClearExpectations(context);
3333 } 3337 }
3334 3338
3335 TEST_P(ResourceProviderTest, TextureAllocationHint) { 3339 TEST_P(ResourceProviderTest, TextureAllocationHint) {
3336 // Only for GL textures. 3340 // Only for GL textures.
3337 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3341 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3338 return; 3342 return;
3339 scoped_ptr<AllocationTrackingContext3D> context_owned( 3343 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3340 new StrictMock<AllocationTrackingContext3D>); 3344 new StrictMock<AllocationTrackingContext3D>);
3341 AllocationTrackingContext3D* context = context_owned.get(); 3345 AllocationTrackingContext3D* context = context_owned.get();
3342 context->set_support_texture_storage(true); 3346 context->set_support_texture_storage(true);
3343 context->set_support_texture_usage(true); 3347 context->set_support_texture_usage(true);
3344 3348
3345 FakeOutputSurfaceClient output_surface_client; 3349 FakeOutputSurfaceClient output_surface_client;
3346 scoped_ptr<OutputSurface> output_surface( 3350 std::unique_ptr<OutputSurface> output_surface(
3347 FakeOutputSurface::Create3d(std::move(context_owned))); 3351 FakeOutputSurface::Create3d(std::move(context_owned)));
3348 CHECK(output_surface->BindToClient(&output_surface_client)); 3352 CHECK(output_surface->BindToClient(&output_surface_client));
3349 3353
3350 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3354 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3351 output_surface.get(), shared_bitmap_manager_.get(), 3355 output_surface.get(), shared_bitmap_manager_.get(),
3352 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3356 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3353 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3357 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3354 3358
3355 gfx::Size size(2, 2); 3359 gfx::Size size(2, 2);
3356 3360
3357 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3361 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3358 const ResourceProvider::TextureHint hints[4] = { 3362 const ResourceProvider::TextureHint hints[4] = {
3359 ResourceProvider::TEXTURE_HINT_DEFAULT, 3363 ResourceProvider::TEXTURE_HINT_DEFAULT,
3360 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3364 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
(...skipping 23 matching lines...) Expand all
3384 3388
3385 Mock::VerifyAndClearExpectations(context); 3389 Mock::VerifyAndClearExpectations(context);
3386 } 3390 }
3387 } 3391 }
3388 } 3392 }
3389 3393
3390 TEST_P(ResourceProviderTest, TextureAllocationHint_BGRA) { 3394 TEST_P(ResourceProviderTest, TextureAllocationHint_BGRA) {
3391 // Only for GL textures. 3395 // Only for GL textures.
3392 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3396 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3393 return; 3397 return;
3394 scoped_ptr<AllocationTrackingContext3D> context_owned( 3398 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3395 new StrictMock<AllocationTrackingContext3D>); 3399 new StrictMock<AllocationTrackingContext3D>);
3396 AllocationTrackingContext3D* context = context_owned.get(); 3400 AllocationTrackingContext3D* context = context_owned.get();
3397 context->set_support_texture_format_bgra8888(true); 3401 context->set_support_texture_format_bgra8888(true);
3398 context->set_support_texture_storage(true); 3402 context->set_support_texture_storage(true);
3399 context->set_support_texture_usage(true); 3403 context->set_support_texture_usage(true);
3400 3404
3401 FakeOutputSurfaceClient output_surface_client; 3405 FakeOutputSurfaceClient output_surface_client;
3402 scoped_ptr<OutputSurface> output_surface( 3406 std::unique_ptr<OutputSurface> output_surface(
3403 FakeOutputSurface::Create3d(std::move(context_owned))); 3407 FakeOutputSurface::Create3d(std::move(context_owned)));
3404 CHECK(output_surface->BindToClient(&output_surface_client)); 3408 CHECK(output_surface->BindToClient(&output_surface_client));
3405 3409
3406 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3410 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3407 output_surface.get(), shared_bitmap_manager_.get(), 3411 output_surface.get(), shared_bitmap_manager_.get(),
3408 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3412 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3409 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3413 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3410 3414
3411 gfx::Size size(2, 2); 3415 gfx::Size size(2, 2);
3412 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3416 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3413 3417
3414 const ResourceProvider::TextureHint hints[4] = { 3418 const ResourceProvider::TextureHint hints[4] = {
3415 ResourceProvider::TEXTURE_HINT_DEFAULT, 3419 ResourceProvider::TEXTURE_HINT_DEFAULT,
3416 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 3420 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
(...skipping 21 matching lines...) Expand all
3438 3442
3439 Mock::VerifyAndClearExpectations(context); 3443 Mock::VerifyAndClearExpectations(context);
3440 } 3444 }
3441 } 3445 }
3442 } 3446 }
3443 3447
3444 TEST_P(ResourceProviderTest, Image_GLTexture) { 3448 TEST_P(ResourceProviderTest, Image_GLTexture) {
3445 // Only for GL textures. 3449 // Only for GL textures.
3446 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3450 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3447 return; 3451 return;
3448 scoped_ptr<AllocationTrackingContext3D> context_owned( 3452 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3449 new StrictMock<AllocationTrackingContext3D>); 3453 new StrictMock<AllocationTrackingContext3D>);
3450 AllocationTrackingContext3D* context = context_owned.get(); 3454 AllocationTrackingContext3D* context = context_owned.get();
3451 3455
3452 FakeOutputSurfaceClient output_surface_client; 3456 FakeOutputSurfaceClient output_surface_client;
3453 scoped_ptr<OutputSurface> output_surface( 3457 std::unique_ptr<OutputSurface> output_surface(
3454 FakeOutputSurface::Create3d(std::move(context_owned))); 3458 FakeOutputSurface::Create3d(std::move(context_owned)));
3455 CHECK(output_surface->BindToClient(&output_surface_client)); 3459 CHECK(output_surface->BindToClient(&output_surface_client));
3456 3460
3457 const int kWidth = 2; 3461 const int kWidth = 2;
3458 const int kHeight = 2; 3462 const int kHeight = 2;
3459 gfx::Size size(kWidth, kHeight); 3463 gfx::Size size(kWidth, kHeight);
3460 ResourceFormat format = RGBA_8888; 3464 ResourceFormat format = RGBA_8888;
3461 ResourceId id = 0; 3465 ResourceId id = 0;
3462 const unsigned kTextureId = 123u; 3466 const unsigned kTextureId = 123u;
3463 const unsigned kImageId = 234u; 3467 const unsigned kImageId = 234u;
3464 3468
3465 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3469 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3466 output_surface.get(), shared_bitmap_manager_.get(), 3470 output_surface.get(), shared_bitmap_manager_.get(),
3467 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3471 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3468 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3472 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3469 3473
3470 id = resource_provider->CreateResource( 3474 id = resource_provider->CreateResource(
3471 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3475 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3472 3476
3473 EXPECT_CALL(*context, NextTextureId()) 3477 EXPECT_CALL(*context, NextTextureId())
3474 .WillOnce(Return(kTextureId)) 3478 .WillOnce(Return(kTextureId))
3475 .RetiresOnSaturation(); 3479 .RetiresOnSaturation();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3522 3526
3523 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId)) 3527 EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId))
3524 .Times(1) 3528 .Times(1)
3525 .RetiresOnSaturation(); 3529 .RetiresOnSaturation();
3526 } 3530 }
3527 3531
3528 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) { 3532 TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) {
3529 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3533 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3530 return; 3534 return;
3531 3535
3532 scoped_ptr<AllocationTrackingContext3D> context_owned( 3536 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3533 new AllocationTrackingContext3D); 3537 new AllocationTrackingContext3D);
3534 AllocationTrackingContext3D* context = context_owned.get(); 3538 AllocationTrackingContext3D* context = context_owned.get();
3535 context_owned->set_support_compressed_texture_etc1(true); 3539 context_owned->set_support_compressed_texture_etc1(true);
3536 3540
3537 FakeOutputSurfaceClient output_surface_client; 3541 FakeOutputSurfaceClient output_surface_client;
3538 scoped_ptr<OutputSurface> output_surface( 3542 std::unique_ptr<OutputSurface> output_surface(
3539 FakeOutputSurface::Create3d(std::move(context_owned))); 3543 FakeOutputSurface::Create3d(std::move(context_owned)));
3540 CHECK(output_surface->BindToClient(&output_surface_client)); 3544 CHECK(output_surface->BindToClient(&output_surface_client));
3541 3545
3542 gfx::Size size(4, 4); 3546 gfx::Size size(4, 4);
3543 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3547 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3544 output_surface.get(), shared_bitmap_manager_.get(), 3548 output_surface.get(), shared_bitmap_manager_.get(),
3545 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3549 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3546 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3550 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3547 int texture_id = 123; 3551 int texture_id = 123;
3548 3552
3549 ResourceId id = resource_provider->CreateResource( 3553 ResourceId id = resource_provider->CreateResource(
3550 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); 3554 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1);
3551 EXPECT_NE(0u, id); 3555 EXPECT_NE(0u, id);
3552 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3556 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3553 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3557 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3554 resource_provider->AllocateForTesting(id); 3558 resource_provider->AllocateForTesting(id);
3555 3559
3556 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); 3560 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
3557 resource_provider->DeleteResource(id); 3561 resource_provider->DeleteResource(id);
3558 } 3562 }
3559 3563
3560 TEST_P(ResourceProviderTest, CompressedTextureETC1Upload) { 3564 TEST_P(ResourceProviderTest, CompressedTextureETC1Upload) {
3561 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3565 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3562 return; 3566 return;
3563 3567
3564 scoped_ptr<AllocationTrackingContext3D> context_owned( 3568 std::unique_ptr<AllocationTrackingContext3D> context_owned(
3565 new AllocationTrackingContext3D); 3569 new AllocationTrackingContext3D);
3566 AllocationTrackingContext3D* context = context_owned.get(); 3570 AllocationTrackingContext3D* context = context_owned.get();
3567 context_owned->set_support_compressed_texture_etc1(true); 3571 context_owned->set_support_compressed_texture_etc1(true);
3568 3572
3569 FakeOutputSurfaceClient output_surface_client; 3573 FakeOutputSurfaceClient output_surface_client;
3570 scoped_ptr<OutputSurface> output_surface( 3574 std::unique_ptr<OutputSurface> output_surface(
3571 FakeOutputSurface::Create3d(std::move(context_owned))); 3575 FakeOutputSurface::Create3d(std::move(context_owned)));
3572 CHECK(output_surface->BindToClient(&output_surface_client)); 3576 CHECK(output_surface->BindToClient(&output_surface_client));
3573 3577
3574 gfx::Size size(4, 4); 3578 gfx::Size size(4, 4);
3575 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3579 std::unique_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3576 output_surface.get(), shared_bitmap_manager_.get(), 3580 output_surface.get(), shared_bitmap_manager_.get(),
3577 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3581 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3578 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3582 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3579 int texture_id = 123; 3583 int texture_id = 123;
3580 uint8_t pixels[8]; 3584 uint8_t pixels[8];
3581 3585
3582 ResourceId id = resource_provider->CreateResource( 3586 ResourceId id = resource_provider->CreateResource(
3583 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); 3587 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1);
3584 EXPECT_NE(0u, id); 3588 EXPECT_NE(0u, id);
3585 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3589 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
(...skipping 20 matching lines...) Expand all
3606 return namespace_->next_texture_id++; 3610 return namespace_->next_texture_id++;
3607 } 3611 }
3608 void RetireTextureId(GLuint) override {} 3612 void RetireTextureId(GLuint) override {}
3609 GLuint PeekTextureId() { 3613 GLuint PeekTextureId() {
3610 base::AutoLock lock(namespace_->lock); 3614 base::AutoLock lock(namespace_->lock);
3611 return namespace_->next_texture_id; 3615 return namespace_->next_texture_id;
3612 } 3616 }
3613 }; 3617 };
3614 3618
3615 TEST(ResourceProviderTest, TextureAllocationChunkSize) { 3619 TEST(ResourceProviderTest, TextureAllocationChunkSize) {
3616 scoped_ptr<TextureIdAllocationTrackingContext> context_owned( 3620 std::unique_ptr<TextureIdAllocationTrackingContext> context_owned(
3617 new TextureIdAllocationTrackingContext); 3621 new TextureIdAllocationTrackingContext);
3618 TextureIdAllocationTrackingContext* context = context_owned.get(); 3622 TextureIdAllocationTrackingContext* context = context_owned.get();
3619 3623
3620 FakeOutputSurfaceClient output_surface_client; 3624 FakeOutputSurfaceClient output_surface_client;
3621 scoped_ptr<OutputSurface> output_surface( 3625 std::unique_ptr<OutputSurface> output_surface(
3622 FakeOutputSurface::Create3d(std::move(context_owned))); 3626 FakeOutputSurface::Create3d(std::move(context_owned)));
3623 CHECK(output_surface->BindToClient(&output_surface_client)); 3627 CHECK(output_surface->BindToClient(&output_surface_client));
3624 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 3628 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
3625 new TestSharedBitmapManager()); 3629 new TestSharedBitmapManager());
3626 3630
3627 gfx::Size size(1, 1); 3631 gfx::Size size(1, 1);
3628 ResourceFormat format = RGBA_8888; 3632 ResourceFormat format = RGBA_8888;
3629 3633
3630 { 3634 {
3631 size_t kTextureAllocationChunkSize = 1; 3635 size_t kTextureAllocationChunkSize = 1;
3632 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3636 std::unique_ptr<ResourceProvider> resource_provider(
3633 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, 3637 ResourceProvider::Create(
3634 kTextureAllocationChunkSize, 3638 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0,
3635 ResourceProviderTest::use_gpu_memory_buffer_resources(), 3639 kTextureAllocationChunkSize,
3636 ResourceProviderTest::use_image_texture_targets())); 3640 ResourceProviderTest::use_gpu_memory_buffer_resources(),
3641 ResourceProviderTest::use_image_texture_targets()));
3637 3642
3638 ResourceId id = resource_provider->CreateResource( 3643 ResourceId id = resource_provider->CreateResource(
3639 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3644 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3640 resource_provider->AllocateForTesting(id); 3645 resource_provider->AllocateForTesting(id);
3641 Mock::VerifyAndClearExpectations(context); 3646 Mock::VerifyAndClearExpectations(context);
3642 3647
3643 DCHECK_EQ(2u, context->PeekTextureId()); 3648 DCHECK_EQ(2u, context->PeekTextureId());
3644 resource_provider->DeleteResource(id); 3649 resource_provider->DeleteResource(id);
3645 } 3650 }
3646 3651
3647 { 3652 {
3648 size_t kTextureAllocationChunkSize = 8; 3653 size_t kTextureAllocationChunkSize = 8;
3649 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3654 std::unique_ptr<ResourceProvider> resource_provider(
3650 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, 3655 ResourceProvider::Create(
3651 kTextureAllocationChunkSize, 3656 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0,
3652 ResourceProviderTest::use_gpu_memory_buffer_resources(), 3657 kTextureAllocationChunkSize,
3653 ResourceProviderTest::use_image_texture_targets())); 3658 ResourceProviderTest::use_gpu_memory_buffer_resources(),
3659 ResourceProviderTest::use_image_texture_targets()));
3654 3660
3655 ResourceId id = resource_provider->CreateResource( 3661 ResourceId id = resource_provider->CreateResource(
3656 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); 3662 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
3657 resource_provider->AllocateForTesting(id); 3663 resource_provider->AllocateForTesting(id);
3658 Mock::VerifyAndClearExpectations(context); 3664 Mock::VerifyAndClearExpectations(context);
3659 3665
3660 DCHECK_EQ(10u, context->PeekTextureId()); 3666 DCHECK_EQ(10u, context->PeekTextureId());
3661 resource_provider->DeleteResource(id); 3667 resource_provider->DeleteResource(id);
3662 } 3668 }
3663 } 3669 }
(...skipping 20 matching lines...) Expand all
3684 EXPECT_TRUE(resource_provider_->CanLockForWrite(id)); 3690 EXPECT_TRUE(resource_provider_->CanLockForWrite(id));
3685 EXPECT_FALSE(resource_provider_->InUseByConsumer(id)); 3691 EXPECT_FALSE(resource_provider_->InUseByConsumer(id));
3686 gpu_memory_buffer_manager_->SetGpuMemoryBufferIsInUseByMacOSWindowServer( 3692 gpu_memory_buffer_manager_->SetGpuMemoryBufferIsInUseByMacOSWindowServer(
3687 gpu_memory_buffer, true); 3693 gpu_memory_buffer, true);
3688 EXPECT_FALSE(resource_provider_->CanLockForWrite(id)); 3694 EXPECT_FALSE(resource_provider_->CanLockForWrite(id));
3689 EXPECT_TRUE(resource_provider_->InUseByConsumer(id)); 3695 EXPECT_TRUE(resource_provider_->InUseByConsumer(id));
3690 } 3696 }
3691 3697
3692 } // namespace 3698 } // namespace
3693 } // namespace cc 3699 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/scoped_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698