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

Side by Side Diff: src/gpu/GrProgramDesc.h

Issue 2208903002: Use sse4.2 CRC32 instructions to hash when available. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 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
« no previous file with comments | « src/core/SkResourceCache.cpp ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrProgramDesc_DEFINED 8 #ifndef GrProgramDesc_DEFINED
9 #define GrProgramDesc_DEFINED 9 #define GrProgramDesc_DEFINED
10 10
11 #include "GrColor.h" 11 #include "GrColor.h"
12 #include "GrTypesPriv.h" 12 #include "GrTypesPriv.h"
13 #include "SkChecksum.h" 13 #include "SkOpts.h"
14 #include "SkTArray.h"
14 15
15 /** This class describes a program to generate. It also serves as a program cach e key. Very little 16 /** This class describes a program to generate. It also serves as a program cach e key. Very little
16 of this is GL-specific. The GL-specific parts could be factored out into a s ubclass. */ 17 of this is GL-specific. The GL-specific parts could be factored out into a s ubclass. */
17 class GrProgramDesc { 18 class GrProgramDesc {
18 public: 19 public:
19 // Creates an uninitialized key that must be populated by GrGpu::buildProgra mDesc() 20 // Creates an uninitialized key that must be populated by GrGpu::buildProgra mDesc()
20 GrProgramDesc() {} 21 GrProgramDesc() {}
21 22
22 // Returns this as a uint32_t array to be used as a key in the program cache . 23 // Returns this as a uint32_t array to be used as a key in the program cache .
23 const uint32_t* asKey() const { 24 const uint32_t* asKey() const {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin( )) + OFFSET); 106 return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin( )) + OFFSET);
106 } 107 }
107 108
108 void finalize() { 109 void finalize() {
109 int keyLength = fKey.count(); 110 int keyLength = fKey.count();
110 SkASSERT(0 == (keyLength % 4)); 111 SkASSERT(0 == (keyLength % 4));
111 *(this->atOffset<uint32_t, GrProgramDesc::kLengthOffset>()) = SkToU32(ke yLength); 112 *(this->atOffset<uint32_t, GrProgramDesc::kLengthOffset>()) = SkToU32(ke yLength);
112 113
113 uint32_t* checksum = this->atOffset<uint32_t, GrProgramDesc::kChecksumOf fset>(); 114 uint32_t* checksum = this->atOffset<uint32_t, GrProgramDesc::kChecksumOf fset>();
114 *checksum = 0; // We'll hash through these bytes, so make sure they're initialized. 115 *checksum = 0; // We'll hash through these bytes, so make sure they're initialized.
115 *checksum = SkChecksum::Murmur3(fKey.begin(), keyLength); 116 *checksum = SkOpts::hash(fKey.begin(), keyLength);
116 } 117 }
117 118
118 // The key, stored in fKey, is composed of four parts: 119 // The key, stored in fKey, is composed of four parts:
119 // 1. uint32_t for total key length. 120 // 1. uint32_t for total key length.
120 // 2. uint32_t for a checksum. 121 // 2. uint32_t for a checksum.
121 // 3. Header struct defined above. Also room for extensions to the header 122 // 3. Header struct defined above. Also room for extensions to the header
122 // 4. A Backend specific payload. Room is preallocated for this 123 // 4. A Backend specific payload. Room is preallocated for this
123 enum KeyOffsets { 124 enum KeyOffsets {
124 // Part 1. 125 // Part 1.
125 kLengthOffset = 0, 126 kLengthOffset = 0,
(...skipping 12 matching lines...) Expand all
138 }; 139 };
139 140
140 SkSTArray<kPreAllocSize, uint8_t, true>& key() { return fKey; } 141 SkSTArray<kPreAllocSize, uint8_t, true>& key() { return fKey; }
141 const SkSTArray<kPreAllocSize, uint8_t, true>& key() const { return fKey; } 142 const SkSTArray<kPreAllocSize, uint8_t, true>& key() const { return fKey; }
142 143
143 private: 144 private:
144 SkSTArray<kPreAllocSize, uint8_t, true> fKey; 145 SkSTArray<kPreAllocSize, uint8_t, true> fKey;
145 }; 146 };
146 147
147 #endif 148 #endif
OLDNEW
« no previous file with comments | « src/core/SkResourceCache.cpp ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698