| 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 #include "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
| 9 #include "GrGLProgramDesc.h" | 9 #include "GrGLProgramDesc.h" |
| 10 #include "GrBackendEffectFactory.h" | 10 #include "GrBackendEffectFactory.h" |
| 11 #include "GrDrawEffect.h" |
| 11 #include "GrEffect.h" | 12 #include "GrEffect.h" |
| 12 #include "GrGpuGL.h" | 13 #include "GrGpuGL.h" |
| 13 #include "GrOptDrawState.h" | 14 #include "GrOptDrawState.h" |
| 14 | 15 |
| 15 #include "SkChecksum.h" | 16 #include "SkChecksum.h" |
| 16 | 17 |
| 17 bool GrGLProgramDesc::GetEffectKeyAndUpdateStats(const GrEffectStage& stage, | 18 bool GrGLProgramDesc::GetEffectKeyAndUpdateStats(const GrEffectStage& stage, |
| 18 const GrGLCaps& caps, | 19 const GrGLCaps& caps, |
| 19 bool useExplicitLocalCoords, | 20 bool useExplicitLocalCoords, |
| 20 GrEffectKeyBuilder* b, | 21 GrEffectKeyBuilder* b, |
| 21 uint16_t* effectKeySize, | 22 uint16_t* effectKeySize, |
| 22 bool* setTrueIfReadsDst, | 23 bool* setTrueIfReadsDst, |
| 23 bool* setTrueIfReadsPos, | 24 bool* setTrueIfReadsPos, |
| 24 bool* setTrueIfRequiresVertexSh
ader) { | 25 bool* setTrueIfRequiresVertexSh
ader) { |
| 25 const GrBackendEffectFactory& factory = stage.getEffect()->getFactory(); | 26 const GrBackendEffectFactory& factory = stage.getEffect()->getFactory(); |
| 26 const GrEffect& effect = *stage.getEffect(); | 27 GrDrawEffect drawEffect(stage, useExplicitLocalCoords); |
| 27 if (effect.willReadDstColor()) { | 28 if (stage.getEffect()->willReadDstColor()) { |
| 28 *setTrueIfReadsDst = true; | 29 *setTrueIfReadsDst = true; |
| 29 } | 30 } |
| 30 if (effect.willReadFragmentPosition()) { | 31 if (stage.getEffect()->willReadFragmentPosition()) { |
| 31 *setTrueIfReadsPos = true; | 32 *setTrueIfReadsPos = true; |
| 32 } | 33 } |
| 33 if (effect.requiresVertexShader()) { | 34 if (stage.getEffect()->requiresVertexShader()) { |
| 34 *setTrueIfRequiresVertexShader = true; | 35 *setTrueIfRequiresVertexShader = true; |
| 35 } | 36 } |
| 36 factory.getGLEffectKey(effect, caps, b); | 37 factory.getGLEffectKey(drawEffect, caps, b); |
| 37 size_t size = b->size(); | 38 size_t size = b->size(); |
| 38 if (size > SK_MaxU16) { | 39 if (size > SK_MaxU16) { |
| 39 *effectKeySize = 0; // suppresses a warning. | 40 *effectKeySize = 0; // suppresses a warning. |
| 40 return false; | 41 return false; |
| 41 } | 42 } |
| 42 *effectKeySize = SkToU16(size); | 43 *effectKeySize = SkToU16(size); |
| 43 if (!GrGLProgramEffects::GenEffectMetaKey(stage, | 44 if (!GrGLProgramEffects::GenEffectMetaKey(drawEffect, caps, b)) { |
| 44 useExplicitLocalCoords, | |
| 45 caps, | |
| 46 b)) { | |
| 47 return false; | 45 return false; |
| 48 } | 46 } |
| 49 return true; | 47 return true; |
| 50 } | 48 } |
| 51 | 49 |
| 52 bool GrGLProgramDesc::Build(const GrOptDrawState& optState, | 50 bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
| 53 GrGpu::DrawType drawType, | 51 GrGpu::DrawType drawType, |
| 54 GrBlendCoeff srcCoeff, | 52 GrBlendCoeff srcCoeff, |
| 55 GrBlendCoeff dstCoeff, | 53 GrBlendCoeff dstCoeff, |
| 56 const GrGpuGL* gpu, | 54 const GrGpuGL* gpu, |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 *checksum = 0; | 312 *checksum = 0; |
| 315 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); | 313 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); |
| 316 } | 314 } |
| 317 | 315 |
| 318 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 316 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
| 319 size_t keyLength = other.keyLength(); | 317 size_t keyLength = other.keyLength(); |
| 320 fKey.reset(keyLength); | 318 fKey.reset(keyLength); |
| 321 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | 319 memcpy(fKey.begin(), other.fKey.begin(), keyLength); |
| 322 return *this; | 320 return *this; |
| 323 } | 321 } |
| OLD | NEW |