aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/lcdtext.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-11-13 10:40:58 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-13 10:40:58 -0800
commita3aff06d83854eb614502e4c45231568ea88a0eb (patch)
treebb0f1bce83e163f53a811a6af651d4c2773fa843 /gm/lcdtext.cpp
parent6987dcaf257dd7c2c8e0014cf7452fde82bcba5b (diff)
add gm for lcd text and surfaceprops
Diffstat (limited to 'gm/lcdtext.cpp')
-rw-r--r--gm/lcdtext.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/gm/lcdtext.cpp b/gm/lcdtext.cpp
index 0b5739c7ab..1e45f3c4d8 100644
--- a/gm/lcdtext.cpp
+++ b/gm/lcdtext.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2011 Google Inc.
*
@@ -122,7 +121,50 @@ private:
typedef skiagm::GM INHERITED;
};
+#include "SkSurface.h"
+
+// ensure that we respect the SkPixelGeometry in SurfaceProps
+class LcdTextProps : public skiagm::GM {
+ static void DrawText(SkCanvas* canvas) {
+ canvas->drawColor(SK_ColorWHITE);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setLCDRenderText(true);
+ paint.setTextSize(30);
+ canvas->drawText("Base", 4, 4, 30, paint);
+ canvas->saveLayer(NULL, NULL);
+ canvas->drawText("Layer", 5, 4, 70, paint);
+ canvas->restore();
+ }
+
+public:
+ SkString onShortName() SK_OVERRIDE {
+ return SkString("lcdtextprops");
+ }
+
+ SkISize onISize() SK_OVERRIDE { return SkISize::Make(230, 120); }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ const SkPixelGeometry geos[] = {
+ kRGB_H_SkPixelGeometry,
+ kUnknown_SkPixelGeometry,
+ };
+
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
+ for (size_t i = 0; i < SK_ARRAY_COUNT(geos); ++i) {
+ SkSurfaceProps props = SkSurfaceProps(0, geos[i]);
+ SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, &props));
+ if (!surf) {
+ surf.reset(SkSurface::NewRaster(info, &props));
+ }
+ DrawText(surf->getCanvas());
+ surf->draw(canvas, SkIntToScalar(i * (info.width() + 10)), 0, NULL);
+ }
+ }
+};
+
///////////////////////////////////////////////////////////////////////////////
DEF_GM( return new LcdTextGM; )
DEF_GM( return new LcdTextSizeGM; )
+DEF_GM( return new LcdTextProps; )