OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkTileGridPicture.h" | 8 #include "SkTileGridPicture.h" |
9 | 9 |
10 #include "SkPictureStateTree.h" | 10 #include "SkPictureStateTree.h" |
11 #include "SkTileGrid.h" | 11 #include "SkTileGrid.h" |
12 | 12 |
13 SkTileGridPicture::SkTileGridPicture(int width, int height, const TileGridInfo&
info) { | 13 |
| 14 SkBBoxHierarchy* SkTileGridFactory::operator()(int width, int height) const { |
| 15 SkASSERT(fInfo.fMargin.width() >= 0); |
| 16 SkASSERT(fInfo.fMargin.height() >= 0); |
| 17 // Note: SkIRects are non-inclusive of the right() column and bottom() row. |
| 18 // For example, an SkIRect at 0,0 with a size of (1,1) will only have |
| 19 // content at pixel (0,0) and will report left=0 and right=1, hence the |
| 20 // "-1"s below. |
| 21 int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInte
rval.width(); |
| 22 int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileIn
terval.height(); |
| 23 return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo, |
| 24 SkTileGridNextDatum<SkPictureStateTree::Draw
>)); |
| 25 } |
| 26 |
| 27 #ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES |
| 28 |
| 29 SkTileGridPicture::SkTileGridPicture(int width, int height, |
| 30 const SkTileGridFactory::TileGridInfo& info
) { |
14 SkASSERT(info.fMargin.width() >= 0); | 31 SkASSERT(info.fMargin.width() >= 0); |
15 SkASSERT(info.fMargin.height() >= 0); | 32 SkASSERT(info.fMargin.height() >= 0); |
16 fInfo = info; | 33 fInfo = info; |
17 // Note: SkIRects are non-inclusive of the right() column and bottom() row. | 34 // Note: SkIRects are non-inclusive of the right() column and bottom() row. |
18 // For example, an SkIRect at 0,0 with a size of (1,1) will only have | 35 // For example, an SkIRect at 0,0 with a size of (1,1) will only have |
19 // content at pixel (0,0) and will report left=0 and right=1, hence the | 36 // content at pixel (0,0) and will report left=0 and right=1, hence the |
20 // "-1"s below. | 37 // "-1"s below. |
21 fXTileCount = (width + info.fTileInterval.width() - 1) / info.fTileInterval.
width(); | 38 fXTileCount = (width + info.fTileInterval.width() - 1) / info.fTileInterval.
width(); |
22 fYTileCount = (height + info.fTileInterval.height() - 1) / info.fTileInterva
l.height(); | 39 fYTileCount = (height + info.fTileInterval.height() - 1) / info.fTileInterva
l.height(); |
23 } | 40 } |
24 | 41 |
25 SkBBoxHierarchy* SkTileGridPicture::createBBoxHierarchy() const { | 42 SkBBoxHierarchy* SkTileGridPicture::createBBoxHierarchy() const { |
26 return SkNEW_ARGS(SkTileGrid, (fXTileCount, fYTileCount, fInfo, | 43 return SkNEW_ARGS(SkTileGrid, (fXTileCount, fYTileCount, fInfo, |
27 SkTileGridNextDatum<SkPictureStateTree::Draw>)); | 44 SkTileGridNextDatum<SkPictureStateTree::Draw>)); |
28 } | 45 } |
| 46 |
| 47 #endif |
OLD | NEW |