From 28ce94a4ffc7576f40776d212f1ada79fafaa061 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Fri, 31 May 2013 11:38:03 -0700 Subject: Overdraw avoidance and merging of clipped ops bug:8951267 If an opaque op, or group of opaque ops covers the invalidate region, skip draw operations that precede it. Clipped operations may now be merged, but only if they share a clipRect - this is a very case for e.g. ListView, where all background elements may now be a part of the same MergingDrawBatch. It is this more aggressive merging that groups together clipped background elements in the ListView case, enabling the overdraw avoidance skipping the window background. Change-Id: Ib0961977e272c5ac37f59e4c67d828467422d259 --- libs/hwui/DeferredDisplayList.h | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'libs/hwui/DeferredDisplayList.h') diff --git a/libs/hwui/DeferredDisplayList.h b/libs/hwui/DeferredDisplayList.h index 9782c1c..7aa1672 100644 --- a/libs/hwui/DeferredDisplayList.h +++ b/libs/hwui/DeferredDisplayList.h @@ -44,8 +44,12 @@ typedef void* mergeid_t; class DeferredDisplayList { public: - DeferredDisplayList() { clear(); } + DeferredDisplayList(const Rect& bounds, bool avoidOverdraw = true) : + mBounds(bounds), mAvoidOverdraw(avoidOverdraw) { + clear(); + } ~DeferredDisplayList() { clear(); } + void reset(const Rect& bounds) { mBounds.set(bounds); } enum OpBatchId { kOpBatch_None = 0, // Don't batch @@ -96,6 +100,12 @@ private: int getStateOpDeferFlags() const; int getDrawOpDeferFlags() const; + void discardDrawingBatches(unsigned int maxIndex); + + // layer space bounds of rendering + Rect mBounds; + const bool mAvoidOverdraw; + /** * At defer time, stores the *defer time* savecount of save/saveLayer ops that were deferred, so * that when an associated restoreToCount is deferred, it can be recorded as a @@ -112,6 +122,9 @@ private: // Points to the index after the most recent barrier int mEarliestBatchIndex; + // Points to the first index that may contain a pure drawing batch + int mEarliestUnclearedIndex; + /** * Maps the mergeid_t returned by an op's getMergeId() to the most recently seen * MergingDrawBatch of that id. These ids are unique per draw type and guaranteed to not @@ -120,6 +133,24 @@ private: TinyHashMap mMergingBatches[kOpBatch_Count]; }; +/** + * Struct containing information that instructs the defer + */ +struct DeferInfo { +public: + DeferInfo() : + batchId(DeferredDisplayList::kOpBatch_None), + mergeId((mergeid_t) -1), + mergeable(false), + opaqueOverBounds(false) { + }; + + int batchId; + mergeid_t mergeId; + bool mergeable; + bool opaqueOverBounds; // opaque over bounds in DeferredDisplayState - can skip ops below +}; + }; // namespace uirenderer }; // namespace android -- cgit v1.1