OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 /* 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. |
10 */ | 10 */ |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 paint.setTextSize(rec[i].fTextSize); | 120 paint.setTextSize(rec[i].fTextSize); |
121 ScaleAbout(canvas, rec[i].fScale, rec[i].fScale, loc.x(), loc.y()); | 121 ScaleAbout(canvas, rec[i].fScale, rec[i].fScale, loc.x(), loc.y()); |
122 canvas->drawText(rec[i].fText, strlen(rec[i].fText), loc.x(), loc.y(
), paint); | 122 canvas->drawText(rec[i].fText, strlen(rec[i].fText), loc.x(), loc.y(
), paint); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 private: | 126 private: |
127 typedef skiagm::GM INHERITED; | 127 typedef skiagm::GM INHERITED; |
128 }; | 128 }; |
129 | |
130 DEF_GM( return new LcdTextGM; ) | 129 DEF_GM( return new LcdTextGM; ) |
131 DEF_GM( return new LcdTextSizeGM; ) | 130 DEF_GM( return new LcdTextSizeGM; ) |
| 131 |
| 132 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 133 |
| 134 DEF_SIMPLE_GM(savelayer_lcdtext, canvas, 620, 260) { |
| 135 SkPaint paint; |
| 136 paint.setAntiAlias(true); |
| 137 paint.setLCDRenderText(true); |
| 138 paint.setTextSize(20); |
| 139 |
| 140 canvas->drawText("Hamburgefons", 12, 30, 30, paint); |
| 141 |
| 142 const bool gPreserveLCDText[] = { false, true }; |
| 143 |
| 144 canvas->translate(0, 20); |
| 145 for (auto preserve : gPreserveLCDText) { |
| 146 preserve ? canvas->saveLayerPreserveLCDTextRequests(nullptr, nullptr) |
| 147 : canvas->saveLayer(nullptr, nullptr); |
| 148 canvas->drawText("Hamburgefons", 12, 30, 60, paint); |
| 149 |
| 150 SkPaint p; |
| 151 p.setColor(0xFFCCCCCC); |
| 152 canvas->drawRect(SkRect::MakeLTRB(25, 70, 200, 100), p); |
| 153 canvas->drawText("Hamburgefons", 12, 30, 90, paint); |
| 154 |
| 155 canvas->restore(); |
| 156 canvas->translate(0, 80); |
| 157 } |
| 158 } |
OLD | NEW |