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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 cc::TestWebGraphicsContext3D::Create().Pass()); | 87 cc::TestWebGraphicsContext3D::Create().Pass()); |
88 output_surface_ = | 88 output_surface_ = |
89 scoped_ptr<TestOutputSurface>( | 89 scoped_ptr<TestOutputSurface>( |
90 new TestOutputSurface(context_provider_, 1, &surface_map_, | 90 new TestOutputSurface(context_provider_, 1, &surface_map_, |
91 compositor_->vsync_manager())).Pass(); | 91 compositor_->vsync_manager())).Pass(); |
92 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 92 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
93 | 93 |
94 mirroring_layer_.reset(new ui::Layer()); | 94 mirroring_layer_.reset(new ui::Layer()); |
95 gfx::Size size = output_surface_->SurfaceSize(); | 95 gfx::Size size = output_surface_->SurfaceSize(); |
96 mirroring_layer_->SetBounds(gfx::Rect(size.width(), size.height())); | 96 mirroring_layer_->SetBounds(gfx::Rect(size.width(), size.height())); |
| 97 } |
97 | 98 |
| 99 void SetUpReflector(bool threaded) { |
98 int32 surface_id = 1; | 100 int32 surface_id = 1; |
99 reflector_ = new ReflectorImpl(compositor_.get(), mirroring_layer_.get(), | 101 |
100 &surface_map_, proxy_.get(), surface_id); | 102 if (threaded) { |
| 103 reflector_ = new ReflectorImpl(compositor_.get(), mirroring_layer_.get(), |
| 104 &surface_map_, proxy_.get(), surface_id); |
| 105 } else { |
| 106 reflector_ = new ReflectorImpl(compositor_.get(), mirroring_layer_.get(), |
| 107 &surface_map_, NULL, surface_id); |
| 108 } |
101 } | 109 } |
102 | 110 |
103 void TearDown() override { | 111 void TearDown() override { |
104 cc::TextureMailbox mailbox; | 112 cc::TextureMailbox mailbox; |
105 scoped_ptr<cc::SingleReleaseCallback> release; | 113 scoped_ptr<cc::SingleReleaseCallback> release; |
106 if (mirroring_layer_->PrepareTextureMailbox(&mailbox, &release, false)) { | 114 if (mirroring_layer_->PrepareTextureMailbox(&mailbox, &release, false)) { |
107 release->Run(0, false); | 115 release->Run(0, false); |
108 } | 116 } |
109 compositor_.reset(); | 117 compositor_.reset(); |
110 ui::TerminateContextFactoryForTests(); | 118 ui::TerminateContextFactoryForTests(); |
(...skipping 15 matching lines...) Expand all Loading... |
126 scoped_ptr<base::MessageLoop> message_loop_; | 134 scoped_ptr<base::MessageLoop> message_loop_; |
127 scoped_refptr<base::MessageLoopProxy> proxy_; | 135 scoped_refptr<base::MessageLoopProxy> proxy_; |
128 scoped_ptr<ui::Compositor> compositor_; | 136 scoped_ptr<ui::Compositor> compositor_; |
129 scoped_ptr<ui::Layer> mirroring_layer_; | 137 scoped_ptr<ui::Layer> mirroring_layer_; |
130 scoped_refptr<ReflectorImpl> reflector_; | 138 scoped_refptr<ReflectorImpl> reflector_; |
131 scoped_ptr<TestOutputSurface> output_surface_; | 139 scoped_ptr<TestOutputSurface> output_surface_; |
132 }; | 140 }; |
133 | 141 |
134 namespace { | 142 namespace { |
135 TEST_F(ReflectorImplTest, CheckNormalOutputSurface) { | 143 TEST_F(ReflectorImplTest, CheckNormalOutputSurface) { |
| 144 bool threaded = true; |
| 145 SetUpReflector(threaded); |
136 output_surface_->SetFlip(false); | 146 output_surface_->SetFlip(false); |
137 Init(); | 147 Init(); |
138 UpdateTexture(); | 148 UpdateTexture(); |
139 EXPECT_TRUE(mirroring_layer_->TextureFlipped()); | 149 EXPECT_TRUE(mirroring_layer_->TextureFlipped()); |
140 EXPECT_EQ(SkRegion(SkIRect::MakeXYWH( | 150 EXPECT_EQ(SkRegion(SkIRect::MakeXYWH( |
141 0, output_surface_->SurfaceSize().height() - kSubRect.height(), | 151 0, output_surface_->SurfaceSize().height() - kSubRect.height(), |
142 kSubRect.width(), kSubRect.height())), | 152 kSubRect.width(), kSubRect.height())), |
143 mirroring_layer_->damaged_region()); | 153 mirroring_layer_->damaged_region()); |
144 } | 154 } |
145 | 155 |
146 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { | 156 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { |
| 157 bool threaded = true; |
| 158 SetUpReflector(threaded); |
147 output_surface_->SetFlip(true); | 159 output_surface_->SetFlip(true); |
148 Init(); | 160 Init(); |
149 UpdateTexture(); | 161 UpdateTexture(); |
| 162 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); |
| 163 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); |
| 164 } |
| 165 |
| 166 TEST_F(ReflectorImplTest, CheckNormalOutputSurface_SingleThread) { |
| 167 bool threaded = false; |
| 168 SetUpReflector(threaded); |
| 169 output_surface_->SetFlip(false); |
| 170 Init(); |
| 171 UpdateTexture(); |
| 172 EXPECT_TRUE(mirroring_layer_->TextureFlipped()); |
| 173 EXPECT_EQ(SkRegion(SkIRect::MakeXYWH( |
| 174 0, output_surface_->SurfaceSize().height() - kSubRect.height(), |
| 175 kSubRect.width(), kSubRect.height())), |
| 176 mirroring_layer_->damaged_region()); |
| 177 } |
| 178 |
| 179 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface_SingleThread) { |
| 180 bool threaded = false; |
| 181 SetUpReflector(threaded); |
| 182 output_surface_->SetFlip(true); |
| 183 Init(); |
| 184 UpdateTexture(); |
150 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); | 185 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); |
151 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); | 186 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); |
152 } | 187 } |
153 | 188 |
154 } // namespace | 189 } // namespace |
155 } // namespace content | 190 } // namespace content |
OLD | NEW |