Stop tons of graphics allocation when hdr/sdr ratio overlay is enabled.
- to reduce memory takup, we create 2 square gfx buffers and
alternatively use one of them to avoid possible tearing.
Bug: 293194007
Test: check SF dumpsys
Change-Id: Ib4d3df480812cc824bcc433566665d915efcc102
diff --git a/services/surfaceflinger/HdrSdrRatioOverlay.h b/services/surfaceflinger/HdrSdrRatioOverlay.h
index 8a2586e..69f95ec 100644
--- a/services/surfaceflinger/HdrSdrRatioOverlay.h
+++ b/services/surfaceflinger/HdrSdrRatioOverlay.h
@@ -35,11 +35,15 @@
private:
float mCurrentHdrSdrRatio = 1.f;
- static sp<GraphicBuffer> draw(float currentHdrSdrRatio, SkColor, ui::Transform::RotationFlags);
+ static sp<GraphicBuffer> draw(float currentHdrSdrRatio, SkColor, ui::Transform::RotationFlags,
+ sp<GraphicBuffer>& ringBufer);
static void drawNumber(float number, int left, SkColor, SkCanvas&);
const sp<GraphicBuffer> getOrCreateBuffers(float currentHdrSdrRatio);
const std::unique_ptr<SurfaceControlHolder> mSurfaceControl;
+
+ size_t mIndex = 0;
+ std::array<sp<GraphicBuffer>, 2> mRingBuffer;
};
} // namespace android