OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "GrGpu.h" | 8 #include "GrGpu.h" |
9 #include "GrRectanizer.h" | 9 #include "GrRectanizer.h" |
10 #include "GrTextStrike.h" | 10 #include "GrTextStrike.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 SkASSERT(glyph); | 299 SkASSERT(glyph); |
300 SkASSERT(scaler); | 300 SkASSERT(scaler); |
301 SkASSERT(fCache.find(glyph->fPackedID)); | 301 SkASSERT(fCache.find(glyph->fPackedID)); |
302 SkASSERT(NULL == glyph->fPlot); | 302 SkASSERT(NULL == glyph->fPlot); |
303 | 303 |
304 SkAutoUnref ar(SkSafeRef(scaler)); | 304 SkAutoUnref ar(SkSafeRef(scaler)); |
305 | 305 |
306 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat); | 306 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat); |
307 | 307 |
308 size_t size = glyph->fBounds.area() * bytesPerPixel; | 308 size_t size = glyph->fBounds.area() * bytesPerPixel; |
309 SkAutoSMalloc<1024> storage(size); | 309 GrAutoMalloc<1024> storage(size); |
| 310 |
310 if (fUseDistanceField) { | 311 if (fUseDistanceField) { |
311 if (!scaler->getPackedGlyphDFImage(glyph->fPackedID, glyph->width(), | 312 if (!scaler->getPackedGlyphDFImage(glyph->fPackedID, glyph->width(), |
312 glyph->height(), | 313 glyph->height(), |
313 storage.get())) { | 314 storage.get())) { |
314 return false; | 315 return false; |
315 } | 316 } |
316 } else { | 317 } else { |
317 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(), | 318 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(), |
318 glyph->height(), | 319 glyph->height(), |
319 glyph->width() * bytesPerPixel, | 320 glyph->width() * bytesPerPixel, |
320 storage.get())) { | 321 storage.get())) { |
321 return false; | 322 return false; |
322 } | 323 } |
323 } | 324 } |
324 | 325 |
325 GrPlot* plot = fAtlas->addToAtlas(&fPlotUsage, glyph->width(), | 326 GrPlot* plot = fAtlas->addToAtlas(&fPlotUsage, glyph->width(), |
326 glyph->height(), storage.get(), | 327 glyph->height(), storage.get(), |
327 &glyph->fAtlasLocation); | 328 &glyph->fAtlasLocation); |
328 | 329 |
329 if (NULL == plot) { | 330 if (NULL == plot) { |
330 return false; | 331 return false; |
331 } | 332 } |
332 | 333 |
333 glyph->fPlot = plot; | 334 glyph->fPlot = plot; |
334 return true; | 335 return true; |
335 } | 336 } |
OLD | NEW |