| 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 |
| 13 SkBBoxHierarchy* SkRTreeFactory::operator()(int width, int height) const { | 13 SkBBoxHierarchy* SkRTreeFactory::operator()(int width, int height) const { |
| 14 // These values were empirically determined to produce reasonable | 14 SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(width), SkIntToScalar(heigh
t)); |
| 15 // performance in most cases. | 15 return SkNEW_ARGS(SkRTree, (aspectRatio)); |
| 16 static const int kRTreeMinChildren = 6; | |
| 17 static const int kRTreeMaxChildren = 11; | |
| 18 | |
| 19 SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(width), | |
| 20 SkIntToScalar(height)); | |
| 21 bool sortDraws = false; // Do not sort draw calls when bulk loading. | |
| 22 | |
| 23 return SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren, | |
| 24 aspectRatio, sortDraws); | |
| 25 } | 16 } |
| 26 | 17 |
| 27 SkBBoxHierarchy* SkTileGridFactory::operator()(int width, int height) const { | 18 SkBBoxHierarchy* SkTileGridFactory::operator()(int width, int height) const { |
| 28 SkASSERT(fInfo.fMargin.width() >= 0); | 19 SkASSERT(fInfo.fMargin.width() >= 0); |
| 29 SkASSERT(fInfo.fMargin.height() >= 0); | 20 SkASSERT(fInfo.fMargin.height() >= 0); |
| 30 // Note: SkIRects are non-inclusive of the right() column and bottom() row. | 21 // Note: SkIRects are non-inclusive of the right() column and bottom() row. |
| 31 // For example, an SkIRect at 0,0 with a size of (1,1) will only have | 22 // For example, an SkIRect at 0,0 with a size of (1,1) will only have |
| 32 // content at pixel (0,0) and will report left=0 and right=1, hence the | 23 // content at pixel (0,0) and will report left=0 and right=1, hence the |
| 33 // "-1"s below. | 24 // "-1"s below. |
| 34 int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInte
rval.width(); | 25 int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInte
rval.width(); |
| 35 int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileIn
terval.height(); | 26 int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileIn
terval.height(); |
| 36 return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo)); | 27 return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo)); |
| 37 } | 28 } |
| OLD | NEW |