30bc527fd6
This reverts commit7cda6f3743
. Reason for revert: legacy convexity code removed -- google3 should be ok Original change's description: > Reland "Revert "Use flat version of path-direction enum"" > > This reverts commit1792b19485
. > > Reason for revert: need to update legacy_convexity, still used by google3 > > Original change's description: > > Revert "Revert "Use flat version of path-direction enum"" > > > > This reverts commit0dacc6b7d3
. > > > > Change-Id: Ie103e9f36b07e4ee256a3688a4decf3a6dd74314 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255832 > > Auto-Submit: Mike Reed <reed@google.com> > > Reviewed-by: Mike Reed <reed@google.com> > > Commit-Queue: Mike Reed <reed@google.com> > > TBR=reed@google.com > > Change-Id: I0ecea0eb8a237298c6b908cc4bfd1cacdfc5b900 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255976 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Mike Reed <reed@google.com> TBR=reed@google.com Change-Id: I3529139bb391c4f62ce5cd0744cdf38a13b71d78 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255984 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Mike Reed <reed@google.com>
104 lines
2.7 KiB
C++
104 lines
2.7 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "gm/gm.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkClipOp.h"
|
|
#include "include/core/SkPaint.h"
|
|
#include "include/core/SkPath.h"
|
|
#include "include/core/SkRect.h"
|
|
#include "include/core/SkScalar.h"
|
|
#include "include/core/SkSize.h"
|
|
#include "include/core/SkString.h"
|
|
#include "include/core/SkTypes.h"
|
|
#include "src/core/SkClipOpPriv.h"
|
|
|
|
class CircularClipsGM : public skiagm::GM {
|
|
SkScalar fX1, fX2, fY, fR;
|
|
SkPath fCircle1, fCircle2;
|
|
|
|
protected:
|
|
void onOnceBeforeDraw() override {
|
|
fX1 = 80;
|
|
fX2 = 120;
|
|
fY = 50;
|
|
fR = 40;
|
|
|
|
fCircle1.addCircle(fX1, fY, fR, SkPathDirection::kCW);
|
|
fCircle2.addCircle(fX2, fY, fR, SkPathDirection::kCW);
|
|
}
|
|
|
|
|
|
bool runAsBench() const override { return true; }
|
|
|
|
SkString onShortName() override {
|
|
return SkString("circular-clips");
|
|
}
|
|
|
|
SkISize onISize() override {
|
|
return SkISize::Make(800, 600);
|
|
}
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
|
const SkClipOp ops[] = {
|
|
kDifference_SkClipOp,
|
|
kIntersect_SkClipOp,
|
|
kUnion_SkClipOp,
|
|
kXOR_SkClipOp,
|
|
kReverseDifference_SkClipOp,
|
|
kReplace_SkClipOp,
|
|
};
|
|
|
|
SkRect rect = SkRect::MakeLTRB(fX1 - fR, fY - fR, fX2 + fR, fY + fR);
|
|
|
|
SkPaint fillPaint;
|
|
|
|
// Giant background circular clips (AA, non-inverted, replace/isect)
|
|
fillPaint.setColor(0x80808080);
|
|
canvas->save();
|
|
canvas->scale(10, 10);
|
|
canvas->translate(-((fX1 + fX2)/2 - fR), -(fY - 2*fR/3));
|
|
canvas->clipPath(fCircle1, true);
|
|
canvas->clipPath(fCircle2, true);
|
|
|
|
canvas->drawRect(rect, fillPaint);
|
|
|
|
canvas->restore();
|
|
|
|
fillPaint.setColor(0xFF000000);
|
|
|
|
for (size_t i = 0; i < 4; i++) {
|
|
fCircle1.toggleInverseFillType();
|
|
if (i % 2 == 0) {
|
|
fCircle2.toggleInverseFillType();
|
|
}
|
|
|
|
canvas->save();
|
|
for (size_t op = 0; op < SK_ARRAY_COUNT(ops); op++) {
|
|
canvas->save();
|
|
|
|
canvas->clipPath(fCircle1);
|
|
canvas->clipPath(fCircle2, ops[op]);
|
|
|
|
canvas->drawRect(rect, fillPaint);
|
|
|
|
canvas->restore();
|
|
canvas->translate(0, 2 * fY);
|
|
}
|
|
canvas->restore();
|
|
canvas->translate(fX1 + fX2, 0);
|
|
}
|
|
}
|
|
|
|
private:
|
|
typedef skiagm::GM INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_GM( return new CircularClipsGM; )
|