skia2/gm/bigtext.cpp
Mike Klein 33d2055e59 GM: some header cleanup
gm.h includes sk_tool_utils.h but does not use it.

The bulk of this CL makes each gm that uses sk_tool_utils include it.

sk_tool_utils.h also provided SkRandom and SkTDArray,
so a couple GMs add those headers too.

Change-Id: Ieb2a7c542f0ca89c3223f744fc11b0ff37af36c1
Reviewed-on: https://skia-review.googlesource.com/10014
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Herb Derby <herb@google.com>
2017-03-22 18:11:49 +00:00

57 lines
1.2 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"
#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPath.h"
/**
* Skia may draw from outlines when the size is very large, so we exercise that
* here.
*/
class BigTextGM : public skiagm::GM {
public:
BigTextGM() {}
protected:
SkString onShortName() override {
return SkString("bigtext");
}
SkISize onISize() override {
return SkISize::Make(640, 480);
}
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setTextSize(1500);
SkRect r;
(void)paint.measureText("/", 1, &r);
SkPoint pos = {
this->width()/2 - r.centerX(),
this->height()/2 - r.centerY()
};
paint.setColor(SK_ColorRED);
canvas->drawText("/", 1, pos.fX, pos.fY, paint);
paint.setColor(SK_ColorBLUE);
canvas->drawPosText("\\", 1, &pos, paint);
}
private:
typedef skiagm::GM INHERITED;
};
DEF_GM(return new BigTextGM;)