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