summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Roard <nicolasroard@google.com>2011-09-30 18:49:21 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-30 18:49:21 -0700
commit89829a24e4efac83486ad878de3438e272aeeddf (patch)
treef1dd48e7efcd4d8c5a265954996c38802e27e7d7
parentf0e6fa61e920b50abc54360342c9f058cd23f601 (diff)
parente813876665227fbf67a696b7da98a0eeaf1064de (diff)
downloadexternal_webkit-89829a24e4efac83486ad878de3438e272aeeddf.zip
external_webkit-89829a24e4efac83486ad878de3438e272aeeddf.tar.gz
external_webkit-89829a24e4efac83486ad878de3438e272aeeddf.tar.bz2
Merge "Fine-tune the number of buckets in PictureSet add some clearing logic as well"
-rw-r--r--Source/WebKit/android/jni/PictureSet.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/Source/WebKit/android/jni/PictureSet.cpp b/Source/WebKit/android/jni/PictureSet.cpp
index 6edb7ba..4d9d16c 100644
--- a/Source/WebKit/android/jni/PictureSet.cpp
+++ b/Source/WebKit/android/jni/PictureSet.cpp
@@ -43,7 +43,7 @@
#define MAX_ADDITIONAL_AREA 0.65
#define MAX_ADDITIONAL_PICTURES 32
-#define BUCKET_SIZE 256
+#define BUCKET_SIZE 1024
#define MAX_BUCKET_COUNT_X 16
#define MAX_BUCKET_COUNT_Y 64
@@ -288,6 +288,38 @@ void PictureSet::addToBucket(Bucket* bucket, int dx, int dy, SkIRect& rect)
first = bucket->begin();
last = bucket->end();
+ bool clearUp = false;
+ if (last - first > MAX_ADDITIONAL_PICTURES) {
+ // too many pictures in the bucket, let's collapse
+ clearUp = true;
+ }
+
+ float bucketBaseArea = 0;
+ float bucketAdditionalArea = 0;
+ for (BucketPicture* current = first; current != last; current++) {
+ float area = current->mArea.width() * current->mArea.height();
+ if (current->mBase)
+ bucketBaseArea += area;
+ else
+ bucketAdditionalArea += area;
+ }
+
+ if (bucketBaseArea > 0 && bucketBaseArea * MAX_ADDITIONAL_AREA <= bucketAdditionalArea) {
+ // additional area too large, not worth maintaining
+ clearUp = true;
+ }
+
+ // To clear things up, we just need to mark the pictures' area as empty
+ // We only keep the base surface.
+ if (clearUp) {
+ for (BucketPicture* current = first; current != last; current++) {
+ if (!current->mBase)
+ current->mArea.setEmpty();
+ SkSafeUnref(current->mPicture);
+ current->mPicture = 0;
+ }
+ }
+
// let's do a pass to collapse out empty areas
BucketPicture* writer = first;
for (BucketPicture* current = first; current != last; current++) {