| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 SkPaint paint; | 130 SkPaint paint; |
| 131 paint.setAntiAlias(true); | 131 paint.setAntiAlias(true); |
| 132 paint.setLCDRenderText(true); | 132 paint.setLCDRenderText(true); |
| 133 paint.setTextSize(30); | 133 paint.setTextSize(30); |
| 134 canvas->drawText("Base", 4, 4, 30, paint); | 134 canvas->drawText("Base", 4, 4, 30, paint); |
| 135 canvas->saveLayer(NULL, NULL); | 135 canvas->saveLayer(NULL, NULL); |
| 136 canvas->drawText("Layer", 5, 4, 70, paint); | 136 canvas->drawText("Layer", 5, 4, 70, paint); |
| 137 canvas->restore(); | 137 canvas->restore(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 public: | 140 protected: |
| 141 SkString onShortName() SK_OVERRIDE { | 141 SkString onShortName() SK_OVERRIDE { |
| 142 return SkString("lcdtextprops"); | 142 return SkString("lcdtextprops"); |
| 143 } | 143 } |
| 144 | 144 |
| 145 SkISize onISize() SK_OVERRIDE { return SkISize::Make(230, 120); } | 145 SkISize onISize() SK_OVERRIDE { return SkISize::Make(230, 120); } |
| 146 | 146 |
| 147 uint32_t onGetFlags() const SK_OVERRIDE { |
| 148 return kSkip565_Flag; |
| 149 } |
| 150 |
| 147 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 151 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 148 const SkPixelGeometry geos[] = { | 152 const SkPixelGeometry geos[] = { |
| 149 kRGB_H_SkPixelGeometry, | 153 kRGB_H_SkPixelGeometry, |
| 150 kUnknown_SkPixelGeometry, | 154 kUnknown_SkPixelGeometry, |
| 151 }; | 155 }; |
| 152 | 156 |
| 153 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | 157 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
| 154 for (size_t i = 0; i < SK_ARRAY_COUNT(geos); ++i) { | 158 for (size_t i = 0; i < SK_ARRAY_COUNT(geos); ++i) { |
| 155 SkSurfaceProps props = SkSurfaceProps(0, geos[i]); | 159 SkSurfaceProps props = SkSurfaceProps(0, geos[i]); |
| 156 SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, &props)); | 160 SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, &props)); |
| 157 if (!surf) { | 161 if (!surf) { |
| 158 surf.reset(SkSurface::NewRaster(info, &props)); | 162 surf.reset(SkSurface::NewRaster(info, &props)); |
| 159 } | 163 } |
| 160 DrawText(surf->getCanvas()); | 164 DrawText(surf->getCanvas()); |
| 161 surf->draw(canvas, SkIntToScalar(i * (info.width() + 10)), 0, NULL); | 165 surf->draw(canvas, SkIntToScalar(i * (info.width() + 10)), 0, NULL); |
| 162 } | 166 } |
| 163 } | 167 } |
| 164 }; | 168 }; |
| 165 | 169 |
| 166 /////////////////////////////////////////////////////////////////////////////// | 170 /////////////////////////////////////////////////////////////////////////////// |
| 167 | 171 |
| 168 DEF_GM( return new LcdTextGM; ) | 172 DEF_GM( return new LcdTextGM; ) |
| 169 DEF_GM( return new LcdTextSizeGM; ) | 173 DEF_GM( return new LcdTextSizeGM; ) |
| 170 DEF_GM( return new LcdTextProps; ) | 174 DEF_GM( return new LcdTextProps; ) |
| OLD | NEW |