Reland 6914 w/ fixes.



git-svn-id: http://skia.googlecode.com/svn/trunk@6916 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrBinHashKey.h b/src/gpu/GrBinHashKey.h
index d2194e9..8fa53ef 100644
--- a/src/gpu/GrBinHashKey.h
+++ b/src/gpu/GrBinHashKey.h
@@ -16,25 +16,27 @@
  *  Hash function class that can take a data chunk of any predetermined length. The hash function
  *  used is the One-at-a-Time Hash (http://burtleburtle.net/bob/hash/doobs.html).
  *
- *  Keys are computed from Entry objects. Entry must be fully ordered by a member:
- *      int compare(const GrTBinHashKey<Entry, ..>& k);
- *  which returns negative if the Entry < k, 0 if it equals k, and positive if k < the Entry.
- *  Additionally, Entry must be flattenable into the key using setKeyData.
+ *  Keys are computed from ENTRY objects. ENTRY must be fully ordered by a member:
+ *      int compare(const GrTBinHashKey<ENTRY, ..>& k);
+ *  which returns negative if the ENTRY < k, 0 if it equals k, and positive if k < the ENTRY.
+ *  Additionally, ENTRY must be flattenable into the key using setKeyData.
  *
  *  This class satisfies the requirements to be a key for a GrTHashTable.
  */
-template<typename Entry, size_t KeySize>
+template<typename ENTRY, size_t KEY_SIZE>
 class GrTBinHashKey {
 public:
+    enum { kKeySize = KEY_SIZE };
+
     GrTBinHashKey() {
         this->reset();
     }
 
-    GrTBinHashKey(const GrTBinHashKey<Entry, KeySize>& other) {
+    GrTBinHashKey(const GrTBinHashKey<ENTRY, KEY_SIZE>& other) {
         *this = other;
     }
 
-    GrTBinHashKey<Entry, KeySize>& operator=(const GrTBinHashKey<Entry, KeySize>& other) {
+    GrTBinHashKey<ENTRY, KEY_SIZE>& operator=(const GrTBinHashKey<ENTRY, KEY_SIZE>& other) {
         memcpy(this, &other, sizeof(*this));
         return *this;
     }
@@ -50,11 +52,11 @@
     }
 
     void setKeyData(const uint32_t* SK_RESTRICT data) {
-        GrAssert(GrIsALIGN4(KeySize));
-        memcpy(&fData, data, KeySize);
+        GrAssert(GrIsALIGN4(KEY_SIZE));
+        memcpy(&fData, data, KEY_SIZE);
 
         uint32_t hash = 0;
-        size_t len = KeySize;
+        size_t len = KEY_SIZE;
         while (len >= 4) {
             hash += *data++;
             hash += (fHash << 10);
@@ -70,17 +72,17 @@
         fHash = hash;
     }
 
-    int compare(const GrTBinHashKey<Entry, KeySize>& key) const {
+    int compare(const GrTBinHashKey<ENTRY, KEY_SIZE>& key) const {
         GrAssert(fIsValid && key.fIsValid);
-        return memcmp(fData, key.fData, KeySize);
+        return memcmp(fData, key.fData, KEY_SIZE);
     }
 
-    static bool EQ(const Entry& entry, const GrTBinHashKey<Entry, KeySize>& key) {
+    static bool EQ(const ENTRY& entry, const GrTBinHashKey<ENTRY, KEY_SIZE>& key) {
         GrAssert(key.fIsValid);
         return 0 == entry.compare(key);
     }
 
-    static bool LT(const Entry& entry, const GrTBinHashKey<Entry, KeySize>& key) {
+    static bool LT(const ENTRY& entry, const GrTBinHashKey<ENTRY, KEY_SIZE>& key) {
         GrAssert(key.fIsValid);
         return entry.compare(key) < 0;
     }
@@ -90,9 +92,14 @@
         return fHash;
     }
 
+    const uint8_t* getData() const {
+        GrAssert(fIsValid);
+        return fData;
+    }
+
 private:
     uint32_t            fHash;
-    uint8_t             fData[KeySize];  // Buffer for key storage
+    uint8_t             fData[KEY_SIZE];  // Buffer for key storage
 
 #if GR_DEBUG
 public: