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" | |
12 #include "GrEffect.h" | 11 #include "GrEffect.h" |
13 #include "GrGpuGL.h" | 12 #include "GrGpuGL.h" |
14 | 13 |
15 #include "SkChecksum.h" | 14 #include "SkChecksum.h" |
16 | 15 |
17 bool GrGLProgramDesc::GetEffectKeyAndUpdateStats(const GrEffectStage& stage, | 16 bool GrGLProgramDesc::GetEffectKeyAndUpdateStats(const GrEffectStage& stage, |
18 const GrGLCaps& caps, | 17 const GrGLCaps& caps, |
19 bool useExplicitLocalCoords, | 18 bool useExplicitLocalCoords, |
20 GrEffectKeyBuilder* b, | 19 GrEffectKeyBuilder* b, |
21 uint16_t* effectKeySize, | 20 uint16_t* effectKeySize, |
22 bool* setTrueIfReadsDst, | 21 bool* setTrueIfReadsDst, |
23 bool* setTrueIfReadsPos, | 22 bool* setTrueIfReadsPos, |
24 bool* setTrueIfRequiresVertexSh
ader) { | 23 bool* setTrueIfRequiresVertexSh
ader) { |
25 const GrBackendEffectFactory& factory = stage.getEffect()->getFactory(); | 24 const GrBackendEffectFactory& factory = stage.getEffect()->getFactory(); |
26 GrDrawEffect drawEffect(stage, useExplicitLocalCoords); | 25 const GrEffect& effect = *stage.getEffect(); |
27 if (stage.getEffect()->willReadDstColor()) { | 26 if (effect.willReadDstColor()) { |
28 *setTrueIfReadsDst = true; | 27 *setTrueIfReadsDst = true; |
29 } | 28 } |
30 if (stage.getEffect()->willReadFragmentPosition()) { | 29 if (effect.willReadFragmentPosition()) { |
31 *setTrueIfReadsPos = true; | 30 *setTrueIfReadsPos = true; |
32 } | 31 } |
33 if (stage.getEffect()->requiresVertexShader()) { | 32 if (effect.requiresVertexShader()) { |
34 *setTrueIfRequiresVertexShader = true; | 33 *setTrueIfRequiresVertexShader = true; |
35 } | 34 } |
36 factory.getGLEffectKey(drawEffect, caps, b); | 35 factory.getGLEffectKey(effect, caps, b); |
37 size_t size = b->size(); | 36 size_t size = b->size(); |
38 if (size > SK_MaxU16) { | 37 if (size > SK_MaxU16) { |
39 *effectKeySize = 0; // suppresses a warning. | 38 *effectKeySize = 0; // suppresses a warning. |
40 return false; | 39 return false; |
41 } | 40 } |
42 *effectKeySize = SkToU16(size); | 41 *effectKeySize = SkToU16(size); |
43 if (!GrGLProgramEffects::GenEffectMetaKey(drawEffect, caps, b)) { | 42 if (!GrGLProgramEffects::GenEffectMetaKey(stage, |
| 43 useExplicitLocalCoords, |
| 44 caps, |
| 45 b)) { |
44 return false; | 46 return false; |
45 } | 47 } |
46 return true; | 48 return true; |
47 } | 49 } |
48 | 50 |
49 bool GrGLProgramDesc::Build(const GrDrawState& drawState, | 51 bool GrGLProgramDesc::Build(const GrDrawState& drawState, |
50 GrGpu::DrawType drawType, | 52 GrGpu::DrawType drawType, |
51 GrDrawState::BlendOptFlags blendOpts, | 53 GrDrawState::BlendOptFlags blendOpts, |
52 GrBlendCoeff srcCoeff, | 54 GrBlendCoeff srcCoeff, |
53 GrBlendCoeff dstCoeff, | 55 GrBlendCoeff dstCoeff, |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 *checksum = 0; | 357 *checksum = 0; |
356 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); | 358 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); |
357 } | 359 } |
358 | 360 |
359 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 361 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
360 size_t keyLength = other.keyLength(); | 362 size_t keyLength = other.keyLength(); |
361 fKey.reset(keyLength); | 363 fKey.reset(keyLength); |
362 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | 364 memcpy(fKey.begin(), other.fKey.begin(), keyLength); |
363 return *this; | 365 return *this; |
364 } | 366 } |
OLD | NEW |