Line data Source code
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 GrGLSLProgramDataManager_DEFINED
9 : #define GrGLSLProgramDataManager_DEFINED
10 :
11 : #include "GrResourceHandle.h"
12 : #include "SkTypes.h"
13 :
14 : class SkMatrix;
15 : class SkMatrix44;
16 :
17 : /** Manages the resources used by a shader program.
18 : * The resources are objects the program uses to communicate with the
19 : * application code.
20 : */
21 : class GrGLSLProgramDataManager : SkNoncopyable {
22 : public:
23 : GR_DEFINE_RESOURCE_HANDLE_CLASS(UniformHandle);
24 :
25 0 : virtual ~GrGLSLProgramDataManager() {}
26 :
27 : /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
28 : * array of uniforms. arrayCount must be <= the array count of the uniform.
29 : */
30 : virtual void set1i(UniformHandle, int32_t) const = 0;
31 : virtual void set1iv(UniformHandle, int arrayCount, const int v[]) const = 0;
32 : virtual void set1f(UniformHandle, float v0) const = 0;
33 : virtual void set1fv(UniformHandle, int arrayCount, const float v[]) const = 0;
34 : virtual void set2f(UniformHandle, float, float) const = 0;
35 : virtual void set2fv(UniformHandle, int arrayCount, const float v[]) const = 0;
36 : virtual void set3f(UniformHandle, float, float, float) const = 0;
37 : virtual void set3fv(UniformHandle, int arrayCount, const float v[]) const = 0;
38 : virtual void set4f(UniformHandle, float, float, float, float) const = 0;
39 : virtual void set4fv(UniformHandle, int arrayCount, const float v[]) const = 0;
40 : // matrices are column-major, the first three upload a single matrix, the latter three upload
41 : // arrayCount matrices into a uniform array.
42 : virtual void setMatrix2f(UniformHandle, const float matrix[]) const = 0;
43 : virtual void setMatrix3f(UniformHandle, const float matrix[]) const = 0;
44 : virtual void setMatrix4f(UniformHandle, const float matrix[]) const = 0;
45 : virtual void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
46 : virtual void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
47 : virtual void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
48 :
49 : // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
50 : void setSkMatrix(UniformHandle, const SkMatrix&) const;
51 :
52 : // convenience method for uploading a SkMatrix44 to a 4x4 matrix uniform
53 : void setSkMatrix44(UniformHandle, const SkMatrix44&) const;
54 :
55 : // for nvpr only
56 : GR_DEFINE_RESOURCE_HANDLE_CLASS(VaryingHandle);
57 : virtual void setPathFragmentInputTransform(VaryingHandle u, int components,
58 : const SkMatrix& matrix) const = 0;
59 :
60 : protected:
61 0 : GrGLSLProgramDataManager() {}
62 :
63 : private:
64 : typedef SkNoncopyable INHERITED;
65 : };
66 :
67 : #endif
|