diff options
author | Romain Guy <romainguy@google.com> | 2012-02-16 19:24:51 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-02-17 13:10:00 -0800 |
commit | 33f6beb10f98e8ba96250e284876d607055d278d (patch) | |
tree | 215fc7d5624b6b41a018374f5d19f7dac84cf72b /libs/hwui/ShapeCache.h | |
parent | 445c83c7755fae179cf3328e89307e2775e97a5e (diff) | |
download | frameworks_base-33f6beb10f98e8ba96250e284876d607055d278d.zip frameworks_base-33f6beb10f98e8ba96250e284876d607055d278d.tar.gz frameworks_base-33f6beb10f98e8ba96250e284876d607055d278d.tar.bz2 |
Record possible clip rejects when recording display lists
This optimization allows us to quickly skip operations that lie
entirely outside of the known bounds of a display list. Because
of ViewGroup.setClipChildren, we must keep the operations recorded
in the display list. setClipChildren(false) is however a very
uncommon operation and we will therefore often benefit from this
new optimization.
Change-Id: I0942c864e55298e6dccd9977d15adefbce3ba3ad
Diffstat (limited to 'libs/hwui/ShapeCache.h')
-rw-r--r-- | libs/hwui/ShapeCache.h | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/libs/hwui/ShapeCache.h b/libs/hwui/ShapeCache.h index 30ce690..f180e94 100644 --- a/libs/hwui/ShapeCache.h +++ b/libs/hwui/ShapeCache.h @@ -489,18 +489,16 @@ void ShapeCache<Entry>::removeTexture(PathTexture* texture) { } } +void computePathBounds(const SkPath *path, const SkPaint* paint, + float& left, float& top, float& offset, uint32_t& width, uint32_t& height); + template<class Entry> PathTexture* ShapeCache<Entry>::addTexture(const Entry& entry, const SkPath *path, const SkPaint* paint) { - const SkRect& bounds = path->getBounds(); - - const float pathWidth = fmax(bounds.width(), 1.0f); - const float pathHeight = fmax(bounds.height(), 1.0f); - - const float offset = (int) floorf(fmax(paint->getStrokeWidth(), 1.0f) * 1.5f + 0.5f); - const uint32_t width = uint32_t(pathWidth + offset * 2.0 + 0.5); - const uint32_t height = uint32_t(pathHeight + offset * 2.0 + 0.5); + float left, top, offset; + uint32_t width, height; + computePathBounds(path, paint, left, top, offset, width, height); if (width > mMaxTextureSize || height > mMaxTextureSize) { ALOGW("Shape %s too large to be rendered into a texture (%dx%d, max=%dx%d)", @@ -517,8 +515,8 @@ PathTexture* ShapeCache<Entry>::addTexture(const Entry& entry, const SkPath *pat } PathTexture* texture = new PathTexture; - texture->left = bounds.fLeft; - texture->top = bounds.fTop; + texture->left = left; + texture->top = top; texture->offset = offset; texture->width = width; texture->height = height; @@ -542,7 +540,7 @@ PathTexture* ShapeCache<Entry>::addTexture(const Entry& entry, const SkPath *pat SkSafeUnref(pathPaint.setXfermode(mode)); SkCanvas canvas(bitmap); - canvas.translate(-bounds.fLeft + offset, -bounds.fTop + offset); + canvas.translate(-left + offset, -top + offset); canvas.drawPath(*path, pathPaint); generateTexture(bitmap, texture); |