diff options
author | Chris Craik <ccraik@google.com> | 2015-02-24 13:46:29 -0800 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2015-02-25 10:18:46 -0800 |
commit | 14100ac9f8efc1a2407e3f5a5c8b2532a49585db (patch) | |
tree | ddcbc13d5205d5a2ce47dc55506716a9490011b4 /libs/hwui/GlopBuilder.cpp | |
parent | cdd35e6776f1e699a507e4ebb3a19b5eb75dc0fb (diff) | |
download | frameworks_base-14100ac9f8efc1a2407e3f5a5c8b2532a49585db.zip frameworks_base-14100ac9f8efc1a2407e3f5a5c8b2532a49585db.tar.gz frameworks_base-14100ac9f8efc1a2407e3f5a5c8b2532a49585db.tar.bz2 |
Glop support for custom textured UVs, simplify drawBitmap(src,dst)
Front load the scaling-to-support-shaders to record time.
Change-Id: I861c82d9d16d3c5e063cf87230127eed0b3f9b54
Diffstat (limited to 'libs/hwui/GlopBuilder.cpp')
-rw-r--r-- | libs/hwui/GlopBuilder.cpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/libs/hwui/GlopBuilder.cpp b/libs/hwui/GlopBuilder.cpp index 4617588..1342c52 100644 --- a/libs/hwui/GlopBuilder.cpp +++ b/libs/hwui/GlopBuilder.cpp @@ -32,7 +32,7 @@ namespace android { namespace uirenderer { #define TRIGGER_STAGE(stageFlag) \ - LOG_ALWAYS_FATAL_IF(stageFlag & mStageFlags, "Stage %d cannot be run twice"); \ + LOG_ALWAYS_FATAL_IF((stageFlag) & mStageFlags, "Stage %d cannot be run twice", (stageFlag)); \ mStageFlags = static_cast<StageFlags>(mStageFlags | (stageFlag)) #define REQUIRE_STAGES(requiredFlags) \ @@ -40,10 +40,10 @@ namespace uirenderer { "not prepared for current stage") static void setUnitQuadTextureCoords(Rect uvs, TextureVertex* quadVertex) { - TextureVertex::setUV(quadVertex++, uvs.left, uvs.top); - TextureVertex::setUV(quadVertex++, uvs.right, uvs.top); - TextureVertex::setUV(quadVertex++, uvs.left, uvs.bottom); - TextureVertex::setUV(quadVertex++, uvs.right, uvs.bottom); + quadVertex[0] = {0, 0, uvs.left, uvs.top}; + quadVertex[1] = {1, 0, uvs.right, uvs.top}; + quadVertex[2] = {0, 1, uvs.left, uvs.bottom}; + quadVertex[3] = {1, 1, uvs.right, uvs.bottom}; } GlopBuilder::GlopBuilder(RenderState& renderState, Caches& caches, Glop* outGlop) @@ -74,25 +74,40 @@ GlopBuilder& GlopBuilder::setMeshUnitQuad() { } GlopBuilder& GlopBuilder::setMeshTexturedUnitQuad(const UvMapper* uvMapper) { + if (uvMapper) { + // can't use unit quad VBO, so build UV vertices manually + return setMeshTexturedUvQuad(uvMapper, Rect(0, 0, 1, 1)); + } + + TRIGGER_STAGE(kMeshStage); + + mOutGlop->mesh.vertexFlags = kTextureCoord_Attrib; + mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP; + mOutGlop->mesh.vertexBufferObject = mRenderState.meshState().getUnitQuadVBO(); + mOutGlop->mesh.vertices = nullptr; + mOutGlop->mesh.texCoordOffset = (GLvoid*) kMeshTextureOffset; + mOutGlop->mesh.indexBufferObject = 0; + mOutGlop->mesh.indices = nullptr; + mOutGlop->mesh.elementCount = 4; + mOutGlop->mesh.stride = kTextureVertexStride; + mDescription.hasTexture = true; + return *this; +} + +GlopBuilder& GlopBuilder::setMeshTexturedUvQuad(const UvMapper* uvMapper, Rect uvs) { TRIGGER_STAGE(kMeshStage); mOutGlop->mesh.vertexFlags = kTextureCoord_Attrib; mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP; if (CC_UNLIKELY(uvMapper)) { - Rect uvs(0, 0, 1, 1); uvMapper->map(uvs); - setUnitQuadTextureCoords(uvs, &mOutGlop->mesh.mappedVertices[0]); - - mOutGlop->mesh.vertexBufferObject = 0; - mOutGlop->mesh.vertices = &mOutGlop->mesh.mappedVertices[0]; - mOutGlop->mesh.texCoordOffset = &mOutGlop->mesh.mappedVertices[0].u; - } else { - // standard UV coordinates, use regular unit quad VBO - mOutGlop->mesh.vertexBufferObject = mRenderState.meshState().getUnitQuadVBO(); - mOutGlop->mesh.vertices = nullptr; - mOutGlop->mesh.texCoordOffset = (GLvoid*) kMeshTextureOffset; } + setUnitQuadTextureCoords(uvs, &mOutGlop->mesh.mappedVertices[0]); + + mOutGlop->mesh.vertexBufferObject = 0; + mOutGlop->mesh.vertices = &mOutGlop->mesh.mappedVertices[0].x; + mOutGlop->mesh.texCoordOffset = &mOutGlop->mesh.mappedVertices[0].u; mOutGlop->mesh.indexBufferObject = 0; mOutGlop->mesh.indices = nullptr; mOutGlop->mesh.elementCount = 4; |