From 906d47fd2bcedb9674b5765d01bd9c758069074c Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Fri, 27 Jun 2014 18:30:23 -0700 Subject: [PATCH] Deep copy SkPath parameter to PathCache task bug:15440706 Change-Id: I2b5b25f620df838cb1155cc8502d86ad3644c212 --- libs/hwui/PathCache.cpp | 4 ++-- libs/hwui/PathCache.h | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 97eb58300ec93..ae486087e7851 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -338,7 +338,7 @@ void PathCache::PathProcessor::onProcess(const sp >& task) { float left, top, offset; uint32_t width, height; - PathCache::computePathBounds(t->path, &t->paint, left, top, offset, width, height); + PathCache::computePathBounds(&t->path, &t->paint, left, top, offset, width, height); PathTexture* texture = t->texture; texture->left = left; @@ -349,7 +349,7 @@ void PathCache::PathProcessor::onProcess(const sp >& task) { if (width <= mMaxTextureSize && height <= mMaxTextureSize) { SkBitmap* bitmap = new SkBitmap(); - drawPath(t->path, &t->paint, *bitmap, left, top, offset, width, height); + drawPath(&t->path, &t->paint, *bitmap, left, top, offset, width, height); t->setResult(bitmap); } else { texture->width = 0; diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h index eee138b8fddf4..bc34188f061cd 100644 --- a/libs/hwui/PathCache.h +++ b/libs/hwui/PathCache.h @@ -272,15 +272,18 @@ private: class PathTask: public Task { public: PathTask(const SkPath* path, const SkPaint* paint, PathTexture* texture): - path(path), paint(*paint), texture(texture) { + path(*path), paint(*paint), texture(texture) { } ~PathTask() { delete future()->get(); } - const SkPath* path; - //copied, since input paint may not be immutable + // copied, since input path not refcounted / guaranteed to survive for duration of task + // TODO: avoid deep copy with refcounting + const SkPath path; + + // copied, since input paint may not be immutable const SkPaint paint; PathTexture* texture; };