aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLPathProgramDataManager.h
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2015-06-29 23:01:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-29 23:01:28 -0700
commit7aedda57f84f942b5f0ba6c1b6e7ba329e6b18f1 (patch)
treec05dd8eb983a44df9cecf410ff5604ffd4593a38 /src/gpu/gl/GrGLPathProgramDataManager.h
parente04edd8c8618f1a637f0cdbe340474e2c10a60ad (diff)
Refactor separable varying location info to be stored in GrGLProgram subclass
Refactor separable varying location info to be stored in GrGLProgram subclass GrGLProgram instead of storing it in GrGLPathProcessor. Separable varyings are exactly analoguous to uniforms: they are inputs to the shader program. Shader compile-time information about uniforms is gathered to GrGLProgramBuilder. This information is the converted to link-time information, uniform locations, when constructing the program. Separable varyings need to have same lifetime model. This is needed in the future to support path rendering in Chromium. The Chromium pseudo-extension will expose program fragment input binding function similar to uniform binding function. Thus the separable varying locations need to be decided and bound before link, e.g. before GrGLProgram is created. This will be achieved in further patches by overloading GrGLProgramBuilder::bindProgramResourceLocations() in GrGLNvprProgramBuilder. BUG=chromium:344330 Review URL: https://codereview.chromium.org/1186113007
Diffstat (limited to 'src/gpu/gl/GrGLPathProgramDataManager.h')
-rw-r--r--src/gpu/gl/GrGLPathProgramDataManager.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLPathProgramDataManager.h b/src/gpu/gl/GrGLPathProgramDataManager.h
new file mode 100644
index 0000000000..9eeac7ea20
--- /dev/null
+++ b/src/gpu/gl/GrGLPathProgramDataManager.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLPathProgramDataManager_DEFINED
+#define GrGLPathProgramDataManager_DEFINED
+
+#include "gl/GrGLProgramDataManager.h"
+
+class GrGLPathProgram;
+class GrGLPathProgramBuilder;
+
+/** Manages the resources used by a shader program for NVPR rendering.
+ */
+class GrGLPathProgramDataManager : SkNoncopyable {
+public:
+ class SeparableVaryingHandle : public GrGLProgramDataManager::ShaderResourceHandle {
+ public:
+ /*
+ * Creates a reference to a separable varying of a GrGLShaderBuilder. The ref can be used
+ * to set the varying with the corresponding GrGLPathProgramDataManager.
+ */
+ static SeparableVaryingHandle CreateFromSeparableVaryingIndex(int i) {
+ return GrGLPathProgramDataManager::SeparableVaryingHandle(i);
+ }
+ SeparableVaryingHandle() { }
+ bool operator==(const SeparableVaryingHandle& other) {
+ return other.fValue == fValue;
+ }
+ private:
+ SeparableVaryingHandle(int value) : ShaderResourceHandle(value) { }
+ int toProgramDataIndex() const { SkASSERT(isValid()); return fValue; }
+ int toShaderBuilderIndex() const { return toProgramDataIndex(); }
+
+ friend class GrGLPathProgramDataManager; // For accessing toProgramDataIndex().
+ friend class GrGLPathProcessor; // For accessing toShaderBuilderIndex().
+ };
+
+ struct SeparableVaryingInfo {
+ GrGLShaderVar fVariable;
+ GrGLint fLocation;
+ };
+
+ // This uses an allocator rather than array so that the GrGLShaderVars don't move in memory
+ // after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their
+ // name strings. Otherwise, we'd have to hand out copies.
+ typedef GrTAllocator<SeparableVaryingInfo> SeparableVaryingInfoArray;
+
+ GrGLPathProgramDataManager(GrGLGpu*, GrGLuint programID, const SeparableVaryingInfoArray&);
+
+ /** Functions for uploading the varying values.
+ */
+ void setPathFragmentInputTransform(SeparableVaryingHandle u,
+ int components,
+ const SkMatrix& matrix) const;
+private:
+ enum {
+ kUnusedSeparableVarying = -1,
+ };
+ struct SeparableVarying {
+ GrGLint fLocation;
+ SkDEBUGCODE(
+ GrSLType fType;
+ int fArrayCount;
+ );
+ };
+ SkTArray<SeparableVarying, true> fSeparableVaryings;
+ GrGLGpu* fGpu;
+ GrGLuint fProgramID;
+ typedef SkNoncopyable INHERITED;
+};
+#endif