diff options
author | Chris Craik <ccraik@google.com> | 2015-02-09 18:58:32 -0800 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2015-02-09 19:08:02 -0800 |
commit | 08fa43fdeb646f56edcd8b33d06ee7d79b203426 (patch) | |
tree | 1daac9af26a7cba89763cd9c3e76beed8903753c /libs/hwui/GlopBuilder.cpp | |
parent | 2ab95d780b023152556d9f8659de734ec7b55047 (diff) | |
download | frameworks_base-08fa43fdeb646f56edcd8b33d06ee7d79b203426.zip frameworks_base-08fa43fdeb646f56edcd8b33d06ee7d79b203426.tar.gz frameworks_base-08fa43fdeb646f56edcd8b33d06ee7d79b203426.tar.bz2 |
Fix Glop vertex alpha blending
Need to force blending if vertices have alpha attribute
Change-Id: I821792db6b613b4d0243cf9c7a045cba014acdc1
Diffstat (limited to 'libs/hwui/GlopBuilder.cpp')
-rw-r--r-- | libs/hwui/GlopBuilder.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/hwui/GlopBuilder.cpp b/libs/hwui/GlopBuilder.cpp index e0f2ec4..5373275 100644 --- a/libs/hwui/GlopBuilder.cpp +++ b/libs/hwui/GlopBuilder.cpp @@ -35,6 +35,10 @@ namespace uirenderer { LOG_ALWAYS_FATAL_IF(stageFlag & mStageFlags, "Stage %d cannot be run twice"); \ mStageFlags = static_cast<StageFlags>(mStageFlags | stageFlag) +#define REQUIRE_STAGES(requiredFlags) \ + LOG_ALWAYS_FATAL_IF((mStageFlags & requiredFlags) != requiredFlags, \ + "not prepared for current stage") + GlopBuilder::GlopBuilder(RenderState& renderState, Caches& caches, Glop* outGlop) : mRenderState(renderState) , mCaches(caches) @@ -127,12 +131,14 @@ GlopBuilder& GlopBuilder::setOptionalPaint(const SkPaint* paint, float alphaScal } TRIGGER_STAGE(kFillStage); + REQUIRE_STAGES(kMeshStage); mOutGlop->fill.color = { alphaScale, alphaScale, alphaScale, alphaScale }; const bool SWAP_SRC_DST = false; // TODO: account for texture blend - if (alphaScale < 1.0f) { + if (alphaScale < 1.0f + || (mOutGlop->mesh.vertexFlags & kAlpha_Attrib)) { Blend::getFactors(SkXfermode::kSrcOver_Mode, SWAP_SRC_DST, &mOutGlop->blend.src, &mOutGlop->blend.dst); } else { @@ -143,6 +149,7 @@ GlopBuilder& GlopBuilder::setOptionalPaint(const SkPaint* paint, float alphaScal } GlopBuilder& GlopBuilder::setPaint(const SkPaint& paint, float alphaScale) { TRIGGER_STAGE(kFillStage); + REQUIRE_STAGES(kMeshStage); const SkShader* shader = paint.getShader(); const SkColorFilter* colorFilter = paint.getColorFilter(); @@ -169,6 +176,7 @@ GlopBuilder& GlopBuilder::setPaint(const SkPaint& paint, float alphaScale) { mOutGlop->blend = { GL_ZERO, GL_ZERO }; if (mOutGlop->fill.color.a < 1.0f + || (mOutGlop->mesh.vertexFlags & kAlpha_Attrib) || PaintUtils::isBlendedShader(shader) || PaintUtils::isBlendedColorFilter(colorFilter) || mode != SkXfermode::kSrcOver_Mode) { @@ -242,7 +250,7 @@ GlopBuilder& GlopBuilder::setPaint(const SkPaint& paint, float alphaScale) { } void GlopBuilder::build() { - LOG_ALWAYS_FATAL_IF(mStageFlags != kAllStages, "glop not fully prepared!"); + REQUIRE_STAGES(kAllStages); mDescription.modulate = mOutGlop->fill.color.a < 1.0f; mOutGlop->fill.program = mCaches.programCache.get(mDescription); |