diff options
author | Russell Brenner <russellbrenner@google.com> | 2011-09-27 15:48:24 -0700 |
---|---|---|
committer | Russell Brenner <russellbrenner@google.com> | 2011-09-27 15:48:24 -0700 |
commit | 2cdcb4f4f308a4b938d07627d52f2bc3788a48f9 (patch) | |
tree | 6248b997fdb7967d5651fbeb84dd8e69bbd8cf07 /Source/WebKit | |
parent | 494b1214559a0b6ddeff8e9b3eebc7f22cb2e951 (diff) | |
download | external_webkit-2cdcb4f4f308a4b938d07627d52f2bc3788a48f9.zip external_webkit-2cdcb4f4f308a4b938d07627d52f2bc3788a48f9.tar.gz external_webkit-2cdcb4f4f308a4b938d07627d52f2bc3788a48f9.tar.bz2 |
Make bucket sizes in increments of 256
As pages grow, limit the number of bucket refills by making them in
chunks of 256 (BUCKET_SIZE). This also fixes a divide-by-zero
error in the earlier update to limit the bucket brigade.
Bug: 5382243
Change-Id: I4ee6eb86c5934175b7cf0f7b69bcfb416d68b967
Diffstat (limited to 'Source/WebKit')
-rw-r--r-- | Source/WebKit/android/jni/PictureSet.cpp | 46 | ||||
-rw-r--r-- | Source/WebKit/android/jni/PictureSet.h | 2 |
2 files changed, 41 insertions, 7 deletions
diff --git a/Source/WebKit/android/jni/PictureSet.cpp b/Source/WebKit/android/jni/PictureSet.cpp index 233a4c9..3f40174 100644 --- a/Source/WebKit/android/jni/PictureSet.cpp +++ b/Source/WebKit/android/jni/PictureSet.cpp @@ -67,8 +67,6 @@ #endif // DEBUG -#define MAX(a,b) ((a)<(b)?(b):(a)) - #if PICTURE_SET_DEBUG class MeasureStream : public SkWStream { public: @@ -84,12 +82,16 @@ public: namespace android { PictureSet::PictureSet() + : mBucketSizeX(0), mBucketSizeY(0), mBucketCountX(0), mBucketCountY(0), + mHeight(0), mWidth(0) { setDimensions(0, 0); mBaseArea = mAdditionalArea = 0; } PictureSet::PictureSet(SkPicture* picture) + : mBucketSizeX(0), mBucketSizeY(0), mBucketCountX(0), mBucketCountY(0), + mHeight(0), mWidth(0) { mBaseArea = mAdditionalArea = 0; if (!picture) { @@ -186,7 +188,7 @@ Bucket* PictureSet::getBucket(int x, int y) BucketPosition position(x+1, y+1); if (!mBuckets.contains(position)) { - XLOGC("PictureSet::getBucket(%d, %d) adding new bucket", x, y); + XLOG("PictureSet::getBucket(%d, %d) adding new bucket", x, y); Bucket* bucket = new Bucket(); mBuckets.add(position, bucket); } @@ -565,22 +567,52 @@ void PictureSet::setDimensions(int width, int height, SkRegion* inval) return; DBG_SET_LOGD("%p old:(w=%d,h=%d) new:(w=%d,h=%d)", this, mWidth, mHeight, width, height); + bool clearCache = false; if (inval) { if (mWidth == width && height > mHeight) { // only grew vertically SkIRect rect; rect.set(0, mHeight, width, height); inval->op(rect, SkRegion::kUnion_Op); } else { + clearCache = true; inval->setRect(0, 0, width, height); } } - clear(); // clear the old cache +#ifdef FAST_PICTURESET + // First figure out how large each bucket would be if we used all of the buckets + int tmpSizeX = (width + MAX_BUCKET_COUNT_X - 1) / MAX_BUCKET_COUNT_X; + int tmpSizeY = (height + MAX_BUCKET_COUNT_Y - 1) / MAX_BUCKET_COUNT_Y; + + // Then round the bucket size up to the nearest chunk + int bucketSizeX = ((tmpSizeX - 1) / BUCKET_SIZE + 1) * BUCKET_SIZE; + int bucketSizeY = ((tmpSizeY - 1) / BUCKET_SIZE + 1) * BUCKET_SIZE; + + int bucketCountX = (width + bucketSizeX - 1) / bucketSizeX; + int bucketCountY = (height + bucketSizeY - 1) / bucketSizeY; + + // Clear the cache if the horizontal bucket count changed or the vertical + // count shrank + if (bucketCountX != mBucketCountX || bucketCountY < mBucketCountY) + clearCache = true; + + // Or if the bucket size changed + if (bucketSizeX != mBucketSizeX || bucketSizeY != mBucketSizeY) + clearCache = true; + + XLOG("old width=%d height=%d bucketSizeX=%d bucketSizeY=%d bucketCountX=%d bucketCountY=%d clearCache=%d", + mWidth, mHeight, mBucketSizeX, mBucketSizeY, mBucketCountX, mBucketCountY, clearCache); + XLOG("new width=%d height=%d bucketSizeX=%d bucketSizeY=%d bucketCountX=%d bucketCountY=%d clearCache=%d", + width, height, bucketSizeX, bucketSizeY, bucketCountX, bucketCountY, clearCache); +#endif + if (clearCache) + clear(); mWidth = width; mHeight = height; #ifdef FAST_PICTURESET - mBucketSizeX = MAX(BUCKET_SIZE, (width + MAX_BUCKET_COUNT_X - 1) / MAX_BUCKET_COUNT_X); - mBucketSizeY = MAX(BUCKET_SIZE, (height + MAX_BUCKET_COUNT_Y - 1) / MAX_BUCKET_COUNT_Y); - XLOGC("mBucketSizeX=%d mBucketSizeY=%d", mBucketSizeX, mBucketSizeY); + mBucketSizeX = bucketSizeX; + mBucketSizeY = bucketSizeY; + mBucketCountX = bucketCountX; + mBucketCountY = bucketCountY; #endif } diff --git a/Source/WebKit/android/jni/PictureSet.h b/Source/WebKit/android/jni/PictureSet.h index 57ae83a..8c1327c 100644 --- a/Source/WebKit/android/jni/PictureSet.h +++ b/Source/WebKit/android/jni/PictureSet.h @@ -119,6 +119,8 @@ namespace android { WTF::Vector<Bucket*> mUpdatedBuckets; int mBucketSizeX; int mBucketSizeY; + int mBucketCountX; + int mBucketCountY; #else struct Pictures { SkRegion mArea; |