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

Side by Side Diff: cc/quads/render_pass.h

Issue 21648002: Extract pair hash functions so that they can be re-used outside of hash tables (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix RenderPass::ID hash Created 7 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 | Annotate | Revision Log
« no previous file with comments | « base/containers/hash_tables.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #ifndef CC_QUADS_RENDER_PASS_H_ 5 #ifndef CC_QUADS_RENDER_PASS_H_
6 #define CC_QUADS_RENDER_PASS_H_ 6 #define CC_QUADS_RENDER_PASS_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 RenderPass(); 110 RenderPass();
111 111
112 private: 112 private:
113 DISALLOW_COPY_AND_ASSIGN(RenderPass); 113 DISALLOW_COPY_AND_ASSIGN(RenderPass);
114 }; 114 };
115 115
116 } // namespace cc 116 } // namespace cc
117 117
118 namespace BASE_HASH_NAMESPACE { 118 namespace BASE_HASH_NAMESPACE {
119 #if defined(COMPILER_MSVC) 119 #if defined(COMPILER_MSVC)
120 template<> 120 inline size_t hash_value(const cc::RenderPass::Id& key) {
121 inline size_t hash_value<cc::RenderPass::Id>(const cc::RenderPass::Id& key) { 121 return base::HashPair(key.layer_id, key.index);
122 return hash_value<std::pair<int, int> >(
123 std::pair<int, int>(key.layer_id, key.index));
124 } 122 }
125 #elif defined(COMPILER_GCC) 123 #elif defined(COMPILER_GCC)
126 template<> 124 template<>
127 struct hash<cc::RenderPass::Id> { 125 struct hash<cc::RenderPass::Id> {
128 size_t operator()(cc::RenderPass::Id key) const { 126 size_t operator()(cc::RenderPass::Id key) const {
129 return hash<std::pair<int, int> >()( 127 return base::HashPair(key.layer_id, key.index);
130 std::pair<int, int>(key.layer_id, key.index));
131 } 128 }
132 }; 129 };
133 #else 130 #else
134 #error define a hash function for your compiler 131 #error define a hash function for your compiler
135 #endif // COMPILER 132 #endif // COMPILER
136 } // namespace BASE_HASH_NAMESPACE 133 } // namespace BASE_HASH_NAMESPACE
137 134
138 namespace cc { 135 namespace cc {
139 typedef ScopedPtrVector<RenderPass> RenderPassList; 136 typedef ScopedPtrVector<RenderPass> RenderPassList;
140 typedef base::hash_map<RenderPass::Id, RenderPass*> RenderPassIdHashMap; 137 typedef base::hash_map<RenderPass::Id, RenderPass*> RenderPassIdHashMap;
141 } // namespace cc 138 } // namespace cc
142 139
143 #endif // CC_QUADS_RENDER_PASS_H_ 140 #endif // CC_QUADS_RENDER_PASS_H_
OLDNEW
« no previous file with comments | « base/containers/hash_tables.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698