diff options
author | 2012-11-01 17:10:32 +0000 | |
---|---|---|
committer | 2012-11-01 17:10:32 +0000 | |
commit | 35ac048e357aefa6289485c8f6a50fadce23c0d2 (patch) | |
tree | e3411b4224959e9cf4938a1c52b5238144dde912 /src/core/SkPicture.cpp | |
parent | d8b5faca043100d7a1e4594b4d10e462532af390 (diff) |
Refactoring RTree integration to support SkBBoxHierarchy polymorphism in SkPicture.
This moves the rtree creation into a virtual method.
Review URL: https://codereview.appspot.com/6811057
git-svn-id: http://skia.googlecode.com/svn/trunk@6242 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkPicture.cpp')
-rw-r--r-- | src/core/SkPicture.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index cc73bda5e4..ed3e9ceba8 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -190,11 +190,12 @@ SkCanvas* SkPicture::beginRecording(int width, int height, bm.setConfig(SkBitmap::kNo_Config, width, height); SkAutoTUnref<SkDevice> dev(SkNEW_ARGS(SkDevice, (bm))); + // Must be set before calling createBBoxHierarchy + fWidth = width; + fHeight = height; + if (recordingFlags & kOptimizeForClippedPlayback_RecordingFlag) { - SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(width), - SkIntToScalar(height)); - SkRTree* tree = SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren, - aspectRatio); + SkBBoxHierarchy* tree = this->createBBoxHierarchy(); SkASSERT(NULL != tree); fRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (recordingFlags, tree, dev)); tree->unref(); @@ -203,12 +204,21 @@ SkCanvas* SkPicture::beginRecording(int width, int height, } fRecord->beginRecording(); - fWidth = width; - fHeight = height; - return fRecord; } +SkBBoxHierarchy* SkPicture::createBBoxHierarchy() const { + // These values were empirically determined to produce reasonable + // performance in most cases. + static const int kRTreeMinChildren = 6; + static const int kRTreeMaxChildren = 11; + + SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(fWidth), + SkIntToScalar(fHeight)); + return SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren, + aspectRatio); +} + SkCanvas* SkPicture::getRecordingCanvas() const { // will be null if we are not recording return fRecord; |