2015-02-19 18:25:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkPaint.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkPath.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkScalar.h"
|
|
|
|
#include "include/core/SkSize.h"
|
|
|
|
#include "include/core/SkString.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/private/SkTArray.h"
|
2015-02-19 18:25:21 +00:00
|
|
|
|
|
|
|
namespace skiagm {
|
|
|
|
|
|
|
|
// this GM tests hairlines which fill nearly the entire render target
|
|
|
|
class StLouisArchGM : public GM {
|
|
|
|
protected:
|
2015-03-26 01:17:31 +00:00
|
|
|
SkString onShortName() override {
|
2015-02-19 18:25:21 +00:00
|
|
|
return SkString("stlouisarch");
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize onISize() override { return SkISize::Make((int)kWidth, (int)kHeight); }
|
2015-02-19 18:25:21 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onOnceBeforeDraw() override {
|
2015-02-19 18:25:21 +00:00
|
|
|
{
|
|
|
|
SkPath* bigQuad = &fPaths.push_back();
|
|
|
|
bigQuad->moveTo(0, 0);
|
|
|
|
bigQuad->quadTo(kWidth/2, kHeight, kWidth, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
SkPath* degenBigQuad = &fPaths.push_back();
|
|
|
|
SkScalar yPos = kHeight / 2 + 10;
|
|
|
|
degenBigQuad->moveTo(0, yPos);
|
|
|
|
degenBigQuad->quadTo(0, yPos, kWidth, yPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
SkPath* bigCubic = &fPaths.push_back();
|
|
|
|
bigCubic->moveTo(0, 0);
|
|
|
|
bigCubic->cubicTo(0, kHeight,
|
|
|
|
kWidth, kHeight,
|
|
|
|
kWidth, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
SkPath* degenBigCubic = &fPaths.push_back();
|
|
|
|
SkScalar yPos = kHeight / 2;
|
|
|
|
degenBigCubic->moveTo(0, yPos);
|
|
|
|
degenBigCubic->cubicTo(0, yPos,
|
|
|
|
0, yPos,
|
|
|
|
kWidth, yPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
SkPath* bigConic = &fPaths.push_back();
|
|
|
|
bigConic->moveTo(0, 0);
|
|
|
|
bigConic->conicTo(kWidth/2, kHeight, kWidth, 0, .5);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
SkPath* degenBigConic = &fPaths.push_back();
|
|
|
|
SkScalar yPos = kHeight / 2 - 10;
|
|
|
|
degenBigConic->moveTo(0, yPos);
|
|
|
|
degenBigConic->conicTo(0, yPos, kWidth, yPos, .5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDraw(SkCanvas* canvas) override {
|
2015-02-19 18:25:21 +00:00
|
|
|
canvas->save();
|
|
|
|
canvas->scale(1, -1);
|
|
|
|
canvas->translate(0, -kHeight);
|
|
|
|
for (int p = 0; p < fPaths.count(); ++p) {
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setARGB(0xff, 0, 0, 0);
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
paint.setStrokeWidth(0);
|
|
|
|
canvas->drawPath(fPaths[p], paint);
|
|
|
|
}
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
const SkScalar kWidth = 256;
|
|
|
|
const SkScalar kHeight = 256;
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkTArray<SkPath> fPaths;
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GM;
|
2015-02-19 18:25:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-01-23 15:22:01 +00:00
|
|
|
DEF_GM( return new StLouisArchGM; )
|
2015-02-19 18:25:21 +00:00
|
|
|
|
2020-08-06 18:11:56 +00:00
|
|
|
} // namespace skiagm
|