OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrGLPathProgramDataManager_DEFINED |
| 9 #define GrGLPathProgramDataManager_DEFINED |
| 10 |
| 11 #include "gl/GrGLProgramDataManager.h" |
| 12 |
| 13 class GrGLPathProgram; |
| 14 class GrGLPathProgramBuilder; |
| 15 |
| 16 /** Manages the resources used by a shader program for NVPR rendering. |
| 17 */ |
| 18 class GrGLPathProgramDataManager : SkNoncopyable { |
| 19 public: |
| 20 class SeparableVaryingHandle : public GrGLProgramDataManager::ShaderResource
Handle { |
| 21 public: |
| 22 /* |
| 23 * Creates a reference to a separable varying of a GrGLShaderBuilder. T
he ref can be used |
| 24 * to set the varying with the corresponding GrGLPathProgramDataManager. |
| 25 */ |
| 26 static SeparableVaryingHandle CreateFromSeparableVaryingIndex(int i) { |
| 27 return GrGLPathProgramDataManager::SeparableVaryingHandle(i); |
| 28 } |
| 29 SeparableVaryingHandle() { } |
| 30 bool operator==(const SeparableVaryingHandle& other) { |
| 31 return other.fValue == fValue; |
| 32 } |
| 33 private: |
| 34 SeparableVaryingHandle(int value) : ShaderResourceHandle(value) { } |
| 35 int toProgramDataIndex() const { SkASSERT(isValid()); return fValue; } |
| 36 int toShaderBuilderIndex() const { return toProgramDataIndex(); } |
| 37 |
| 38 friend class GrGLPathProgramDataManager; // For accessing toProgramDataI
ndex(). |
| 39 friend class GrGLPathProcessor; // For accessing toShaderBuilderIndex(). |
| 40 }; |
| 41 |
| 42 struct SeparableVaryingInfo { |
| 43 GrGLShaderVar fVariable; |
| 44 GrGLint fLocation; |
| 45 }; |
| 46 |
| 47 // This uses an allocator rather than array so that the GrGLShaderVars don't
move in memory |
| 48 // after they are inserted. Users of GrGLShaderBuilder get refs to the vars
and ptrs to their |
| 49 // name strings. Otherwise, we'd have to hand out copies. |
| 50 typedef GrTAllocator<SeparableVaryingInfo> SeparableVaryingInfoArray; |
| 51 |
| 52 GrGLPathProgramDataManager(GrGLGpu*, GrGLuint programID, const SeparableVary
ingInfoArray&); |
| 53 |
| 54 /** Functions for uploading the varying values. |
| 55 */ |
| 56 void setPathFragmentInputTransform(SeparableVaryingHandle u, |
| 57 int components, |
| 58 const SkMatrix& matrix) const; |
| 59 private: |
| 60 enum { |
| 61 kUnusedSeparableVarying = -1, |
| 62 }; |
| 63 struct SeparableVarying { |
| 64 GrGLint fLocation; |
| 65 SkDEBUGCODE( |
| 66 GrSLType fType; |
| 67 int fArrayCount; |
| 68 ); |
| 69 }; |
| 70 SkTArray<SeparableVarying, true> fSeparableVaryings; |
| 71 GrGLGpu* fGpu; |
| 72 GrGLuint fProgramID; |
| 73 typedef SkNoncopyable INHERITED; |
| 74 }; |
| 75 #endif |
OLD | NEW |