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

Side by Side Diff: cc/playback/pixel_ref_map.cc

Issue 1279843004: cc: Plumb more details about pixel refs to tile manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « cc/playback/pixel_ref_map.h ('k') | cc/playback/pixel_ref_map_unittest.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/playback/pixel_ref_map.h" 5 #include "cc/playback/pixel_ref_map.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
11 #include "cc/playback/display_item_list.h" 11 #include "cc/playback/display_item_list.h"
12 #include "cc/playback/picture.h" 12 #include "cc/playback/picture.h"
13 #include "skia/ext/pixel_ref_utils.h" 13 #include "skia/ext/pixel_ref_utils.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 PixelRefMap::PixelRefMap(const gfx::Size& cell_size) : cell_size_(cell_size) { 17 PixelRefMap::PixelRefMap(const gfx::Size& cell_size) : cell_size_(cell_size) {
18 DCHECK(!cell_size.IsEmpty()); 18 DCHECK(!cell_size.IsEmpty());
19 } 19 }
20 20
21 PixelRefMap::~PixelRefMap() { 21 PixelRefMap::~PixelRefMap() {
22 } 22 }
23 23
24 void PixelRefMap::GatherPixelRefsFromPicture(SkPicture* picture) { 24 void PixelRefMap::GatherPixelRefsFromPicture(SkPicture* picture,
25 const gfx::Rect& layer_rect) {
25 DCHECK(picture); 26 DCHECK(picture);
26 27
27 int min_x = std::numeric_limits<int>::max(); 28 int min_x = std::numeric_limits<int>::max();
28 int min_y = std::numeric_limits<int>::max(); 29 int min_y = std::numeric_limits<int>::max();
29 int max_x = 0; 30 int max_x = 0;
30 int max_y = 0; 31 int max_y = 0;
31 32
32 skia::DiscardablePixelRefList pixel_refs; 33 skia::DiscardablePixelRefList pixel_refs;
33 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture, &pixel_refs); 34 skia::PixelRefUtils::GatherDiscardablePixelRefs(picture, &pixel_refs);
34 for (skia::DiscardablePixelRefList::const_iterator it = pixel_refs.begin(); 35 for (skia::DiscardablePixelRefList::const_iterator it = pixel_refs.begin();
35 it != pixel_refs.end(); ++it) { 36 it != pixel_refs.end(); ++it) {
36 gfx::Point min( 37 gfx::Point min(
37 MathUtil::UncheckedRoundDown(static_cast<int>(it->pixel_ref_rect.x()), 38 MathUtil::UncheckedRoundDown(static_cast<int>(it->pixel_ref_rect.x()),
38 cell_size_.width()), 39 cell_size_.width()),
39 MathUtil::UncheckedRoundDown(static_cast<int>(it->pixel_ref_rect.y()), 40 MathUtil::UncheckedRoundDown(static_cast<int>(it->pixel_ref_rect.y()),
40 cell_size_.height())); 41 cell_size_.height()));
41 gfx::Point max(MathUtil::UncheckedRoundDown( 42 gfx::Point max(MathUtil::UncheckedRoundDown(
42 static_cast<int>(std::ceil(it->pixel_ref_rect.right())), 43 static_cast<int>(std::ceil(it->pixel_ref_rect.right())),
43 cell_size_.width()), 44 cell_size_.width()),
44 MathUtil::UncheckedRoundDown( 45 MathUtil::UncheckedRoundDown(
45 static_cast<int>(std::ceil(it->pixel_ref_rect.bottom())), 46 static_cast<int>(std::ceil(it->pixel_ref_rect.bottom())),
46 cell_size_.height())); 47 cell_size_.height()));
47 48
49 // We recorded the picture as if it was at (0, 0) by translating by layer
50 // rect origin. Add the rect origin back here. It really doesn't make much
51 // of a difference, since the query for pixel refs doesn't use this
52 // information. However, since picture pile / display list also returns this
53 // information, it would be nice to express it relative to the layer, not
54 // relative to the particular implementation of the raster source.
55 skia::PositionPixelRef position_pixel_ref = *it;
56 position_pixel_ref.pixel_ref_rect.setXYWH(
57 position_pixel_ref.pixel_ref_rect.x() + layer_rect.x(),
58 position_pixel_ref.pixel_ref_rect.y() + layer_rect.y(),
59 position_pixel_ref.pixel_ref_rect.width(),
60 position_pixel_ref.pixel_ref_rect.height());
61
48 for (int y = min.y(); y <= max.y(); y += cell_size_.height()) { 62 for (int y = min.y(); y <= max.y(); y += cell_size_.height()) {
49 for (int x = min.x(); x <= max.x(); x += cell_size_.width()) { 63 for (int x = min.x(); x <= max.x(); x += cell_size_.width()) {
50 PixelRefMapKey key(x, y); 64 PixelRefMapKey key(x, y);
51 data_hash_map_[key].push_back(it->pixel_ref); 65 data_hash_map_[key].push_back(position_pixel_ref);
52 } 66 }
53 } 67 }
54 68
55 min_x = std::min(min_x, min.x()); 69 min_x = std::min(min_x, min.x());
56 min_y = std::min(min_y, min.y()); 70 min_y = std::min(min_y, min.y());
57 max_x = std::max(max_x, max.x()); 71 max_x = std::max(max_x, max.x());
58 max_y = std::max(max_y, max.y()); 72 max_y = std::max(max_y, max.y());
59 } 73 }
60 74
61 min_pixel_cell_ = gfx::Point(min_x, min_y); 75 min_pixel_cell_ = gfx::Point(min_x, min_y);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 181
168 // Make the current x be cell_size.width() less than min point, so that 182 // Make the current x be cell_size.width() less than min point, so that
169 // the first increment will point at min_point_. 183 // the first increment will point at min_point_.
170 current_x_ = min_point_.x() - cell_size.width(); 184 current_x_ = min_point_.x() - cell_size.width();
171 current_y_ = min_point_.y(); 185 current_y_ = min_point_.y();
172 if (current_y_ <= max_point_.y()) 186 if (current_y_ <= max_point_.y())
173 ++(*this); 187 ++(*this);
174 } 188 }
175 189
176 } // namespace cc 190 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/pixel_ref_map.h ('k') | cc/playback/pixel_ref_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698