| 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_update_controller.h" | 5 #include "cc/resources/resource_update_controller.h" |
| 6 | 6 |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "cc/resources/prioritized_resource_manager.h" | 8 #include "cc/resources/prioritized_resource_manager.h" |
| 9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
| 10 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const int kFlushPeriodFull = 4; | 25 const int kFlushPeriodFull = 4; |
| 26 const int kFlushPeriodPartial = kFlushPeriodFull; | 26 const int kFlushPeriodPartial = kFlushPeriodFull; |
| 27 | 27 |
| 28 class ResourceUpdateControllerTest; | 28 class ResourceUpdateControllerTest; |
| 29 | 29 |
| 30 class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D { | 30 class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D { |
| 31 public: | 31 public: |
| 32 explicit WebGraphicsContext3DForUploadTest(ResourceUpdateControllerTest* test) | 32 explicit WebGraphicsContext3DForUploadTest(ResourceUpdateControllerTest* test) |
| 33 : test_(test) {} | 33 : test_(test) {} |
| 34 | 34 |
| 35 virtual void flush() OVERRIDE; | 35 virtual void flush() override; |
| 36 virtual void shallowFlushCHROMIUM() OVERRIDE; | 36 virtual void shallowFlushCHROMIUM() override; |
| 37 virtual void texSubImage2D(GLenum target, | 37 virtual void texSubImage2D(GLenum target, |
| 38 GLint level, | 38 GLint level, |
| 39 GLint xoffset, | 39 GLint xoffset, |
| 40 GLint yoffset, | 40 GLint yoffset, |
| 41 GLsizei width, | 41 GLsizei width, |
| 42 GLsizei height, | 42 GLsizei height, |
| 43 GLenum format, | 43 GLenum format, |
| 44 GLenum type, | 44 GLenum type, |
| 45 const void* pixels) OVERRIDE; | 45 const void* pixels) override; |
| 46 | 46 |
| 47 virtual void getQueryObjectuivEXT(GLuint id, GLenum pname, GLuint* value) | 47 virtual void getQueryObjectuivEXT(GLuint id, GLenum pname, GLuint* value) |
| 48 OVERRIDE; | 48 override; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 ResourceUpdateControllerTest* test_; | 51 ResourceUpdateControllerTest* test_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 class ResourceUpdateControllerTest : public Test { | 54 class ResourceUpdateControllerTest : public Test { |
| 55 public: | 55 public: |
| 56 ResourceUpdateControllerTest() | 56 ResourceUpdateControllerTest() |
| 57 : proxy_(), | 57 : proxy_(), |
| 58 queue_(make_scoped_ptr(new ResourceUpdateQueue)), | 58 queue_(make_scoped_ptr(new ResourceUpdateQueue)), |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 << "Last upload wasn't followed by a flush."; | 321 << "Last upload wasn't followed by a flush."; |
| 322 } | 322 } |
| 323 | 323 |
| 324 class FakeResourceUpdateControllerClient | 324 class FakeResourceUpdateControllerClient |
| 325 : public ResourceUpdateControllerClient { | 325 : public ResourceUpdateControllerClient { |
| 326 public: | 326 public: |
| 327 FakeResourceUpdateControllerClient() { Reset(); } | 327 FakeResourceUpdateControllerClient() { Reset(); } |
| 328 void Reset() { ready_to_finalize_called_ = false; } | 328 void Reset() { ready_to_finalize_called_ = false; } |
| 329 bool ReadyToFinalizeCalled() const { return ready_to_finalize_called_; } | 329 bool ReadyToFinalizeCalled() const { return ready_to_finalize_called_; } |
| 330 | 330 |
| 331 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE { | 331 virtual void ReadyToFinalizeTextureUpdates() override { |
| 332 ready_to_finalize_called_ = true; | 332 ready_to_finalize_called_ = true; |
| 333 } | 333 } |
| 334 | 334 |
| 335 protected: | 335 protected: |
| 336 bool ready_to_finalize_called_; | 336 bool ready_to_finalize_called_; |
| 337 }; | 337 }; |
| 338 | 338 |
| 339 class FakeResourceUpdateController : public ResourceUpdateController { | 339 class FakeResourceUpdateController : public ResourceUpdateController { |
| 340 public: | 340 public: |
| 341 static scoped_ptr<FakeResourceUpdateController> Create( | 341 static scoped_ptr<FakeResourceUpdateController> Create( |
| 342 ResourceUpdateControllerClient* client, | 342 ResourceUpdateControllerClient* client, |
| 343 base::TestSimpleTaskRunner* task_runner, | 343 base::TestSimpleTaskRunner* task_runner, |
| 344 scoped_ptr<ResourceUpdateQueue> queue, | 344 scoped_ptr<ResourceUpdateQueue> queue, |
| 345 ResourceProvider* resource_provider) { | 345 ResourceProvider* resource_provider) { |
| 346 return make_scoped_ptr(new FakeResourceUpdateController( | 346 return make_scoped_ptr(new FakeResourceUpdateController( |
| 347 client, task_runner, queue.Pass(), resource_provider)); | 347 client, task_runner, queue.Pass(), resource_provider)); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void SetNow(base::TimeTicks time) { now_ = time; } | 350 void SetNow(base::TimeTicks time) { now_ = time; } |
| 351 base::TimeTicks Now() const { return now_; } | 351 base::TimeTicks Now() const { return now_; } |
| 352 void SetUpdateTextureTime(base::TimeDelta time) { | 352 void SetUpdateTextureTime(base::TimeDelta time) { |
| 353 update_textures_time_ = time; | 353 update_textures_time_ = time; |
| 354 } | 354 } |
| 355 virtual base::TimeTicks UpdateMoreTexturesCompletionTime() OVERRIDE { | 355 virtual base::TimeTicks UpdateMoreTexturesCompletionTime() override { |
| 356 size_t total_updates = | 356 size_t total_updates = |
| 357 resource_provider_->NumBlockingUploads() + update_more_textures_size_; | 357 resource_provider_->NumBlockingUploads() + update_more_textures_size_; |
| 358 return now_ + total_updates * update_textures_time_; | 358 return now_ + total_updates * update_textures_time_; |
| 359 } | 359 } |
| 360 void SetUpdateMoreTexturesSize(size_t size) { | 360 void SetUpdateMoreTexturesSize(size_t size) { |
| 361 update_more_textures_size_ = size; | 361 update_more_textures_size_ = size; |
| 362 } | 362 } |
| 363 virtual size_t UpdateMoreTexturesSize() const OVERRIDE { | 363 virtual size_t UpdateMoreTexturesSize() const override { |
| 364 return update_more_textures_size_; | 364 return update_more_textures_size_; |
| 365 } | 365 } |
| 366 | 366 |
| 367 protected: | 367 protected: |
| 368 FakeResourceUpdateController(ResourceUpdateControllerClient* client, | 368 FakeResourceUpdateController(ResourceUpdateControllerClient* client, |
| 369 base::TestSimpleTaskRunner* task_runner, | 369 base::TestSimpleTaskRunner* task_runner, |
| 370 scoped_ptr<ResourceUpdateQueue> queue, | 370 scoped_ptr<ResourceUpdateQueue> queue, |
| 371 ResourceProvider* resource_provider) | 371 ResourceProvider* resource_provider) |
| 372 : ResourceUpdateController( | 372 : ResourceUpdateController( |
| 373 client, task_runner, queue.Pass(), resource_provider), | 373 client, task_runner, queue.Pass(), resource_provider), |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 RunPendingTask(task_runner.get(), controller.get()); | 508 RunPendingTask(task_runner.get(), controller.get()); |
| 509 } | 509 } |
| 510 | 510 |
| 511 EXPECT_FALSE(task_runner->HasPendingTask()); | 511 EXPECT_FALSE(task_runner->HasPendingTask()); |
| 512 EXPECT_TRUE(client.ReadyToFinalizeCalled()); | 512 EXPECT_TRUE(client.ReadyToFinalizeCalled()); |
| 513 EXPECT_EQ(2, num_total_uploads_); | 513 EXPECT_EQ(2, num_total_uploads_); |
| 514 } | 514 } |
| 515 | 515 |
| 516 } // namespace | 516 } // namespace |
| 517 } // namespace cc | 517 } // namespace cc |
| OLD | NEW |