Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 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>( |
| 86 new TestOutputSurface(context_provider_, | 84 new TestOutputSurface(context_provider_)).Pass(); |
|
danakj
2015/03/25 17:40:38
(the .Pass() is redundant and not needed here. "ne
simonhong
2015/03/25 18:05:22
Done.
| |
| 87 compositor_->vsync_manager())).Pass(); | |
| 88 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 85 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 89 | 86 |
| 90 mirroring_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 87 mirroring_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
| 91 gfx::Size size = output_surface_->SurfaceSize(); | 88 gfx::Size size = output_surface_->SurfaceSize(); |
| 92 mirroring_layer_->SetBounds(gfx::Rect(size.width(), size.height())); | 89 mirroring_layer_->SetBounds(gfx::Rect(size.width(), size.height())); |
| 93 } | 90 } |
| 94 | 91 |
| 95 void SetUpReflector() { | 92 void SetUpReflector() { |
| 96 reflector_ = make_scoped_ptr( | 93 reflector_ = make_scoped_ptr( |
| 97 new ReflectorImpl(compositor_.get(), mirroring_layer_.get())); | 94 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) { | 135 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { |
| 139 output_surface_->SetFlip(true); | 136 output_surface_->SetFlip(true); |
| 140 SetUpReflector(); | 137 SetUpReflector(); |
| 141 UpdateTexture(); | 138 UpdateTexture(); |
| 142 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); | 139 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); |
| 143 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); | 140 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); |
| 144 } | 141 } |
| 145 | 142 |
| 146 } // namespace | 143 } // namespace |
| 147 } // namespace content | 144 } // namespace content |
| OLD | NEW |