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 | 8 |
9 | 9 |
10 #include "GrTextContext.h" | 10 #include "GrTextContext.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 if (NULL == fDrawTarget) { | 24 if (NULL == fDrawTarget) { |
25 return; | 25 return; |
26 } | 26 } |
27 | 27 |
28 GrDrawState* drawState = fDrawTarget->drawState(); | 28 GrDrawState* drawState = fDrawTarget->drawState(); |
29 GrDrawState::AutoRestoreEffects are(drawState); | 29 GrDrawState::AutoRestoreEffects are(drawState); |
30 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); | 30 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); |
31 | 31 |
32 if (fCurrVertex > 0) { | 32 if (fCurrVertex > 0) { |
33 // setup our sampler state for our text texture/atlas | 33 // setup our sampler state for our text texture/atlas |
34 GrAssert(GrIsALIGN4(fCurrVertex)); | 34 SkASSERT(GrIsALIGN4(fCurrVertex)); |
35 GrAssert(fCurrTexture); | 35 SkASSERT(fCurrTexture); |
36 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 36 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
37 | 37 |
38 // This effect could be stored with one of the cache objects (atlas?) | 38 // This effect could be stored with one of the cache objects (atlas?) |
39 drawState->addCoverageEffect( | 39 drawState->addCoverageEffect( |
40 GrSimpleTextureEffect::CreateWithCustomCoords(fC
urrTexture, params), | 40 GrSimpleTextureEffect::CreateWithCustomCoords(fC
urrTexture, params), |
41 kGlyphCoordsAttributeIndex)->unref(); | 41 kGlyphCoordsAttributeIndex)->unref(); |
42 | 42 |
43 if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) { | 43 if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) { |
44 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || | 44 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || |
45 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || | 45 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 GrAssert(glyph->fAtlas); | 196 SkASSERT(glyph->fAtlas); |
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->fAtlas->texture(); |
203 GrAssert(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 |
213 // a number of verts to reserve and whether to perform a flush. | 213 // a number of verts to reserve and whether to perform a flush. |
(...skipping 16 matching lines...) Expand all Loading... |
230 fMaxVertices = kDefaultRequestedVerts; | 230 fMaxVertices = kDefaultRequestedVerts; |
231 } else if (fMaxVertices > maxQuadVertices) { | 231 } else if (fMaxVertices > maxQuadVertices) { |
232 // don't exceed the limit of the index buffer | 232 // don't exceed the limit of the index buffer |
233 fMaxVertices = maxQuadVertices; | 233 fMaxVertices = maxQuadVertices; |
234 } | 234 } |
235 bool success = fDrawTarget->reserveVertexAndIndexSpace(fMaxVertices, | 235 bool success = fDrawTarget->reserveVertexAndIndexSpace(fMaxVertices, |
236 0, | 236 0, |
237 GrTCast<void**>(&
fVertices), | 237 GrTCast<void**>(&
fVertices), |
238 NULL); | 238 NULL); |
239 GrAlwaysAssert(success); | 239 GrAlwaysAssert(success); |
240 GrAssert(2*sizeof(GrPoint) == fDrawTarget->getDrawState().getVertexSize(
)); | 240 SkASSERT(2*sizeof(GrPoint) == fDrawTarget->getDrawState().getVertexSize(
)); |
241 } | 241 } |
242 | 242 |
243 GrFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); | 243 GrFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); |
244 GrFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); | 244 GrFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); |
245 | 245 |
246 fVertices[2*fCurrVertex].setRectFan(SkFixedToFloat(vx), | 246 fVertices[2*fCurrVertex].setRectFan(SkFixedToFloat(vx), |
247 SkFixedToFloat(vy), | 247 SkFixedToFloat(vy), |
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 } |
OLD | NEW |