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

Side by Side Diff: cc/test/layer_tree_pixel_test.cc

Issue 15004009: cc: Fix readback from non-root layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/test/layer_tree_pixel_test.h ('k') | cc/test/pixel_test.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/layer_tree_pixel_test.h" 5 #include "cc/test/layer_tree_pixel_test.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "cc/test/paths.h" 8 #include "cc/test/paths.h"
9 #include "cc/test/pixel_comparator.h" 9 #include "cc/test/pixel_comparator.h"
10 #include "cc/test/pixel_test_utils.h" 10 #include "cc/test/pixel_test_utils.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // To rebaseline: 56 // To rebaseline:
57 // EXPECT_TRUE(WritePNGFile(*bitmap, test_data_dir.Append(ref_file_), true)); 57 // EXPECT_TRUE(WritePNGFile(*bitmap, test_data_dir.Append(ref_file_), true));
58 58
59 EXPECT_TRUE(MatchesPNGFile(*bitmap, 59 EXPECT_TRUE(MatchesPNGFile(*bitmap,
60 test_data_dir.Append(ref_file_), 60 test_data_dir.Append(ref_file_),
61 *pixel_comparator_)); 61 *pixel_comparator_));
62 EndTest(); 62 EndTest();
63 } 63 }
64 64
65 void LayerTreePixelTest::BeginTest() { 65 void LayerTreePixelTest::BeginTest() {
66 layer_tree_host()->root_layer()->RequestCopyAsBitmap( 66 Layer* target = readback_target_ ? readback_target_
67 : layer_tree_host()->root_layer();
68 target->RequestCopyAsBitmap(
67 base::Bind(&LayerTreePixelTest::ReadbackResult, 69 base::Bind(&LayerTreePixelTest::ReadbackResult,
68 base::Unretained(this))); 70 base::Unretained(this)));
69 PostSetNeedsCommitToMainThread(); 71 PostSetNeedsCommitToMainThread();
70 } 72 }
71 73
72 void LayerTreePixelTest::AfterTest() {} 74 void LayerTreePixelTest::AfterTest() {}
73 75
74 scoped_refptr<SolidColorLayer> LayerTreePixelTest::CreateSolidColorLayer( 76 scoped_refptr<SolidColorLayer> LayerTreePixelTest::CreateSolidColorLayer(
75 gfx::Rect rect, SkColor color) { 77 gfx::Rect rect, SkColor color) {
76 scoped_refptr<SolidColorLayer> layer = SolidColorLayer::Create(); 78 scoped_refptr<SolidColorLayer> layer = SolidColorLayer::Create();
(...skipping 30 matching lines...) Expand all
107 layer->AddChild(border_left); 109 layer->AddChild(border_left);
108 layer->AddChild(border_right); 110 layer->AddChild(border_right);
109 layer->AddChild(border_bottom); 111 layer->AddChild(border_bottom);
110 return layer; 112 return layer;
111 } 113 }
112 114
113 void LayerTreePixelTest::RunPixelTest( 115 void LayerTreePixelTest::RunPixelTest(
114 scoped_refptr<Layer> content_root, 116 scoped_refptr<Layer> content_root,
115 base::FilePath file_name) { 117 base::FilePath file_name) {
116 content_root_ = content_root; 118 content_root_ = content_root;
119 readback_target_ = NULL;
117 ref_file_ = file_name; 120 ref_file_ = file_name;
118 RunTest(true); 121 RunTest(true);
119 } 122 }
123
124 void LayerTreePixelTest::RunPixelTestWithReadbackTarget(
125 scoped_refptr<Layer> content_root,
126 Layer* target,
127 base::FilePath file_name) {
128 content_root_ = content_root;
129 readback_target_ = target;
130 ref_file_ = file_name;
131 RunTest(true);
132 }
120 133
121 void LayerTreePixelTest::SetupTree() { 134 void LayerTreePixelTest::SetupTree() {
122 scoped_refptr<Layer> root = Layer::Create(); 135 scoped_refptr<Layer> root = Layer::Create();
123 root->SetBounds(content_root_->bounds()); 136 root->SetBounds(content_root_->bounds());
124 root->AddChild(content_root_); 137 root->AddChild(content_root_);
125 layer_tree_host()->SetRootLayer(root); 138 layer_tree_host()->SetRootLayer(root);
126 LayerTreeTest::SetupTree(); 139 LayerTreeTest::SetupTree();
127 } 140 }
128 141
129 } // namespace cc 142 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_pixel_test.h ('k') | cc/test/pixel_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698