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

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

Issue 414573002: Move vertex buffer setup out of drawPackedGlyph(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make sure we release vertex pool; get rid of unnecessary texture ptr. Created 6 years, 5 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
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrDistanceFieldTextContext.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 2013 Google Inc. 2 * Copyright 2013 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 "GrBitmapTextContext.h" 8 #include "GrBitmapTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVe rtexAttribBinding} 47 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVe rtexAttribBinding}
48 }; 48 };
49 49
50 }; 50 };
51 51
52 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, 52 GrBitmapTextContext::GrBitmapTextContext(GrContext* context,
53 const SkDeviceProperties& properties) 53 const SkDeviceProperties& properties)
54 : GrTextContext(context, properties) { 54 : GrTextContext(context, properties) {
55 fStrike = NULL; 55 fStrike = NULL;
56 56
57 fCurrTexture = NULL;
58 fCurrVertex = 0; 57 fCurrVertex = 0;
59 fEffectTextureUniqueID = SK_InvalidUniqueID; 58 fEffectTextureUniqueID = SK_InvalidUniqueID;
60 59
61 fVertices = NULL; 60 fVertices = NULL;
62 fMaxVertices = 0;
63 61
64 fVertexBounds.setLargestInverted(); 62 fVertexBounds.setLargestInverted();
65 } 63 }
66 64
67 GrBitmapTextContext::~GrBitmapTextContext() { 65 GrBitmapTextContext::~GrBitmapTextContext() {
68 this->flushGlyphs(); 66 this->flushGlyphs();
69 } 67 }
70 68
71 bool GrBitmapTextContext::canDraw(const SkPaint& paint) { 69 bool GrBitmapTextContext::canDraw(const SkPaint& paint) {
72 return !SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix()); 70 return !SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix());
(...skipping 11 matching lines...) Expand all
84 return; 82 return;
85 } 83 }
86 84
87 GrDrawState* drawState = fDrawTarget->drawState(); 85 GrDrawState* drawState = fDrawTarget->drawState();
88 GrDrawState::AutoRestoreEffects are(drawState); 86 GrDrawState::AutoRestoreEffects are(drawState);
89 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); 87 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget());
90 88
91 if (fCurrVertex > 0) { 89 if (fCurrVertex > 0) {
92 // setup our sampler state for our text texture/atlas 90 // setup our sampler state for our text texture/atlas
93 SkASSERT(SkIsAlign4(fCurrVertex)); 91 SkASSERT(SkIsAlign4(fCurrVertex));
94 SkASSERT(fCurrTexture);
95 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon e_FilterMode); 92 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon e_FilterMode);
96 93
97 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); 94 GrTexture* currTexture = fStrike->getTexture();
95 SkASSERT(currTexture);
96 uint32_t textureUniqueID = currTexture->getUniqueID();
98 97
99 if (textureUniqueID != fEffectTextureUniqueID) { 98 if (textureUniqueID != fEffectTextureUniqueID) {
100 fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture , params)); 99 fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(currTexture, params));
101 fEffectTextureUniqueID = textureUniqueID; 100 fEffectTextureUniqueID = textureUniqueID;
102 } 101 }
103 102
104 // This effect could be stored with one of the cache objects (atlas?) 103 // This effect could be stored with one of the cache objects (atlas?)
105 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC olorAttributeIndex : 104 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC olorAttributeIndex :
106 kGlyphCoordsNoCol orAttributeIndex; 105 kGlyphCoordsNoCol orAttributeIndex;
107 drawState->addCoverageEffect(fCachedEffect.get(), coordsIdx); 106 drawState->addCoverageEffect(fCachedEffect.get(), coordsIdx);
108 SkASSERT(NULL != fStrike); 107 SkASSERT(NULL != fStrike);
109 switch (fStrike->getMaskFormat()) { 108 switch (fStrike->getMaskFormat()) {
110 // Color bitmap text 109 // Color bitmap text
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 break; 144 break;
146 default: 145 default:
147 SkFAIL("Unexepected mask format."); 146 SkFAIL("Unexepected mask format.");
148 } 147 }
149 int nGlyphs = fCurrVertex / 4; 148 int nGlyphs = fCurrVertex / 4;
150 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); 149 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
151 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, 150 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType,
152 nGlyphs, 151 nGlyphs,
153 4, 6, &fVertexBounds); 152 4, 6, &fVertexBounds);
154 153
155 fDrawTarget->resetVertexSource();
156 fVertices = NULL;
157 fMaxVertices = 0;
158 fCurrVertex = 0; 154 fCurrVertex = 0;
159 fVertexBounds.setLargestInverted(); 155 fVertexBounds.setLargestInverted();
160 SkSafeSetNull(fCurrTexture);
161 } 156 }
157
158 fDrawTarget->resetVertexSource();
159 fVertices = NULL;
162 } 160 }
163 161
164 inline void GrBitmapTextContext::init(const GrPaint& paint, const SkPaint& skPai nt) { 162 inline void GrBitmapTextContext::init(const GrPaint& paint, const SkPaint& skPai nt) {
165 GrTextContext::init(paint, skPaint); 163 GrTextContext::init(paint, skPaint);
166 164
167 fStrike = NULL; 165 fStrike = NULL;
168 166
169 fCurrTexture = NULL;
170 fCurrVertex = 0; 167 fCurrVertex = 0;
171 168
172 fVertices = NULL; 169 fVertices = NULL;
173 fMaxVertices = 0;
174 } 170 }
175 171
176 inline void GrBitmapTextContext::finish() { 172 inline void GrBitmapTextContext::finish() {
177 this->flushGlyphs(); 173 this->flushGlyphs();
178 174
179 GrTextContext::finish(); 175 GrTextContext::finish();
180 } 176 }
181 177
182 void GrBitmapTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint, 178 void GrBitmapTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint,
183 const char text[], size_t byteLength, 179 const char text[], size_t byteLength,
184 SkScalar x, SkScalar y) { 180 SkScalar x, SkScalar y) {
185 SkASSERT(byteLength == 0 || text != NULL); 181 SkASSERT(byteLength == 0 || text != NULL);
186 182
187 // nothing to draw 183 // nothing to draw
188 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) { 184 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) {
189 return; 185 return;
190 } 186 }
191 187
192 this->init(paint, skPaint); 188 this->init(paint, skPaint);
193 189
190 if (NULL == fDrawTarget) {
191 return;
192 }
193
194 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); 194 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
195 195
196 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &fContext->getMa trix()); 196 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &fContext->getMa trix());
197 SkGlyphCache* cache = autoCache.getCache(); 197 SkGlyphCache* cache = autoCache.getCache();
198 GrFontScaler* fontScaler = GetGrFontScaler(cache); 198 GrFontScaler* fontScaler = GetGrFontScaler(cache);
199 if (NULL == fStrike) {
200 fStrike = fContext->getFontCache()->getStrike(fontScaler, false);
201 }
199 202
200 // transform our starting point 203 // transform our starting point
201 { 204 {
202 SkPoint loc; 205 SkPoint loc;
203 fContext->getMatrix().mapXY(x, y, &loc); 206 fContext->getMatrix().mapXY(x, y, &loc);
204 x = loc.fX; 207 x = loc.fX;
205 y = loc.fY; 208 y = loc.fY;
206 } 209 }
207 210
208 // need to measure first 211 // need to measure first
209 if (fSkPaint.getTextAlign() != SkPaint::kLeft_Align) { 212 if (fSkPaint.getTextAlign() != SkPaint::kLeft_Align) {
210 SkVector stop; 213 SkVector stop;
211 214
212 MeasureText(cache, glyphCacheProc, text, byteLength, &stop); 215 MeasureText(cache, glyphCacheProc, text, byteLength, &stop);
213 216
214 SkScalar stopX = stop.fX; 217 SkScalar stopX = stop.fX;
215 SkScalar stopY = stop.fY; 218 SkScalar stopY = stop.fY;
216 219
217 if (fSkPaint.getTextAlign() == SkPaint::kCenter_Align) { 220 if (fSkPaint.getTextAlign() == SkPaint::kCenter_Align) {
218 stopX = SkScalarHalf(stopX); 221 stopX = SkScalarHalf(stopX);
219 stopY = SkScalarHalf(stopY); 222 stopY = SkScalarHalf(stopY);
220 } 223 }
221 x -= stopX; 224 x -= stopX;
222 y -= stopY; 225 y -= stopY;
223 } 226 }
224 227
225 const char* stop = text + byteLength; 228 const char* stop = text + byteLength;
226 229
230 // allocate vertices
231 SkASSERT(NULL == fVertices);
232 bool useColorVerts = kA8_GrMaskFormat == fStrike->getMaskFormat();
233 if (useColorVerts) {
234 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>(
235 SK_ARRAY_COUNT(gTextVertexWi thColorAttribs));
236 } else {
237 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
238 SK_ARRAY_COUNT(gTextVertexAt tribs));
239 }
240 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL);
241 bool success = fDrawTarget->reserveVertexAndIndexSpace(4*numGlyphs,
242 0,
243 &fVertices,
244 NULL);
245 GrAlwaysAssert(success);
246
227 SkAutoKern autokern; 247 SkAutoKern autokern;
228 248
229 SkFixed fxMask = ~0; 249 SkFixed fxMask = ~0;
230 SkFixed fyMask = ~0; 250 SkFixed fyMask = ~0;
231 SkFixed halfSampleX, halfSampleY; 251 SkFixed halfSampleX, halfSampleY;
232 if (cache->isSubpixel()) { 252 if (cache->isSubpixel()) {
233 halfSampleX = halfSampleY = (SK_FixedHalf >> SkGlyph::kSubBits); 253 halfSampleX = halfSampleY = (SK_FixedHalf >> SkGlyph::kSubBits);
234 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(fContext->getM atrix()); 254 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(fContext->getM atrix());
235 if (kX_SkAxisAlignment == baseline) { 255 if (kX_SkAxisAlignment == baseline) {
236 fyMask = 0; 256 fyMask = 0;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 SkASSERT(byteLength == 0 || text != NULL); 297 SkASSERT(byteLength == 0 || text != NULL);
278 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 298 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
279 299
280 // nothing to draw 300 // nothing to draw
281 if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) { 301 if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) {
282 return; 302 return;
283 } 303 }
284 304
285 this->init(paint, skPaint); 305 this->init(paint, skPaint);
286 306
307 if (NULL == fDrawTarget) {
308 return;
309 }
310
287 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); 311 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
288 312
289 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &fContext->getMa trix()); 313 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &fContext->getMa trix());
290 SkGlyphCache* cache = autoCache.getCache(); 314 SkGlyphCache* cache = autoCache.getCache();
291 GrFontScaler* fontScaler = GetGrFontScaler(cache); 315 GrFontScaler* fontScaler = GetGrFontScaler(cache);
316
317 if (NULL == fStrike) {
318 fStrike = fContext->getFontCache()->getStrike(fontScaler, false);
319 }
292 320
293 // store original matrix before we reset, so we can use it to transform posi tions 321 // store original matrix before we reset, so we can use it to transform posi tions
294 SkMatrix ctm = fContext->getMatrix(); 322 SkMatrix ctm = fContext->getMatrix();
295 GrContext::AutoMatrix autoMatrix; 323 GrContext::AutoMatrix autoMatrix;
296 autoMatrix.setIdentity(fContext, &fPaint); 324 autoMatrix.setIdentity(fContext, &fPaint);
297 325
326 // allocate vertices
327 SkASSERT(NULL == fVertices);
328 bool useColorVerts = kA8_GrMaskFormat == fStrike->getMaskFormat();
329 if (useColorVerts) {
330 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>(
331 SK_ARRAY_COUNT(gTextVertexWi thColorAttribs));
332 } else {
333 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
334 SK_ARRAY_COUNT(gTextVertexAt tribs));
335 }
336 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL);
337 bool success = fDrawTarget->reserveVertexAndIndexSpace(4*numGlyphs,
338 0,
339 &fVertices,
340 NULL);
341 GrAlwaysAssert(success);
342
298 const char* stop = text + byteLength; 343 const char* stop = text + byteLength;
299 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); 344 SkTextAlignProc alignProc(fSkPaint.getTextAlign());
300 SkTextMapStateProc tmsProc(ctm, constY, scalarsPerPosition); 345 SkTextMapStateProc tmsProc(ctm, constY, scalarsPerPosition);
301 SkFixed halfSampleX = 0, halfSampleY = 0; 346 SkFixed halfSampleX = 0, halfSampleY = 0;
302 347
303 if (cache->isSubpixel()) { 348 if (cache->isSubpixel()) {
304 // maybe we should skip the rounding if linearText is set 349 // maybe we should skip the rounding if linearText is set
305 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(ctm); 350 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(ctm);
306 351
307 SkFixed fxMask = ~0; 352 SkFixed fxMask = ~0;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 } 464 }
420 } 465 }
421 } 466 }
422 467
423 this->finish(); 468 this->finish();
424 } 469 }
425 470
426 void GrBitmapTextContext::drawPackedGlyph(GrGlyph::PackedID packed, 471 void GrBitmapTextContext::drawPackedGlyph(GrGlyph::PackedID packed,
427 SkFixed vx, SkFixed vy, 472 SkFixed vx, SkFixed vy,
428 GrFontScaler* scaler) { 473 GrFontScaler* scaler) {
429 if (NULL == fDrawTarget) {
430 return;
431 }
432
433 if (NULL == fStrike) {
434 fStrike = fContext->getFontCache()->getStrike(scaler, false);
435 }
436
437 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); 474 GrGlyph* glyph = fStrike->getGlyph(packed, scaler);
438 if (NULL == glyph || glyph->fBounds.isEmpty()) { 475 if (NULL == glyph || glyph->fBounds.isEmpty()) {
439 return; 476 return;
440 } 477 }
441 478
442 vx += SkIntToFixed(glyph->fBounds.fLeft); 479 vx += SkIntToFixed(glyph->fBounds.fLeft);
443 vy += SkIntToFixed(glyph->fBounds.fTop); 480 vy += SkIntToFixed(glyph->fBounds.fTop);
444 481
445 // keep them as ints until we've done the clip-test 482 // keep them as ints until we've done the clip-test
446 SkFixed width = glyph->fBounds.width(); 483 SkFixed width = glyph->fBounds.width();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); 546 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
510 glyph->fPlot->setDrawToken(drawToken); 547 glyph->fPlot->setDrawToken(drawToken);
511 548
512 // now promote them to fixed (TODO: Rethink using fixed pt). 549 // now promote them to fixed (TODO: Rethink using fixed pt).
513 width = SkIntToFixed(width); 550 width = SkIntToFixed(width);
514 height = SkIntToFixed(height); 551 height = SkIntToFixed(height);
515 552
516 GrTexture* texture = glyph->fPlot->texture(); 553 GrTexture* texture = glyph->fPlot->texture();
517 SkASSERT(texture); 554 SkASSERT(texture);
518 555
519 if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) {
520 this->flushGlyphs();
521 fCurrTexture = texture;
522 fCurrTexture->ref();
523 }
524
525 bool useColorVerts = kA8_GrMaskFormat == fStrike->getMaskFormat();
526
527 if (NULL == fVertices) {
528 // If we need to reserve vertices allow the draw target to suggest
529 // a number of verts to reserve and whether to perform a flush.
530 fMaxVertices = kMinRequestedVerts;
531 if (useColorVerts) {
532 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttri bs>(
533 SK_ARRAY_COUNT(gTextVertexWithColorAttribs));
534 } else {
535 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
536 SK_ARRAY_COUNT(gTextVertexAttribs));
537 }
538 bool flush = fDrawTarget->geometryHints(&fMaxVertices, NULL);
539 if (flush) {
540 this->flushGlyphs();
541 fContext->flush();
542 if (useColorVerts) {
543 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorA ttribs>(
544 SK_ARRAY_COUNT(gTextVertexWithColorAttribs));
545 } else {
546 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
547 SK_ARRAY_COUNT(gTextVertexAttribs));
548 }
549 }
550 fMaxVertices = kDefaultRequestedVerts;
551 // ignore return, no point in flushing again.
552 fDrawTarget->geometryHints(&fMaxVertices, NULL);
553
554 int maxQuadVertices = 4 * fContext->getQuadIndexBuffer()->maxQuads();
555 if (fMaxVertices < kMinRequestedVerts) {
556 fMaxVertices = kDefaultRequestedVerts;
557 } else if (fMaxVertices > maxQuadVertices) {
558 // don't exceed the limit of the index buffer
559 fMaxVertices = maxQuadVertices;
560 }
561 bool success = fDrawTarget->reserveVertexAndIndexSpace(fMaxVertices,
562 0,
563 &fVertices,
564 NULL);
565 GrAlwaysAssert(success);
566 }
567
568 SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); 556 SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX);
569 SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); 557 SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY);
570 558
571 SkRect r; 559 SkRect r;
572 r.fLeft = SkFixedToFloat(vx); 560 r.fLeft = SkFixedToFloat(vx);
573 r.fTop = SkFixedToFloat(vy); 561 r.fTop = SkFixedToFloat(vy);
574 r.fRight = SkFixedToFloat(vx + width); 562 r.fRight = SkFixedToFloat(vx + width);
575 r.fBottom = SkFixedToFloat(vy + height); 563 r.fBottom = SkFixedToFloat(vy + height);
576 564
577 fVertexBounds.growToInclude(r); 565 fVertexBounds.growToInclude(r);
578 566
567 bool useColorVerts = kA8_GrMaskFormat == fStrike->getMaskFormat();
579 size_t vertSize = useColorVerts ? (2 * sizeof(SkPoint) + sizeof(GrColor)) : 568 size_t vertSize = useColorVerts ? (2 * sizeof(SkPoint) + sizeof(GrColor)) :
580 (2 * sizeof(SkPoint)); 569 (2 * sizeof(SkPoint));
581 570
582 SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexSize()); 571 SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexSize());
583 572
584 SkPoint* positions = reinterpret_cast<SkPoint*>( 573 SkPoint* positions = reinterpret_cast<SkPoint*>(
585 reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex); 574 reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex);
586 positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize); 575 positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize);
587 576
588 // The texture coords are last in both the with and without color vertex lay outs. 577 // The texture coords are last in both the with and without color vertex lay outs.
589 SkPoint* textureCoords = reinterpret_cast<SkPoint*>( 578 SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
590 reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint)) ; 579 reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint)) ;
591 textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)), 580 textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)),
592 SkFixedToFloat(texture->normalizeFixedY(ty)), 581 SkFixedToFloat(texture->normalizeFixedY(ty)),
593 SkFixedToFloat(texture->normalizeFixedX(tx + width )), 582 SkFixedToFloat(texture->normalizeFixedX(tx + width )),
594 SkFixedToFloat(texture->normalizeFixedY(ty + heigh t)), 583 SkFixedToFloat(texture->normalizeFixedY(ty + heigh t)),
595 vertSize); 584 vertSize);
596 if (useColorVerts) { 585 if (useColorVerts) {
597 // color comes after position. 586 // color comes after position.
598 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); 587 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1);
599 for (int i = 0; i < 4; ++i) { 588 for (int i = 0; i < 4; ++i) {
600 *colors = fPaint.getColor(); 589 *colors = fPaint.getColor();
601 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors ) + vertSize); 590 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors ) + vertSize);
602 } 591 }
603 } 592 }
604 fCurrVertex += 4; 593 fCurrVertex += 4;
605 } 594 }
OLDNEW
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrDistanceFieldTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698