Add back alpha atrace log
bug:20922838
Change-Id: I70ccbffdd5f140cd1dd71fbf456fb5b085e74a4a
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 @@
}
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<int>(getWidth()),
+ static_cast<int>(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 @@
&& 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 @@
};
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;