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

Side by Side Diff: cc/layer_tree_host_perftest.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
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/layer_tree_host.h" 5 #include "cc/layer_tree_host.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void readTestFile(std::string name) { 78 void readTestFile(std::string name) {
79 test_name_ = name; 79 test_name_ = name;
80 base::FilePath test_data_dir; 80 base::FilePath test_data_dir;
81 ASSERT_TRUE(PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)); 81 ASSERT_TRUE(PathService::Get(cc::DIR_TEST_DATA, &test_data_dir));
82 base::FilePath json_file = test_data_dir.AppendASCII(name + ".json"); 82 base::FilePath json_file = test_data_dir.AppendASCII(name + ".json");
83 ASSERT_TRUE(file_util::ReadFileToString(json_file, &json_)); 83 ASSERT_TRUE(file_util::ReadFileToString(json_file, &json_));
84 } 84 }
85 85
86 virtual void buildTree() OVERRIDE { 86 virtual void buildTree() OVERRIDE {
87 gfx::Size viewport = gfx::Size(720, 1038); 87 gfx::Size viewport = gfx::Size(720, 1038);
88 m_layerTreeHost->setViewportSize(viewport, viewport); 88 layer_tree_host_->setViewportSize(viewport, viewport);
89 scoped_refptr<Layer> root = ParseTreeFromJson(json_, 89 scoped_refptr<Layer> root = ParseTreeFromJson(json_,
90 &fake_content_layer_client_); 90 &fake_content_layer_client_);
91 ASSERT_TRUE(root.get()); 91 ASSERT_TRUE(root.get());
92 m_layerTreeHost->setRootLayer(root); 92 layer_tree_host_->setRootLayer(root);
93 } 93 }
94 94
95 private: 95 private:
96 std::string json_; 96 std::string json_;
97 }; 97 };
98 98
99 // Simulates a tab switcher scene with two stacks of 10 tabs each. 99 // Simulates a tab switcher scene with two stacks of 10 tabs each.
100 TEST_F(LayerTreeHostPerfTestJsonReader, TenTenSingleThread) { 100 TEST_F(LayerTreeHostPerfTestJsonReader, TenTenSingleThread) {
101 readTestFile("10_10_layer_tree"); 101 readTestFile("10_10_layer_tree");
102 runTest(false); 102 runTest(false);
103 } 103 }
104 104
105 // Simulates main-thread scrolling on each frame. 105 // Simulates main-thread scrolling on each frame.
106 class ScrollingLayerTreePerfTest : public LayerTreeHostPerfTestJsonReader { 106 class ScrollingLayerTreePerfTest : public LayerTreeHostPerfTestJsonReader {
107 public: 107 public:
108 ScrollingLayerTreePerfTest() 108 ScrollingLayerTreePerfTest()
109 : LayerTreeHostPerfTestJsonReader() { 109 : LayerTreeHostPerfTestJsonReader() {
110 } 110 }
111 111
112 virtual void buildTree() OVERRIDE { 112 virtual void buildTree() OVERRIDE {
113 LayerTreeHostPerfTestJsonReader::buildTree(); 113 LayerTreeHostPerfTestJsonReader::buildTree();
114 m_scrollable = m_layerTreeHost->rootLayer()->children()[1]; 114 scrollable_ = layer_tree_host_->RootLayer()->Children()[1];
115 ASSERT_TRUE(m_scrollable); 115 ASSERT_TRUE(scrollable_);
116 } 116 }
117 117
118 virtual void layout() OVERRIDE { 118 virtual void layout() OVERRIDE {
119 static const gfx::Vector2d delta = gfx::Vector2d(0, 10); 119 static const gfx::Vector2d delta = gfx::Vector2d(0, 10);
120 m_scrollable->setScrollOffset(m_scrollable->scrollOffset() + delta); 120 scrollable_->SetScrollOffset(scrollable_->ScrollOffset() + delta);
121 } 121 }
122 122
123 private: 123 private:
124 scoped_refptr<Layer> m_scrollable; 124 scoped_refptr<Layer> scrollable_;
125 }; 125 };
126 126
127 TEST_F(ScrollingLayerTreePerfTest, LongScrollablePage) { 127 TEST_F(ScrollingLayerTreePerfTest, LongScrollablePage) {
128 readTestFile("long_scrollable_page"); 128 readTestFile("long_scrollable_page");
129 runTest(false); 129 runTest(false);
130 } 130 }
131 131
132 } // namespace 132 } // namespace
133 } // namespace cc 133 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698