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

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

Issue 2277053002: Add drawRegion() API to SkCanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added shader to test Created 4 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkColorFilter.h" 8 #include "SkColorFilter.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 break; 65 break;
66 case kNever_TileUsage: 66 case kNever_TileUsage:
67 if (!preserveLCDText) { 67 if (!preserveLCDText) {
68 geo = kUnknown_SkPixelGeometry; 68 geo = kUnknown_SkPixelGeometry;
69 } 69 }
70 break; 70 break;
71 } 71 }
72 return geo; 72 return geo;
73 } 73 }
74 74
75 static inline bool is_int(float x) {
76 return x == (float) sk_float_round2int(x);
77 }
78
79 void SkBaseDevice::drawRegion(const SkDraw& draw, const SkRegion& region, const SkPaint& paint) {
80 bool isNonTranslate = draw.fMatrix->getType() & ~(SkMatrix::kTranslate_Mask) ;
81 bool complexPaint = paint.getStyle() != SkPaint::kFill_Style || paint.getMas kFilter() ||
82 paint.getPathEffect();
83 bool antiAlias = paint.isAntiAlias() && (!is_int(draw.fMatrix->getTranslateX ()) ||
84 !is_int(draw.fMatrix->getTranslateY ()));
85 if (isNonTranslate || complexPaint || antiAlias) {
86 SkPath path;
87 region.getBoundaryPath(&path);
88 return this->drawPath(draw, path, paint, nullptr, false);
89 }
90
91 SkRegion::Iterator it(region);
92 while (!it.done()) {
93 this->drawRect(draw, SkRect::Make(it.rect()), paint);
94 it.next();
95 }
96 }
97
75 void SkBaseDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar star tAngle, 98 void SkBaseDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar star tAngle,
76 SkScalar sweepAngle, bool useCenter, const SkPaint& p aint) { 99 SkScalar sweepAngle, bool useCenter, const SkPaint& p aint) {
77 SkASSERT(SkScalarAbs(sweepAngle) >= 0.f && SkScalarAbs(sweepAngle) < 360.f); 100 SkASSERT(SkScalarAbs(sweepAngle) >= 0.f && SkScalarAbs(sweepAngle) < 360.f);
78 SkPath path; 101 SkPath path;
79 if (useCenter) { 102 if (useCenter) {
80 path.moveTo(oval.centerX(), oval.centerY()); 103 path.moveTo(oval.centerX(), oval.centerY());
81 } 104 }
82 path.arcTo(oval, startAngle, sweepAngle, !useCenter); 105 path.arcTo(oval, startAngle, sweepAngle, !useCenter);
83 if (useCenter) { 106 if (useCenter) {
84 path.close(); 107 path.close();
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 573
551 // Also log filter quality independent scale factor. 574 // Also log filter quality independent scale factor.
552 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor, 575 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor,
553 kLast_ScaleFactor + 1); 576 kLast_ScaleFactor + 1);
554 577
555 // Also log an overall histogram of filter quality. 578 // Also log an overall histogram of filter quality.
556 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali ty + 1); 579 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali ty + 1);
557 #endif 580 #endif
558 } 581 }
559 582
OLDNEW
« include/core/SkCanvas.h ('K') | « src/core/SkCanvas.cpp ('k') | src/core/SkLiteDL.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698