diff options
author | Romain Guy <romainguy@google.com> | 2010-07-12 20:20:03 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2010-07-12 20:20:03 -0700 |
commit | 6926c72e25b8dec3dd4b84af0819fa1937ae7296 (patch) | |
tree | b59a3b01ddbc9ae8c0b5f11eaa6fcf27a9f9511d /libs/hwui/Program.cpp | |
parent | 260e102162322958cf17dbd895cd6bd30dc87e32 (diff) |
Correctly support pre-multiplied alpha, optimizations, more stuff.
Add support for the following drawing functions:
- drawBitmap(int[]...)
- drawPaint()
Optimizes shader state changes by enabling/disabling attribute arrays
only when needed.
Adds quick rejects when drawing trivial shapes to avoid unnecessary
OpenGL operations.
Change-Id: Ic2c6c2ed1523d08a63a8c95601a1ec40b6c7fbc9
Diffstat (limited to 'libs/hwui/Program.cpp')
-rw-r--r-- | libs/hwui/Program.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp index 3b5e5da0ad18..609b28a4f361 100644 --- a/libs/hwui/Program.cpp +++ b/libs/hwui/Program.cpp @@ -146,6 +146,16 @@ void DrawColorProgram::set(const mat4& projectionMatrix, const mat4& modelViewMa glUniformMatrix4fv(transform, 1, GL_FALSE, &t.data[0]); } +void DrawColorProgram::use() { + Program::use(); + glEnableVertexAttribArray(position); +} + +void DrawColorProgram::remove() { + Program::remove(); + glDisableVertexAttribArray(position); +} + /////////////////////////////////////////////////////////////////////////////// // Draw texture /////////////////////////////////////////////////////////////////////////////// @@ -156,5 +166,17 @@ DrawTextureProgram::DrawTextureProgram(): sampler = addUniform("sampler"); } +void DrawTextureProgram::use() { + DrawColorProgram::use(); + glActiveTexture(GL_TEXTURE0); + glUniform1i(sampler, 0); + glEnableVertexAttribArray(texCoords); +} + +void DrawTextureProgram::remove() { + DrawColorProgram::remove(); + glDisableVertexAttribArray(texCoords); +} + }; // namespace uirenderer }; // namespace android |