summaryrefslogtreecommitdiffstats
path: root/libs/hwui/DisplayListRenderer.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/DisplayListRenderer.h')
-rw-r--r--libs/hwui/DisplayListRenderer.h57
1 files changed, 31 insertions, 26 deletions
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 901e8f0..3301ce4 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -17,13 +17,17 @@
#ifndef ANDROID_HWUI_DISPLAY_LIST_RENDERER_H
#define ANDROID_HWUI_DISPLAY_LIST_RENDERER_H
+#include <SkDrawFilter.h>
#include <SkMatrix.h>
#include <SkPaint.h>
#include <SkPath.h>
+#include <SkRegion.h>
+#include <SkTLazy.h>
#include <cutils/compiler.h>
+#include "DisplayList.h"
#include "DisplayListLogBuffer.h"
-#include "RenderNode.h"
+#include "StatefulBaseRenderer.h"
namespace android {
namespace uirenderer {
@@ -44,9 +48,10 @@ namespace uirenderer {
///////////////////////////////////////////////////////////////////////////////
class DeferredDisplayList;
-class DisplayListRenderer;
class DisplayListOp;
+class DisplayListRenderer;
class DrawOp;
+class RenderNode;
class StateOp;
/**
@@ -93,9 +98,8 @@ public:
virtual bool clipPath(const SkPath* path, SkRegion::Op op);
virtual bool clipRegion(const SkRegion* region, SkRegion::Op op);
- // Misc - should be implemented with SkPaint inspection
- virtual void resetPaintFilter();
- virtual void setupPaintFilter(int clearBits, int setBits);
+ // Misc
+ virtual void setDrawFilter(SkDrawFilter* filter);
bool isCurrentTransformSimple() {
return currentTransform()->isSimple();
@@ -218,35 +222,34 @@ private:
inline const SkPaint* refPaint(const SkPaint* paint) {
if (!paint) return NULL;
- const SkPaint* paintCopy = mPaintMap.valueFor(paint);
- if (paintCopy == NULL
- || paintCopy->getGenerationID() != paint->getGenerationID()
- // We can't compare shader pointers because that will always
- // change as we do partial copying via wrapping. However, if the
- // shader changes the paint generationID will have changed and
- // so we don't hit this comparison anyway
- || !(paint->getShader() && paintCopy->getShader()
- && paint->getShader()->getGenerationID() == paintCopy->getShader()->getGenerationID())) {
- paintCopy = copyPaint(paint);
+ // If there is a draw filter apply it here and store the modified paint
+ // so that we don't need to modify the paint every time we access it.
+ SkTLazy<SkPaint> filteredPaint;
+ if (mDrawFilter.get()) {
+ paint = filteredPaint.init();
+ mDrawFilter->filter(filteredPaint.get(), SkDrawFilter::kPaint_Type);
+ }
+
+ // compute the hash key for the paint and check the cache.
+ const uint32_t key = paint->getHash();
+ const SkPaint* cachedPaint = mPaintMap.valueFor(key);
+ // In the unlikely event that 2 unique paints have the same hash we do a
+ // object equality check to ensure we don't erroneously dedup them.
+ if (cachedPaint == NULL || *cachedPaint != *paint) {
+ cachedPaint = new SkPaint(*paint);
// replaceValueFor() performs an add if the entry doesn't exist
- mPaintMap.replaceValueFor(paint, paintCopy);
+ mPaintMap.replaceValueFor(key, cachedPaint);
+ mDisplayListData->paints.add(cachedPaint);
}
- return paintCopy;
+ return cachedPaint;
}
inline SkPaint* copyPaint(const SkPaint* paint) {
if (!paint) return NULL;
SkPaint* paintCopy = new SkPaint(*paint);
- if (paint->getShader()) {
- SkShader* shaderCopy = SkShader::CreateLocalMatrixShader(
- paint->getShader(), paint->getShader()->getLocalMatrix());
- paintCopy->setShader(shaderCopy);
- paintCopy->setGenerationID(paint->getGenerationID());
- shaderCopy->setGenerationID(paint->getShader()->getGenerationID());
- shaderCopy->unref();
- }
mDisplayListData->paints.add(paintCopy);
+
return paintCopy;
}
@@ -289,7 +292,7 @@ private:
return patch;
}
- DefaultKeyedVector<const SkPaint*, const SkPaint*> mPaintMap;
+ DefaultKeyedVector<uint32_t, const SkPaint*> mPaintMap;
DefaultKeyedVector<const SkPath*, const SkPath*> mPathMap;
DefaultKeyedVector<const SkRegion*, const SkRegion*> mRegionMap;
@@ -304,6 +307,8 @@ private:
int mRestoreSaveCount;
+ SkAutoTUnref<SkDrawFilter> mDrawFilter;
+
friend class RenderNode;
}; // class DisplayListRenderer