Loading core/java/android/view/Window.java +0 −5 Original line number Diff line number Diff line Loading @@ -56,11 +56,6 @@ public abstract class Window { public static final int FEATURE_CONTEXT_MENU = 6; /** Flag for custom title. You cannot combine this feature with other title features. */ public static final int FEATURE_CUSTOM_TITLE = 7; /** Flag for asking for an OpenGL enabled window. All 2D graphics will be handled by OpenGL ES. @hide */ public static final int FEATURE_OPENGL = 8; /** * Flag for enabling the Action Bar. * This is enabled by default for some devices. The Action Bar Loading libs/hwui/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ LOCAL_SRC_FILES:= \ Patch.cpp \ PatchCache.cpp \ Program.cpp \ ProgramCache.cpp \ TextureCache.cpp LOCAL_C_INCLUDES += \ Loading libs/hwui/OpenGLRenderer.cpp +31 −26 Original line number Diff line number Diff line Loading @@ -45,32 +45,22 @@ namespace uirenderer { #define MB(s) s * 1024 * 1024 // Generates simple and textured vertices #define SV(x, y) { { x, y } } #define FV(x, y, u, v) { { x, y }, { u, v } } /////////////////////////////////////////////////////////////////////////////// // Globals /////////////////////////////////////////////////////////////////////////////// static const SimpleVertex gDrawColorVertices[] = { SV(0.0f, 0.0f), SV(1.0f, 0.0f), SV(0.0f, 1.0f), SV(1.0f, 1.0f) }; static const GLsizei gDrawColorVertexStride = sizeof(SimpleVertex); static const GLsizei gDrawColorVertexCount = 4; // This array is never used directly but used as a memcpy source in the // OpenGLRenderer constructor static const TextureVertex gDrawTextureVertices[] = { static const TextureVertex gMeshVertices[] = { FV(0.0f, 0.0f, 0.0f, 0.0f), FV(1.0f, 0.0f, 1.0f, 0.0f), FV(0.0f, 1.0f, 0.0f, 1.0f), FV(1.0f, 1.0f, 1.0f, 1.0f) }; static const GLsizei gDrawTextureVertexStride = sizeof(TextureVertex); static const GLsizei gDrawTextureVertexCount = 4; static const GLsizei gMeshStride = sizeof(TextureVertex); static const GLsizei gMeshCount = 4; // In this array, the index of each Blender equals the value of the first // entry. For instance, gBlends[1] == gBlends[SkXfermode::kSrc_Mode] Loading Loading @@ -143,7 +133,18 @@ OpenGLRenderer::OpenGLRenderer(): mLastTexture = 0; memcpy(mDrawTextureVertices, gDrawTextureVertices, sizeof(gDrawTextureVertices)); memcpy(mMeshVertices, gMeshVertices, sizeof(gMeshVertices)); ProgramDescription d; mProgramCache.get(d); d.hasTexture = true; mProgramCache.get(d); d.hasAlpha8Texture = true; d.hasGradient = true; d.hasBitmap = true; d.shadersMode = SkXfermode::kDstOut_Mode; d.colorOp = ProgramDescription::kColorMatrix; mProgramCache.get(d); } OpenGLRenderer::~OpenGLRenderer() { Loading Loading @@ -650,9 +651,13 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot mModelView.scale(right - left, bottom - top, 1.0f); if (!useProgram(mDrawColorProgram)) { const GLvoid* p = &gDrawColorVertices[0].position[0]; const GLvoid* vertices = &mMeshVertices[0].position[0]; const GLvoid* texCoords = &mMeshVertices[0].texture[0]; glVertexAttribPointer(mDrawColorProgram->position, 2, GL_FLOAT, GL_FALSE, gDrawColorVertexStride, p); gMeshStride, vertices); glVertexAttribPointer(mDrawColorProgram->texCoords, 2, GL_FLOAT, GL_FALSE, gMeshStride, texCoords); } if (!ignoreTransform) { Loading @@ -664,7 +669,7 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot glUniform4f(mDrawColorProgram->color, r, g, b, a); glDrawArrays(GL_TRIANGLE_STRIP, 0, gDrawColorVertexCount); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); } void OpenGLRenderer::drawLinearGradientShader(float left, float top, float right, float bottom, Loading Loading @@ -717,9 +722,9 @@ void OpenGLRenderer::drawLinearGradientShader(float left, float top, float right &screenSpace.data[0]); glVertexAttribPointer(mDrawLinearGradientProgram->position, 2, GL_FLOAT, GL_FALSE, gDrawTextureVertexStride, &mDrawTextureVertices[0].position[0]); gMeshStride, &mMeshVertices[0].position[0]); glDrawArrays(GL_TRIANGLE_STRIP, 0, gDrawTextureVertexCount); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); } void OpenGLRenderer::drawBitmapShader(float left, float top, float right, float bottom, Loading Loading @@ -757,7 +762,7 @@ void OpenGLRenderer::drawBitmapShader(float left, float top, float right, float resetDrawTextureTexCoords(u1, v1, u2, v2); drawTextureMesh(left, top, right, bottom, texture->id, alpha, mode, texture->blend, &mDrawTextureVertices[0].position[0], &mDrawTextureVertices[0].texture[0], NULL); &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0], NULL); resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f); } Loading @@ -769,13 +774,13 @@ void OpenGLRenderer::drawTextureRect(float left, float top, float right, float b getAlphaAndMode(paint, &alpha, &mode); drawTextureMesh(left, top, right, bottom, texture->id, alpha / 255.0f, mode, texture->blend, &mDrawTextureVertices[0].position[0], &mDrawTextureVertices[0].texture[0], NULL); &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0], NULL); } void OpenGLRenderer::drawTextureRect(float left, float top, float right, float bottom, GLuint texture, float alpha, SkXfermode::Mode mode, bool blend) { drawTextureMesh(left, top, right, bottom, texture, alpha, mode, blend, &mDrawTextureVertices[0].position[0], &mDrawTextureVertices[0].texture[0], NULL); &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0], NULL); } void OpenGLRenderer::drawTextureMesh(float left, float top, float right, float bottom, Loading @@ -794,12 +799,12 @@ void OpenGLRenderer::drawTextureMesh(float left, float top, float right, float b glUniform4f(mDrawTextureProgram->color, alpha, alpha, alpha, alpha); glVertexAttribPointer(mDrawTextureProgram->position, 2, GL_FLOAT, GL_FALSE, gDrawTextureVertexStride, vertices); gMeshStride, vertices); glVertexAttribPointer(mDrawTextureProgram->texCoords, 2, GL_FLOAT, GL_FALSE, gDrawTextureVertexStride, texCoords); gMeshStride, texCoords); if (!indices) { glDrawArrays(GL_TRIANGLE_STRIP, 0, gDrawTextureVertexCount); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); } else { glDrawElements(GL_TRIANGLES, elementsCount, GL_UNSIGNED_SHORT, indices); } Loading Loading @@ -842,7 +847,7 @@ bool OpenGLRenderer::useProgram(const sp<Program>& program) { } void OpenGLRenderer::resetDrawTextureTexCoords(float u1, float v1, float u2, float v2) { TextureVertex* v = &mDrawTextureVertices[0]; TextureVertex* v = &mMeshVertices[0]; TextureVertex::setUV(v++, u1, v1); TextureVertex::setUV(v++, u2, v1); TextureVertex::setUV(v++, u1, v2); Loading libs/hwui/OpenGLRenderer.h +4 −2 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include "PatchCache.h" #include "Vertex.h" #include "FontRenderer.h" #include "ProgramCache.h" namespace android { namespace uirenderer { Loading Loading @@ -268,7 +269,7 @@ private: SkXfermode::Mode mode); /** * Resets the texture coordinates stored in mDrawTextureVertices. Setting the values * Resets the texture coordinates stored in mMeshVertices. Setting the values * back to default is achieved by calling: * * resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f); Loading Loading @@ -337,7 +338,7 @@ private: sp<DrawLinearGradientProgram> mDrawLinearGradientProgram; // Used to draw textured quads TextureVertex mDrawTextureVertices[4]; TextureVertex mMeshVertices[4]; // Current texture state GLuint mLastTexture; Loading Loading @@ -372,6 +373,7 @@ private: TextureCache mTextureCache; LayerCache mLayerCache; GradientCache mGradientCache; ProgramCache mProgramCache; PatchCache mPatchCache; }; // class OpenGLRenderer Loading libs/hwui/Program.cpp +4 −7 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ namespace uirenderer { #define SHADER_SOURCE(name, source) const char* name = #source #include "shaders/drawColor.vert" #include "shaders/drawColor.frag" #include "shaders/drawTexture.vert" Loading Loading @@ -127,7 +126,7 @@ GLuint Program::buildShader(const char* source, GLenum type) { /////////////////////////////////////////////////////////////////////////////// DrawColorProgram::DrawColorProgram(): Program(gDrawColorVertexShader, gDrawColorFragmentShader) { Program(gDrawTextureVertexShader, gDrawColorFragmentShader) { getAttribsAndUniforms(); } Loading @@ -138,6 +137,7 @@ DrawColorProgram::DrawColorProgram(const char* vertex, const char* fragment): void DrawColorProgram::getAttribsAndUniforms() { position = addAttrib("position"); texCoords = addAttrib("texCoords"); color = addUniform("color"); transform = addUniform("transform"); } Loading @@ -154,11 +154,13 @@ void DrawColorProgram::set(const mat4& projectionMatrix, const mat4& modelViewMa void DrawColorProgram::use() { Program::use(); glEnableVertexAttribArray(position); glEnableVertexAttribArray(texCoords); } void DrawColorProgram::remove() { Program::remove(); glDisableVertexAttribArray(position); glDisableVertexAttribArray(texCoords); } /////////////////////////////////////////////////////////////////////////////// Loading @@ -167,26 +169,21 @@ void DrawColorProgram::remove() { DrawTextureProgram::DrawTextureProgram(): DrawColorProgram(gDrawTextureVertexShader, gDrawTextureFragmentShader) { texCoords = addAttrib("texCoords"); sampler = addUniform("sampler"); } DrawTextureProgram::DrawTextureProgram(const char* vertex, const char* fragment): DrawColorProgram(vertex, fragment) { texCoords = addAttrib("texCoords"); sampler = addUniform("sampler"); } void DrawTextureProgram::use() { DrawColorProgram::use(); glActiveTexture(GL_TEXTURE0); glUniform1i(sampler, 0); glEnableVertexAttribArray(texCoords); } void DrawTextureProgram::remove() { DrawColorProgram::remove(); glDisableVertexAttribArray(texCoords); } /////////////////////////////////////////////////////////////////////////////// Loading Loading
core/java/android/view/Window.java +0 −5 Original line number Diff line number Diff line Loading @@ -56,11 +56,6 @@ public abstract class Window { public static final int FEATURE_CONTEXT_MENU = 6; /** Flag for custom title. You cannot combine this feature with other title features. */ public static final int FEATURE_CUSTOM_TITLE = 7; /** Flag for asking for an OpenGL enabled window. All 2D graphics will be handled by OpenGL ES. @hide */ public static final int FEATURE_OPENGL = 8; /** * Flag for enabling the Action Bar. * This is enabled by default for some devices. The Action Bar Loading
libs/hwui/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ LOCAL_SRC_FILES:= \ Patch.cpp \ PatchCache.cpp \ Program.cpp \ ProgramCache.cpp \ TextureCache.cpp LOCAL_C_INCLUDES += \ Loading
libs/hwui/OpenGLRenderer.cpp +31 −26 Original line number Diff line number Diff line Loading @@ -45,32 +45,22 @@ namespace uirenderer { #define MB(s) s * 1024 * 1024 // Generates simple and textured vertices #define SV(x, y) { { x, y } } #define FV(x, y, u, v) { { x, y }, { u, v } } /////////////////////////////////////////////////////////////////////////////// // Globals /////////////////////////////////////////////////////////////////////////////// static const SimpleVertex gDrawColorVertices[] = { SV(0.0f, 0.0f), SV(1.0f, 0.0f), SV(0.0f, 1.0f), SV(1.0f, 1.0f) }; static const GLsizei gDrawColorVertexStride = sizeof(SimpleVertex); static const GLsizei gDrawColorVertexCount = 4; // This array is never used directly but used as a memcpy source in the // OpenGLRenderer constructor static const TextureVertex gDrawTextureVertices[] = { static const TextureVertex gMeshVertices[] = { FV(0.0f, 0.0f, 0.0f, 0.0f), FV(1.0f, 0.0f, 1.0f, 0.0f), FV(0.0f, 1.0f, 0.0f, 1.0f), FV(1.0f, 1.0f, 1.0f, 1.0f) }; static const GLsizei gDrawTextureVertexStride = sizeof(TextureVertex); static const GLsizei gDrawTextureVertexCount = 4; static const GLsizei gMeshStride = sizeof(TextureVertex); static const GLsizei gMeshCount = 4; // In this array, the index of each Blender equals the value of the first // entry. For instance, gBlends[1] == gBlends[SkXfermode::kSrc_Mode] Loading Loading @@ -143,7 +133,18 @@ OpenGLRenderer::OpenGLRenderer(): mLastTexture = 0; memcpy(mDrawTextureVertices, gDrawTextureVertices, sizeof(gDrawTextureVertices)); memcpy(mMeshVertices, gMeshVertices, sizeof(gMeshVertices)); ProgramDescription d; mProgramCache.get(d); d.hasTexture = true; mProgramCache.get(d); d.hasAlpha8Texture = true; d.hasGradient = true; d.hasBitmap = true; d.shadersMode = SkXfermode::kDstOut_Mode; d.colorOp = ProgramDescription::kColorMatrix; mProgramCache.get(d); } OpenGLRenderer::~OpenGLRenderer() { Loading Loading @@ -650,9 +651,13 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot mModelView.scale(right - left, bottom - top, 1.0f); if (!useProgram(mDrawColorProgram)) { const GLvoid* p = &gDrawColorVertices[0].position[0]; const GLvoid* vertices = &mMeshVertices[0].position[0]; const GLvoid* texCoords = &mMeshVertices[0].texture[0]; glVertexAttribPointer(mDrawColorProgram->position, 2, GL_FLOAT, GL_FALSE, gDrawColorVertexStride, p); gMeshStride, vertices); glVertexAttribPointer(mDrawColorProgram->texCoords, 2, GL_FLOAT, GL_FALSE, gMeshStride, texCoords); } if (!ignoreTransform) { Loading @@ -664,7 +669,7 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot glUniform4f(mDrawColorProgram->color, r, g, b, a); glDrawArrays(GL_TRIANGLE_STRIP, 0, gDrawColorVertexCount); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); } void OpenGLRenderer::drawLinearGradientShader(float left, float top, float right, float bottom, Loading Loading @@ -717,9 +722,9 @@ void OpenGLRenderer::drawLinearGradientShader(float left, float top, float right &screenSpace.data[0]); glVertexAttribPointer(mDrawLinearGradientProgram->position, 2, GL_FLOAT, GL_FALSE, gDrawTextureVertexStride, &mDrawTextureVertices[0].position[0]); gMeshStride, &mMeshVertices[0].position[0]); glDrawArrays(GL_TRIANGLE_STRIP, 0, gDrawTextureVertexCount); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); } void OpenGLRenderer::drawBitmapShader(float left, float top, float right, float bottom, Loading Loading @@ -757,7 +762,7 @@ void OpenGLRenderer::drawBitmapShader(float left, float top, float right, float resetDrawTextureTexCoords(u1, v1, u2, v2); drawTextureMesh(left, top, right, bottom, texture->id, alpha, mode, texture->blend, &mDrawTextureVertices[0].position[0], &mDrawTextureVertices[0].texture[0], NULL); &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0], NULL); resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f); } Loading @@ -769,13 +774,13 @@ void OpenGLRenderer::drawTextureRect(float left, float top, float right, float b getAlphaAndMode(paint, &alpha, &mode); drawTextureMesh(left, top, right, bottom, texture->id, alpha / 255.0f, mode, texture->blend, &mDrawTextureVertices[0].position[0], &mDrawTextureVertices[0].texture[0], NULL); &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0], NULL); } void OpenGLRenderer::drawTextureRect(float left, float top, float right, float bottom, GLuint texture, float alpha, SkXfermode::Mode mode, bool blend) { drawTextureMesh(left, top, right, bottom, texture, alpha, mode, blend, &mDrawTextureVertices[0].position[0], &mDrawTextureVertices[0].texture[0], NULL); &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0], NULL); } void OpenGLRenderer::drawTextureMesh(float left, float top, float right, float bottom, Loading @@ -794,12 +799,12 @@ void OpenGLRenderer::drawTextureMesh(float left, float top, float right, float b glUniform4f(mDrawTextureProgram->color, alpha, alpha, alpha, alpha); glVertexAttribPointer(mDrawTextureProgram->position, 2, GL_FLOAT, GL_FALSE, gDrawTextureVertexStride, vertices); gMeshStride, vertices); glVertexAttribPointer(mDrawTextureProgram->texCoords, 2, GL_FLOAT, GL_FALSE, gDrawTextureVertexStride, texCoords); gMeshStride, texCoords); if (!indices) { glDrawArrays(GL_TRIANGLE_STRIP, 0, gDrawTextureVertexCount); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); } else { glDrawElements(GL_TRIANGLES, elementsCount, GL_UNSIGNED_SHORT, indices); } Loading Loading @@ -842,7 +847,7 @@ bool OpenGLRenderer::useProgram(const sp<Program>& program) { } void OpenGLRenderer::resetDrawTextureTexCoords(float u1, float v1, float u2, float v2) { TextureVertex* v = &mDrawTextureVertices[0]; TextureVertex* v = &mMeshVertices[0]; TextureVertex::setUV(v++, u1, v1); TextureVertex::setUV(v++, u2, v1); TextureVertex::setUV(v++, u1, v2); Loading
libs/hwui/OpenGLRenderer.h +4 −2 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include "PatchCache.h" #include "Vertex.h" #include "FontRenderer.h" #include "ProgramCache.h" namespace android { namespace uirenderer { Loading Loading @@ -268,7 +269,7 @@ private: SkXfermode::Mode mode); /** * Resets the texture coordinates stored in mDrawTextureVertices. Setting the values * Resets the texture coordinates stored in mMeshVertices. Setting the values * back to default is achieved by calling: * * resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f); Loading Loading @@ -337,7 +338,7 @@ private: sp<DrawLinearGradientProgram> mDrawLinearGradientProgram; // Used to draw textured quads TextureVertex mDrawTextureVertices[4]; TextureVertex mMeshVertices[4]; // Current texture state GLuint mLastTexture; Loading Loading @@ -372,6 +373,7 @@ private: TextureCache mTextureCache; LayerCache mLayerCache; GradientCache mGradientCache; ProgramCache mProgramCache; PatchCache mPatchCache; }; // class OpenGLRenderer Loading
libs/hwui/Program.cpp +4 −7 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ namespace uirenderer { #define SHADER_SOURCE(name, source) const char* name = #source #include "shaders/drawColor.vert" #include "shaders/drawColor.frag" #include "shaders/drawTexture.vert" Loading Loading @@ -127,7 +126,7 @@ GLuint Program::buildShader(const char* source, GLenum type) { /////////////////////////////////////////////////////////////////////////////// DrawColorProgram::DrawColorProgram(): Program(gDrawColorVertexShader, gDrawColorFragmentShader) { Program(gDrawTextureVertexShader, gDrawColorFragmentShader) { getAttribsAndUniforms(); } Loading @@ -138,6 +137,7 @@ DrawColorProgram::DrawColorProgram(const char* vertex, const char* fragment): void DrawColorProgram::getAttribsAndUniforms() { position = addAttrib("position"); texCoords = addAttrib("texCoords"); color = addUniform("color"); transform = addUniform("transform"); } Loading @@ -154,11 +154,13 @@ void DrawColorProgram::set(const mat4& projectionMatrix, const mat4& modelViewMa void DrawColorProgram::use() { Program::use(); glEnableVertexAttribArray(position); glEnableVertexAttribArray(texCoords); } void DrawColorProgram::remove() { Program::remove(); glDisableVertexAttribArray(position); glDisableVertexAttribArray(texCoords); } /////////////////////////////////////////////////////////////////////////////// Loading @@ -167,26 +169,21 @@ void DrawColorProgram::remove() { DrawTextureProgram::DrawTextureProgram(): DrawColorProgram(gDrawTextureVertexShader, gDrawTextureFragmentShader) { texCoords = addAttrib("texCoords"); sampler = addUniform("sampler"); } DrawTextureProgram::DrawTextureProgram(const char* vertex, const char* fragment): DrawColorProgram(vertex, fragment) { texCoords = addAttrib("texCoords"); sampler = addUniform("sampler"); } void DrawTextureProgram::use() { DrawColorProgram::use(); glActiveTexture(GL_TEXTURE0); glUniform1i(sampler, 0); glEnableVertexAttribArray(texCoords); } void DrawTextureProgram::remove() { DrawColorProgram::remove(); glDisableVertexAttribArray(texCoords); } /////////////////////////////////////////////////////////////////////////////// Loading