Loading libs/hwui/Glop.h +2 −0 Original line number Diff line number Diff line Loading @@ -94,8 +94,10 @@ struct Glop { struct TextureData { Texture* texture; GLenum target; GLenum filter; GLenum clamp; Matrix4* textureTransform; } texture; bool colorEnabled; Loading libs/hwui/GlopBuilder.cpp +36 −12 Original line number Diff line number Diff line Loading @@ -274,7 +274,8 @@ GlopBuilder& GlopBuilder::setFillTexturePaint(Texture& texture, bool isAlphaMask TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { &texture, PaintUtils::getFilter(paint), GL_CLAMP_TO_EDGE }; mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, PaintUtils::getFilter(paint), GL_CLAMP_TO_EDGE, nullptr }; if (paint) { int color = paint->getColor(); Loading Loading @@ -315,7 +316,7 @@ GlopBuilder& GlopBuilder::setFillPaint(const SkPaint& paint, float alphaScale) { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; setFill(paint.getColor(), alphaScale, PaintUtils::getXfermode(paint.getXfermode()), paint.getShader(), paint.getColorFilter()); Loading @@ -329,7 +330,7 @@ GlopBuilder& GlopBuilder::setFillPathTexturePaint(PathTexture& texture, REQUIRE_STAGES(kMeshStage); //specify invalid filter/clamp, since these are always static for PathTextures mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; setFill(paint.getColor(), alphaScale, PaintUtils::getXfermode(paint.getXfermode()), paint.getShader(), paint.getColorFilter()); Loading @@ -345,7 +346,7 @@ GlopBuilder& GlopBuilder::setFillShadowTexturePaint(ShadowTexture& texture, int REQUIRE_STAGES(kMeshStage); //specify invalid filter/clamp, since these are always static for ShadowTextures mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; const int ALPHA_BITMASK = SK_ColorBLACK; const int COLOR_BITMASK = ~ALPHA_BITMASK; Loading @@ -366,7 +367,7 @@ GlopBuilder& GlopBuilder::setFillBlack() { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; setFill(SK_ColorBLACK, 1.0f, SkXfermode::kSrcOver_Mode, nullptr, nullptr); return *this; } Loading @@ -375,7 +376,7 @@ GlopBuilder& GlopBuilder::setFillClear() { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; setFill(SK_ColorBLACK, 1.0f, SkXfermode::kClear_Mode, nullptr, nullptr); return *this; } Loading @@ -385,7 +386,8 @@ GlopBuilder& GlopBuilder::setFillLayer(Texture& texture, const SkColorFilter* co TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { &texture, GL_LINEAR, GL_CLAMP_TO_EDGE }; mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, GL_LINEAR, GL_CLAMP_TO_EDGE, nullptr }; mOutGlop->fill.color = { alpha, alpha, alpha, alpha }; setFill(SK_ColorWHITE, alpha, mode, nullptr, colorFilter); Loading @@ -394,6 +396,21 @@ GlopBuilder& GlopBuilder::setFillLayer(Texture& texture, const SkColorFilter* co return *this; } GlopBuilder& GlopBuilder::setFillTextureLayer(Layer& layer, float alpha) { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { &(layer.getTexture()), layer.getRenderTarget(), GL_LINEAR, GL_CLAMP_TO_EDGE, &layer.getTexTransform() }; mOutGlop->fill.color = { alpha, alpha, alpha, alpha }; setFill(SK_ColorWHITE, alpha, layer.getMode(), nullptr, layer.getColorFilter()); mDescription.modulate = mOutGlop->fill.color.a < 1.0f; mDescription.hasTextureTransform = true; return *this; } //////////////////////////////////////////////////////////////////////////////// // Transform //////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -492,20 +509,27 @@ GlopBuilder& GlopBuilder::setRoundRectClipState(const RoundRectClipState* roundR void verify(const ProgramDescription& description, const Glop& glop) { bool hasTexture = glop.fill.texture.texture != nullptr; LOG_ALWAYS_FATAL_IF(description.hasTexture != hasTexture); LOG_ALWAYS_FATAL_IF(description.hasTexture && description.hasExternalTexture); LOG_ALWAYS_FATAL_IF((description.hasTexture || description.hasExternalTexture )!= hasTexture); LOG_ALWAYS_FATAL_IF((glop.mesh.vertices.flags & VertexAttribFlags::kTextureCoord) != hasTexture); if ((glop.mesh.vertices.flags & VertexAttribFlags::kAlpha) && glop.mesh.vertices.bufferObject) { LOG_ALWAYS_FATAL("VBO and alpha attributes are not currently compatible"); } if (description.hasTextureTransform != (glop.fill.texture.textureTransform != nullptr)) { LOG_ALWAYS_FATAL("Texture transform incorrectly specified"); } } void GlopBuilder::build() { REQUIRE_STAGES(kAllStages); mDescription.hasTexture = static_cast<int>(mOutGlop->mesh.vertices.flags & VertexAttribFlags::kTextureCoord); mDescription.hasColors = static_cast<int>(mOutGlop->mesh.vertices.flags & VertexAttribFlags::kColor); mDescription.hasVertexAlpha = static_cast<int>(mOutGlop->mesh.vertices.flags & VertexAttribFlags::kAlpha); if (mOutGlop->mesh.vertices.flags & VertexAttribFlags::kTextureCoord) { mDescription.hasTexture = mOutGlop->fill.texture.target == GL_TEXTURE_2D; mDescription.hasExternalTexture = mOutGlop->fill.texture.target == GL_TEXTURE_EXTERNAL_OES; } mDescription.hasColors = mOutGlop->mesh.vertices.flags & VertexAttribFlags::kColor; mDescription.hasVertexAlpha = mOutGlop->mesh.vertices.flags & VertexAttribFlags::kAlpha; // serialize shader info into ShaderData GLuint textureUnit = mOutGlop->fill.texture.texture ? 1 : 0; Loading libs/hwui/GlopBuilder.h +8 −0 Original line number Diff line number Diff line Loading @@ -57,11 +57,19 @@ public: GlopBuilder& setFillClear(); GlopBuilder& setFillLayer(Texture& texture, const SkColorFilter* colorFilter, float alpha, SkXfermode::Mode mode); GlopBuilder& setFillTextureLayer(Layer& layer, float alpha); GlopBuilder& setTransform(const Matrix4& ortho, const Matrix4& transform, bool fudgingOffset); GlopBuilder& setModelViewMapUnitToRect(const Rect destination); GlopBuilder& setModelViewMapUnitToRectSnap(const Rect destination); GlopBuilder& setModelViewMapUnitToRectOptionalSnap(bool snap, const Rect destination) { if (snap) { return setModelViewMapUnitToRectSnap(destination); } else { return setModelViewMapUnitToRect(destination); } } GlopBuilder& setModelViewOffsetRect(float offsetX, float offsetY, const Rect source); GlopBuilder& setModelViewOffsetRectSnap(float offsetX, float offsetY, const Rect source); Loading libs/hwui/LayerRenderer.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -356,8 +356,9 @@ void LayerRenderer::flushLayer(RenderState& renderState, Layer* layer) { bool LayerRenderer::copyLayer(RenderState& renderState, Layer* layer, SkBitmap* bitmap) { Caches& caches = Caches::getInstance(); if (layer && bitmap->width() <= caches.maxTextureSize && bitmap->height() <= caches.maxTextureSize) { if (layer && bitmap->width() <= caches.maxTextureSize && bitmap->height() <= caches.maxTextureSize) { GLuint fbo = caches.fboCache.get(); if (!fbo) { Loading libs/hwui/OpenGLRenderer.cpp +18 −5 Original line number Diff line number Diff line Loading @@ -846,8 +846,21 @@ void OpenGLRenderer::composeLayer(const Snapshot& removed, const Snapshot& resto } void OpenGLRenderer::drawTextureLayer(Layer* layer, const Rect& rect) { float alpha = getLayerAlpha(layer); if (USE_GLOPS) { bool snap = !layer->getForceFilter() && layer->getWidth() == (uint32_t) rect.getWidth() && layer->getHeight() == (uint32_t) rect.getHeight(); Glop glop; GlopBuilder aBuilder(mRenderState, mCaches, &glop); aBuilder.setMeshTexturedUvQuad(nullptr, Rect(0, 1, 1, 0)) // TODO: simplify with VBO .setFillTextureLayer(*layer, getLayerAlpha(layer)) .setTransform(currentSnapshot()->getOrthoMatrix(), *currentTransform(), false) .setModelViewMapUnitToRectOptionalSnap(snap, rect) .setRoundRectClipState(currentSnapshot()->roundRectClipState) .build(); } float alpha = getLayerAlpha(layer); setupDraw(); if (layer->getRenderTarget() == GL_TEXTURE_2D) { setupDrawWithTexture(); Loading @@ -866,10 +879,10 @@ void OpenGLRenderer::drawTextureLayer(Layer* layer, const Rect& rect) { } else { setupDrawExternalTexture(layer->getTextureId()); } if (currentTransform()->isPureTranslate() && !layer->getForceFilter() && layer->getWidth() == (uint32_t) rect.getWidth() && layer->getHeight() == (uint32_t) rect.getHeight()) { if (currentTransform()->isPureTranslate() && !layer->getForceFilter() && layer->getWidth() == (uint32_t) rect.getWidth() && layer->getHeight() == (uint32_t) rect.getHeight()) { const float x = (int) floorf(rect.left + currentTransform()->getTranslateX() + 0.5f); const float y = (int) floorf(rect.top + currentTransform()->getTranslateY() + 0.5f); Loading Loading
libs/hwui/Glop.h +2 −0 Original line number Diff line number Diff line Loading @@ -94,8 +94,10 @@ struct Glop { struct TextureData { Texture* texture; GLenum target; GLenum filter; GLenum clamp; Matrix4* textureTransform; } texture; bool colorEnabled; Loading
libs/hwui/GlopBuilder.cpp +36 −12 Original line number Diff line number Diff line Loading @@ -274,7 +274,8 @@ GlopBuilder& GlopBuilder::setFillTexturePaint(Texture& texture, bool isAlphaMask TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { &texture, PaintUtils::getFilter(paint), GL_CLAMP_TO_EDGE }; mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, PaintUtils::getFilter(paint), GL_CLAMP_TO_EDGE, nullptr }; if (paint) { int color = paint->getColor(); Loading Loading @@ -315,7 +316,7 @@ GlopBuilder& GlopBuilder::setFillPaint(const SkPaint& paint, float alphaScale) { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; setFill(paint.getColor(), alphaScale, PaintUtils::getXfermode(paint.getXfermode()), paint.getShader(), paint.getColorFilter()); Loading @@ -329,7 +330,7 @@ GlopBuilder& GlopBuilder::setFillPathTexturePaint(PathTexture& texture, REQUIRE_STAGES(kMeshStage); //specify invalid filter/clamp, since these are always static for PathTextures mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; setFill(paint.getColor(), alphaScale, PaintUtils::getXfermode(paint.getXfermode()), paint.getShader(), paint.getColorFilter()); Loading @@ -345,7 +346,7 @@ GlopBuilder& GlopBuilder::setFillShadowTexturePaint(ShadowTexture& texture, int REQUIRE_STAGES(kMeshStage); //specify invalid filter/clamp, since these are always static for ShadowTextures mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; const int ALPHA_BITMASK = SK_ColorBLACK; const int COLOR_BITMASK = ~ALPHA_BITMASK; Loading @@ -366,7 +367,7 @@ GlopBuilder& GlopBuilder::setFillBlack() { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; setFill(SK_ColorBLACK, 1.0f, SkXfermode::kSrcOver_Mode, nullptr, nullptr); return *this; } Loading @@ -375,7 +376,7 @@ GlopBuilder& GlopBuilder::setFillClear() { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM }; mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr }; setFill(SK_ColorBLACK, 1.0f, SkXfermode::kClear_Mode, nullptr, nullptr); return *this; } Loading @@ -385,7 +386,8 @@ GlopBuilder& GlopBuilder::setFillLayer(Texture& texture, const SkColorFilter* co TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { &texture, GL_LINEAR, GL_CLAMP_TO_EDGE }; mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, GL_LINEAR, GL_CLAMP_TO_EDGE, nullptr }; mOutGlop->fill.color = { alpha, alpha, alpha, alpha }; setFill(SK_ColorWHITE, alpha, mode, nullptr, colorFilter); Loading @@ -394,6 +396,21 @@ GlopBuilder& GlopBuilder::setFillLayer(Texture& texture, const SkColorFilter* co return *this; } GlopBuilder& GlopBuilder::setFillTextureLayer(Layer& layer, float alpha) { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = { &(layer.getTexture()), layer.getRenderTarget(), GL_LINEAR, GL_CLAMP_TO_EDGE, &layer.getTexTransform() }; mOutGlop->fill.color = { alpha, alpha, alpha, alpha }; setFill(SK_ColorWHITE, alpha, layer.getMode(), nullptr, layer.getColorFilter()); mDescription.modulate = mOutGlop->fill.color.a < 1.0f; mDescription.hasTextureTransform = true; return *this; } //////////////////////////////////////////////////////////////////////////////// // Transform //////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -492,20 +509,27 @@ GlopBuilder& GlopBuilder::setRoundRectClipState(const RoundRectClipState* roundR void verify(const ProgramDescription& description, const Glop& glop) { bool hasTexture = glop.fill.texture.texture != nullptr; LOG_ALWAYS_FATAL_IF(description.hasTexture != hasTexture); LOG_ALWAYS_FATAL_IF(description.hasTexture && description.hasExternalTexture); LOG_ALWAYS_FATAL_IF((description.hasTexture || description.hasExternalTexture )!= hasTexture); LOG_ALWAYS_FATAL_IF((glop.mesh.vertices.flags & VertexAttribFlags::kTextureCoord) != hasTexture); if ((glop.mesh.vertices.flags & VertexAttribFlags::kAlpha) && glop.mesh.vertices.bufferObject) { LOG_ALWAYS_FATAL("VBO and alpha attributes are not currently compatible"); } if (description.hasTextureTransform != (glop.fill.texture.textureTransform != nullptr)) { LOG_ALWAYS_FATAL("Texture transform incorrectly specified"); } } void GlopBuilder::build() { REQUIRE_STAGES(kAllStages); mDescription.hasTexture = static_cast<int>(mOutGlop->mesh.vertices.flags & VertexAttribFlags::kTextureCoord); mDescription.hasColors = static_cast<int>(mOutGlop->mesh.vertices.flags & VertexAttribFlags::kColor); mDescription.hasVertexAlpha = static_cast<int>(mOutGlop->mesh.vertices.flags & VertexAttribFlags::kAlpha); if (mOutGlop->mesh.vertices.flags & VertexAttribFlags::kTextureCoord) { mDescription.hasTexture = mOutGlop->fill.texture.target == GL_TEXTURE_2D; mDescription.hasExternalTexture = mOutGlop->fill.texture.target == GL_TEXTURE_EXTERNAL_OES; } mDescription.hasColors = mOutGlop->mesh.vertices.flags & VertexAttribFlags::kColor; mDescription.hasVertexAlpha = mOutGlop->mesh.vertices.flags & VertexAttribFlags::kAlpha; // serialize shader info into ShaderData GLuint textureUnit = mOutGlop->fill.texture.texture ? 1 : 0; Loading
libs/hwui/GlopBuilder.h +8 −0 Original line number Diff line number Diff line Loading @@ -57,11 +57,19 @@ public: GlopBuilder& setFillClear(); GlopBuilder& setFillLayer(Texture& texture, const SkColorFilter* colorFilter, float alpha, SkXfermode::Mode mode); GlopBuilder& setFillTextureLayer(Layer& layer, float alpha); GlopBuilder& setTransform(const Matrix4& ortho, const Matrix4& transform, bool fudgingOffset); GlopBuilder& setModelViewMapUnitToRect(const Rect destination); GlopBuilder& setModelViewMapUnitToRectSnap(const Rect destination); GlopBuilder& setModelViewMapUnitToRectOptionalSnap(bool snap, const Rect destination) { if (snap) { return setModelViewMapUnitToRectSnap(destination); } else { return setModelViewMapUnitToRect(destination); } } GlopBuilder& setModelViewOffsetRect(float offsetX, float offsetY, const Rect source); GlopBuilder& setModelViewOffsetRectSnap(float offsetX, float offsetY, const Rect source); Loading
libs/hwui/LayerRenderer.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -356,8 +356,9 @@ void LayerRenderer::flushLayer(RenderState& renderState, Layer* layer) { bool LayerRenderer::copyLayer(RenderState& renderState, Layer* layer, SkBitmap* bitmap) { Caches& caches = Caches::getInstance(); if (layer && bitmap->width() <= caches.maxTextureSize && bitmap->height() <= caches.maxTextureSize) { if (layer && bitmap->width() <= caches.maxTextureSize && bitmap->height() <= caches.maxTextureSize) { GLuint fbo = caches.fboCache.get(); if (!fbo) { Loading
libs/hwui/OpenGLRenderer.cpp +18 −5 Original line number Diff line number Diff line Loading @@ -846,8 +846,21 @@ void OpenGLRenderer::composeLayer(const Snapshot& removed, const Snapshot& resto } void OpenGLRenderer::drawTextureLayer(Layer* layer, const Rect& rect) { float alpha = getLayerAlpha(layer); if (USE_GLOPS) { bool snap = !layer->getForceFilter() && layer->getWidth() == (uint32_t) rect.getWidth() && layer->getHeight() == (uint32_t) rect.getHeight(); Glop glop; GlopBuilder aBuilder(mRenderState, mCaches, &glop); aBuilder.setMeshTexturedUvQuad(nullptr, Rect(0, 1, 1, 0)) // TODO: simplify with VBO .setFillTextureLayer(*layer, getLayerAlpha(layer)) .setTransform(currentSnapshot()->getOrthoMatrix(), *currentTransform(), false) .setModelViewMapUnitToRectOptionalSnap(snap, rect) .setRoundRectClipState(currentSnapshot()->roundRectClipState) .build(); } float alpha = getLayerAlpha(layer); setupDraw(); if (layer->getRenderTarget() == GL_TEXTURE_2D) { setupDrawWithTexture(); Loading @@ -866,10 +879,10 @@ void OpenGLRenderer::drawTextureLayer(Layer* layer, const Rect& rect) { } else { setupDrawExternalTexture(layer->getTextureId()); } if (currentTransform()->isPureTranslate() && !layer->getForceFilter() && layer->getWidth() == (uint32_t) rect.getWidth() && layer->getHeight() == (uint32_t) rect.getHeight()) { if (currentTransform()->isPureTranslate() && !layer->getForceFilter() && layer->getWidth() == (uint32_t) rect.getWidth() && layer->getHeight() == (uint32_t) rect.getHeight()) { const float x = (int) floorf(rect.left + currentTransform()->getTranslateX() + 0.5f); const float y = (int) floorf(rect.top + currentTransform()->getTranslateY() + 0.5f); Loading