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

Side by Side Diff: cc/debug/picture_record_benchmark.cc

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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/debug/picture_record_benchmark.h" 5 #include "cc/debug/picture_record_benchmark.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "cc/layers/layer.h" 11 #include "cc/layers/layer.h"
12 #include "cc/layers/picture_layer.h" 12 #include "cc/layers/picture_layer.h"
13 #include "cc/resources/picture.h" 13 #include "cc/resources/picture.h"
14 #include "cc/trees/layer_tree_host.h" 14 #include "cc/trees/layer_tree_host.h"
15 #include "cc/trees/layer_tree_host_common.h" 15 #include "cc/trees/layer_tree_host_common.h"
16 #include "third_party/skia/include/core/SkBBHFactory.h"
17 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
18 17
19 namespace cc { 18 namespace cc {
20 19
21 namespace { 20 namespace {
22 21
23 const int kPositionIncrement = 100; 22 const int kPositionIncrement = 100;
24 const int kTileGridSize = 512; 23 const int kTileGridSize = 512;
25 const int kTileGridBorder = 1;
26 24
27 } // namespace 25 } // namespace
28 26
29 PictureRecordBenchmark::PictureRecordBenchmark( 27 PictureRecordBenchmark::PictureRecordBenchmark(
30 scoped_ptr<base::Value> value, 28 scoped_ptr<base::Value> value,
31 const MicroBenchmark::DoneCallback& callback) 29 const MicroBenchmark::DoneCallback& callback)
32 : MicroBenchmark(callback) { 30 : MicroBenchmark(callback) {
33 if (!value) 31 if (!value)
34 return; 32 return;
35 33
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 84 }
87 85
88 void PictureRecordBenchmark::Run(Layer* layer) { 86 void PictureRecordBenchmark::Run(Layer* layer) {
89 layer->RunMicroBenchmark(this); 87 layer->RunMicroBenchmark(this);
90 } 88 }
91 89
92 void PictureRecordBenchmark::RunOnLayer(PictureLayer* layer) { 90 void PictureRecordBenchmark::RunOnLayer(PictureLayer* layer) {
93 ContentLayerClient* painter = layer->client(); 91 ContentLayerClient* painter = layer->client();
94 gfx::Size content_bounds = layer->content_bounds(); 92 gfx::Size content_bounds = layer->content_bounds();
95 93
96 SkTileGridFactory::TileGridInfo tile_grid_info; 94 gfx::Size tile_grid_size(kTileGridSize, kTileGridSize);
97 tile_grid_info.fTileInterval.set(kTileGridSize - 2 * kTileGridBorder,
98 kTileGridSize - 2 * kTileGridBorder);
99 tile_grid_info.fMargin.set(kTileGridBorder, kTileGridBorder);
100 tile_grid_info.fOffset.set(-kTileGridBorder, -kTileGridBorder);
101 95
102 for (size_t i = 0; i < dimensions_.size(); ++i) { 96 for (size_t i = 0; i < dimensions_.size(); ++i) {
103 std::pair<int, int> dimensions = dimensions_[i]; 97 std::pair<int, int> dimensions = dimensions_[i];
104 int width = dimensions.first; 98 int width = dimensions.first;
105 int height = dimensions.second; 99 int height = dimensions.second;
106 100
107 int y_limit = std::max(1, content_bounds.height() - height); 101 int y_limit = std::max(1, content_bounds.height() - height);
108 int x_limit = std::max(1, content_bounds.width() - width); 102 int x_limit = std::max(1, content_bounds.width() - width);
109 for (int y = 0; y < y_limit; y += kPositionIncrement) { 103 for (int y = 0; y < y_limit; y += kPositionIncrement) {
110 for (int x = 0; x < x_limit; x += kPositionIncrement) { 104 for (int x = 0; x < x_limit; x += kPositionIncrement) {
111 gfx::Rect rect = gfx::Rect(x, y, width, height); 105 gfx::Rect rect = gfx::Rect(x, y, width, height);
112 106
113 base::TimeTicks start = base::TimeTicks::HighResNow(); 107 base::TimeTicks start = base::TimeTicks::HighResNow();
114 108
115 scoped_refptr<Picture> picture = Picture::Create( 109 scoped_refptr<Picture> picture = Picture::Create(
116 rect, painter, tile_grid_info, false, Picture::RECORD_NORMALLY); 110 rect, painter, tile_grid_size, false, Picture::RECORD_NORMALLY);
117 111
118 base::TimeTicks end = base::TimeTicks::HighResNow(); 112 base::TimeTicks end = base::TimeTicks::HighResNow();
119 base::TimeDelta duration = end - start; 113 base::TimeDelta duration = end - start;
120 TotalTime& total_time = times_[dimensions]; 114 TotalTime& total_time = times_[dimensions];
121 total_time.first += duration; 115 total_time.first += duration;
122 total_time.second++; 116 total_time.second++;
123 } 117 }
124 } 118 }
125 } 119 }
126 } 120 }
127 121
128 } // namespace cc 122 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698