diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-16 16:02:10 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-16 16:02:10 +0000 |
commit | d393b17cf3427bd6f6255f8670067d9aa529e409 (patch) | |
tree | 3c534a8644f344121e6e56b3322ea7ebcf62d51c /src | |
parent | 4453e8b45aaaaea568da35f8144177bdc8d2e171 (diff) |
Retract SkPicture::kOptimizeForClippedPlayback_RecordingFlag from public API
This CL sets the stage for retracting the SkPicture::kOptimizeForClippedPlayback_RecordingFlag flag
from the public API (more work needs to be done in Blink & Chrome). In the new world the only way
to set this flag (and thus instantiate an SkPicture-derived
class) is by passing a factory to the SkPictureRecorder class. This is to get all clients always using
factories so that we can then change the factory call used (i.e., so the factory just creates a BBH) and
do away with the SkPicture-derived classes.
BUG=skia:2315
R=reed@google.com
Author: robertphillips@google.com
Review URL: https://codereview.chromium.org/239703006
git-svn-id: http://skia.googlecode.com/svn/trunk@14221 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPicture.cpp | 4 | ||||
-rw-r--r-- | src/core/SkQuadTreePicture.h | 9 | ||||
-rw-r--r-- | src/core/SkRTreePicture.cpp | 25 |
3 files changed, 34 insertions, 4 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index d805fc52a2..986dc424c9 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -253,6 +253,10 @@ SkCanvas* SkPicture::beginRecording(int width, int height, } SkBBoxHierarchy* SkPicture::createBBoxHierarchy() const { + // TODO: this code is now replicated in SkRTreePicture. Once all external + // clients have been weaned off of kOptimizeForClippedPlayback_RecordingFlag, + // this code can be removed. + // These values were empirically determined to produce reasonable // performance in most cases. static const int kRTreeMinChildren = 6; diff --git a/src/core/SkQuadTreePicture.h b/src/core/SkQuadTreePicture.h index 67e6658deb..811383b668 100644 --- a/src/core/SkQuadTreePicture.h +++ b/src/core/SkQuadTreePicture.h @@ -12,9 +12,8 @@ #include "SkRect.h" /** - * Subclass of SkPicture that override the behavior of the - * kOptimizeForClippedPlayback_RecordingFlag by creating an SkQuadGrid - * structure rather than an R-Tree. The quad tree has generally faster + * Subclass of SkPicture that creates an SkQuadGrid + * structure. The quad tree has generally faster * tree creation time, but slightly slower query times, as compared to * R-Tree, so some cases may be faster and some cases slower. */ @@ -29,7 +28,9 @@ private: }; class SkQuadTreePictureFactory : public SkPictureFactory { -private: +public: + SkQuadTreePictureFactory() {} + virtual SkPicture* create(int width, int height) SK_OVERRIDE { return SkNEW_ARGS(SkQuadTreePicture, (SkIRect::MakeWH(width, height))); } diff --git a/src/core/SkRTreePicture.cpp b/src/core/SkRTreePicture.cpp new file mode 100644 index 0000000000..87c94e5647 --- /dev/null +++ b/src/core/SkRTreePicture.cpp @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkRTreePicture.h" + +#include "SkRTree.h" + + +SkBBoxHierarchy* SkRTreePicture::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)); + bool sortDraws = false; // Do not sort draw calls when bulk loading. + + return SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren, + aspectRatio, sortDraws); +} |