diff options
author | Romain Guy <romainguy@android.com> | 2010-07-16 23:13:33 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2010-07-16 23:18:27 -0700 |
commit | f9764a4f532561f6e2e985ff3b25112f1132ce44 (patch) | |
tree | 910110cc35d1d3e2a48f000734ec50f6e53ced0f /libs/hwui/Program.cpp | |
parent | 7fac2e18339f765320d759e8d4c090f92431959e (diff) |
Add program for linear gradient.
This change adds a new DrawLinearGradientProgram class to enable the drawing
of linear gradients. Two new vertex and fragment shaders are introduced,
based on DrawTextureProgram's shaders.
Change-Id: I885afc076bb6cef8cd3962ae21a086fa6a03bf96
Diffstat (limited to 'libs/hwui/Program.cpp')
-rw-r--r-- | libs/hwui/Program.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp index 609b28a4f361..6202ba3647da 100644 --- a/libs/hwui/Program.cpp +++ b/libs/hwui/Program.cpp @@ -33,6 +33,9 @@ namespace uirenderer { #include "shaders/drawTexture.vert" #include "shaders/drawTexture.frag" +#include "shaders/drawLinearGradient.vert" +#include "shaders/drawLinearGradient.frag" + /////////////////////////////////////////////////////////////////////////////// // Base program /////////////////////////////////////////////////////////////////////////////// @@ -178,5 +181,26 @@ void DrawTextureProgram::remove() { glDisableVertexAttribArray(texCoords); } +/////////////////////////////////////////////////////////////////////////////// +// Draw linear gradient +/////////////////////////////////////////////////////////////////////////////// + +DrawLinearGradientProgram::DrawLinearGradientProgram(): + DrawColorProgram(gDrawLinearGradientVertexShader, gDrawLinearGradientFragmentShader) { + gradient = addUniform("gradient"); + gradientLength = addUniform("gradientLength"); + sampler = addUniform("sampler"); +} + +void DrawLinearGradientProgram::use() { + DrawColorProgram::use(); + glActiveTexture(GL_TEXTURE0); + glUniform1i(sampler, 0); +} + +void DrawLinearGradientProgram::remove() { + DrawColorProgram::remove(); +} + }; // namespace uirenderer }; // namespace android |