2014-02-21 02:32:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 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"
|
|
|
|
#include "include/core/SkPoint.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkRRect.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#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"
|
2014-02-21 02:32:36 +00:00
|
|
|
|
|
|
|
class DRRectGM : public skiagm::GM {
|
|
|
|
public:
|
|
|
|
DRRectGM() {}
|
|
|
|
|
|
|
|
protected:
|
2014-04-30 13:20:45 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
SkString onShortName() override {
|
2014-02-21 02:32:36 +00:00
|
|
|
return SkString("drrect");
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize onISize() override {
|
2014-02-21 02:32:36 +00:00
|
|
|
return SkISize::Make(640, 480);
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDraw(SkCanvas* canvas) override {
|
2014-02-21 02:32:36 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
|
|
|
|
SkRRect outers[4];
|
|
|
|
// like squares/circles, to exercise fast-cases in GPU
|
|
|
|
SkRect r = { 0, 0, 100, 100 };
|
|
|
|
SkVector radii[4] = {
|
|
|
|
{ 0, 0 }, { 30, 1 }, { 10, 40 }, { 40, 40 }
|
|
|
|
};
|
2014-02-21 03:02:02 +00:00
|
|
|
|
2014-02-21 02:32:36 +00:00
|
|
|
const SkScalar dx = r.width() + 16;
|
|
|
|
const SkScalar dy = r.height() + 16;
|
|
|
|
|
|
|
|
outers[0].setRect(r);
|
|
|
|
outers[1].setOval(r);
|
|
|
|
outers[2].setRectXY(r, 20, 20);
|
|
|
|
outers[3].setRectRadii(r, radii);
|
|
|
|
|
|
|
|
SkRRect inners[5];
|
|
|
|
r.inset(25, 25);
|
|
|
|
|
|
|
|
inners[0].setEmpty();
|
|
|
|
inners[1].setRect(r);
|
|
|
|
inners[2].setOval(r);
|
|
|
|
inners[3].setRectXY(r, 20, 20);
|
|
|
|
inners[4].setRectRadii(r, radii);
|
|
|
|
|
|
|
|
canvas->translate(16, 16);
|
|
|
|
for (size_t j = 0; j < SK_ARRAY_COUNT(inners); ++j) {
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(outers); ++i) {
|
|
|
|
canvas->save();
|
|
|
|
canvas->translate(dx * j, dy * i);
|
|
|
|
canvas->drawDRRect(outers[i], inners[j], paint);
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GM;
|
2014-02-21 02:32:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DEF_GM( return new DRRectGM; )
|