summaryrefslogtreecommitdiff
path: root/libs/hwui/VectorDrawable.cpp
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2016-04-29 18:41:29 -0700
committerDoris Liu <tianliu@google.com>2016-05-02 15:34:40 -0700
commitf8d131cc8dc4ef675b8f8fc57dcc26062d575d32 (patch)
tree51c0be31e4c4e1761ce717d982fa59c5d67cc127 /libs/hwui/VectorDrawable.cpp
parenta1e7be375e618544e22287d0ee59f517536f95e1 (diff)
Count native allocation for VD against Java heap
There are two parts to VD's native allocation: 1) VD's internal data structure (i.e. groups, paths, etc that make up of the VD tree). This structure can change, when a VD is used to load a different drawable resource. 2) Two bitmap caches, not both of which will necessarily be allocated The size of the bitmap cache depends on canvas matrix and drawable bounds, and therefore can often change. We need to count the native allocation from the above against Java heap. Bug: 26269056 Change-Id: If833aedcf7f3efe00ea73a41ddccb1b48066ffd8
Diffstat (limited to 'libs/hwui/VectorDrawable.cpp')
-rw-r--r--libs/hwui/VectorDrawable.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp
index ac17ed2eb735..f0348e4977ae 100644
--- a/libs/hwui/VectorDrawable.cpp
+++ b/libs/hwui/VectorDrawable.cpp
@@ -456,7 +456,7 @@ bool Group::GroupProperties::isValidProperty(int propertyId) {
return propertyId >= 0 && propertyId < static_cast<int>(Property::count);
}
-void Tree::draw(Canvas* outCanvas, SkColorFilter* colorFilter,
+int Tree::draw(Canvas* outCanvas, SkColorFilter* colorFilter,
const SkRect& bounds, bool needsMirroring, bool canReuseCache) {
// The imageView can scale the canvas in different ways, in order to
// avoid blurry scaling, we have to draw into a bitmap with exact pixel
@@ -478,7 +478,7 @@ void Tree::draw(Canvas* outCanvas, SkColorFilter* colorFilter,
scaledHeight = std::min(Tree::MAX_CACHED_BITMAP_SIZE, scaledHeight);
if (scaledWidth <= 0 || scaledHeight <= 0) {
- return;
+ return 0;
}
mStagingProperties.setScaledSize(scaledWidth, scaledHeight);
@@ -500,6 +500,7 @@ void Tree::draw(Canvas* outCanvas, SkColorFilter* colorFilter,
mStagingProperties.setBounds(tmpBounds);
outCanvas->drawVectorDrawable(this);
outCanvas->restoreToCount(saveCount);
+ return scaledWidth * scaledHeight;
}
void Tree::drawStaging(Canvas* outCanvas) {