diff options
author | Romain Guy <romainguy@google.com> | 2012-12-03 12:34:51 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2013-01-14 14:27:54 -0800 |
commit | 735738c4ddf3229caa5f6e634bf591953ac29944 (patch) | |
tree | 4e972e943ffefc5bc268629ed45e8a5783ffe7c5 /libs/hwui/DisplayListRenderer.h | |
parent | 57b59e025bc10056daf42cd741b626843ff344f5 (diff) | |
download | frameworks_base-735738c4ddf3229caa5f6e634bf591953ac29944.zip frameworks_base-735738c4ddf3229caa5f6e634bf591953ac29944.tar.gz frameworks_base-735738c4ddf3229caa5f6e634bf591953ac29944.tar.bz2 |
Preliminary Support for region clipping
Region clipping, using Canvas.clipPath or Canvas.clipRegion, requires
a stencil buffer to be always present. In addition, extra wiring is
required in JNI and display lists.
This change only adds the necessary JNI/C++ APIs and some extra
plumbing to start the real work on properly supporting region
clipping.
A new debug define called DEBUG_CLIP_REGIONS can be used to draw
the current clip region. It is off by default, as is region
clipping.
The default implementation of clipPath() and clipRegion(), now
in native, mimics the previous Dalvik implementation to prevent
regressions.
Change-Id: I7903e7cfd7412b9b9b622566d4dbfce7bdcec00c
Diffstat (limited to 'libs/hwui/DisplayListRenderer.h')
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index fb01753..f55f1f2 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -85,6 +85,8 @@ public: SetMatrix, ConcatMatrix, ClipRect, + ClipPath, + ClipRegion, // Drawing operations DrawDisplayList, DrawLayer, @@ -457,6 +459,10 @@ private: return (SkPath*) getInt(); } + SkRegion* getRegion() { + return (SkRegion*) getInt(); + } + SkPaint* getPaint(OpenGLRenderer& renderer) { return renderer.filterPaint((SkPaint*) getInt()); } @@ -496,6 +502,7 @@ private: Vector<SkPaint*> mPaints; Vector<SkPath*> mPaths; SortedVector<SkPath*> mSourcePaths; + Vector<SkRegion*> mRegions; Vector<SkMatrix*> mMatrices; Vector<SkiaShader*> mShaders; Vector<Layer*> mLayers; @@ -577,6 +584,8 @@ public: virtual void concatMatrix(SkMatrix* matrix); virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op); + virtual bool clipPath(SkPath* path, SkRegion::Op op); + virtual bool clipRegion(SkRegion* region, SkRegion::Op op); virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags, uint32_t level = 0); @@ -657,6 +666,10 @@ public: return mSourcePaths; } + const Vector<SkRegion*>& getRegions() const { + return mRegions; + } + const Vector<Layer*>& getLayers() const { return mLayers; } @@ -802,6 +815,26 @@ private: return paintCopy; } + inline SkRegion* addRegion(SkRegion* region) { + if (!region) { + addInt((int) NULL); + return region; + } + + SkRegion* regionCopy = mRegionMap.valueFor(region); + // TODO: Add generation ID to SkRegion + if (regionCopy == NULL) { + regionCopy = new SkRegion(*region); + // replaceValueFor() performs an add if the entry doesn't exist + mRegionMap.replaceValueFor(region, regionCopy); + mRegions.add(regionCopy); + } + + addInt((int) regionCopy); + + return regionCopy; + } + inline void addDisplayList(DisplayList* displayList) { // TODO: To be safe, the display list should be ref-counted in the // resources cache, but we rely on the caller (UI toolkit) to @@ -876,6 +909,9 @@ private: SortedVector<SkPath*> mSourcePaths; + Vector<SkRegion*> mRegions; + DefaultKeyedVector<SkRegion*, SkRegion*> mRegionMap; + Vector<SkiaShader*> mShaders; DefaultKeyedVector<SkiaShader*, SkiaShader*> mShaderMap; |