skia2/gm/drrect.cpp
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

71 lines
1.7 KiB
C++

/*
* Copyright 2014 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/SkPath.h"
#include "include/core/SkRRect.h"
class DRRectGM : public skiagm::GM {
public:
DRRectGM() {}
protected:
SkString onShortName() override {
return SkString("drrect");
}
SkISize onISize() override {
return SkISize::Make(640, 480);
}
void onDraw(SkCanvas* canvas) override {
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 }
};
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:
typedef GM INHERITED;
};
DEF_GM( return new DRRectGM; )