diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-18 18:04:41 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-18 18:04:41 +0000 |
commit | 770963f23f4fc313db0fa3bac18b1b8aafb55f17 (patch) | |
tree | e5260b887047621f440fdeca0ff716455d4849b7 /src/core/SkBBHFactory.cpp | |
parent | 7b8999b5047e059f8dbce2bb24586ac49d928731 (diff) |
Staging for cleanup of SkPicture-related headers
https://codereview.chromium.org/243173002
git-svn-id: http://skia.googlecode.com/svn/trunk@14258 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkBBHFactory.cpp')
-rw-r--r-- | src/core/SkBBHFactory.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/core/SkBBHFactory.cpp b/src/core/SkBBHFactory.cpp new file mode 100644 index 0000000000..7411eb34da --- /dev/null +++ b/src/core/SkBBHFactory.cpp @@ -0,0 +1,44 @@ +/* + * 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 "SkBBHFactory.h" +#include "SkPictureStateTree.h" +#include "SkQuadTree.h" +#include "SkRTree.h" +#include "SkTileGrid.h" + + +SkBBoxHierarchy* SkQuadTreeFactory::operator()(int width, int height) const { + return SkNEW_ARGS(SkQuadTree, (SkIRect::MakeWH(width, height))); +} + +SkBBoxHierarchy* SkRTreeFactory::operator()(int width, int height) 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(width), + SkIntToScalar(height)); + bool sortDraws = false; // Do not sort draw calls when bulk loading. + + return SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren, + aspectRatio, sortDraws); +} + +SkBBoxHierarchy* SkTileGridFactory::operator()(int width, int height) const { + SkASSERT(fInfo.fMargin.width() >= 0); + SkASSERT(fInfo.fMargin.height() >= 0); + // Note: SkIRects are non-inclusive of the right() column and bottom() row. + // For example, an SkIRect at 0,0 with a size of (1,1) will only have + // content at pixel (0,0) and will report left=0 and right=1, hence the + // "-1"s below. + int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInterval.width(); + int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileInterval.height(); + return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo, + SkTileGridNextDatum<SkPictureStateTree::Draw>)); +} |