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 "GrAtlas.h" | 8 #include "GrAtlas.h" |
9 #include "GrGpu.h" | 9 #include "GrGpu.h" |
10 #include "GrRectanizer.h" | 10 #include "GrRectanizer.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 #endif | 224 #endif |
225 | 225 |
226 SkASSERT(glyph); | 226 SkASSERT(glyph); |
227 SkASSERT(scaler); | 227 SkASSERT(scaler); |
228 SkASSERT(fCache.contains(glyph)); | 228 SkASSERT(fCache.contains(glyph)); |
229 if (glyph->fAtlas) { | 229 if (glyph->fAtlas) { |
230 glyph->fAtlas->setDrawToken(currentDrawToken); | 230 glyph->fAtlas->setDrawToken(currentDrawToken); |
231 return true; | 231 return true; |
232 } | 232 } |
233 | 233 |
234 GrAutoRef ar(scaler); | 234 SkAutoRef ar(scaler); |
235 | 235 |
236 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat); | 236 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat); |
237 size_t size = glyph->fBounds.area() * bytesPerPixel; | 237 size_t size = glyph->fBounds.area() * bytesPerPixel; |
238 SkAutoSMalloc<1024> storage(size); | 238 SkAutoSMalloc<1024> storage(size); |
239 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(), | 239 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(), |
240 glyph->height(), | 240 glyph->height(), |
241 glyph->width() * bytesPerPixel, | 241 glyph->width() * bytesPerPixel, |
242 storage.get())) { | 242 storage.get())) { |
243 return false; | 243 return false; |
244 } | 244 } |
245 | 245 |
246 GrAtlas* atlas = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(), | 246 GrAtlas* atlas = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(), |
247 glyph->height(), storage.get(), | 247 glyph->height(), storage.get(), |
248 fMaskFormat, | 248 fMaskFormat, |
249 &glyph->fAtlasLocation); | 249 &glyph->fAtlasLocation); |
250 if (NULL == atlas) { | 250 if (NULL == atlas) { |
251 return false; | 251 return false; |
252 } | 252 } |
253 | 253 |
254 glyph->fAtlas = atlas; | 254 glyph->fAtlas = atlas; |
255 atlas->setDrawToken(currentDrawToken); | 255 atlas->setDrawToken(currentDrawToken); |
256 return true; | 256 return true; |
257 } | 257 } |
OLD | NEW |