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

Side by Side Diff: src/gpu/GrFontScaler.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 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 | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrGeometryBuffer.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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrFontScaler.h" 9 #include "GrFontScaler.h"
10 #include "SkDescriptor.h" 10 #include "SkDescriptor.h"
11 #include "SkDistanceFieldGen.h" 11 #include "SkDistanceFieldGen.h"
12 #include "SkGlyphCache.h" 12 #include "SkGlyphCache.h"
13 13
14 /////////////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////////////
15 15
16 GrFontScaler::GrFontScaler(SkGlyphCache* strike) { 16 GrFontScaler::GrFontScaler(SkGlyphCache* strike) {
17 fStrike = strike; 17 fStrike = strike;
18 fKey = NULL; 18 fKey = nullptr;
19 } 19 }
20 20
21 GrFontScaler::~GrFontScaler() { 21 GrFontScaler::~GrFontScaler() {
22 SkSafeUnref(fKey); 22 SkSafeUnref(fKey);
23 } 23 }
24 24
25 GrMaskFormat GrFontScaler::getMaskFormat() const { 25 GrMaskFormat GrFontScaler::getMaskFormat() const {
26 SkMask::Format format = fStrike->getMaskFormat(); 26 SkMask::Format format = fStrike->getMaskFormat();
27 switch (format) { 27 switch (format) {
28 case SkMask::kBW_Format: 28 case SkMask::kBW_Format:
29 // fall through to kA8 -- we store BW glyphs in our 8-bit cache 29 // fall through to kA8 -- we store BW glyphs in our 8-bit cache
30 case SkMask::kA8_Format: 30 case SkMask::kA8_Format:
31 return kA8_GrMaskFormat; 31 return kA8_GrMaskFormat;
32 case SkMask::kLCD16_Format: 32 case SkMask::kLCD16_Format:
33 return kA565_GrMaskFormat; 33 return kA565_GrMaskFormat;
34 case SkMask::kARGB32_Format: 34 case SkMask::kARGB32_Format:
35 return kARGB_GrMaskFormat; 35 return kARGB_GrMaskFormat;
36 default: 36 default:
37 SkDEBUGFAIL("unsupported SkMask::Format"); 37 SkDEBUGFAIL("unsupported SkMask::Format");
38 return kA8_GrMaskFormat; 38 return kA8_GrMaskFormat;
39 } 39 }
40 } 40 }
41 41
42 const GrFontDescKey* GrFontScaler::getKey() { 42 const GrFontDescKey* GrFontScaler::getKey() {
43 if (NULL == fKey) { 43 if (nullptr == fKey) {
44 fKey = new GrFontDescKey(fStrike->getDescriptor()); 44 fKey = new GrFontDescKey(fStrike->getDescriptor());
45 } 45 }
46 return fKey; 46 return fKey;
47 } 47 }
48 48
49 GrMaskFormat GrFontScaler::getPackedGlyphMaskFormat(const SkGlyph& glyph) const { 49 GrMaskFormat GrFontScaler::getPackedGlyphMaskFormat(const SkGlyph& glyph) const {
50 SkMask::Format format = static_cast<SkMask::Format>(glyph.fMaskFormat); 50 SkMask::Format format = static_cast<SkMask::Format>(glyph.fMaskFormat);
51 switch (format) { 51 switch (format) {
52 case SkMask::kBW_Format: 52 case SkMask::kBW_Format:
53 // fall through to kA8 -- we store BW glyphs in our 8-bit cache 53 // fall through to kA8 -- we store BW glyphs in our 8-bit cache
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 src += srcRowBytes; 110 src += srcRowBytes;
111 } 111 }
112 } 112 }
113 } 113 }
114 114
115 bool GrFontScaler::getPackedGlyphImage(const SkGlyph& glyph, int width, int heig ht, int dstRB, 115 bool GrFontScaler::getPackedGlyphImage(const SkGlyph& glyph, int width, int heig ht, int dstRB,
116 GrMaskFormat expectedMaskFormat, void* ds t) { 116 GrMaskFormat expectedMaskFormat, void* ds t) {
117 SkASSERT(glyph.fWidth == width); 117 SkASSERT(glyph.fWidth == width);
118 SkASSERT(glyph.fHeight == height); 118 SkASSERT(glyph.fHeight == height);
119 const void* src = fStrike->findImage(glyph); 119 const void* src = fStrike->findImage(glyph);
120 if (NULL == src) { 120 if (nullptr == src) {
121 return false; 121 return false;
122 } 122 }
123 123
124 // crbug:510931 124 // crbug:510931
125 // Retrieving the image from the cache can actually change the mask format. This case is very 125 // Retrieving the image from the cache can actually change the mask format. This case is very
126 // uncommon so for now we just draw a clear box for these glyphs. 126 // uncommon so for now we just draw a clear box for these glyphs.
127 if (getPackedGlyphMaskFormat(glyph) != expectedMaskFormat) { 127 if (getPackedGlyphMaskFormat(glyph) != expectedMaskFormat) {
128 const int bpp = GrMaskFormatBytesPerPixel(expectedMaskFormat); 128 const int bpp = GrMaskFormatBytesPerPixel(expectedMaskFormat);
129 for (int y = 0; y < height; y++) { 129 for (int y = 0; y < height; y++) {
130 sk_bzero(dst, width * bpp); 130 sk_bzero(dst, width * bpp);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 dst = (char*)dst + dstRB; 164 dst = (char*)dst + dstRB;
165 } 165 }
166 } 166 }
167 return true; 167 return true;
168 } 168 }
169 169
170 bool GrFontScaler::getPackedGlyphDFImage(const SkGlyph& glyph, int width, int he ight, void* dst) { 170 bool GrFontScaler::getPackedGlyphDFImage(const SkGlyph& glyph, int width, int he ight, void* dst) {
171 SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width); 171 SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width);
172 SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height); 172 SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height);
173 const void* image = fStrike->findImage(glyph); 173 const void* image = fStrike->findImage(glyph);
174 if (NULL == image) { 174 if (nullptr == image) {
175 return false; 175 return false;
176 } 176 }
177 // now generate the distance field 177 // now generate the distance field
178 SkASSERT(dst); 178 SkASSERT(dst);
179 SkMask::Format maskFormat = static_cast<SkMask::Format>(glyph.fMaskFormat); 179 SkMask::Format maskFormat = static_cast<SkMask::Format>(glyph.fMaskFormat);
180 if (SkMask::kA8_Format == maskFormat) { 180 if (SkMask::kA8_Format == maskFormat) {
181 // make the distance field from the image 181 // make the distance field from the image
182 SkGenerateDistanceFieldFromA8Image((unsigned char*)dst, 182 SkGenerateDistanceFieldFromA8Image((unsigned char*)dst,
183 (unsigned char*)image, 183 (unsigned char*)image,
184 glyph.fWidth, glyph.fHeight, 184 glyph.fWidth, glyph.fHeight,
(...skipping 13 matching lines...) Expand all
198 198
199 const SkPath* GrFontScaler::getGlyphPath(const SkGlyph& glyph) { 199 const SkPath* GrFontScaler::getGlyphPath(const SkGlyph& glyph) {
200 return fStrike->findPath(glyph); 200 return fStrike->findPath(glyph);
201 } 201 }
202 202
203 const SkGlyph& GrFontScaler::grToSkGlyph(GrGlyph::PackedID id) { 203 const SkGlyph& GrFontScaler::grToSkGlyph(GrGlyph::PackedID id) {
204 return fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(id), 204 return fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(id),
205 GrGlyph::UnpackFixedX(id), 205 GrGlyph::UnpackFixedX(id),
206 GrGlyph::UnpackFixedY(id)); 206 GrGlyph::UnpackFixedY(id));
207 } 207 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrGeometryBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698