blob: 442a1e5bc678f740d57b3c1a0fcb9a7cdcdf1235 [file] [log] [blame]
egdaniel018fb622015-10-28 07:26:40 -07001/*
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
egdaniel167ab912016-05-09 11:03:48 -070011#include "GrResourceHandle.h"
egdaniel018fb622015-10-28 07:26:40 -070012#include "SkTypes.h"
13
egdaniel7dc4bd02015-10-29 07:57:01 -070014class SkMatrix;
15
egdaniel018fb622015-10-28 07:26:40 -070016/** Manages the resources used by a shader program.
17 * The resources are objects the program uses to communicate with the
18 * application code.
19 */
20class GrGLSLProgramDataManager : SkNoncopyable {
21public:
egdaniel167ab912016-05-09 11:03:48 -070022 GR_DEFINE_RESOURCE_HANDLE_CLASS(UniformHandle);
egdaniel018fb622015-10-28 07:26:40 -070023
24 virtual ~GrGLSLProgramDataManager() {}
25
26 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
27 * array of uniforms. arrayCount must be <= the array count of the uniform.
28 */
fmenozzi497e9e22016-06-21 09:42:12 -070029 virtual void set1i(UniformHandle, int32_t) const = 0;
fmenozzi35a98c72016-07-20 08:26:12 -070030 virtual void set1iv(UniformHandle, int arrayCount, const int v[]) const = 0;
egdaniel018fb622015-10-28 07:26:40 -070031 virtual void set1f(UniformHandle, float v0) const = 0;
32 virtual void set1fv(UniformHandle, int arrayCount, const float v[]) const = 0;
33 virtual void set2f(UniformHandle, float, float) const = 0;
34 virtual void set2fv(UniformHandle, int arrayCount, const float v[]) const = 0;
35 virtual void set3f(UniformHandle, float, float, float) const = 0;
36 virtual void set3fv(UniformHandle, int arrayCount, const float v[]) const = 0;
37 virtual void set4f(UniformHandle, float, float, float, float) const = 0;
38 virtual void set4fv(UniformHandle, int arrayCount, const float v[]) const = 0;
39 // matrices are column-major, the first three upload a single matrix, the latter three upload
40 // arrayCount matrices into a uniform array.
cdalton8d988b32016-03-07 15:39:09 -080041 virtual void setMatrix2f(UniformHandle, const float matrix[]) const = 0;
egdaniel018fb622015-10-28 07:26:40 -070042 virtual void setMatrix3f(UniformHandle, const float matrix[]) const = 0;
43 virtual void setMatrix4f(UniformHandle, const float matrix[]) const = 0;
cdalton8d988b32016-03-07 15:39:09 -080044 virtual void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
egdaniel018fb622015-10-28 07:26:40 -070045 virtual void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
46 virtual void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
47
48 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
egdaniel2829bb72016-02-03 09:52:51 -080049 void setSkMatrix(UniformHandle, const SkMatrix&) const;
egdaniel018fb622015-10-28 07:26:40 -070050
51 // for nvpr only
egdaniel167ab912016-05-09 11:03:48 -070052 GR_DEFINE_RESOURCE_HANDLE_CLASS(VaryingHandle);
egdaniel0eafe792015-11-20 14:01:22 -080053 virtual void setPathFragmentInputTransform(VaryingHandle u, int components,
egdaniel018fb622015-10-28 07:26:40 -070054 const SkMatrix& matrix) const = 0;
55
56protected:
57 GrGLSLProgramDataManager() {}
58
59private:
egdaniel018fb622015-10-28 07:26:40 -070060 typedef SkNoncopyable INHERITED;
61};
62
63#endif