OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "cc/test/fake_output_surface_client.h" | 8 #include "cc/test/fake_output_surface_client.h" |
9 #include "cc/test/test_context_provider.h" | 9 #include "cc/test/test_context_provider.h" |
10 #include "cc/test/test_web_graphics_context_3d.h" | 10 #include "cc/test/test_web_graphics_context_3d.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 bool RunsTasksOnCurrentThread() const override { return true; } | 35 bool RunsTasksOnCurrentThread() const override { return true; } |
36 | 36 |
37 protected: | 37 protected: |
38 ~FakeTaskRunner() override {} | 38 ~FakeTaskRunner() override {} |
39 }; | 39 }; |
40 | 40 |
41 class TestOutputSurface : public BrowserCompositorOutputSurface { | 41 class TestOutputSurface : public BrowserCompositorOutputSurface { |
42 public: | 42 public: |
43 TestOutputSurface( | 43 TestOutputSurface( |
44 const scoped_refptr<cc::ContextProvider>& context_provider) | 44 const scoped_refptr<cc::ContextProvider>& context_provider, |
45 : BrowserCompositorOutputSurface(context_provider) {} | 45 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) |
| 46 : BrowserCompositorOutputSurface(context_provider, |
| 47 vsync_manager) {} |
46 | 48 |
47 void SetFlip(bool flip) { capabilities_.flipped_output_surface = flip; } | 49 void SetFlip(bool flip) { capabilities_.flipped_output_surface = flip; } |
48 | 50 |
49 void SwapBuffers(cc::CompositorFrame* frame) override {} | 51 void SwapBuffers(cc::CompositorFrame* frame) override {} |
50 | 52 |
51 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
52 void OnSurfaceDisplayed() override {} | 54 void OnSurfaceDisplayed() override {} |
53 void OnSurfaceRecycled() override {} | 55 void OnSurfaceRecycled() override {} |
54 bool ShouldNotShowFramesAfterRecycle() const override { return false; } | 56 bool ShouldNotShowFramesAfterRecycle() const override { return false; } |
55 #endif | 57 #endif |
(...skipping 17 matching lines...) Expand all Loading... |
73 new NoTransportImageTransportFactory)); | 75 new NoTransportImageTransportFactory)); |
74 message_loop_.reset(new base::MessageLoop()); | 76 message_loop_.reset(new base::MessageLoop()); |
75 proxy_ = message_loop_->message_loop_proxy(); | 77 proxy_ = message_loop_->message_loop_proxy(); |
76 compositor_task_runner_ = new FakeTaskRunner(); | 78 compositor_task_runner_ = new FakeTaskRunner(); |
77 compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget, | 79 compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget, |
78 context_factory, | 80 context_factory, |
79 compositor_task_runner_.get())); | 81 compositor_task_runner_.get())); |
80 context_provider_ = cc::TestContextProvider::Create( | 82 context_provider_ = cc::TestContextProvider::Create( |
81 cc::TestWebGraphicsContext3D::Create().Pass()); | 83 cc::TestWebGraphicsContext3D::Create().Pass()); |
82 output_surface_ = | 84 output_surface_ = |
83 scoped_ptr<TestOutputSurface>(new TestOutputSurface(context_provider_)); | 85 scoped_ptr<TestOutputSurface>( |
| 86 new TestOutputSurface(context_provider_, |
| 87 compositor_->vsync_manager())).Pass(); |
84 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 88 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
85 | 89 |
86 mirroring_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 90 mirroring_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
87 gfx::Size size = output_surface_->SurfaceSize(); | 91 gfx::Size size = output_surface_->SurfaceSize(); |
88 mirroring_layer_->SetBounds(gfx::Rect(size.width(), size.height())); | 92 mirroring_layer_->SetBounds(gfx::Rect(size.width(), size.height())); |
89 } | 93 } |
90 | 94 |
91 void SetUpReflector() { | 95 void SetUpReflector() { |
92 reflector_ = make_scoped_ptr( | 96 reflector_ = make_scoped_ptr( |
93 new ReflectorImpl(compositor_.get(), mirroring_layer_.get())); | 97 new ReflectorImpl(compositor_.get(), mirroring_layer_.get())); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { | 138 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { |
135 output_surface_->SetFlip(true); | 139 output_surface_->SetFlip(true); |
136 SetUpReflector(); | 140 SetUpReflector(); |
137 UpdateTexture(); | 141 UpdateTexture(); |
138 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); | 142 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); |
139 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); | 143 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); |
140 } | 144 } |
141 | 145 |
142 } // namespace | 146 } // namespace |
143 } // namespace content | 147 } // namespace content |
OLD | NEW |