4241f5e0a8
This reverts commit e1af44498b
.
Reason for revert: breaking google3?
Original change's description:
> add guard to switch to SkPathTypes
>
> Change-Id: I44d8b5ae8a5172d11a6d4cd9d994373dd3816d6f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241278
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Mike Reed <reed@google.com>
TBR=robertphillips@google.com,kjlubick@google.com,fmalita@chromium.org,reed@google.com
Change-Id: If1fffb6310921ee6f213af000da793afcf62ab0b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241560
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
86 lines
2.7 KiB
C++
86 lines
2.7 KiB
C++
/*
|
|
* Copyright 2011 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkPath.h"
|
|
#include "include/core/SkRegion.h"
|
|
#include "include/core/SkShader.h"
|
|
#include "include/effects/SkCornerPathEffect.h"
|
|
#include "include/effects/SkGradientShader.h"
|
|
#include "samplecode/Sample.h"
|
|
#include "src/utils/SkUTF.h"
|
|
|
|
class FillTypeView : public Sample {
|
|
SkPath fPath;
|
|
public:
|
|
FillTypeView() {
|
|
const SkScalar radius = SkIntToScalar(45);
|
|
fPath.addCircle(SkIntToScalar(50), SkIntToScalar(50), radius);
|
|
fPath.addCircle(SkIntToScalar(100), SkIntToScalar(100), radius);
|
|
|
|
this->setBGColor(0xFFDDDDDD);
|
|
}
|
|
|
|
protected:
|
|
virtual SkString name() { return SkString("FillType"); }
|
|
|
|
void showPath(SkCanvas* canvas, int x, int y, SkPath::FillType ft,
|
|
SkScalar scale, const SkPaint& paint) {
|
|
|
|
const SkRect r = { 0, 0, SkIntToScalar(150), SkIntToScalar(150) };
|
|
|
|
canvas->save();
|
|
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
|
|
canvas->clipRect(r);
|
|
canvas->drawColor(SK_ColorWHITE);
|
|
fPath.setFillType(ft);
|
|
canvas->translate(r.centerX(), r.centerY());
|
|
canvas->scale(scale, scale);
|
|
canvas->translate(-r.centerX(), -r.centerY());
|
|
canvas->drawPath(fPath, paint);
|
|
canvas->restore();
|
|
}
|
|
|
|
void showFour(SkCanvas* canvas, SkScalar scale, const SkPaint& paint) {
|
|
showPath(canvas, 0, 0, SkPath::kWinding_FillType,
|
|
scale, paint);
|
|
showPath(canvas, 200, 0, SkPath::kEvenOdd_FillType,
|
|
scale, paint);
|
|
showPath(canvas, 00, 200, SkPath::kInverseWinding_FillType,
|
|
scale, paint);
|
|
showPath(canvas, 200, 200, SkPath::kInverseEvenOdd_FillType,
|
|
scale, paint);
|
|
}
|
|
|
|
virtual void onDrawContent(SkCanvas* canvas) {
|
|
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
|
|
|
SkPaint paint;
|
|
const SkScalar scale = SkIntToScalar(5)/4;
|
|
|
|
paint.setAntiAlias(false);
|
|
paint.setColor(0x8000FF00);
|
|
|
|
showFour(canvas, SK_Scalar1, paint);
|
|
canvas->translate(SkIntToScalar(450), 0);
|
|
showFour(canvas, scale, paint);
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
canvas->translate(SkIntToScalar(-450), SkIntToScalar(450));
|
|
showFour(canvas, SK_Scalar1, paint);
|
|
canvas->translate(SkIntToScalar(450), 0);
|
|
showFour(canvas, scale, paint);
|
|
}
|
|
|
|
private:
|
|
typedef Sample INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_SAMPLE( return new FillTypeView(); )
|