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

Unified Diff: cc/tiles/picture_layer_tiling.h

Issue 1133243010: cc: Optimize the tile map key hash for 4-byte size_t. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years, 7 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 | « no previous file | cc/tiles/picture_layer_tiling.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/picture_layer_tiling.h
diff --git a/cc/tiles/picture_layer_tiling.h b/cc/tiles/picture_layer_tiling.h
index 8af4c4c9b3014054c1b5dcfc70bdcdabd9a2fb00..2077afc1c370d85a56369b8b9a0a0ac07541012b 100644
--- a/cc/tiles/picture_layer_tiling.h
+++ b/cc/tiles/picture_layer_tiling.h
@@ -52,6 +52,35 @@ class CC_EXPORT PictureLayerTilingClient {
virtual ~PictureLayerTilingClient() {}
};
+struct TileMapKey {
+ TileMapKey(int x, int y) : index_x(x), index_y(y) {}
+ explicit TileMapKey(const std::pair<int, int>& index)
+ : index_x(index.first), index_y(index.second) {}
+
+ bool operator==(const TileMapKey& other) const {
+ return index_x == other.index_x && index_y == other.index_y;
+ }
+
+ int index_x;
+ int index_y;
+};
+
+} // namespace cc
+
+namespace BASE_HASH_NAMESPACE {
+template <>
+struct hash<cc::TileMapKey> {
+ size_t operator()(const cc::TileMapKey& key) const {
+ uint16 value1 = static_cast<uint16>(key.index_x);
+ uint16 value2 = static_cast<uint16>(key.index_y);
+ uint32 value1_32 = value1;
+ return (value1_32 << 16) | value2;
+ }
+};
+} // namespace BASE_HASH_NAMESPACE
+
+namespace cc {
+
class CC_EXPORT PictureLayerTiling {
public:
static const int kBorderTexels = 1;
@@ -225,7 +254,6 @@ class CC_EXPORT PictureLayerTiling {
EVENTUALLY_RECT
};
- using TileMapKey = std::pair<int, int>;
using TileMap = base::ScopedPtrHashMap<TileMapKey, ScopedTilePtr>;
struct FrameVisibleRect {
« no previous file with comments | « no previous file | cc/tiles/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698