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

Side by Side Diff: gm/textblob.cpp

Issue 563783003: Ensure blob typeface information survives SkGPipe serialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Pass TypefaceBuffer by ptr Created 6 years, 3 months 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 unified diff | Download patch
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | src/core/SkPtrRecorder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 { { 4, kScalar_Pos, 1 }, { 4, kPoint_Pos, .75f }, { 4, kDefault_ Pos, 1.25f } }, 59 { { 4, kScalar_Pos, 1 }, { 4, kPoint_Pos, .75f }, { 4, kDefault_ Pos, 1.25f } },
60 { { 4, kPoint_Pos, 1 }, { 4, kDefault_Pos, .75f }, { 4, kScalar_ Pos, 1.25f } }, 60 { { 4, kPoint_Pos, 1 }, { 4, kDefault_Pos, .75f }, { 4, kScalar_ Pos, 1.25f } },
61 }, 61 },
62 }; 62 };
63 63
64 const SkScalar kFontSize = 16; 64 const SkScalar kFontSize = 16;
65 } 65 }
66 66
67 class TextBlobGM : public skiagm::GM { 67 class TextBlobGM : public skiagm::GM {
68 public: 68 public:
69 TextBlobGM(const char* txt) { 69 TextBlobGM(const char* txt)
70 : fTypeface(sk_tool_utils::create_portable_typeface("Times", SkTypeface: :kNormal)) {
70 SkPaint p; 71 SkPaint p;
72 p.setTypeface(fTypeface);
71 size_t txtLen = strlen(txt); 73 size_t txtLen = strlen(txt);
72 int glyphCount = p.textToGlyphs(txt, txtLen, NULL); 74 int glyphCount = p.textToGlyphs(txt, txtLen, NULL);
73 75
74 fGlyphs.append(glyphCount); 76 fGlyphs.append(glyphCount);
75 p.textToGlyphs(txt, txtLen, fGlyphs.begin()); 77 p.textToGlyphs(txt, txtLen, fGlyphs.begin());
76 } 78 }
77 79
78 protected: 80 protected:
79 virtual SkString onShortName() SK_OVERRIDE { 81 virtual SkString onShortName() SK_OVERRIDE {
80 return SkString("textblob"); 82 return SkString("textblob");
(...skipping 23 matching lines...) Expand all
104 } 106 }
105 107
106 private: 108 private:
107 const SkTextBlob* makeBlob(unsigned blobIndex) { 109 const SkTextBlob* makeBlob(unsigned blobIndex) {
108 SkTextBlobBuilder builder; 110 SkTextBlobBuilder builder;
109 111
110 SkPaint font; 112 SkPaint font;
111 font.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 113 font.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
112 font.setAntiAlias(true); 114 font.setAntiAlias(true);
113 font.setSubpixelText(true); 115 font.setSubpixelText(true);
116 font.setTypeface(fTypeface);
114 117
115 for (unsigned l = 0; l < SK_ARRAY_COUNT(blobConfigs[blobIndex]); ++l) { 118 for (unsigned l = 0; l < SK_ARRAY_COUNT(blobConfigs[blobIndex]); ++l) {
116 unsigned currentGlyph = 0; 119 unsigned currentGlyph = 0;
117 120
118 for (unsigned c = 0; c < SK_ARRAY_COUNT(blobConfigs[blobIndex][l]); ++c) { 121 for (unsigned c = 0; c < SK_ARRAY_COUNT(blobConfigs[blobIndex][l]); ++c) {
119 const BlobCfg* cfg = &blobConfigs[blobIndex][l][c]; 122 const BlobCfg* cfg = &blobConfigs[blobIndex][l][c];
120 unsigned count = cfg->count; 123 unsigned count = cfg->count;
121 124
122 if (count > fGlyphs.count() - currentGlyph) { 125 if (count > fGlyphs.count() - currentGlyph) {
123 count = fGlyphs.count() - currentGlyph; 126 count = fGlyphs.count() - currentGlyph;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 SkFAIL("unhandled pos value"); 169 SkFAIL("unhandled pos value");
167 } 170 }
168 171
169 currentGlyph += count; 172 currentGlyph += count;
170 } 173 }
171 } 174 }
172 175
173 return builder.build(); 176 return builder.build();
174 } 177 }
175 178
176 SkTDArray<uint16_t> fGlyphs; 179 SkTDArray<uint16_t> fGlyphs;
180 SkAutoTUnref<SkTypeface> fTypeface;
177 181
178 typedef skiagm::GM INHERITED; 182 typedef skiagm::GM INHERITED;
179 }; 183 };
180 184
181 DEF_GM( return SkNEW_ARGS(TextBlobGM, ("hamburgefons")); ) 185 DEF_GM( return SkNEW_ARGS(TextBlobGM, ("hamburgefons")); )
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | src/core/SkPtrRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698