Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: components/exo/surface_unittest.cc

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: exo::Surface uses CompositorFrameSink accessor from CompositorFrameSinkHolder Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "cc/output/compositor_frame.h" 6 #include "cc/output/compositor_frame.h"
7 #include "cc/quads/texture_draw_quad.h" 7 #include "cc/quads/texture_draw_quad.h"
8 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_manager.h" 9 #include "cc/surfaces/surface_manager.h"
10 #include "components/exo/buffer.h" 10 #include "components/exo/buffer.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 surface->Commit(); 43 surface->Commit();
44 44
45 // Commit without calling Attach() should have no effect. 45 // Commit without calling Attach() should have no effect.
46 surface->Commit(); 46 surface->Commit();
47 EXPECT_EQ(0, release_buffer_call_count); 47 EXPECT_EQ(0, release_buffer_call_count);
48 48
49 // Attach a null buffer to surface, this should release the previously 49 // Attach a null buffer to surface, this should release the previously
50 // attached buffer. 50 // attached buffer.
51 surface->Attach(nullptr); 51 surface->Attach(nullptr);
52 surface->Commit(); 52 surface->Commit();
53 // CompositorFrameSinkHolder::ReclaimResources() gets called via
54 // MojoCompositorFrameSinkClient interface. We need to wait here for the mojo
55 // call to finish so that the release callback finishes running before
56 // the assertion below
reveman 2016/12/07 00:46:58 nit: s/below/below./
Alex Z. 2016/12/07 20:09:36 Done.
57 RunAllPendingInMessageLoop();
53 ASSERT_EQ(1, release_buffer_call_count); 58 ASSERT_EQ(1, release_buffer_call_count);
54 } 59 }
55 60
56 TEST_F(SurfaceTest, Damage) { 61 TEST_F(SurfaceTest, Damage) {
57 gfx::Size buffer_size(256, 256); 62 gfx::Size buffer_size(256, 256);
58 std::unique_ptr<Buffer> buffer( 63 std::unique_ptr<Buffer> buffer(
59 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 64 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
60 std::unique_ptr<Surface> surface(new Surface); 65 std::unique_ptr<Surface> surface(new Surface);
61 66
62 // Attach the buffer to the surface. This will update the pending bounds of 67 // Attach the buffer to the surface. This will update the pending bounds of
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 surface->Commit(); 189 surface->Commit();
185 EXPECT_EQ(crop_size.ToString(), 190 EXPECT_EQ(crop_size.ToString(),
186 surface->window()->bounds().size().ToString()); 191 surface->window()->bounds().size().ToString());
187 EXPECT_EQ(crop_size.ToString(), surface->content_size().ToString()); 192 EXPECT_EQ(crop_size.ToString(), surface->content_size().ToString());
188 } 193 }
189 194
190 const cc::CompositorFrame& GetFrameFromSurface(Surface* surface) { 195 const cc::CompositorFrame& GetFrameFromSurface(Surface* surface) {
191 cc::SurfaceId surface_id = surface->GetSurfaceId(); 196 cc::SurfaceId surface_id = surface->GetSurfaceId();
192 cc::SurfaceManager* surface_manager = 197 cc::SurfaceManager* surface_manager =
193 aura::Env::GetInstance()->context_factory()->GetSurfaceManager(); 198 aura::Env::GetInstance()->context_factory()->GetSurfaceManager();
194 const cc::CompositorFrame& frame = 199 cc::Surface* another_surface = surface_manager->GetSurfaceForId(surface_id);
reveman 2016/12/07 00:46:58 s/another_surface/cc_surface/
Alex Z. 2016/12/07 20:09:36 This cc::Surface was added for debugging. I have r
195 surface_manager->GetSurfaceForId(surface_id)->GetEligibleFrame(); 200 DCHECK(another_surface);
201 const cc::CompositorFrame& frame = another_surface->GetEligibleFrame();
196 return frame; 202 return frame;
197 } 203 }
198 204
199 TEST_F(SurfaceTest, SetBlendMode) { 205 TEST_F(SurfaceTest, SetBlendMode) {
200 gfx::Size buffer_size(1, 1); 206 gfx::Size buffer_size(1, 1);
201 std::unique_ptr<Buffer> buffer( 207 std::unique_ptr<Buffer> buffer(
202 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 208 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
203 std::unique_ptr<Surface> surface(new Surface); 209 std::unique_ptr<Surface> surface(new Surface);
204 210
205 surface->Attach(buffer.get()); 211 surface->Attach(buffer.get());
206 surface->SetBlendMode(SkBlendMode::kSrc); 212 surface->SetBlendMode(SkBlendMode::kSrc);
207 surface->Commit(); 213 surface->Commit();
214 RunAllPendingInMessageLoop();
208 215
209 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get()); 216 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
210 ASSERT_EQ(1u, frame.render_pass_list.size()); 217 ASSERT_EQ(1u, frame.render_pass_list.size());
211 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size()); 218 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size());
212 EXPECT_FALSE(frame.render_pass_list.back() 219 EXPECT_FALSE(frame.render_pass_list.back()
213 ->quad_list.back() 220 ->quad_list.back()
214 ->ShouldDrawWithBlending()); 221 ->ShouldDrawWithBlending());
215 } 222 }
216 223
217 TEST_F(SurfaceTest, OverlayCandidate) { 224 TEST_F(SurfaceTest, OverlayCandidate) {
218 gfx::Size buffer_size(1, 1); 225 gfx::Size buffer_size(1, 1);
219 std::unique_ptr<Buffer> buffer(new Buffer( 226 std::unique_ptr<Buffer> buffer(new Buffer(
220 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), 0, 0, true, true)); 227 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), 0, 0, true, true));
221 std::unique_ptr<Surface> surface(new Surface); 228 std::unique_ptr<Surface> surface(new Surface);
222 229
223 surface->Attach(buffer.get()); 230 surface->Attach(buffer.get());
224 surface->Commit(); 231 surface->Commit();
232 RunAllPendingInMessageLoop();
225 233
226 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get()); 234 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
227 ASSERT_EQ(1u, frame.render_pass_list.size()); 235 ASSERT_EQ(1u, frame.render_pass_list.size());
228 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size()); 236 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size());
229 cc::DrawQuad* draw_quad = frame.render_pass_list.back()->quad_list.back(); 237 cc::DrawQuad* draw_quad = frame.render_pass_list.back()->quad_list.back();
230 ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT, draw_quad->material); 238 ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT, draw_quad->material);
231 239
232 const cc::TextureDrawQuad* texture_quad = 240 const cc::TextureDrawQuad* texture_quad =
233 cc::TextureDrawQuad::MaterialCast(draw_quad); 241 cc::TextureDrawQuad::MaterialCast(draw_quad);
234 EXPECT_FALSE(texture_quad->resource_size_in_pixels().IsEmpty()); 242 EXPECT_FALSE(texture_quad->resource_size_in_pixels().IsEmpty());
235 } 243 }
236 244
237 TEST_F(SurfaceTest, SetAlpha) { 245 TEST_F(SurfaceTest, SetAlpha) {
238 gfx::Size buffer_size(1, 1); 246 gfx::Size buffer_size(1, 1);
239 std::unique_ptr<Buffer> buffer( 247 std::unique_ptr<Buffer> buffer(
240 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 248 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
241 std::unique_ptr<Surface> surface(new Surface); 249 std::unique_ptr<Surface> surface(new Surface);
242 250
243 surface->Attach(buffer.get()); 251 surface->Attach(buffer.get());
244 surface->SetAlpha(0.5f); 252 surface->SetAlpha(0.5f);
245 surface->Commit(); 253 surface->Commit();
246 } 254 }
247 255
248 TEST_F(SurfaceTest, Commit) { 256 TEST_F(SurfaceTest, Commit) {
249 std::unique_ptr<Surface> surface(new Surface); 257 std::unique_ptr<Surface> surface(new Surface);
250
reveman 2016/12/07 00:46:58 was this intentionally removed?
Alex Z. 2016/12/07 20:09:36 No. I guess it was removed along with the printf's
251 // Calling commit without a buffer should succeed. 258 // Calling commit without a buffer should succeed.
252 surface->Commit(); 259 surface->Commit();
253 } 260 }
254 261
255 } // namespace 262 } // namespace
256 } // namespace exo 263 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698