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

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

Issue 742663002: add roundOut that returns its result (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkImageFilter.cpp » ('j') | 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkDraw.h" 8 #include "SkDraw.h"
9 #include "SkBlitter.h" 9 #include "SkBlitter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 806 }
807 807
808 const SkMatrix& matrix = *fMatrix; 808 const SkMatrix& matrix = *fMatrix;
809 SkRect devRect; 809 SkRect devRect;
810 810
811 // transform rect into devRect 811 // transform rect into devRect
812 matrix.mapPoints(rect_points(devRect), rect_points(rect), 2); 812 matrix.mapPoints(rect_points(devRect), rect_points(rect), 2);
813 devRect.sort(); 813 devRect.sort();
814 814
815 // look for the quick exit, before we build a blitter 815 // look for the quick exit, before we build a blitter
816 SkIRect ir; 816 SkIRect ir = devRect.roundOut();
817 devRect.roundOut(&ir);
818 if (paint.getStyle() != SkPaint::kFill_Style) { 817 if (paint.getStyle() != SkPaint::kFill_Style) {
819 // extra space for hairlines 818 // extra space for hairlines
820 if (paint.getStrokeWidth() == 0) { 819 if (paint.getStrokeWidth() == 0) {
821 ir.outset(1, 1); 820 ir.outset(1, 1);
822 } else { 821 } else {
823 SkScalar radius = SkScalarHalf(paint.getStrokeWidth()); 822 SkScalar radius = SkScalarHalf(paint.getStrokeWidth());
824 ir.outset(radius, radius); 823 ir.outset(radius, radius);
825 } 824 }
826 } 825 }
827 if (fRC->quickReject(ir)) { 826 if (fRC->quickReject(ir)) {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 SkIntToScalar(bitmap.height())); 1202 SkIntToScalar(bitmap.height()));
1204 c.drawRect(rr, install.paintWithShader()); 1203 c.drawRect(rr, install.paintWithShader());
1205 } 1204 }
1206 this->drawDevMask(mask, paint); 1205 this->drawDevMask(mask, paint);
1207 } 1206 }
1208 } 1207 }
1209 1208
1210 static bool clipped_out(const SkMatrix& m, const SkRasterClip& c, 1209 static bool clipped_out(const SkMatrix& m, const SkRasterClip& c,
1211 const SkRect& srcR) { 1210 const SkRect& srcR) {
1212 SkRect dstR; 1211 SkRect dstR;
1213 SkIRect devIR;
1214
1215 m.mapRect(&dstR, srcR); 1212 m.mapRect(&dstR, srcR);
1216 dstR.roundOut(&devIR); 1213 return c.quickReject(dstR.roundOut());
1217 return c.quickReject(devIR);
1218 } 1214 }
1219 1215
1220 static bool clipped_out(const SkMatrix& matrix, const SkRasterClip& clip, 1216 static bool clipped_out(const SkMatrix& matrix, const SkRasterClip& clip,
1221 int width, int height) { 1217 int width, int height) {
1222 SkRect r; 1218 SkRect r;
1223 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height)); 1219 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height));
1224 return clipped_out(matrix, clip, r); 1220 return clipped_out(matrix, clip, r);
1225 } 1221 }
1226 1222
1227 static bool clipHandlesSprite(const SkRasterClip& clip, int x, int y, 1223 static bool clipHandlesSprite(const SkRasterClip& clip, int x, int y,
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 #endif 2271 #endif
2276 2272
2277 //////////////////////////////////////////////////////////////////////////////// //////////////// 2273 //////////////////////////////////////////////////////////////////////////////// ////////////////
2278 2274
2279 #include "SkPath.h" 2275 #include "SkPath.h"
2280 #include "SkDraw.h" 2276 #include "SkDraw.h"
2281 #include "SkRegion.h" 2277 #include "SkRegion.h"
2282 #include "SkBlitter.h" 2278 #include "SkBlitter.h"
2283 2279
2284 static bool compute_bounds(const SkPath& devPath, const SkIRect* clipBounds, 2280 static bool compute_bounds(const SkPath& devPath, const SkIRect* clipBounds,
2285 const SkMaskFilter* filter, const SkMatrix* filterMatrix, 2281 const SkMaskFilter* filter, const SkMatrix* filterMat rix,
2286 SkIRect* bounds) { 2282 SkIRect* bounds) {
2287 if (devPath.isEmpty()) { 2283 if (devPath.isEmpty()) {
2288 return false; 2284 return false;
2289 } 2285 }
2290 2286
2291 // init our bounds from the path 2287 // init our bounds from the path
2292 { 2288 {
2293 SkRect pathBounds = devPath.getBounds(); 2289 SkRect pathBounds = devPath.getBounds();
2294 pathBounds.inset(-SK_ScalarHalf, -SK_ScalarHalf); 2290 pathBounds.inset(-SK_ScalarHalf, -SK_ScalarHalf);
2295 pathBounds.roundOut(bounds); 2291 pathBounds.roundOut(bounds);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 mask->fImage = SkMask::AllocImage(size); 2370 mask->fImage = SkMask::AllocImage(size);
2375 memset(mask->fImage, 0, mask->computeImageSize()); 2371 memset(mask->fImage, 0, mask->computeImageSize());
2376 } 2372 }
2377 2373
2378 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2374 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2379 draw_into_mask(*mask, devPath, style); 2375 draw_into_mask(*mask, devPath, style);
2380 } 2376 }
2381 2377
2382 return true; 2378 return true;
2383 } 2379 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698