| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrBatchFontCache.h" | 8 #include "GrBatchFontCache.h" |
| 9 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 #include "GrFontAtlasSizes.h" | 10 #include "GrFontAtlasSizes.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 while (!iter.done()) { | 166 while (!iter.done()) { |
| 167 if (id == (*iter).fID) { | 167 if (id == (*iter).fID) { |
| 168 (*iter).fID = GrBatchAtlas::kInvalidAtlasID; | 168 (*iter).fID = GrBatchAtlas::kInvalidAtlasID; |
| 169 fAtlasedGlyphs--; | 169 fAtlasedGlyphs--; |
| 170 SkASSERT(fAtlasedGlyphs >= 0); | 170 SkASSERT(fAtlasedGlyphs >= 0); |
| 171 } | 171 } |
| 172 ++iter; | 172 ++iter; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool GrBatchTextStrike::addGlyphToAtlas(GrBatchTarget* batchTarget, GrGlyph* gly
ph, | 176 bool GrBatchTextStrike::addGlyphToAtlas(GrDrawBatch::Target* target, GrGlyph* gl
yph, |
| 177 GrFontScaler* scaler, const SkGlyph& skG
lyph, | 177 GrFontScaler* scaler, const SkGlyph& skG
lyph, |
| 178 GrMaskFormat expectedMaskFormat) { | 178 GrMaskFormat expectedMaskFormat) { |
| 179 SkASSERT(glyph); | 179 SkASSERT(glyph); |
| 180 SkASSERT(scaler); | 180 SkASSERT(scaler); |
| 181 SkASSERT(fCache.find(glyph->fPackedID)); | 181 SkASSERT(fCache.find(glyph->fPackedID)); |
| 182 | 182 |
| 183 SkAutoUnref ar(SkSafeRef(scaler)); | 183 SkAutoUnref ar(SkSafeRef(scaler)); |
| 184 | 184 |
| 185 int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat); | 185 int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat); |
| 186 | 186 |
| 187 size_t size = glyph->fBounds.area() * bytesPerPixel; | 187 size_t size = glyph->fBounds.area() * bytesPerPixel; |
| 188 SkAutoSMalloc<1024> storage(size); | 188 SkAutoSMalloc<1024> storage(size); |
| 189 | 189 |
| 190 if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedI
D)) { | 190 if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedI
D)) { |
| 191 if (!scaler->getPackedGlyphDFImage(skGlyph, glyph->width(), glyph->heigh
t(), | 191 if (!scaler->getPackedGlyphDFImage(skGlyph, glyph->width(), glyph->heigh
t(), |
| 192 storage.get())) { | 192 storage.get())) { |
| 193 return false; | 193 return false; |
| 194 } | 194 } |
| 195 } else { | 195 } else { |
| 196 if (!scaler->getPackedGlyphImage(skGlyph, glyph->width(), glyph->height(
), | 196 if (!scaler->getPackedGlyphImage(skGlyph, glyph->width(), glyph->height(
), |
| 197 glyph->width() * bytesPerPixel, expecte
dMaskFormat, | 197 glyph->width() * bytesPerPixel, expecte
dMaskFormat, |
| 198 storage.get())) { | 198 storage.get())) { |
| 199 return false; | 199 return false; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, batchTarget, e
xpectedMaskFormat, | 203 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect
edMaskFormat, |
| 204 glyph->width(), glyph->height(), | 204 glyph->width(), glyph->height(), |
| 205 storage.get(), &glyph->fAtlasLoca
tion); | 205 storage.get(), &glyph->fAtlasLoca
tion); |
| 206 if (success) { | 206 if (success) { |
| 207 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); | 207 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); |
| 208 fAtlasedGlyphs++; | 208 fAtlasedGlyphs++; |
| 209 } | 209 } |
| 210 return success; | 210 return success; |
| 211 } | 211 } |
| OLD | NEW |