OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBBHFactory.h" | 8 #include "SkBBHFactory.h" |
9 #include "SkRTree.h" | 9 #include "SkRTree.h" |
10 #include "SkTileGrid.h" | |
11 | 10 |
12 SkBBoxHierarchy* SkRTreeFactory::operator()(const SkRect& bounds) const { | 11 SkBBoxHierarchy* SkRTreeFactory::operator()(const SkRect& bounds) const { |
13 SkScalar aspectRatio = bounds.width() / bounds.height(); | 12 SkScalar aspectRatio = bounds.width() / bounds.height(); |
14 return SkNEW_ARGS(SkRTree, (aspectRatio)); | 13 return SkNEW_ARGS(SkRTree, (aspectRatio)); |
15 } | 14 } |
16 | |
17 SkBBoxHierarchy* SkTileGridFactory::operator()(const SkRect& bounds) const { | |
18 SkASSERT(fInfo.fMargin.width() >= 0); | |
19 SkASSERT(fInfo.fMargin.height() >= 0); | |
20 | |
21 // We want a conservative answer for the size... | |
22 const SkIRect ibounds = bounds.roundOut(); | |
23 const int width = ibounds.width(); | |
24 const int height = ibounds.height(); | |
25 | |
26 // Note: SkIRects are non-inclusive of the right() column and bottom() row. | |
27 // For example, an SkIRect at 0,0 with a size of (1,1) will only have | |
28 // content at pixel (0,0) and will report left=0 and right=1, hence the | |
29 // "-1"s below. | |
30 int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInte
rval.width(); | |
31 int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileIn
terval.height(); | |
32 return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo)); | |
33 } | |
OLD | NEW |