blob: 508cdf06f8a9dfa567c55b716c74d1724f311765 [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;
egdaniel018fb622015-10-28 07:26:40 -070030 virtual void set1f(UniformHandle, float v0) const = 0;
31 virtual void set1fv(UniformHandle, int arrayCount, const float v[]) const = 0;
32 virtual void set2f(UniformHandle, float, float) const = 0;
33 virtual void set2fv(UniformHandle, int arrayCount, const float v[]) const = 0;
34 virtual void set3f(UniformHandle, float, float, float) const = 0;
35 virtual void set3fv(UniformHandle, int arrayCount, const float v[]) const = 0;
36 virtual void set4f(UniformHandle, float, float, float, float) const = 0;
37 virtual void set4fv(UniformHandle, int arrayCount, const float v[]) const = 0;
38 // matrices are column-major, the first three upload a single matrix, the latter three upload
39 // arrayCount matrices into a uniform array.
cdalton8d988b32016-03-07 15:39:09 -080040 virtual void setMatrix2f(UniformHandle, const float matrix[]) const = 0;
egdaniel018fb622015-10-28 07:26:40 -070041 virtual void setMatrix3f(UniformHandle, const float matrix[]) const = 0;
42 virtual void setMatrix4f(UniformHandle, const float matrix[]) const = 0;
cdalton8d988b32016-03-07 15:39:09 -080043 virtual void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
egdaniel018fb622015-10-28 07:26:40 -070044 virtual void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
45 virtual void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
46
47 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
egdaniel2829bb72016-02-03 09:52:51 -080048 void setSkMatrix(UniformHandle, const SkMatrix&) const;
egdaniel018fb622015-10-28 07:26:40 -070049
50 // for nvpr only
egdaniel167ab912016-05-09 11:03:48 -070051 GR_DEFINE_RESOURCE_HANDLE_CLASS(VaryingHandle);
egdaniel0eafe792015-11-20 14:01:22 -080052 virtual void setPathFragmentInputTransform(VaryingHandle u, int components,
egdaniel018fb622015-10-28 07:26:40 -070053 const SkMatrix& matrix) const = 0;
54
55protected:
56 GrGLSLProgramDataManager() {}
57
58private:
egdaniel018fb622015-10-28 07:26:40 -070059 typedef SkNoncopyable INHERITED;
60};
61
62#endif