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
This commit is contained in:
parent
d8b5faca04
commit
35ac048e35
@ -13,6 +13,7 @@
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkSerializationHelpers.h"
|
||||
|
||||
class SkBBoxHierarchy;
|
||||
class SkBitmap;
|
||||
class SkCanvas;
|
||||
class SkPicturePlayback;
|
||||
@ -154,16 +155,13 @@ protected:
|
||||
SkPictureRecord* fRecord;
|
||||
int fWidth, fHeight;
|
||||
|
||||
// For testing. Derived classes may instantiate an alternate
|
||||
// SkBBoxHierarchy implementation
|
||||
virtual SkBBoxHierarchy* createBBoxHierarchy() const;
|
||||
|
||||
private:
|
||||
SkPicturePlayback* fPlayback;
|
||||
|
||||
/** Used by the R-Tree when kOptimizeForClippedPlayback_RecordingFlag is
|
||||
set, these were empirically determined to produce reasonable performance
|
||||
in most cases.
|
||||
*/
|
||||
static const int kRTreeMinChildren = 6;
|
||||
static const int kRTreeMaxChildren = 11;
|
||||
|
||||
friend class SkFlatPicture;
|
||||
friend class SkPicturePlayback;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user