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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/pixel_ref_map.h
diff --git a/cc/resources/pixel_ref_map.h b/cc/resources/pixel_ref_map.h
new file mode 100644
index 0000000000000000000000000000000000000000..fbc8953b58b479300304cf2173979cfaa693e7bd
--- /dev/null
+++ b/cc/resources/pixel_ref_map.h
@@ -0,0 +1,85 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_RESOURCES_PIXEL_REF_MAP_H_
+#define CC_RESOURCES_PIXEL_REF_MAP_H_
+
+#include <utility>
+#include <vector>
+
+#include "base/containers/hash_tables.h"
+#include "base/lazy_instance.h"
+#include "base/memory/ref_counted.h"
+#include "cc/base/cc_export.h"
+#include "third_party/skia/include/core/SkPicture.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
+
+class SkPixelRef;
+
+namespace cc {
+
+class Picture;
+
+typedef std::pair<int, int> PixelRefMapKey;
+typedef std::vector<SkPixelRef*> PixelRefs;
+
+// This class is used and owned by cc Picture class. It is used to gather pixel
+// refs which would happen after record. It takes in |cell_size| to decide how
+// big each grid cell should be.
+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
+ public:
+ explicit PixelRefMap(const gfx::Size& cell_size);
+ ~PixelRefMap();
+ void GatherPixelRefsFromPicture(SkPicture* picture);
+
+ private:
+ gfx::Point min_pixel_cell_;
+ gfx::Point max_pixel_cell_;
+ gfx::Size cell_size_;
+
+ friend class PixelRefMapIterator;
+};
+
+// This iterator imprecisely returns the set of pixel refs that are needed to
+// raster this layer rect from this picture. Internally, pixel refs are
+// clumped into tile grid buckets, so there may be false positives.
+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
+ public:
+ // Default iterator constructor that is used as place holder for invalid
+ // PixelRefMapIterator.
+ PixelRefMapIterator();
+ PixelRefMapIterator(const gfx::Rect& layer_rect, const Picture* picture);
+ ~PixelRefMapIterator();
+
+ SkPixelRef* operator->() const {
+ DCHECK_LT(current_index_, current_pixel_refs_->size());
+ return (*current_pixel_refs_)[current_index_];
+ }
+
+ SkPixelRef* operator*() const {
+ DCHECK_LT(current_index_, current_pixel_refs_->size());
+ return (*current_pixel_refs_)[current_index_];
+ }
+
+ PixelRefMapIterator& operator++();
+ operator bool() const { return current_index_ < current_pixel_refs_->size(); }
+
+ private:
+ static base::LazyInstance<PixelRefs> empty_pixel_refs_;
+ const PixelRefMap* map_;
+ const PixelRefs* current_pixel_refs_;
+ unsigned current_index_;
+
+ gfx::Rect layer_rect_;
+
+ gfx::Point min_point_;
+ gfx::Point max_point_;
+ int current_x_;
+ int current_y_;
+};
+
+} // namespace cc
+
+#endif // CC_RESOURCES_PIXEL_REF_MAP_H_
« 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