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

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

Issue 620093006: Use +- 2B for unbounded draw ops. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: constant Created 6 years, 2 months 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
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkTileGrid.h" 8 #include "SkTileGrid.h"
9 9
10 SkTileGrid::SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGrid Info& info) 10 SkTileGrid::SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGrid Info& info)
11 : fXTiles(xTiles) 11 : fXTiles(xTiles)
12 , fYTiles(yTiles) 12 , fYTiles(yTiles)
13 , fInfo(info) 13 , fInfo(info)
14 , fCount(0) 14 , fCount(0)
15 , fTiles(SkNEW_ARRAY(SkTDArray<unsigned>, xTiles * yTiles)) { 15 , fTiles(SkNEW_ARRAY(SkTDArray<unsigned>, xTiles * yTiles)) {
16 // Margin is offset by 1 as a provision for AA and 16 // Margin is offset by 1 as a provision for AA and
17 // to cancel-out the outset applied by getClipDeviceBounds. 17 // to cancel-out the outset applied by getClipDeviceBounds.
18 fInfo.fMargin.fHeight++; 18 fInfo.fMargin.fHeight++;
19 fInfo.fMargin.fWidth++; 19 fInfo.fMargin.fWidth++;
20 } 20 }
21 21
22 SkTileGrid::~SkTileGrid() { 22 SkTileGrid::~SkTileGrid() {
23 SkDELETE_ARRAY(fTiles); 23 SkDELETE_ARRAY(fTiles);
24 } 24 }
25 25
26 void SkTileGrid::insert(unsigned opIndex, const SkRect& fbounds, bool) { 26 void SkTileGrid::insert(unsigned opIndex, const SkRect& fbounds, bool) {
27 SkASSERT(!fbounds.isEmpty()); 27 SkASSERT(!fbounds.isEmpty());
28
28 SkIRect dilatedBounds; 29 SkIRect dilatedBounds;
29 if (fbounds.isLargest()) { 30 fbounds.roundOut(&dilatedBounds);
30 // Dilating the largest SkIRect will overflow. Other nearly-largest rec ts may overflow too, 31 dilatedBounds.outset(fInfo.fMargin.width(), fInfo.fMargin.height());
31 // but we don't make active use of them like we do the largest. 32 dilatedBounds.offset(fInfo.fOffset);
32 dilatedBounds.setLargest();
33 } else {
34 fbounds.roundOut(&dilatedBounds);
35 dilatedBounds.outset(fInfo.fMargin.width(), fInfo.fMargin.height());
36 dilatedBounds.offset(fInfo.fOffset);
37 }
38 33
39 const SkIRect gridBounds = 34 const SkIRect gridBounds =
40 { 0, 0, fInfo.fTileInterval.width() * fXTiles, fInfo.fTileInterval.heigh t() * fYTiles }; 35 { 0, 0, fInfo.fTileInterval.width() * fXTiles, fInfo.fTileInterval.heigh t() * fYTiles };
41 if (!SkIRect::Intersects(dilatedBounds, gridBounds)) { 36 if (!SkIRect::Intersects(dilatedBounds, gridBounds)) {
42 return; 37 return;
43 } 38 }
44 39
45 // Note: SkIRects are non-inclusive of the right() column and bottom() row, 40 // Note: SkIRects are non-inclusive of the right() column and bottom() row,
46 // hence the "-1"s in the computations of maxX and maxY. 41 // hence the "-1"s in the computations of maxX and maxY.
47 int minX = SkMax32(0, SkMin32(dilatedBounds.left() / fInfo.fTileInterval.wid th(), fXTiles - 1)); 42 int minX = SkMax32(0, SkMin32(dilatedBounds.left() / fInfo.fTileInterval.wid th(), fXTiles - 1));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 140 }
146 } 141 }
147 } 142 }
148 143
149 void SkTileGrid::clear() { 144 void SkTileGrid::clear() {
150 for (int i = 0; i < fXTiles * fYTiles; i++) { 145 for (int i = 0; i < fXTiles * fYTiles; i++) {
151 fTiles[i].reset(); 146 fTiles[i].reset();
152 } 147 }
153 } 148 }
154 149
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698