Refactor HWUI to better handle Canvas DrawFilters.
First, this CL removes the need to decompose the DrawFilters
in Java and instead passes the SkDrawFilter to HWUI directly.
This also allows the removal of duplicated logic between HWUI
and other Canvas implementations regarding Paint filter levels.
Second, the DrawFilter is now stored in the DisplayListRenderer
where we apply it to every paint BEFORE it is stored in the
DisplayList. This eliminates the need to filter all Paints on
playback and removes additional complexity at playback.
Finally, as a result of storing the filtered paint we can now
do a better job caching the paints. This takes advantage of
recent changes in Skia to quickly enable quick hashing and
comparison of paint objects.
Change-Id: Iec507a2d894827975cc4f1d22241542bb0534b4e
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index b691019..c40258b 100755
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -3057,47 +3057,10 @@
///////////////////////////////////////////////////////////////////////////////
// Draw filters
///////////////////////////////////////////////////////////////////////////////
-
-void OpenGLRenderer::resetPaintFilter() {
- // when clearing the PaintFilter, the masks should also be cleared for simple DrawModifier
- // comparison, see MergingDrawBatch::canMergeWith
- mDrawModifiers.mHasDrawFilter = false;
- mDrawModifiers.mPaintFilterClearBits = 0;
- mDrawModifiers.mPaintFilterSetBits = 0;
-}
-
-void OpenGLRenderer::setupPaintFilter(int clearBits, int setBits) {
- // TODO: don't bother with boolean, it's redundant with clear/set bits
- mDrawModifiers.mHasDrawFilter = true;
- mDrawModifiers.mPaintFilterClearBits = clearBits & SkPaint::kAllFlags;
- mDrawModifiers.mPaintFilterSetBits = setBits & SkPaint::kAllFlags;
-}
-
-const SkPaint* OpenGLRenderer::filterPaint(const SkPaint* paint) {
- // TODO: use CompatFlagsDrawFilter here, and combine logic with android/graphics/DrawFilter.cpp
- // to avoid clobbering 0x02 paint flag
-
- // Equivalent to the Java Paint's FILTER_BITMAP_FLAG.
- static const uint32_t sFilterBitmapFlag = 0x02;
-
- if (CC_LIKELY(!mDrawModifiers.mHasDrawFilter || !paint)) {
- return paint;
- }
-
- const uint32_t clearBits = mDrawModifiers.mPaintFilterClearBits;
- const uint32_t setBits = mDrawModifiers.mPaintFilterSetBits;
-
- const uint32_t flags = (paint->getFlags() & ~clearBits) | setBits;
- mFilteredPaint = *paint;
- mFilteredPaint.setFlags(flags);
-
- // check if paint filter trying to override bitmap filter
- if ((clearBits | setBits) & sFilterBitmapFlag) {
- mFilteredPaint.setFilterLevel(flags & sFilterBitmapFlag
- ? SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel);
- }
-
- return &mFilteredPaint;
+void OpenGLRenderer::setDrawFilter(SkDrawFilter* filter) {
+ // We should never get here since we apply the draw filter when stashing
+ // the paints in the DisplayList.
+ LOG_ALWAYS_FATAL("OpenGLRenderer does not directly support DrawFilters");
}
///////////////////////////////////////////////////////////////////////////////