Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: src/core/SkBBHFactory.cpp

Issue 736583004: allow pictures to have a full bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use new roundOut Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // 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
21 // Note: SkIRects are non-inclusive of the right() column and bottom() row. 26 // 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 27 // 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 28 // content at pixel (0,0) and will report left=0 and right=1, hence the
24 // "-1"s below. 29 // "-1"s below.
25 int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInte rval.width(); 30 int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInte rval.width();
26 int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileIn terval.height(); 31 int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileIn terval.height();
27 return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo)); 32 return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo));
28 } 33 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698