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

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

Issue 2562263002: [ABANDONED] Revert of Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: 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
« no previous file with comments | « components/exo/surface.cc ('k') | components/exo/test/run_all_unittests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
57 RunAllPendingInMessageLoop();
58 ASSERT_EQ(1, release_buffer_call_count); 53 ASSERT_EQ(1, release_buffer_call_count);
59 } 54 }
60 55
61 TEST_F(SurfaceTest, Damage) { 56 TEST_F(SurfaceTest, Damage) {
62 gfx::Size buffer_size(256, 256); 57 gfx::Size buffer_size(256, 256);
63 std::unique_ptr<Buffer> buffer( 58 std::unique_ptr<Buffer> buffer(
64 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 59 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
65 std::unique_ptr<Surface> surface(new Surface); 60 std::unique_ptr<Surface> surface(new Surface);
66 61
67 // Attach the buffer to the surface. This will update the pending bounds of 62 // Attach the buffer to the surface. This will update the pending bounds of
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 198
204 TEST_F(SurfaceTest, SetBlendMode) { 199 TEST_F(SurfaceTest, SetBlendMode) {
205 gfx::Size buffer_size(1, 1); 200 gfx::Size buffer_size(1, 1);
206 std::unique_ptr<Buffer> buffer( 201 std::unique_ptr<Buffer> buffer(
207 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 202 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
208 std::unique_ptr<Surface> surface(new Surface); 203 std::unique_ptr<Surface> surface(new Surface);
209 204
210 surface->Attach(buffer.get()); 205 surface->Attach(buffer.get());
211 surface->SetBlendMode(SkBlendMode::kSrc); 206 surface->SetBlendMode(SkBlendMode::kSrc);
212 surface->Commit(); 207 surface->Commit();
213 RunAllPendingInMessageLoop();
214 208
215 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get()); 209 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
216 ASSERT_EQ(1u, frame.render_pass_list.size()); 210 ASSERT_EQ(1u, frame.render_pass_list.size());
217 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size()); 211 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size());
218 EXPECT_FALSE(frame.render_pass_list.back() 212 EXPECT_FALSE(frame.render_pass_list.back()
219 ->quad_list.back() 213 ->quad_list.back()
220 ->ShouldDrawWithBlending()); 214 ->ShouldDrawWithBlending());
221 } 215 }
222 216
223 TEST_F(SurfaceTest, OverlayCandidate) { 217 TEST_F(SurfaceTest, OverlayCandidate) {
224 gfx::Size buffer_size(1, 1); 218 gfx::Size buffer_size(1, 1);
225 std::unique_ptr<Buffer> buffer(new Buffer( 219 std::unique_ptr<Buffer> buffer(new Buffer(
226 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), 0, 0, true, true)); 220 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), 0, 0, true, true));
227 std::unique_ptr<Surface> surface(new Surface); 221 std::unique_ptr<Surface> surface(new Surface);
228 222
229 surface->Attach(buffer.get()); 223 surface->Attach(buffer.get());
230 surface->Commit(); 224 surface->Commit();
231 RunAllPendingInMessageLoop();
232 225
233 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get()); 226 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
234 ASSERT_EQ(1u, frame.render_pass_list.size()); 227 ASSERT_EQ(1u, frame.render_pass_list.size());
235 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size()); 228 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size());
236 cc::DrawQuad* draw_quad = frame.render_pass_list.back()->quad_list.back(); 229 cc::DrawQuad* draw_quad = frame.render_pass_list.back()->quad_list.back();
237 ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT, draw_quad->material); 230 ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT, draw_quad->material);
238 231
239 const cc::TextureDrawQuad* texture_quad = 232 const cc::TextureDrawQuad* texture_quad =
240 cc::TextureDrawQuad::MaterialCast(draw_quad); 233 cc::TextureDrawQuad::MaterialCast(draw_quad);
241 EXPECT_FALSE(texture_quad->resource_size_in_pixels().IsEmpty()); 234 EXPECT_FALSE(texture_quad->resource_size_in_pixels().IsEmpty());
(...skipping 12 matching lines...) Expand all
254 247
255 TEST_F(SurfaceTest, Commit) { 248 TEST_F(SurfaceTest, Commit) {
256 std::unique_ptr<Surface> surface(new Surface); 249 std::unique_ptr<Surface> surface(new Surface);
257 250
258 // Calling commit without a buffer should succeed. 251 // Calling commit without a buffer should succeed.
259 surface->Commit(); 252 surface->Commit();
260 } 253 }
261 254
262 } // namespace 255 } // namespace
263 } // namespace exo 256 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/surface.cc ('k') | components/exo/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698