2013-06-05 18:00:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 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 14:59:30 +00:00
|
|
|
#include "include/core/SkColor.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkFont.h"
|
2019-05-01 14:59:30 +00:00
|
|
|
#include "include/core/SkFontTypes.h"
|
|
|
|
#include "include/core/SkPaint.h"
|
|
|
|
#include "include/core/SkPoint.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkSize.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/core/SkTypeface.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/ToolUtils.h"
|
2013-06-05 18:00:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Skia may draw from outlines when the size is very large, so we exercise that
|
|
|
|
* here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class BigTextGM : public skiagm::GM {
|
|
|
|
public:
|
|
|
|
BigTextGM() {}
|
|
|
|
|
|
|
|
protected:
|
2014-04-30 13:20:45 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
SkString onShortName() override {
|
2013-06-05 18:00:30 +00:00
|
|
|
return SkString("bigtext");
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize onISize() override {
|
2013-06-05 18:00:30 +00:00
|
|
|
return SkISize::Make(640, 480);
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDraw(SkCanvas* canvas) override {
|
2013-06-05 18:00:30 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
2019-03-20 16:12:10 +00:00
|
|
|
SkFont font(ToolUtils::create_portable_typeface(), 1500);
|
2013-06-05 18:00:30 +00:00
|
|
|
|
|
|
|
SkRect r;
|
2019-05-07 19:38:46 +00:00
|
|
|
(void)font.measureText("/", 1, SkTextEncoding::kUTF8, &r);
|
2013-06-05 18:00:30 +00:00
|
|
|
SkPoint pos = {
|
|
|
|
this->width()/2 - r.centerX(),
|
|
|
|
this->height()/2 - r.centerY()
|
|
|
|
};
|
|
|
|
|
|
|
|
paint.setColor(SK_ColorRED);
|
2019-05-07 19:38:46 +00:00
|
|
|
canvas->drawSimpleText("/", 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint);
|
2013-06-06 07:01:37 +00:00
|
|
|
|
2013-06-05 18:00:30 +00:00
|
|
|
paint.setColor(SK_ColorBLUE);
|
2019-05-07 19:38:46 +00:00
|
|
|
canvas->drawSimpleText("\\", 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint);
|
2013-06-05 18:00:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef skiagm::GM INHERITED;
|
|
|
|
};
|
|
|
|
|
2015-08-26 20:07:48 +00:00
|
|
|
DEF_GM(return new BigTextGM;)
|