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

Side by Side Diff: cc/quads/render_pass_unittest.cc

Issue 14060015: cc: Async readback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « cc/quads/render_pass.cc ('k') | cc/resources/resource_provider.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/quads/render_pass.h" 5 #include "cc/quads/render_pass.h"
6 6
7 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/quads/checkerboard_draw_quad.h" 8 #include "cc/quads/checkerboard_draw_quad.h"
9 #include "cc/test/geometry_test_utils.h" 9 #include "cc/test/geometry_test_utils.h"
10 #include "cc/test/render_pass_test_common.h" 10 #include "cc/test/render_pass_test_common.h"
(...skipping 11 matching lines...) Expand all
22 // If you add a new field to this class, make sure to add it to the 22 // If you add a new field to this class, make sure to add it to the
23 // Copy() tests. 23 // Copy() tests.
24 RenderPass::Id id; 24 RenderPass::Id id;
25 QuadList quad_list; 25 QuadList quad_list;
26 SharedQuadStateList shared_quad_state_list; 26 SharedQuadStateList shared_quad_state_list;
27 gfx::Transform transform_to_root_target; 27 gfx::Transform transform_to_root_target;
28 gfx::Rect output_rect; 28 gfx::Rect output_rect;
29 gfx::RectF damage_rect; 29 gfx::RectF damage_rect;
30 bool has_transparent_background; 30 bool has_transparent_background;
31 bool has_occlusion_from_outside_target_surface; 31 bool has_occlusion_from_outside_target_surface;
32 std::vector<RenderPass::RequestCopyAsBitmapCallback> copy_callbacks;
32 }; 33 };
33 34
34 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { 35 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) {
35 RenderPass::Id id(3, 2); 36 RenderPass::Id id(3, 2);
36 gfx::Rect output_rect(45, 22, 120, 13); 37 gfx::Rect output_rect(45, 22, 120, 13);
37 gfx::Transform transform_to_root = 38 gfx::Transform transform_to_root =
38 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 39 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
39 gfx::Rect damage_rect(56, 123, 19, 43); 40 gfx::Rect damage_rect(56, 123, 19, 43);
40 bool has_transparent_background = true; 41 bool has_transparent_background = true;
41 bool has_occlusion_from_outside_target_surface = true; 42 bool has_occlusion_from_outside_target_surface = true;
42 43
43 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 44 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
44 pass->SetAll(id, 45 pass->SetAll(id,
45 output_rect, 46 output_rect,
46 damage_rect, 47 damage_rect,
47 transform_to_root, 48 transform_to_root,
48 has_transparent_background, 49 has_transparent_background,
49 has_occlusion_from_outside_target_surface); 50 has_occlusion_from_outside_target_surface);
51 pass->copy_callbacks.push_back(RenderPass::RequestCopyAsBitmapCallback());
50 52
51 // Stick a quad in the pass, this should not get copied. 53 // Stick a quad in the pass, this should not get copied.
52 scoped_ptr<SharedQuadState> shared_state = SharedQuadState::Create(); 54 scoped_ptr<SharedQuadState> shared_state = SharedQuadState::Create();
53 shared_state->SetAll( 55 shared_state->SetAll(
54 gfx::Transform(), gfx::Size(), gfx::Rect(), gfx::Rect(), false, 1); 56 gfx::Transform(), gfx::Size(), gfx::Rect(), gfx::Rect(), false, 1);
55 pass->AppendSharedQuadState(shared_state.Pass()); 57 pass->AppendSharedQuadState(shared_state.Pass());
56 58
57 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = 59 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad =
58 CheckerboardDrawQuad::Create(); 60 CheckerboardDrawQuad::Create();
59 checkerboard_quad->SetNew( 61 checkerboard_quad->SetNew(
60 pass->shared_quad_state_list.back(), gfx::Rect(), SkColor()); 62 pass->shared_quad_state_list.back(), gfx::Rect(), SkColor());
61 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>()); 63 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>());
62 64
63 RenderPass::Id new_id(63, 4); 65 RenderPass::Id new_id(63, 4);
64 66
65 scoped_ptr<RenderPass> copy = pass->Copy(new_id); 67 scoped_ptr<RenderPass> copy = pass->Copy(new_id);
66 EXPECT_EQ(new_id, copy->id); 68 EXPECT_EQ(new_id, copy->id);
67 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect); 69 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect);
68 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); 70 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target);
69 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect); 71 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect);
70 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); 72 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background);
71 EXPECT_EQ(pass->has_occlusion_from_outside_target_surface, 73 EXPECT_EQ(pass->has_occlusion_from_outside_target_surface,
72 copy->has_occlusion_from_outside_target_surface); 74 copy->has_occlusion_from_outside_target_surface);
73 EXPECT_EQ(0u, copy->quad_list.size()); 75 EXPECT_EQ(0u, copy->quad_list.size());
74 76
77 // The copy callback should not be copied/duplicated.
78 EXPECT_EQ(0u, copy->copy_callbacks.size());
79
75 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); 80 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass));
76 } 81 }
77 82
78 } // namespace 83 } // namespace
79 } // namespace cc 84 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/render_pass.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698