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" | 10 #include "SkTileGrid.h" |
11 | 11 |
12 | 12 SkBBoxHierarchy* SkRTreeFactory::operator()(const SkRect& bounds) const { |
13 SkBBoxHierarchy* SkRTreeFactory::operator()(int width, int height) const { | 13 SkScalar aspectRatio = bounds.width() / bounds.height(); |
14 SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(width), SkIntToScalar(heigh t)); | |
15 return SkNEW_ARGS(SkRTree, (aspectRatio)); | 14 return SkNEW_ARGS(SkRTree, (aspectRatio)); |
16 } | 15 } |
17 | 16 |
18 SkBBoxHierarchy* SkTileGridFactory::operator()(int width, int height) const { | 17 SkBBoxHierarchy* SkTileGridFactory::operator()(const SkRect& bounds) const { |
19 SkASSERT(fInfo.fMargin.width() >= 0); | 18 SkASSERT(fInfo.fMargin.width() >= 0); |
20 SkASSERT(fInfo.fMargin.height() >= 0); | 19 SkASSERT(fInfo.fMargin.height() >= 0); |
20 | |
21 const int width = SkScalarRoundToInt(bounds.width()); | |
mtklein
2014/11/18 21:06:49
Is RoundToInt away-from-zero?
reed1
2014/11/18 22:05:30
Nope, but I can change it to that.
Really what we
mtklein
2014/11/18 22:26:11
That sounds right.
reed1
2014/11/19 14:49:16
Done.
| |
22 const int height = SkScalarRoundToInt(bounds.height()); | |
23 | |
21 // Note: SkIRects are non-inclusive of the right() column and bottom() row. | 24 // Note: SkIRects are non-inclusive of the right() column and bottom() row. |
22 // For example, an SkIRect at 0,0 with a size of (1,1) will only have | 25 // For example, an SkIRect at 0,0 with a size of (1,1) will only have |
23 // content at pixel (0,0) and will report left=0 and right=1, hence the | 26 // content at pixel (0,0) and will report left=0 and right=1, hence the |
24 // "-1"s below. | 27 // "-1"s below. |
25 int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInte rval.width(); | 28 int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInte rval.width(); |
26 int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileIn terval.height(); | 29 int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileIn terval.height(); |
27 return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo)); | 30 return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo)); |
28 } | 31 } |
OLD | NEW |