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

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

Issue 24981004: GrAtlas cleanup: Split out GrPlot and GrAtlas (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Tweaked comment 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/GrRectanizer.cpp ('k') | 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 133
134 vx += SkIntToFixed(glyph->fBounds.fLeft); 134 vx += SkIntToFixed(glyph->fBounds.fLeft);
135 vy += SkIntToFixed(glyph->fBounds.fTop); 135 vy += SkIntToFixed(glyph->fBounds.fTop);
136 136
137 // keep them as ints until we've done the clip-test 137 // keep them as ints until we've done the clip-test
138 GrFixed width = glyph->fBounds.width(); 138 GrFixed width = glyph->fBounds.width();
139 GrFixed height = glyph->fBounds.height(); 139 GrFixed height = glyph->fBounds.height();
140 140
141 // check if we clipped out 141 // check if we clipped out
142 if (true || NULL == glyph->fAtlas) { 142 if (true || NULL == glyph->fPlot) {
143 int x = vx >> 16; 143 int x = vx >> 16;
144 int y = vy >> 16; 144 int y = vy >> 16;
145 if (fClipRect.quickReject(x, y, x + width, y + height)) { 145 if (fClipRect.quickReject(x, y, x + width, y + height)) {
146 // SkCLZ(3); // so we can set a break-point in the debugger 146 // SkCLZ(3); // so we can set a break-point in the debugger
147 return; 147 return;
148 } 148 }
149 } 149 }
150 150
151 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); 151 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
152 if (NULL == glyph->fAtlas) { 152 if (NULL == glyph->fPlot) {
153 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { 153 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) {
154 goto HAS_ATLAS; 154 goto HAS_ATLAS;
155 } 155 }
156 156
157 // try to clear out an unused atlas before we flush 157 // try to clear out an unused plot before we flush
158 fContext->getFontCache()->freeAtlasExceptFor(fStrike); 158 fContext->getFontCache()->freePlotExceptFor(fStrike);
159 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { 159 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) {
160 goto HAS_ATLAS; 160 goto HAS_ATLAS;
161 } 161 }
162 162
163 // before we purge the cache, we must flush any accumulated draws 163 // before we purge the cache, we must flush any accumulated draws
164 this->flushGlyphs(); 164 this->flushGlyphs();
165 fContext->flush(); 165 fContext->flush();
166 166
167 // try to purge 167 // try to purge
168 fContext->getFontCache()->purgeExceptFor(fStrike); 168 fContext->getFontCache()->purgeExceptFor(fStrike);
(...skipping 17 matching lines...) Expand all
186 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds. fLeft)), 186 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds. fLeft)),
187 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds. fTop))); 187 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds. fTop)));
188 GrPaint tmpPaint(fPaint); 188 GrPaint tmpPaint(fPaint);
189 am.setPreConcat(fContext, translate, &tmpPaint); 189 am.setPreConcat(fContext, translate, &tmpPaint);
190 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); 190 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
191 fContext->drawPath(tmpPaint, *glyph->fPath, stroke); 191 fContext->drawPath(tmpPaint, *glyph->fPath, stroke);
192 return; 192 return;
193 } 193 }
194 194
195 HAS_ATLAS: 195 HAS_ATLAS:
196 SkASSERT(glyph->fAtlas); 196 SkASSERT(glyph->fPlot);
197 197
198 // now promote them to fixed (TODO: Rethink using fixed pt). 198 // now promote them to fixed (TODO: Rethink using fixed pt).
199 width = SkIntToFixed(width); 199 width = SkIntToFixed(width);
200 height = SkIntToFixed(height); 200 height = SkIntToFixed(height);
201 201
202 GrTexture* texture = glyph->fAtlas->texture(); 202 GrTexture* texture = glyph->fPlot->texture();
203 SkASSERT(texture); 203 SkASSERT(texture);
204 204
205 if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) { 205 if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) {
206 this->flushGlyphs(); 206 this->flushGlyphs();
207 fCurrTexture = texture; 207 fCurrTexture = texture;
208 fCurrTexture->ref(); 208 fCurrTexture->ref();
209 } 209 }
210 210
211 if (NULL == fVertices) { 211 if (NULL == fVertices) {
212 // If we need to reserve vertices allow the draw target to suggest 212 // If we need to reserve vertices allow the draw target to suggest
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 SkFixedToFloat(vx + width), 248 SkFixedToFloat(vx + width),
249 SkFixedToFloat(vy + height), 249 SkFixedToFloat(vy + height),
250 2 * sizeof(SkPoint)); 250 2 * sizeof(SkPoint));
251 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)), 251 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)),
252 SkFixedToFloat(texture->normalizeFixed Y(ty)), 252 SkFixedToFloat(texture->normalizeFixed Y(ty)),
253 SkFixedToFloat(texture->normalizeFixed X(tx + width)), 253 SkFixedToFloat(texture->normalizeFixed X(tx + width)),
254 SkFixedToFloat(texture->normalizeFixed Y(ty + height)), 254 SkFixedToFloat(texture->normalizeFixed Y(ty + height)),
255 2 * sizeof(SkPoint)); 255 2 * sizeof(SkPoint));
256 fCurrVertex += 4; 256 fCurrVertex += 4;
257 } 257 }
OLDNEW
« no previous file with comments | « src/gpu/GrRectanizer.cpp ('k') | src/gpu/GrTextStrike.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698