| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrGLProgramDesc_DEFINED | 8 #ifndef GrGLProgramDesc_DEFINED |
| 9 #define GrGLProgramDesc_DEFINED | 9 #define GrGLProgramDesc_DEFINED |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 of this is GL-specific. There is the generation of GrGLEffect::EffectKeys an
d the dst-read part | 23 of this is GL-specific. There is the generation of GrGLEffect::EffectKeys an
d the dst-read part |
| 24 of the key set by GrGLShaderBuilder. If the interfaces that set those portio
ns were abstracted | 24 of the key set by GrGLShaderBuilder. If the interfaces that set those portio
ns were abstracted |
| 25 to be API-neutral then so could this class. */ | 25 to be API-neutral then so could this class. */ |
| 26 class GrGLProgramDesc { | 26 class GrGLProgramDesc { |
| 27 public: | 27 public: |
| 28 GrGLProgramDesc() : fInitialized(false) {} | 28 GrGLProgramDesc() : fInitialized(false) {} |
| 29 GrGLProgramDesc(const GrGLProgramDesc& desc) { *this = desc; } | 29 GrGLProgramDesc(const GrGLProgramDesc& desc) { *this = desc; } |
| 30 | 30 |
| 31 // Returns this as a uint32_t array to be used as a key in the program cache
. | 31 // Returns this as a uint32_t array to be used as a key in the program cache
. |
| 32 const uint32_t* asKey() const { | 32 const uint32_t* asKey() const { |
| 33 GrAssert(fInitialized); | 33 SkASSERT(fInitialized); |
| 34 return reinterpret_cast<const uint32_t*>(fKey.get()); | 34 return reinterpret_cast<const uint32_t*>(fKey.get()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Gets the number of bytes in asKey(). It will be a 4-byte aligned value. W
hen comparing two | 37 // Gets the number of bytes in asKey(). It will be a 4-byte aligned value. W
hen comparing two |
| 38 // keys the size of either key can be used with memcmp() since the lengths t
hemselves begin the | 38 // keys the size of either key can be used with memcmp() since the lengths t
hemselves begin the |
| 39 // keys and thus the memcmp will exit early if the keys are of different len
gths. | 39 // keys and thus the memcmp will exit early if the keys are of different len
gths. |
| 40 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset>
(); } | 40 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset>
(); } |
| 41 | 41 |
| 42 // Gets the a checksum of the key. Can be used as a hash value for a fast lo
okup in a cache. | 42 // Gets the a checksum of the key. Can be used as a hash value for a fast lo
okup in a cache. |
| 43 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff
set>(); } | 43 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff
set>(); } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 64 GrDrawState::BlendOptFlags, | 64 GrDrawState::BlendOptFlags, |
| 65 GrBlendCoeff srcCoeff, | 65 GrBlendCoeff srcCoeff, |
| 66 GrBlendCoeff dstCoeff, | 66 GrBlendCoeff dstCoeff, |
| 67 const GrGpuGL* gpu, | 67 const GrGpuGL* gpu, |
| 68 const GrDeviceCoordTexture* dstCopy, | 68 const GrDeviceCoordTexture* dstCopy, |
| 69 SkTArray<const GrEffectStage*, true>* outColorStages, | 69 SkTArray<const GrEffectStage*, true>* outColorStages, |
| 70 SkTArray<const GrEffectStage*, true>* outCoverageStages, | 70 SkTArray<const GrEffectStage*, true>* outCoverageStages, |
| 71 GrGLProgramDesc* outDesc); | 71 GrGLProgramDesc* outDesc); |
| 72 | 72 |
| 73 int numColorEffects() const { | 73 int numColorEffects() const { |
| 74 GrAssert(fInitialized); | 74 SkASSERT(fInitialized); |
| 75 return this->getHeader().fColorEffectCnt; | 75 return this->getHeader().fColorEffectCnt; |
| 76 } | 76 } |
| 77 | 77 |
| 78 int numCoverageEffects() const { | 78 int numCoverageEffects() const { |
| 79 GrAssert(fInitialized); | 79 SkASSERT(fInitialized); |
| 80 return this->getHeader().fCoverageEffectCnt; | 80 return this->getHeader().fCoverageEffectCnt; |
| 81 } | 81 } |
| 82 | 82 |
| 83 int numTotalEffects() const { return this->numColorEffects() + this->numCove
rageEffects(); } | 83 int numTotalEffects() const { return this->numColorEffects() + this->numCove
rageEffects(); } |
| 84 | 84 |
| 85 GrGLProgramDesc& operator= (const GrGLProgramDesc& other); | 85 GrGLProgramDesc& operator= (const GrGLProgramDesc& other); |
| 86 | 86 |
| 87 bool operator== (const GrGLProgramDesc& other) const { | 87 bool operator== (const GrGLProgramDesc& other) const { |
| 88 GrAssert(fInitialized && other.fInitialized); | 88 SkASSERT(fInitialized && other.fInitialized); |
| 89 // The length is masked as a hint to the compiler that the address will
be 4 byte aligned. | 89 // The length is masked as a hint to the compiler that the address will
be 4 byte aligned. |
| 90 return 0 == memcmp(this->asKey(), other.asKey(), this->keyLength() & ~0x
3); | 90 return 0 == memcmp(this->asKey(), other.asKey(), this->keyLength() & ~0x
3); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool operator!= (const GrGLProgramDesc& other) const { | 93 bool operator!= (const GrGLProgramDesc& other) const { |
| 94 return !(*this == other); | 94 return !(*this == other); |
| 95 } | 95 } |
| 96 | 96 |
| 97 static bool Less(const GrGLProgramDesc& a, const GrGLProgramDesc& b) { | 97 static bool Less(const GrGLProgramDesc& a, const GrGLProgramDesc& b) { |
| 98 return memcmp(a.asKey(), b.asKey(), a.keyLength() & ~0x3) < 0; | 98 return memcmp(a.asKey(), b.asKey(), a.keyLength() & ~0x3) < 0; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 SkAutoSMalloc<kPreAllocSize> fKey; | 212 SkAutoSMalloc<kPreAllocSize> fKey; |
| 213 bool fInitialized; | 213 bool fInitialized; |
| 214 | 214 |
| 215 // GrGLProgram and GrGLShaderBuilder read the private fields to generate cod
e. TODO: Move all | 215 // GrGLProgram and GrGLShaderBuilder read the private fields to generate cod
e. TODO: Move all |
| 216 // code generation to GrGLShaderBuilder (and maybe add getters rather than f
riending). | 216 // code generation to GrGLShaderBuilder (and maybe add getters rather than f
riending). |
| 217 friend class GrGLProgram; | 217 friend class GrGLProgram; |
| 218 friend class GrGLShaderBuilder; | 218 friend class GrGLShaderBuilder; |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 #endif | 221 #endif |
| OLD | NEW |