diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-28 16:20:27 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-28 16:20:27 +0000 |
commit | 213c42bb69d375818cc0713a51c28c48ab501763 (patch) | |
tree | 365b1a60419eb03d7a60565cfb88d89204206798 | |
parent | c10a88825d119054a9f4e7b7af7a3f887e30ab6b (diff) |
Create new lcdtext page within gm
http://codereview.appspot.com/4654071
git-svn-id: http://skia.googlecode.com/svn/trunk@1736 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gm/lcdtext.cpp | 82 | ||||
-rw-r--r-- | gyp/gm.gyp | 1 |
2 files changed, 83 insertions, 0 deletions
diff --git a/gm/lcdtext.cpp b/gm/lcdtext.cpp new file mode 100644 index 0000000000..90a9ccbb3b --- /dev/null +++ b/gm/lcdtext.cpp @@ -0,0 +1,82 @@ +/* + Copyright 2011 Google Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +/* 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); } + + void drawBG(SkCanvas* canvas) { + canvas->drawColor(SK_ColorWHITE); + } + + virtual void onDraw(SkCanvas* canvas) { + this->drawBG(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); + +} diff --git a/gyp/gm.gyp b/gyp/gm.gyp index 10b85928b2..2d6689153b 100644 --- a/gyp/gm.gyp +++ b/gyp/gm.gyp @@ -13,6 +13,7 @@ '../gm/blurs.cpp', '../gm/filltypes.cpp', '../gm/gradients.cpp', + '../gm/lcdtext.cpp', '../gm/nocolorbleed.cpp', '../gm/pathfill.cpp', '../gm/points.cpp', |