From 6926c72e25b8dec3dd4b84af0819fa1937ae7296 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 12 Jul 2010 20:20:03 -0700 Subject: 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 --- libs/hwui/Program.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libs/hwui/Program.cpp') 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 -- cgit v1.2.3-59-g8ed1b