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

Side by Side Diff: src/gpu/GrTextContext.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 | « no previous file | src/gpu/GrTextStrike.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 * 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 8
9 9
10 #include "GrTextContext.h" 10 #include "GrTextContext.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // check if we clipped out 146 // check if we clipped out
147 if (true || NULL == glyph->fPlot) { 147 if (true || NULL == glyph->fPlot) {
148 int x = vx >> 16; 148 int x = vx >> 16;
149 int y = vy >> 16; 149 int y = vy >> 16;
150 if (fClipRect.quickReject(x, y, x + width, y + height)) { 150 if (fClipRect.quickReject(x, y, x + width, y + height)) {
151 // SkCLZ(3); // so we can set a break-point in the debugger 151 // SkCLZ(3); // so we can set a break-point in the debugger
152 return; 152 return;
153 } 153 }
154 } 154 }
155 155
156 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
157 if (NULL == glyph->fPlot) { 156 if (NULL == glyph->fPlot) {
158 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { 157 if (fStrike->getGlyphAtlas(glyph, scaler)) {
159 goto HAS_ATLAS; 158 goto HAS_ATLAS;
160 } 159 }
161 160
162 // try to clear out an unused plot before we flush 161 // try to clear out an unused plot before we flush
163 fContext->getFontCache()->freePlotExceptFor(fStrike); 162 fContext->getFontCache()->freePlotExceptFor(fStrike);
164 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { 163 if (fStrike->getGlyphAtlas(glyph, scaler)) {
165 goto HAS_ATLAS; 164 goto HAS_ATLAS;
166 } 165 }
167 166
168 if (c_DumpFontCache) { 167 if (c_DumpFontCache) {
169 #ifdef SK_DEVELOPER 168 #ifdef SK_DEVELOPER
170 fContext->getFontCache()->dump(); 169 fContext->getFontCache()->dump();
171 #endif 170 #endif
172 } 171 }
173 172
174 // before we purge the cache, we must flush any accumulated draws 173 // before we purge the cache, we must flush any accumulated draws
175 this->flushGlyphs(); 174 this->flushGlyphs();
176 fContext->flush(); 175 fContext->flush();
177 176
178 // try to purge 177 // try to purge
179 fContext->getFontCache()->purgeExceptFor(fStrike); 178 fContext->getFontCache()->purgeExceptFor(fStrike);
180 // need to use new flush count here 179 // need to use new flush count here
181 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { 180 if (fStrike->getGlyphAtlas(glyph, scaler)) {
182 goto HAS_ATLAS; 181 goto HAS_ATLAS;
183 } 182 }
184 183
185 if (NULL == glyph->fPath) { 184 if (NULL == glyph->fPath) {
186 SkPath* path = SkNEW(SkPath); 185 SkPath* path = SkNEW(SkPath);
187 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { 186 if (!scaler->getGlyphPath(glyph->glyphID(), path)) {
188 // flag the glyph as being dead? 187 // flag the glyph as being dead?
189 delete path; 188 delete path;
190 return; 189 return;
191 } 190 }
192 glyph->fPath = path; 191 glyph->fPath = path;
193 } 192 }
194 193
195 GrContext::AutoMatrix am; 194 GrContext::AutoMatrix am;
196 SkMatrix translate; 195 SkMatrix translate;
197 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds. fLeft)), 196 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds. fLeft)),
198 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds. fTop))); 197 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds. fTop)));
199 GrPaint tmpPaint(fPaint); 198 GrPaint tmpPaint(fPaint);
200 am.setPreConcat(fContext, translate, &tmpPaint); 199 am.setPreConcat(fContext, translate, &tmpPaint);
201 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); 200 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
202 fContext->drawPath(tmpPaint, *glyph->fPath, stroke); 201 fContext->drawPath(tmpPaint, *glyph->fPath, stroke);
203 return; 202 return;
204 } 203 }
205 204
206 HAS_ATLAS: 205 HAS_ATLAS:
207 SkASSERT(glyph->fPlot); 206 SkASSERT(glyph->fPlot);
207 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
208 glyph->fPlot->setDrawToken(drawToken);
208 209
209 // now promote them to fixed (TODO: Rethink using fixed pt). 210 // now promote them to fixed (TODO: Rethink using fixed pt).
210 width = SkIntToFixed(width); 211 width = SkIntToFixed(width);
211 height = SkIntToFixed(height); 212 height = SkIntToFixed(height);
212 213
213 GrTexture* texture = glyph->fPlot->texture(); 214 GrTexture* texture = glyph->fPlot->texture();
214 SkASSERT(texture); 215 SkASSERT(texture);
215 216
216 if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) { 217 if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) {
217 this->flushGlyphs(); 218 this->flushGlyphs();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 SkFixedToFloat(vx + width), 260 SkFixedToFloat(vx + width),
260 SkFixedToFloat(vy + height), 261 SkFixedToFloat(vy + height),
261 2 * sizeof(SkPoint)); 262 2 * sizeof(SkPoint));
262 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)), 263 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)),
263 SkFixedToFloat(texture->normalizeFixed Y(ty)), 264 SkFixedToFloat(texture->normalizeFixed Y(ty)),
264 SkFixedToFloat(texture->normalizeFixed X(tx + width)), 265 SkFixedToFloat(texture->normalizeFixed X(tx + width)),
265 SkFixedToFloat(texture->normalizeFixed Y(ty + height)), 266 SkFixedToFloat(texture->normalizeFixed Y(ty + height)),
266 2 * sizeof(SkPoint)); 267 2 * sizeof(SkPoint));
267 fCurrVertex += 4; 268 fCurrVertex += 4;
268 } 269 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrTextStrike.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698