| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "Resources.h" | 9 #include "Resources.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 glyphPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 64 glyphPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| 65 | 65 |
| 66 SkAutoSTMalloc<128, SkPoint> posStorage(glyphCount); | 66 SkAutoSTMalloc<128, SkPoint> posStorage(glyphCount); |
| 67 SkPoint* pos = posStorage.get(); | 67 SkPoint* pos = posStorage.get(); |
| 68 getGlyphPositions(glyphPaint, glyphs, glyphCount, x, y, pos); | 68 getGlyphPositions(glyphPaint, glyphs, glyphCount, x, y, pos); |
| 69 | 69 |
| 70 applyKerning(pos, adjustments, glyphCount, glyphPaint); | 70 applyKerning(pos, adjustments, glyphCount, glyphPaint); |
| 71 canvas->drawPosText(glyphs, glyphCount * sizeof(uint16_t), pos, glyphPaint); | 71 canvas->drawPosText(glyphs, glyphCount * sizeof(uint16_t), pos, glyphPaint); |
| 72 } | 72 } |
| 73 | 73 |
| 74 static const struct { | 74 constexpr struct { |
| 75 const char* fName; | 75 const char* fName; |
| 76 SkTypeface::Style fStyle; | 76 SkTypeface::Style fStyle; |
| 77 } gFaceStyles[] = { | 77 } gFaceStyles[] = { |
| 78 { "sans-serif", SkTypeface::kNormal }, | 78 { "sans-serif", SkTypeface::kNormal }, |
| 79 { "sans-serif", SkTypeface::kBold }, | 79 { "sans-serif", SkTypeface::kBold }, |
| 80 { "sans-serif", SkTypeface::kItalic }, | 80 { "sans-serif", SkTypeface::kItalic }, |
| 81 { "sans-serif", SkTypeface::kBoldItalic }, | 81 { "sans-serif", SkTypeface::kBoldItalic }, |
| 82 { "serif", SkTypeface::kNormal }, | 82 { "serif", SkTypeface::kNormal }, |
| 83 { "serif", SkTypeface::kBold }, | 83 { "serif", SkTypeface::kBold }, |
| 84 { "serif", SkTypeface::kItalic }, | 84 { "serif", SkTypeface::kItalic }, |
| 85 { "serif", SkTypeface::kBoldItalic }, | 85 { "serif", SkTypeface::kBoldItalic }, |
| 86 { "monospace", SkTypeface::kNormal }, | 86 { "monospace", SkTypeface::kNormal }, |
| 87 { "monospace", SkTypeface::kBold }, | 87 { "monospace", SkTypeface::kBold }, |
| 88 { "monospace", SkTypeface::kItalic }, | 88 { "monospace", SkTypeface::kItalic }, |
| 89 { "monospace", SkTypeface::kBoldItalic }, | 89 { "monospace", SkTypeface::kBoldItalic }, |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 static const int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles); | 92 constexpr int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles); |
| 93 | 93 |
| 94 class TypefaceStylesGM : public skiagm::GM { | 94 class TypefaceStylesGM : public skiagm::GM { |
| 95 sk_sp<SkTypeface> fFaces[gFaceStylesCount]; | 95 sk_sp<SkTypeface> fFaces[gFaceStylesCount]; |
| 96 bool fApplyKerning; | 96 bool fApplyKerning; |
| 97 | 97 |
| 98 public: | 98 public: |
| 99 TypefaceStylesGM(bool applyKerning) | 99 TypefaceStylesGM(bool applyKerning) |
| 100 : fApplyKerning(applyKerning) { | 100 : fApplyKerning(applyKerning) { |
| 101 memset(fFaces, 0, sizeof(fFaces)); | 101 memset(fFaces, 0, sizeof(fFaces)); |
| 102 } | 102 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 277 |
| 278 private: | 278 private: |
| 279 typedef skiagm::GM INHERITED; | 279 typedef skiagm::GM INHERITED; |
| 280 }; | 280 }; |
| 281 | 281 |
| 282 /////////////////////////////////////////////////////////////////////////////// | 282 /////////////////////////////////////////////////////////////////////////////// |
| 283 | 283 |
| 284 DEF_GM( return new TypefaceStylesGM(false); ) | 284 DEF_GM( return new TypefaceStylesGM(false); ) |
| 285 DEF_GM( return new TypefaceStylesGM(true); ) | 285 DEF_GM( return new TypefaceStylesGM(true); ) |
| 286 DEF_GM( return new TypefaceRenderingGM(); ) | 286 DEF_GM( return new TypefaceRenderingGM(); ) |
| OLD | NEW |