Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: gm/lcdtext.cpp

Issue 727543002: add gm for lcd text and surfaceprops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/lcdtext.cpp
diff --git a/gm/lcdtext.cpp b/gm/lcdtext.cpp
index 0b5739c7abb95d37dfd0c540b263ea0b0389cf83..1e45f3c4d8d30284864bc2de910e39476da158c6 100644
--- a/gm/lcdtext.cpp
+++ b/gm/lcdtext.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2011 Google Inc.
f(malita) 2014/11/13 18:35:30 2014, but prolly not worth re-queueing.
*
@@ -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; )
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698