Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
|
f(malita)
2014/11/13 18:35:30
2014, but prolly not worth re-queueing.
| |
| 4 * | 3 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 | 8 |
| 10 /* Tests text rendering with LCD and subpixel rendering turned on and off. | 9 /* Tests text rendering with LCD and subpixel rendering turned on and off. |
| 11 */ | 10 */ |
| 12 | 11 |
| 13 #include "gm.h" | 12 #include "gm.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 paint.setTextSize(rec[i].fTextSize); | 114 paint.setTextSize(rec[i].fTextSize); |
| 116 ScaleAbout(canvas, rec[i].fScale, rec[i].fScale, loc.x(), loc.y()); | 115 ScaleAbout(canvas, rec[i].fScale, rec[i].fScale, loc.x(), loc.y()); |
| 117 canvas->drawText(rec[i].fText, strlen(rec[i].fText), loc.x(), loc.y( ), paint); | 116 canvas->drawText(rec[i].fText, strlen(rec[i].fText), loc.x(), loc.y( ), paint); |
| 118 } | 117 } |
| 119 } | 118 } |
| 120 | 119 |
| 121 private: | 120 private: |
| 122 typedef skiagm::GM INHERITED; | 121 typedef skiagm::GM INHERITED; |
| 123 }; | 122 }; |
| 124 | 123 |
| 124 #include "SkSurface.h" | |
| 125 | |
| 126 // ensure that we respect the SkPixelGeometry in SurfaceProps | |
| 127 class LcdTextProps : public skiagm::GM { | |
| 128 static void DrawText(SkCanvas* canvas) { | |
| 129 canvas->drawColor(SK_ColorWHITE); | |
| 130 SkPaint paint; | |
| 131 paint.setAntiAlias(true); | |
| 132 paint.setLCDRenderText(true); | |
| 133 paint.setTextSize(30); | |
| 134 canvas->drawText("Base", 4, 4, 30, paint); | |
| 135 canvas->saveLayer(NULL, NULL); | |
| 136 canvas->drawText("Layer", 5, 4, 70, paint); | |
| 137 canvas->restore(); | |
| 138 } | |
| 139 | |
| 140 public: | |
| 141 SkString onShortName() SK_OVERRIDE { | |
| 142 return SkString("lcdtextprops"); | |
| 143 } | |
| 144 | |
| 145 SkISize onISize() SK_OVERRIDE { return SkISize::Make(230, 120); } | |
| 146 | |
| 147 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | |
| 148 const SkPixelGeometry geos[] = { | |
| 149 kRGB_H_SkPixelGeometry, | |
| 150 kUnknown_SkPixelGeometry, | |
| 151 }; | |
| 152 | |
| 153 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | |
| 154 for (size_t i = 0; i < SK_ARRAY_COUNT(geos); ++i) { | |
| 155 SkSurfaceProps props = SkSurfaceProps(0, geos[i]); | |
| 156 SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, &props)); | |
| 157 if (!surf) { | |
| 158 surf.reset(SkSurface::NewRaster(info, &props)); | |
| 159 } | |
| 160 DrawText(surf->getCanvas()); | |
| 161 surf->draw(canvas, SkIntToScalar(i * (info.width() + 10)), 0, NULL); | |
| 162 } | |
| 163 } | |
| 164 }; | |
| 165 | |
| 125 /////////////////////////////////////////////////////////////////////////////// | 166 /////////////////////////////////////////////////////////////////////////////// |
| 126 | 167 |
| 127 DEF_GM( return new LcdTextGM; ) | 168 DEF_GM( return new LcdTextGM; ) |
| 128 DEF_GM( return new LcdTextSizeGM; ) | 169 DEF_GM( return new LcdTextSizeGM; ) |
| 170 DEF_GM( return new LcdTextProps; ) | |
| OLD | NEW |