d6176b0dca
This CL is part II of IV (I broke down the 1280 files into 4 CLs). Review URL: https://codereview.appspot.com/6474054 git-svn-id: http://skia.googlecode.com/svn/trunk@5263 2bbb7eff-a529-9590-31e7-b0007b416f81
71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
|
|
/*
|
|
* Copyright 2011 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
|
|
/* Tests text rendering with LCD and subpixel rendering turned on and off.
|
|
*/
|
|
|
|
#include "gm.h"
|
|
#include "SkCanvas.h"
|
|
|
|
namespace skiagm {
|
|
|
|
class LcdTextGM : public GM {
|
|
public:
|
|
LcdTextGM() {
|
|
const int pointSize = 36;
|
|
textHeight = SkIntToScalar(pointSize);
|
|
}
|
|
|
|
protected:
|
|
|
|
SkString onShortName() {
|
|
return SkString("lcdtext");
|
|
}
|
|
|
|
SkISize onISize() { return make_isize(640, 480); }
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
|
|
y = textHeight;
|
|
drawText(canvas, SkString("TEXT: SubpixelTrue LCDRenderTrue"),
|
|
true, true);
|
|
drawText(canvas, SkString("TEXT: SubpixelTrue LCDRenderFalse"),
|
|
true, false);
|
|
drawText(canvas, SkString("TEXT: SubpixelFalse LCDRenderTrue"),
|
|
false, true);
|
|
drawText(canvas, SkString("TEXT: SubpixelFalse LCDRenderFalse"),
|
|
false, false);
|
|
}
|
|
|
|
void drawText(SkCanvas* canvas, const SkString& string,
|
|
bool subpixelTextEnabled, bool lcdRenderTextEnabled) {
|
|
SkPaint paint;
|
|
paint.setColor(SK_ColorBLACK);
|
|
paint.setDither(true);
|
|
paint.setAntiAlias(true);
|
|
paint.setSubpixelText(subpixelTextEnabled);
|
|
paint.setLCDRenderText(lcdRenderTextEnabled);
|
|
paint.setTextSize(textHeight);
|
|
|
|
canvas->drawText(string.c_str(), string.size(), 0, y, paint);
|
|
y += textHeight;
|
|
}
|
|
|
|
private:
|
|
typedef GM INHERITED;
|
|
SkScalar y, textHeight;
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
static GM* MyFactory(void*) { return new LcdTextGM; }
|
|
static GMRegistry reg(MyFactory);
|
|
|
|
}
|