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

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: Convert region to a path in complex case 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 void SkBaseDevice::drawRegion(const SkDraw& draw, const SkRegion& region, const SkPaint& paint) {
76 bool complexMatrix = !draw.fMatrix->isScaleTranslate();
77 bool complexPaint = paint.isAntiAlias() || paint.getImageFilter() || paint.g etMaskFilter();
78 if (complexMatrix && complexPaint) {
msarett 2016/08/25 13:02:32 Hwui also checks that the paint must be kFill_Styl
bsalomon 2016/08/25 13:58:20 To me a clear definition of drawRegion(region, pai
msarett 2016/08/25 15:07:35 Agreed. New checks should catch everything I thin
79 SkPath path;
80 region.getBoundaryPath(&path);
81 return this->drawPath(draw, path, paint, nullptr, false);
82 }
83
84 SkRegion::Iterator it(region);
85 while (!it.done()) {
86 this->drawRect(draw, SkRect::Make(it.rect()), paint);
87 it.next();
88 }
89 }
90
75 void SkBaseDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar star tAngle, 91 void SkBaseDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar star tAngle,
76 SkScalar sweepAngle, bool useCenter, const SkPaint& p aint) { 92 SkScalar sweepAngle, bool useCenter, const SkPaint& p aint) {
77 SkASSERT(SkScalarAbs(sweepAngle) >= 0.f && SkScalarAbs(sweepAngle) < 360.f); 93 SkASSERT(SkScalarAbs(sweepAngle) >= 0.f && SkScalarAbs(sweepAngle) < 360.f);
78 SkPath path; 94 SkPath path;
79 if (useCenter) { 95 if (useCenter) {
80 path.moveTo(oval.centerX(), oval.centerY()); 96 path.moveTo(oval.centerX(), oval.centerY());
81 } 97 }
82 path.arcTo(oval, startAngle, sweepAngle, !useCenter); 98 path.arcTo(oval, startAngle, sweepAngle, !useCenter);
83 if (useCenter) { 99 if (useCenter) {
84 path.close(); 100 path.close();
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 566
551 // Also log filter quality independent scale factor. 567 // Also log filter quality independent scale factor.
552 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor, 568 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor,
553 kLast_ScaleFactor + 1); 569 kLast_ScaleFactor + 1);
554 570
555 // Also log an overall histogram of filter quality. 571 // Also log an overall histogram of filter quality.
556 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali ty + 1); 572 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali ty + 1);
557 #endif 573 #endif
558 } 574 }
559 575
OLDNEW
« gm/drawregionrotate.cpp ('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