| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/test/test_simple_task_runner.h" | 8 #include "base/test/test_simple_task_runner.h" |
| 9 #include "cc/output/managed_memory_policy.h" | 9 #include "cc/output/managed_memory_policy.h" |
| 10 #include "cc/output/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
| 11 #include "cc/output/software_output_device.h" | 11 #include "cc/output/software_output_device.h" |
| 12 #include "cc/test/begin_frame_args_test.h" | 12 #include "cc/test/begin_frame_args_test.h" |
| 13 #include "cc/test/fake_output_surface.h" | 13 #include "cc/test/fake_output_surface.h" |
| 14 #include "cc/test/fake_output_surface_client.h" | 14 #include "cc/test/fake_output_surface_client.h" |
| 15 #include "cc/test/test_context_provider.h" | 15 #include "cc/test/test_context_provider.h" |
| 16 #include "cc/test/test_web_graphics_context_3d.h" | 16 #include "cc/test/test_web_graphics_context_3d.h" |
| 17 #include "gpu/GLES2/gl2extchromium.h" | 17 #include "gpu/GLES2/gl2extchromium.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class TestOutputSurface : public OutputSurface { | 23 class TestOutputSurface : public OutputSurface { |
| 24 public: | 24 public: |
| 25 explicit TestOutputSurface(scoped_refptr<ContextProvider> context_provider) | 25 explicit TestOutputSurface( |
| 26 scoped_refptr<TestContextProvider> context_provider) |
| 26 : OutputSurface(std::move(context_provider), nullptr, nullptr) {} | 27 : OutputSurface(std::move(context_provider), nullptr, nullptr) {} |
| 27 | 28 |
| 28 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, | 29 TestOutputSurface(scoped_refptr<TestContextProvider> context_provider, |
| 29 scoped_refptr<ContextProvider> worker_context_provider) | 30 scoped_refptr<TestContextProvider> worker_context_provider) |
| 30 : OutputSurface(std::move(context_provider), | 31 : OutputSurface(std::move(context_provider), |
| 31 std::move(worker_context_provider), | 32 std::move(worker_context_provider), |
| 32 nullptr) {} | 33 nullptr) {} |
| 33 | 34 |
| 34 explicit TestOutputSurface( | 35 explicit TestOutputSurface( |
| 35 std::unique_ptr<SoftwareOutputDevice> software_device) | 36 std::unique_ptr<SoftwareOutputDevice> software_device) |
| 36 : OutputSurface(nullptr, nullptr, std::move(software_device)) {} | 37 : OutputSurface(nullptr, nullptr, std::move(software_device)) {} |
| 37 | 38 |
| 38 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, | 39 TestOutputSurface(scoped_refptr<TestContextProvider> context_provider, |
| 39 std::unique_ptr<SoftwareOutputDevice> software_device) | 40 std::unique_ptr<SoftwareOutputDevice> software_device) |
| 40 : OutputSurface(std::move(context_provider), | 41 : OutputSurface(std::move(context_provider), |
| 41 nullptr, | 42 nullptr, |
| 42 std::move(software_device)) {} | 43 std::move(software_device)) {} |
| 43 | 44 |
| 44 void SwapBuffers(CompositorFrame* frame) override { | 45 void SwapBuffers(CompositorFrame* frame) override { |
| 45 client_->DidSwapBuffers(); | 46 client_->DidSwapBuffers(); |
| 46 client_->DidSwapBuffersComplete(); | 47 client_->DidSwapBuffersComplete(); |
| 47 } | 48 } |
| 49 uint32_t GetFramebufferCopyTextureFormat() override { |
| 50 // TestContextProvider has no real framebuffer, just use RGB. |
| 51 return GL_RGB; |
| 52 } |
| 48 | 53 |
| 49 void DidSwapBuffersForTesting() { client_->DidSwapBuffers(); } | 54 void DidSwapBuffersForTesting() { client_->DidSwapBuffers(); } |
| 50 | 55 |
| 51 void OnSwapBuffersCompleteForTesting() { client_->DidSwapBuffersComplete(); } | 56 void OnSwapBuffersCompleteForTesting() { client_->DidSwapBuffersComplete(); } |
| 52 | 57 |
| 53 protected: | 58 protected: |
| 54 }; | 59 }; |
| 55 | 60 |
| 56 class TestSoftwareOutputDevice : public SoftwareOutputDevice { | 61 class TestSoftwareOutputDevice : public SoftwareOutputDevice { |
| 57 public: | 62 public: |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 158 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
| 154 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); | 159 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); |
| 155 output_surface.DiscardBackbuffer(); | 160 output_surface.DiscardBackbuffer(); |
| 156 | 161 |
| 157 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 162 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
| 158 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); | 163 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); |
| 159 } | 164 } |
| 160 | 165 |
| 161 } // namespace | 166 } // namespace |
| 162 } // namespace cc | 167 } // namespace cc |
| OLD | NEW |