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

Side by Side Diff: cc/resources/pixel_ref_map.h

Issue 909353002: Move PixelRefMap and its Iterator out from Picture class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 5 years, 10 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/resources/picture_unittest.cc ('k') | cc/resources/pixel_ref_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_RESOURCES_PIXEL_REF_MAP_H_
6 #define CC_RESOURCES_PIXEL_REF_MAP_H_
7
8 #include <utility>
9 #include <vector>
10
11 #include "base/containers/hash_tables.h"
12 #include "base/lazy_instance.h"
13 #include "base/memory/ref_counted.h"
14 #include "cc/base/cc_export.h"
15 #include "third_party/skia/include/core/SkPicture.h"
16 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/geometry/size.h"
18
19 class SkPixelRef;
20
21 namespace cc {
22
23 class Picture;
24
25 typedef std::pair<int, int> PixelRefMapKey;
26 typedef std::vector<SkPixelRef*> PixelRefs;
27
28 // This class is used and owned by cc Picture class. It is used to gather pixel
29 // refs which would happen after record. It takes in |cell_size| to decide how
30 // big each grid cell should be.
31 class CC_EXPORT PixelRefMap : public base::hash_map<PixelRefMapKey, PixelRefs> {
vmpstr 2015/03/05 19:31:44 I find this kinda iffy. Is it difficult to have a
weiliangc 2015/03/09 18:50:21 Accessing hash_map is way less often than I expect
32 public:
33 explicit PixelRefMap(const gfx::Size& cell_size);
34 ~PixelRefMap();
35 void GatherPixelRefsFromPicture(SkPicture* picture);
36
37 private:
38 gfx::Point min_pixel_cell_;
39 gfx::Point max_pixel_cell_;
40 gfx::Size cell_size_;
41
42 friend class PixelRefMapIterator;
43 };
44
45 // This iterator imprecisely returns the set of pixel refs that are needed to
46 // raster this layer rect from this picture. Internally, pixel refs are
47 // clumped into tile grid buckets, so there may be false positives.
48 class CC_EXPORT PixelRefMapIterator {
vmpstr 2015/03/05 19:31:44 This can also be PixelRefMap::Iterator, which migh
weiliangc 2015/03/09 18:50:21 Moved to PixelRefMap::Iterator. Before when Pixel
49 public:
50 // Default iterator constructor that is used as place holder for invalid
51 // PixelRefMapIterator.
52 PixelRefMapIterator();
53 PixelRefMapIterator(const gfx::Rect& layer_rect, const Picture* picture);
54 ~PixelRefMapIterator();
55
56 SkPixelRef* operator->() const {
57 DCHECK_LT(current_index_, current_pixel_refs_->size());
58 return (*current_pixel_refs_)[current_index_];
59 }
60
61 SkPixelRef* operator*() const {
62 DCHECK_LT(current_index_, current_pixel_refs_->size());
63 return (*current_pixel_refs_)[current_index_];
64 }
65
66 PixelRefMapIterator& operator++();
67 operator bool() const { return current_index_ < current_pixel_refs_->size(); }
68
69 private:
70 static base::LazyInstance<PixelRefs> empty_pixel_refs_;
71 const PixelRefMap* map_;
72 const PixelRefs* current_pixel_refs_;
73 unsigned current_index_;
74
75 gfx::Rect layer_rect_;
76
77 gfx::Point min_point_;
78 gfx::Point max_point_;
79 int current_x_;
80 int current_y_;
81 };
82
83 } // namespace cc
84
85 #endif // CC_RESOURCES_PIXEL_REF_MAP_H_
OLDNEW
« no previous file with comments | « cc/resources/picture_unittest.cc ('k') | cc/resources/pixel_ref_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698