From 5d4e24edaaec4a23019f659dfd6e26abe081aac9 Mon Sep 17 00:00:00 2001 From: Lloyd Pique Date: Wed, 19 Aug 2020 20:02:44 -0700 Subject: CE: Default-Initialize shadowRadius and a timestamp The unit tests in particular assume that all values are initialzed to some reasonable default. The OutputTest takesEarlyOutIfLayerHasEmptyVisibleRegion was aborting on an integer overflow inside Rect::inset() because an uninitialized shadowRadius was being converted to -INT32_MIN. The OutputTest gathersClientCompositionRequests() was sometimes failing because it assumes that the timestamp is set to zero by default, and is set to a (nonzero) value by the code under test. With both these fixes, the CompositionEngine tests pass. Test: atest libcompositionengine_test Bug: None Change-Id: I7ff56a0f24f6d5960493b18458f52766f955151d --- .../include/compositionengine/LayerFECompositionState.h | 2 +- .../include/compositionengine/impl/OutputLayerCompositionState.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'services') diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h index 8a9763bbeb..b4ed92f965 100644 --- a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h @@ -116,7 +116,7 @@ struct LayerFECompositionState { FloatRect geomLayerBounds; // length of the shadow in screen space - float shadowRadius; + float shadowRadius{0.f}; /* * Geometry state diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h index 75394fadb7..d2b38d1815 100644 --- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h @@ -110,7 +110,7 @@ struct OutputLayerCompositionState { void dump(std::string& result) const; // Timestamp for when the layer is queued for client composition - nsecs_t clientCompositionTimestamp; + nsecs_t clientCompositionTimestamp{0}; }; } // namespace compositionengine::impl -- cgit v1.2.3-59-g8ed1b