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

Unified Diff: samplecode/SampleFatBits.cpp

Issue 1452973002: add caps option 'k' to FatBits (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleFatBits.cpp
diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp
index 0a47259d8343fed722a138a6fbb822973ce67182..f3a2f6c54a50f46c280f42883956c4b9b223126d 100644
--- a/samplecode/SampleFatBits.cpp
+++ b/samplecode/SampleFatBits.cpp
@@ -47,6 +47,7 @@ public:
fUseClip = false;
fRectAsOval = false;
fUseTriangle = false;
+ fStrokeCap = SkPaint::kButt_Cap;
fClipRect.set(2, 2, 11, 8 );
}
@@ -102,6 +103,8 @@ public:
void drawRect(SkCanvas* canvas, SkPoint pts[2]);
void drawTriangle(SkCanvas* canvas, SkPoint pts[3]);
+ SkPaint::Cap fStrokeCap;
+
private:
bool fAA, fGrid, fShowSkeleton, fUseGPU, fUseClip, fRectAsOval, fUseTriangle;
Style fStyle;
@@ -114,6 +117,7 @@ private:
void setupPaint(SkPaint* paint) {
bool aa = this->getAA();
+ paint->setStrokeCap(fStrokeCap);
switch (fStyle) {
case kHair_Style:
paint->setStrokeWidth(0);
@@ -246,10 +250,14 @@ void FatBits::drawLineSkeleton(SkCanvas* max, const SkPoint pts[]) {
SkPaint p;
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1 * fZoom);
+ p.setStrokeCap(fStrokeCap);
SkPath dst;
p.getFillPath(path, &dst);
path = dst;
+ path.moveTo(pts[0]);
+ path.lineTo(pts[1]);
+
if (fUseGPU) {
path.moveTo(dst.getPoint(0));
path.lineTo(dst.getPoint(2));
@@ -430,6 +438,14 @@ protected:
this->setStyle(FatBits::kStroke_Style);
}
return true;
+ case 'k': {
+ const SkPaint::Cap caps[] = {
+ SkPaint::kButt_Cap, SkPaint::kRound_Cap, SkPaint::kSquare_Cap,
+ };
+ fFB.fStrokeCap = caps[(fFB.fStrokeCap + 1) % 3];
+ this->inval(nullptr);
+ return true;
+ } break;
case 'a':
fFB.setAA(!fFB.getAA());
this->inval(nullptr);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698