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 } | |
98 | 97 |
99 void SetUpReflector(bool threaded) { | |
100 int32 surface_id = 1; | 98 int32 surface_id = 1; |
101 | 99 reflector_ = new ReflectorImpl(compositor_.get(), mirroring_layer_.get(), |
102 if (threaded) { | 100 &surface_map_, proxy_.get(), surface_id); |
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 } | |
109 } | 101 } |
110 | 102 |
111 void TearDown() override { | 103 void TearDown() override { |
112 cc::TextureMailbox mailbox; | 104 cc::TextureMailbox mailbox; |
113 scoped_ptr<cc::SingleReleaseCallback> release; | 105 scoped_ptr<cc::SingleReleaseCallback> release; |
114 if (mirroring_layer_->PrepareTextureMailbox(&mailbox, &release, false)) { | 106 if (mirroring_layer_->PrepareTextureMailbox(&mailbox, &release, false)) { |
115 release->Run(0, false); | 107 release->Run(0, false); |
116 } | 108 } |
117 compositor_.reset(); | 109 compositor_.reset(); |
118 ui::TerminateContextFactoryForTests(); | 110 ui::TerminateContextFactoryForTests(); |
(...skipping 15 matching lines...) Expand all Loading... |
134 scoped_ptr<base::MessageLoop> message_loop_; | 126 scoped_ptr<base::MessageLoop> message_loop_; |
135 scoped_refptr<base::MessageLoopProxy> proxy_; | 127 scoped_refptr<base::MessageLoopProxy> proxy_; |
136 scoped_ptr<ui::Compositor> compositor_; | 128 scoped_ptr<ui::Compositor> compositor_; |
137 scoped_ptr<ui::Layer> mirroring_layer_; | 129 scoped_ptr<ui::Layer> mirroring_layer_; |
138 scoped_refptr<ReflectorImpl> reflector_; | 130 scoped_refptr<ReflectorImpl> reflector_; |
139 scoped_ptr<TestOutputSurface> output_surface_; | 131 scoped_ptr<TestOutputSurface> output_surface_; |
140 }; | 132 }; |
141 | 133 |
142 namespace { | 134 namespace { |
143 TEST_F(ReflectorImplTest, CheckNormalOutputSurface) { | 135 TEST_F(ReflectorImplTest, CheckNormalOutputSurface) { |
144 bool threaded = true; | |
145 SetUpReflector(threaded); | |
146 output_surface_->SetFlip(false); | 136 output_surface_->SetFlip(false); |
147 Init(); | 137 Init(); |
148 UpdateTexture(); | 138 UpdateTexture(); |
149 EXPECT_TRUE(mirroring_layer_->TextureFlipped()); | 139 EXPECT_TRUE(mirroring_layer_->TextureFlipped()); |
150 EXPECT_EQ(SkRegion(SkIRect::MakeXYWH( | 140 EXPECT_EQ(SkRegion(SkIRect::MakeXYWH( |
151 0, output_surface_->SurfaceSize().height() - kSubRect.height(), | 141 0, output_surface_->SurfaceSize().height() - kSubRect.height(), |
152 kSubRect.width(), kSubRect.height())), | 142 kSubRect.width(), kSubRect.height())), |
153 mirroring_layer_->damaged_region()); | 143 mirroring_layer_->damaged_region()); |
154 } | 144 } |
155 | 145 |
156 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { | 146 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { |
157 bool threaded = true; | |
158 SetUpReflector(threaded); | |
159 output_surface_->SetFlip(true); | 147 output_surface_->SetFlip(true); |
160 Init(); | 148 Init(); |
161 UpdateTexture(); | 149 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(); | |
185 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); | 150 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); |
186 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); | 151 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); |
187 } | 152 } |
188 | 153 |
189 } // namespace | 154 } // namespace |
190 } // namespace content | 155 } // namespace content |
OLD | NEW |