skia2/gm/thinstrokedrects.cpp
mtklein 72c9faab45 Fix up all the easy virtual ... SK_OVERRIDE cases.
This fixes every case where virtual and SK_OVERRIDE were on the same line,
which should be the bulk of cases.  We'll have to manually clean up the rest
over time unless I level up in regexes.

for f in (find . -type f); perl -p -i -e 's/virtual (.*)SK_OVERRIDE/\1SK_OVERRIDE/g' $f; end

BUG=skia:

Review URL: https://codereview.chromium.org/806653007
2015-01-09 10:06:40 -08:00

79 lines
2.1 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.h"
namespace skiagm {
// Draw rects with various stroke widths at 1/8 pixel increments
class ThinStrokedRectsGM : public GM {
public:
ThinStrokedRectsGM() {
this->setBGColor(0xFF000000);
}
protected:
SkString onShortName() SK_OVERRIDE {
return SkString("thinstrokedrects");
}
SkISize onISize() SK_OVERRIDE {
return SkISize::Make(240, 320);
}
void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
paint.setColor(SK_ColorWHITE);
paint.setStyle(SkPaint::kStroke_Style);
paint.setAntiAlias(true);
static const SkRect rect = { 0, 0, 10, 10 };
static const SkRect rect2 = { 0, 0, 20, 20 };
static const SkScalar gStrokeWidths[] = {
4, 2, 1, 0.5f, 0.25f, 0.125f, 0
};
canvas->translate(5, 5);
for (int i = 0; i < 8; ++i) {
canvas->save();
canvas->translate(i*0.125f, i*30.0f);
for (size_t j = 0; j < SK_ARRAY_COUNT(gStrokeWidths); ++j) {
paint.setStrokeWidth(gStrokeWidths[j]);
canvas->drawRect(rect, paint);
canvas->translate(15, 0);
}
canvas->restore();
}
// Draw a second time in red with a scale
paint.setColor(SK_ColorRED);
canvas->translate(0, 15);
for (int i = 0; i < 8; ++i) {
canvas->save();
canvas->translate(i*0.125f, i*30.0f);
canvas->scale(0.5f, 0.5f);
for (size_t j = 0; j < SK_ARRAY_COUNT(gStrokeWidths); ++j) {
paint.setStrokeWidth(2.0f * gStrokeWidths[j]);
canvas->drawRect(rect2, paint);
canvas->translate(30, 0);
}
canvas->restore();
}
}
private:
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_GM( return SkNEW(ThinStrokedRectsGM); )
}