| 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/test/test_simple_task_runner.h" | 8 #include "base/test/test_simple_task_runner.h" |
| 8 #include "cc/output/managed_memory_policy.h" | 9 #include "cc/output/managed_memory_policy.h" |
| 9 #include "cc/output/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
| 10 #include "cc/output/software_output_device.h" | 11 #include "cc/output/software_output_device.h" |
| 11 #include "cc/test/begin_frame_args_test.h" | 12 #include "cc/test/begin_frame_args_test.h" |
| 12 #include "cc/test/fake_output_surface.h" | 13 #include "cc/test/fake_output_surface.h" |
| 13 #include "cc/test/fake_output_surface_client.h" | 14 #include "cc/test/fake_output_surface_client.h" |
| 14 #include "cc/test/test_context_provider.h" | 15 #include "cc/test/test_context_provider.h" |
| 15 #include "cc/test/test_web_graphics_context_3d.h" | 16 #include "cc/test/test_web_graphics_context_3d.h" |
| 16 #include "gpu/GLES2/gl2extchromium.h" | 17 #include "gpu/GLES2/gl2extchromium.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace cc { | 20 namespace cc { |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 class TestOutputSurface : public OutputSurface { | 23 class TestOutputSurface : public OutputSurface { |
| 23 public: | 24 public: |
| 24 explicit TestOutputSurface(scoped_refptr<ContextProvider> context_provider) | 25 explicit TestOutputSurface(scoped_refptr<ContextProvider> context_provider) |
| 25 : OutputSurface(context_provider) {} | 26 : OutputSurface(context_provider) {} |
| 26 | 27 |
| 27 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, | 28 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, |
| 28 scoped_refptr<ContextProvider> worker_context_provider) | 29 scoped_refptr<ContextProvider> worker_context_provider) |
| 29 : OutputSurface(worker_context_provider) {} | 30 : OutputSurface(worker_context_provider) {} |
| 30 | 31 |
| 31 explicit TestOutputSurface(scoped_ptr<SoftwareOutputDevice> software_device) | 32 explicit TestOutputSurface( |
| 33 std::unique_ptr<SoftwareOutputDevice> software_device) |
| 32 : OutputSurface(std::move(software_device)) {} | 34 : OutputSurface(std::move(software_device)) {} |
| 33 | 35 |
| 34 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, | 36 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, |
| 35 scoped_ptr<SoftwareOutputDevice> software_device) | 37 std::unique_ptr<SoftwareOutputDevice> software_device) |
| 36 : OutputSurface(context_provider, std::move(software_device)) {} | 38 : OutputSurface(context_provider, std::move(software_device)) {} |
| 37 | 39 |
| 38 void SwapBuffers(CompositorFrame* frame) override { | 40 void SwapBuffers(CompositorFrame* frame) override { |
| 39 client_->DidSwapBuffers(); | 41 client_->DidSwapBuffers(); |
| 40 client_->DidSwapBuffersComplete(); | 42 client_->DidSwapBuffersComplete(); |
| 41 } | 43 } |
| 42 | 44 |
| 43 void CommitVSyncParametersForTesting(base::TimeTicks timebase, | 45 void CommitVSyncParametersForTesting(base::TimeTicks timebase, |
| 44 base::TimeDelta interval) { | 46 base::TimeDelta interval) { |
| 45 CommitVSyncParameters(timebase, interval); | 47 CommitVSyncParameters(timebase, interval); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 EXPECT_FALSE(output_surface.BindToClient(&client)); | 153 EXPECT_FALSE(output_surface.BindToClient(&client)); |
| 152 EXPECT_FALSE(output_surface.HasClient()); | 154 EXPECT_FALSE(output_surface.HasClient()); |
| 153 } | 155 } |
| 154 | 156 |
| 155 TEST(OutputSurfaceTest, SoftwareOutputDeviceBackbufferManagement) { | 157 TEST(OutputSurfaceTest, SoftwareOutputDeviceBackbufferManagement) { |
| 156 TestSoftwareOutputDevice* software_output_device = | 158 TestSoftwareOutputDevice* software_output_device = |
| 157 new TestSoftwareOutputDevice(); | 159 new TestSoftwareOutputDevice(); |
| 158 | 160 |
| 159 // TestOutputSurface now owns software_output_device and has responsibility to | 161 // TestOutputSurface now owns software_output_device and has responsibility to |
| 160 // free it. | 162 // free it. |
| 161 TestOutputSurface output_surface(make_scoped_ptr(software_output_device)); | 163 TestOutputSurface output_surface(base::WrapUnique(software_output_device)); |
| 162 | 164 |
| 163 EXPECT_EQ(0, software_output_device->ensure_backbuffer_count()); | 165 EXPECT_EQ(0, software_output_device->ensure_backbuffer_count()); |
| 164 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); | 166 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); |
| 165 | 167 |
| 166 output_surface.EnsureBackbuffer(); | 168 output_surface.EnsureBackbuffer(); |
| 167 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 169 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
| 168 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); | 170 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); |
| 169 output_surface.DiscardBackbuffer(); | 171 output_surface.DiscardBackbuffer(); |
| 170 | 172 |
| 171 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 173 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
| 172 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); | 174 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); |
| 173 } | 175 } |
| 174 | 176 |
| 175 } // namespace | 177 } // namespace |
| 176 } // namespace cc | 178 } // namespace cc |
| OLD | NEW |