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

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

Issue 26253003: Fix for blinking/corrupted text in Canvas 2D. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrTextStrike.h ('k') | no next file » | 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 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 glyph->init(packed, bounds); 252 glyph->init(packed, bounds);
253 fCache.insert(packed, glyph); 253 fCache.insert(packed, glyph);
254 return glyph; 254 return glyph;
255 } 255 }
256 256
257 bool GrTextStrike::removeUnusedPlots() { 257 bool GrTextStrike::removeUnusedPlots() {
258 fCache.getArray().visitAll(invalidate_glyph); 258 fCache.getArray().visitAll(invalidate_glyph);
259 return fAtlasMgr->removeUnusedPlots(&fAtlas); 259 return fAtlasMgr->removeUnusedPlots(&fAtlas);
260 } 260 }
261 261
262 bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler, 262 bool GrTextStrike::getGlyphAtlas(GrGlyph* glyph, GrFontScaler* scaler) {
263 GrDrawTarget::DrawToken currentDrawToken) {
264 #if 0 // testing hack to force us to flush our cache often 263 #if 0 // testing hack to force us to flush our cache often
265 static int gCounter; 264 static int gCounter;
266 if ((++gCounter % 10) == 0) return false; 265 if ((++gCounter % 10) == 0) return false;
267 #endif 266 #endif
268 267
269 SkASSERT(glyph); 268 SkASSERT(glyph);
270 SkASSERT(scaler); 269 SkASSERT(scaler);
271 SkASSERT(fCache.contains(glyph)); 270 SkASSERT(fCache.contains(glyph));
272 if (glyph->fPlot) { 271 SkASSERT(NULL == glyph->fPlot);
273 glyph->fPlot->setDrawToken(currentDrawToken);
274 return true;
275 }
276 272
277 SkAutoRef ar(scaler); 273 SkAutoRef ar(scaler);
278 274
279 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat); 275 int bytesPerPixel = GrMaskFormatBytesPerPixel(fMaskFormat);
280 size_t size = glyph->fBounds.area() * bytesPerPixel; 276 size_t size = glyph->fBounds.area() * bytesPerPixel;
281 SkAutoSMalloc<1024> storage(size); 277 SkAutoSMalloc<1024> storage(size);
282 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(), 278 if (!scaler->getPackedGlyphImage(glyph->fPackedID, glyph->width(),
283 glyph->height(), 279 glyph->height(),
284 glyph->width() * bytesPerPixel, 280 glyph->width() * bytesPerPixel,
285 storage.get())) { 281 storage.get())) {
286 return false; 282 return false;
287 } 283 }
288 284
289 GrPlot* plot = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(), 285 GrPlot* plot = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(),
290 glyph->height(), storage.get(), 286 glyph->height(), storage.get(),
291 &glyph->fAtlasLocation); 287 &glyph->fAtlasLocation);
292 if (NULL == plot) { 288 if (NULL == plot) {
293 return false; 289 return false;
294 } 290 }
295 291
296 glyph->fPlot = plot; 292 glyph->fPlot = plot;
297 plot->setDrawToken(currentDrawToken);
298 return true; 293 return true;
299 } 294 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextStrike.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698