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

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

Issue 15435003: cc: Add CopyAsBitmapRequest class to hold the readback callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nolint Created 7 years, 7 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/test/layer_tree_pixel_test.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/base/scoped_ptr_vector.h"
9 #include "cc/output/copy_output_request.h"
8 #include "cc/quads/checkerboard_draw_quad.h" 10 #include "cc/quads/checkerboard_draw_quad.h"
9 #include "cc/test/geometry_test_utils.h" 11 #include "cc/test/geometry_test_utils.h"
10 #include "cc/test/render_pass_test_common.h" 12 #include "cc/test/render_pass_test_common.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations .h" 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations .h"
13 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 15 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
14 #include "ui/gfx/transform.h" 16 #include "ui/gfx/transform.h"
15 17
16 using cc::TestRenderPass; 18 using cc::TestRenderPass;
17 19
18 namespace cc { 20 namespace cc {
19 namespace { 21 namespace {
20 22
21 struct RenderPassSize { 23 struct RenderPassSize {
22 // If you add a new field to this class, make sure to add it to the 24 // If you add a new field to this class, make sure to add it to the
23 // Copy() tests. 25 // Copy() tests.
24 RenderPass::Id id; 26 RenderPass::Id id;
25 QuadList quad_list; 27 QuadList quad_list;
26 SharedQuadStateList shared_quad_state_list; 28 SharedQuadStateList shared_quad_state_list;
27 gfx::Transform transform_to_root_target; 29 gfx::Transform transform_to_root_target;
28 gfx::Rect output_rect; 30 gfx::Rect output_rect;
29 gfx::RectF damage_rect; 31 gfx::RectF damage_rect;
30 bool has_transparent_background; 32 bool has_transparent_background;
31 bool has_occlusion_from_outside_target_surface; 33 bool has_occlusion_from_outside_target_surface;
32 std::vector<RenderPass::RequestCopyAsBitmapCallback> copy_callbacks; 34 ScopedPtrVector<CopyOutputRequest> copy_callbacks;
33 }; 35 };
34 36
35 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { 37 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) {
36 RenderPass::Id id(3, 2); 38 RenderPass::Id id(3, 2);
37 gfx::Rect output_rect(45, 22, 120, 13); 39 gfx::Rect output_rect(45, 22, 120, 13);
38 gfx::Transform transform_to_root = 40 gfx::Transform transform_to_root =
39 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 41 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
40 gfx::Rect damage_rect(56, 123, 19, 43); 42 gfx::Rect damage_rect(56, 123, 19, 43);
41 bool has_transparent_background = true; 43 bool has_transparent_background = true;
42 bool has_occlusion_from_outside_target_surface = true; 44 bool has_occlusion_from_outside_target_surface = true;
43 45
44 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 46 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
45 pass->SetAll(id, 47 pass->SetAll(id,
46 output_rect, 48 output_rect,
47 damage_rect, 49 damage_rect,
48 transform_to_root, 50 transform_to_root,
49 has_transparent_background, 51 has_transparent_background,
50 has_occlusion_from_outside_target_surface); 52 has_occlusion_from_outside_target_surface);
51 pass->copy_callbacks.push_back(RenderPass::RequestCopyAsBitmapCallback()); 53 pass->copy_requests.push_back(CopyOutputRequest::CreateBitmapRequest(
54 CopyOutputRequest::CopyAsBitmapCallback()));
52 55
53 // Stick a quad in the pass, this should not get copied. 56 // Stick a quad in the pass, this should not get copied.
54 scoped_ptr<SharedQuadState> shared_state = SharedQuadState::Create(); 57 scoped_ptr<SharedQuadState> shared_state = SharedQuadState::Create();
55 shared_state->SetAll( 58 shared_state->SetAll(
56 gfx::Transform(), gfx::Size(), gfx::Rect(), gfx::Rect(), false, 1); 59 gfx::Transform(), gfx::Size(), gfx::Rect(), gfx::Rect(), false, 1);
57 pass->AppendSharedQuadState(shared_state.Pass()); 60 pass->AppendSharedQuadState(shared_state.Pass());
58 61
59 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = 62 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad =
60 CheckerboardDrawQuad::Create(); 63 CheckerboardDrawQuad::Create();
61 checkerboard_quad->SetNew( 64 checkerboard_quad->SetNew(
62 pass->shared_quad_state_list.back(), gfx::Rect(), SkColor()); 65 pass->shared_quad_state_list.back(), gfx::Rect(), SkColor());
63 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>()); 66 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>());
64 67
65 RenderPass::Id new_id(63, 4); 68 RenderPass::Id new_id(63, 4);
66 69
67 scoped_ptr<RenderPass> copy = pass->Copy(new_id); 70 scoped_ptr<RenderPass> copy = pass->Copy(new_id);
68 EXPECT_EQ(new_id, copy->id); 71 EXPECT_EQ(new_id, copy->id);
69 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect); 72 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect);
70 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); 73 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target);
71 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect); 74 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect);
72 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); 75 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background);
73 EXPECT_EQ(pass->has_occlusion_from_outside_target_surface, 76 EXPECT_EQ(pass->has_occlusion_from_outside_target_surface,
74 copy->has_occlusion_from_outside_target_surface); 77 copy->has_occlusion_from_outside_target_surface);
75 EXPECT_EQ(0u, copy->quad_list.size()); 78 EXPECT_EQ(0u, copy->quad_list.size());
76 79
77 // The copy callback should not be copied/duplicated. 80 // The copy request should not be copied/duplicated.
78 EXPECT_EQ(0u, copy->copy_callbacks.size()); 81 EXPECT_EQ(1u, pass->copy_requests.size());
82 EXPECT_EQ(0u, copy->copy_requests.size());
79 83
80 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); 84 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass));
81 } 85 }
82 86
83 } // namespace 87 } // namespace
84 } // namespace cc 88 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/render_pass.cc ('k') | cc/test/layer_tree_pixel_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698