From 1a0808e64c170fa7b620b858fa5875f6f08a2b54 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Wed, 13 May 2015 16:33:04 -0700 Subject: Add back alpha atrace log bug:20922838 Change-Id: I70ccbffdd5f140cd1dd71fbf456fb5b085e74a4a --- libs/hwui/RenderNode.cpp | 7 +++++++ libs/hwui/RenderProperties.h | 14 +++++++------- libs/hwui/utils/TraceUtils.h | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 8f95e0d..9146b68 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -392,6 +392,13 @@ void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) { } LOG_ALWAYS_FATAL_IF(!isLayer && properties().getHasOverlappingRendering()); renderer.scaleAlpha(properties().getAlpha()); + + if (CC_UNLIKELY(ATRACE_ENABLED() && properties().promotedToLayer())) { + // pretend to cause savelayer to warn about performance problem affecting old versions + ATRACE_FORMAT("%s alpha caused saveLayer %dx%d", getName(), + static_cast(getWidth()), + static_cast(getHeight())); + } } if (clipFlags) { Rect clipRect; diff --git a/libs/hwui/RenderProperties.h b/libs/hwui/RenderProperties.h index a43566d..98029a8 100644 --- a/libs/hwui/RenderProperties.h +++ b/libs/hwui/RenderProperties.h @@ -576,15 +576,15 @@ public: && getOutline().getAlpha() != 0.0f; } - LayerType effectiveLayerType() const { - LayerType type = mLayerProperties.mType; - if (type == LayerType::None + bool promotedToLayer() const { + return mLayerProperties.mType == LayerType::None && !MathUtils::isZero(mPrimitiveFields.mAlpha) && mPrimitiveFields.mAlpha < 1 - && mPrimitiveFields.mHasOverlappingRendering) { - return LayerType::RenderLayer; - } - return type; + && mPrimitiveFields.mHasOverlappingRendering; + } + + LayerType effectiveLayerType() const { + return promotedToLayer() ? LayerType::RenderLayer : mLayerProperties.mType; } private: diff --git a/libs/hwui/utils/TraceUtils.h b/libs/hwui/utils/TraceUtils.h index ff8ccb8..ddc272c 100644 --- a/libs/hwui/utils/TraceUtils.h +++ b/libs/hwui/utils/TraceUtils.h @@ -35,7 +35,7 @@ public: }; static void atraceFormatBegin(const char* fmt, ...) { - if (CC_UNLIKELY(!ATRACE_ENABLED())) return; + if (CC_LIKELY(!ATRACE_ENABLED())) return; const int BUFFER_SIZE = 256; va_list ap; -- cgit v1.1