| OLD | NEW |
| 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 "GrDefaultGeoProcFactory.h" | 10 #include "GrDefaultGeoProcFactory.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); | 131 numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
| 132 } | 132 } |
| 133 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; | 133 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; |
| 134 | 134 |
| 135 const char* stop = text + byteLength; | 135 const char* stop = text + byteLength; |
| 136 | 136 |
| 137 SkAutoKern autokern; | 137 SkAutoKern autokern; |
| 138 | 138 |
| 139 SkFixed fxMask = ~0; | 139 SkFixed fxMask = ~0; |
| 140 SkFixed fyMask = ~0; | 140 SkFixed fyMask = ~0; |
| 141 SkFixed halfSampleX, halfSampleY; | 141 SkScalar halfSampleX, halfSampleY; |
| 142 if (cache->isSubpixel()) { | 142 if (cache->isSubpixel()) { |
| 143 halfSampleX = halfSampleY = SkGlyph::kSubpixelRound; | 143 halfSampleX = halfSampleY = SkFixedToScalar(SkGlyph::kSubpixelRound); |
| 144 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix); | 144 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix); |
| 145 if (kX_SkAxisAlignment == baseline) { | 145 if (kX_SkAxisAlignment == baseline) { |
| 146 fyMask = 0; | 146 fyMask = 0; |
| 147 halfSampleY = SK_FixedHalf; | 147 halfSampleY = SK_ScalarHalf; |
| 148 } else if (kY_SkAxisAlignment == baseline) { | 148 } else if (kY_SkAxisAlignment == baseline) { |
| 149 fxMask = 0; | 149 fxMask = 0; |
| 150 halfSampleX = SK_FixedHalf; | 150 halfSampleX = SK_ScalarHalf; |
| 151 } | 151 } |
| 152 } else { | 152 } else { |
| 153 halfSampleX = halfSampleY = SK_FixedHalf; | 153 halfSampleX = halfSampleY = SK_ScalarHalf; |
| 154 } | 154 } |
| 155 | 155 |
| 156 SkFixed fx = SkScalarToFixed(x) + halfSampleX; | 156 Sk48Dot16 fx = SkScalarTo48Dot16(x + halfSampleX); |
| 157 SkFixed fy = SkScalarToFixed(y) + halfSampleY; | 157 Sk48Dot16 fy = SkScalarTo48Dot16(y + halfSampleY); |
| 158 | 158 |
| 159 // if we have RGB, then we won't have any SkShaders so no need to use a loca
lmatrix, but for | 159 // if we have RGB, then we won't have any SkShaders so no need to use a loca
lmatrix, but for |
| 160 // performance reasons we just invert here instead | 160 // performance reasons we just invert here instead |
| 161 if (!viewMatrix.invert(&fLocalMatrix)) { | 161 if (!viewMatrix.invert(&fLocalMatrix)) { |
| 162 SkDebugf("Cannot invert viewmatrix\n"); | 162 SkDebugf("Cannot invert viewmatrix\n"); |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 | 165 |
| 166 while (text < stop) { | 166 while (text < stop) { |
| 167 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); | 167 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); |
| 168 | 168 |
| 169 fx += autokern.adjust(glyph); | 169 fx += autokern.adjust(glyph); |
| 170 | 170 |
| 171 if (glyph.fWidth) { | 171 if (glyph.fWidth) { |
| 172 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 172 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 173 glyph.getSubXFixed(), | 173 glyph.getSubXFixed(), |
| 174 glyph.getSubYFixed()), | 174 glyph.getSubYFixed()), |
| 175 SkFixedFloorToFixed(fx), | 175 Sk48Dot16FloorToInt(fx), |
| 176 SkFixedFloorToFixed(fy), | 176 Sk48Dot16FloorToInt(fy), |
| 177 fontScaler); | 177 fontScaler); |
| 178 } | 178 } |
| 179 | 179 |
| 180 fx += glyph.fAdvanceX; | 180 fx += glyph.fAdvanceX; |
| 181 fy += glyph.fAdvanceY; | 181 fy += glyph.fAdvanceY; |
| 182 } | 182 } |
| 183 | 183 |
| 184 this->finish(); | 184 this->finish(); |
| 185 } | 185 } |
| 186 | 186 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 212 SkDebugf("Cannot invert viewmatrix\n"); | 212 SkDebugf("Cannot invert viewmatrix\n"); |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 | 215 |
| 216 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); | 216 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
| 217 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; | 217 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; |
| 218 | 218 |
| 219 const char* stop = text + byteLength; | 219 const char* stop = text + byteLength; |
| 220 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); | 220 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); |
| 221 SkTextMapStateProc tmsProc(viewMatrix, offset, scalarsPerPosition); | 221 SkTextMapStateProc tmsProc(viewMatrix, offset, scalarsPerPosition); |
| 222 SkFixed halfSampleX = 0, halfSampleY = 0; | 222 SkScalar halfSampleX = 0, halfSampleY = 0; |
| 223 | 223 |
| 224 if (cache->isSubpixel()) { | 224 if (cache->isSubpixel()) { |
| 225 // maybe we should skip the rounding if linearText is set | 225 // maybe we should skip the rounding if linearText is set |
| 226 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix); | 226 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix); |
| 227 | 227 |
| 228 SkFixed fxMask = ~0; | 228 SkFixed fxMask = ~0; |
| 229 SkFixed fyMask = ~0; | 229 SkFixed fyMask = ~0; |
| 230 if (kX_SkAxisAlignment == baseline) { | 230 if (kX_SkAxisAlignment == baseline) { |
| 231 fyMask = 0; | 231 fyMask = 0; |
| 232 halfSampleY = SK_FixedHalf; | 232 halfSampleY = SK_ScalarHalf; |
| 233 } else if (kY_SkAxisAlignment == baseline) { | 233 } else if (kY_SkAxisAlignment == baseline) { |
| 234 fxMask = 0; | 234 fxMask = 0; |
| 235 halfSampleX = SK_FixedHalf; | 235 halfSampleX = SK_ScalarHalf; |
| 236 } | 236 } |
| 237 | 237 |
| 238 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { | 238 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { |
| 239 while (text < stop) { | 239 while (text < stop) { |
| 240 SkPoint tmsLoc; | 240 SkPoint tmsLoc; |
| 241 tmsProc(pos, &tmsLoc); | 241 tmsProc(pos, &tmsLoc); |
| 242 SkFixed fx = SkScalarToFixed(tmsLoc.fX) + halfSampleX; | 242 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + halfSampleX); |
| 243 SkFixed fy = SkScalarToFixed(tmsLoc.fY) + halfSampleY; | 243 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + halfSampleY); |
| 244 | 244 |
| 245 const SkGlyph& glyph = glyphCacheProc(cache, &text, | 245 const SkGlyph& glyph = glyphCacheProc(cache, &text, |
| 246 fx & fxMask, fy & fyMask); | 246 fx & fxMask, fy & fyMask); |
| 247 | 247 |
| 248 if (glyph.fWidth) { | 248 if (glyph.fWidth) { |
| 249 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 249 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 250 glyph.getSubXFixed(), | 250 glyph.getSubXFixed(), |
| 251 glyph.getSubYFixed()), | 251 glyph.getSubYFixed()), |
| 252 SkFixedFloorToFixed(fx), | 252 Sk48Dot16FloorToInt(fx), |
| 253 SkFixedFloorToFixed(fy), | 253 Sk48Dot16FloorToInt(fy), |
| 254 fontScaler); | 254 fontScaler); |
| 255 } | 255 } |
| 256 pos += scalarsPerPosition; | 256 pos += scalarsPerPosition; |
| 257 } | 257 } |
| 258 } else { | 258 } else { |
| 259 while (text < stop) { | 259 while (text < stop) { |
| 260 const char* currentText = text; | 260 const char* currentText = text; |
| 261 const SkGlyph& metricGlyph = glyphCacheProc(cache, &text, 0, 0); | 261 const SkGlyph& metricGlyph = glyphCacheProc(cache, &text, 0, 0); |
| 262 | 262 |
| 263 if (metricGlyph.fWidth) { | 263 if (metricGlyph.fWidth) { |
| 264 SkDEBUGCODE(SkFixed prevAdvX = metricGlyph.fAdvanceX;) | 264 SkDEBUGCODE(SkFixed prevAdvX = metricGlyph.fAdvanceX;) |
| 265 SkDEBUGCODE(SkFixed prevAdvY = metricGlyph.fAdvanceY;) | 265 SkDEBUGCODE(SkFixed prevAdvY = metricGlyph.fAdvanceY;) |
| 266 SkPoint tmsLoc; | 266 SkPoint tmsLoc; |
| 267 tmsProc(pos, &tmsLoc); | 267 tmsProc(pos, &tmsLoc); |
| 268 SkIPoint fixedLoc; | 268 SkPoint alignLoc; |
| 269 alignProc(tmsLoc, metricGlyph, &fixedLoc); | 269 alignProc(tmsLoc, metricGlyph, &alignLoc); |
| 270 | 270 |
| 271 SkFixed fx = fixedLoc.fX + halfSampleX; | 271 Sk48Dot16 fx = SkScalarTo48Dot16(alignLoc.fX + halfSampleX); |
| 272 SkFixed fy = fixedLoc.fY + halfSampleY; | 272 Sk48Dot16 fy = SkScalarTo48Dot16(alignLoc.fY + halfSampleY); |
| 273 | 273 |
| 274 // have to call again, now that we've been "aligned" | 274 // have to call again, now that we've been "aligned" |
| 275 const SkGlyph& glyph = glyphCacheProc(cache, ¤tText, | 275 const SkGlyph& glyph = glyphCacheProc(cache, ¤tText, |
| 276 fx & fxMask, fy & fyMa
sk); | 276 fx & fxMask, fy & fyMa
sk); |
| 277 // the assumption is that the metrics haven't changed | 277 // the assumption is that the metrics haven't changed |
| 278 SkASSERT(prevAdvX == glyph.fAdvanceX); | 278 SkASSERT(prevAdvX == glyph.fAdvanceX); |
| 279 SkASSERT(prevAdvY == glyph.fAdvanceY); | 279 SkASSERT(prevAdvY == glyph.fAdvanceY); |
| 280 SkASSERT(glyph.fWidth); | 280 SkASSERT(glyph.fWidth); |
| 281 | 281 |
| 282 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 282 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 283 glyph.getSubXFixed(), | 283 glyph.getSubXFixed(), |
| 284 glyph.getSubYFixed()), | 284 glyph.getSubYFixed()), |
| 285 SkFixedFloorToFixed(fx), | 285 Sk48Dot16FloorToInt(fx), |
| 286 SkFixedFloorToFixed(fy), | 286 Sk48Dot16FloorToInt(fy), |
| 287 fontScaler); | 287 fontScaler); |
| 288 } | 288 } |
| 289 pos += scalarsPerPosition; | 289 pos += scalarsPerPosition; |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 } else { // not subpixel | 292 } else { // not subpixel |
| 293 | 293 |
| 294 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { | 294 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { |
| 295 while (text < stop) { | 295 while (text < stop) { |
| 296 // the last 2 parameters are ignored | 296 // the last 2 parameters are ignored |
| 297 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 297 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 298 | 298 |
| 299 if (glyph.fWidth) { | 299 if (glyph.fWidth) { |
| 300 SkPoint tmsLoc; | 300 SkPoint tmsLoc; |
| 301 tmsProc(pos, &tmsLoc); | 301 tmsProc(pos, &tmsLoc); |
| 302 | 302 |
| 303 SkFixed fx = SkScalarToFixed(tmsLoc.fX) + SK_FixedHalf; //ha
lfSampleX; | 303 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + SK_ScalarHalf);
//halfSampleX; |
| 304 SkFixed fy = SkScalarToFixed(tmsLoc.fY) + SK_FixedHalf; //ha
lfSampleY; | 304 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + SK_ScalarHalf);
//halfSampleY; |
| 305 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 305 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 306 glyph.getSubXFixed(), | 306 glyph.getSubXFixed(), |
| 307 glyph.getSubYFixed()), | 307 glyph.getSubYFixed()), |
| 308 SkFixedFloorToFixed(fx), | 308 Sk48Dot16FloorToInt(fx), |
| 309 SkFixedFloorToFixed(fy), | 309 Sk48Dot16FloorToInt(fy), |
| 310 fontScaler); | 310 fontScaler); |
| 311 } | 311 } |
| 312 pos += scalarsPerPosition; | 312 pos += scalarsPerPosition; |
| 313 } | 313 } |
| 314 } else { | 314 } else { |
| 315 while (text < stop) { | 315 while (text < stop) { |
| 316 // the last 2 parameters are ignored | 316 // the last 2 parameters are ignored |
| 317 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 317 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 318 | 318 |
| 319 if (glyph.fWidth) { | 319 if (glyph.fWidth) { |
| 320 SkPoint tmsLoc; | 320 SkPoint tmsLoc; |
| 321 tmsProc(pos, &tmsLoc); | 321 tmsProc(pos, &tmsLoc); |
| 322 | 322 |
| 323 SkIPoint fixedLoc; | 323 SkPoint alignLoc; |
| 324 alignProc(tmsLoc, glyph, &fixedLoc); | 324 alignProc(tmsLoc, glyph, &alignLoc); |
| 325 | 325 |
| 326 SkFixed fx = fixedLoc.fX + SK_FixedHalf; //halfSampleX; | 326 Sk48Dot16 fx = SkScalarTo48Dot16(alignLoc.fX + SK_ScalarHalf
); //halfSampleX; |
| 327 SkFixed fy = fixedLoc.fY + SK_FixedHalf; //halfSampleY; | 327 Sk48Dot16 fy = SkScalarTo48Dot16(alignLoc.fY + SK_ScalarHalf
); //halfSampleY; |
| 328 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 328 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 329 glyph.getSubXFixed(), | 329 glyph.getSubXFixed(), |
| 330 glyph.getSubYFixed()), | 330 glyph.getSubYFixed()), |
| 331 SkFixedFloorToFixed(fx), | 331 Sk48Dot16FloorToInt(fx), |
| 332 SkFixedFloorToFixed(fy), | 332 Sk48Dot16FloorToInt(fy), |
| 333 fontScaler); | 333 fontScaler); |
| 334 } | 334 } |
| 335 pos += scalarsPerPosition; | 335 pos += scalarsPerPosition; |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 this->finish(); | 340 this->finish(); |
| 341 } | 341 } |
| 342 | 342 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 } | 398 } |
| 399 | 399 |
| 400 // we should never get here | 400 // we should never get here |
| 401 SkASSERT(false); | 401 SkASSERT(false); |
| 402 } | 402 } |
| 403 | 403 |
| 404 return false; | 404 return false; |
| 405 } | 405 } |
| 406 | 406 |
| 407 void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed, | 407 void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed, |
| 408 SkFixed vx, SkFixed vy, | 408 int vx, int vy, |
| 409 GrFontScaler* scaler) { | 409 GrFontScaler* scaler) { |
| 410 if (NULL == fDrawTarget) { | 410 if (NULL == fDrawTarget) { |
| 411 return; | 411 return; |
| 412 } | 412 } |
| 413 | 413 |
| 414 if (NULL == fStrike) { | 414 if (NULL == fStrike) { |
| 415 fStrike = fContext->getFontCache()->getStrike(scaler, false); | 415 fStrike = fContext->getFontCache()->getStrike(scaler, false); |
| 416 } | 416 } |
| 417 | 417 |
| 418 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); | 418 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); |
| 419 if (NULL == glyph || glyph->fBounds.isEmpty()) { | 419 if (NULL == glyph || glyph->fBounds.isEmpty()) { |
| 420 return; | 420 return; |
| 421 } | 421 } |
| 422 | 422 |
| 423 vx += SkIntToFixed(glyph->fBounds.fLeft); | 423 int x = vx + glyph->fBounds.fLeft; |
| 424 vy += SkIntToFixed(glyph->fBounds.fTop); | 424 int y = vy + glyph->fBounds.fTop; |
| 425 | 425 |
| 426 // keep them as ints until we've done the clip-test | 426 // keep them as ints until we've done the clip-test |
| 427 int width = glyph->fBounds.width(); | 427 int width = glyph->fBounds.width(); |
| 428 int height = glyph->fBounds.height(); | 428 int height = glyph->fBounds.height(); |
| 429 | 429 |
| 430 // check if we clipped out | 430 // check if we clipped out |
| 431 int x = vx >> 16; | |
| 432 int y = vy >> 16; | |
| 433 if (fClipRect.quickReject(x, y, x + width, y + height)) { | 431 if (fClipRect.quickReject(x, y, x + width, y + height)) { |
| 434 return; | 432 return; |
| 435 } | 433 } |
| 436 | 434 |
| 437 // If the glyph is too large we fall back to paths | 435 // If the glyph is too large we fall back to paths |
| 438 if (NULL == glyph->fPlot && !uploadGlyph(glyph, scaler)) { | 436 if (NULL == glyph->fPlot && !uploadGlyph(glyph, scaler)) { |
| 439 if (NULL == glyph->fPath) { | 437 if (NULL == glyph->fPath) { |
| 440 SkPath* path = SkNEW(SkPath); | 438 SkPath* path = SkNEW(SkPath); |
| 441 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { | 439 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
| 442 // flag the glyph as being dead? | 440 // flag the glyph as being dead? |
| 443 delete path; | 441 delete path; |
| 444 return; | 442 return; |
| 445 } | 443 } |
| 446 glyph->fPath = path; | 444 glyph->fPath = path; |
| 447 } | 445 } |
| 448 | 446 |
| 449 // flush any accumulated draws before drawing this glyph as a path. | 447 // flush any accumulated draws before drawing this glyph as a path. |
| 450 this->flush(); | 448 this->flush(); |
| 451 | 449 |
| 452 SkMatrix translate; | 450 SkMatrix translate; |
| 453 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds.
fLeft)), | 451 translate.setTranslate(SkIntToScalar(vx), SkIntToScalar(vy)); |
| 454 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds.
fTop))); | |
| 455 SkPath tmpPath(*glyph->fPath); | 452 SkPath tmpPath(*glyph->fPath); |
| 456 tmpPath.transform(translate); | 453 tmpPath.transform(translate); |
| 457 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); | 454 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); |
| 458 fContext->drawPath(fRenderTarget, fClip, fPaint, SkMatrix::I(), tmpPath,
strokeInfo); | 455 fContext->drawPath(fRenderTarget, fClip, fPaint, SkMatrix::I(), tmpPath,
strokeInfo); |
| 459 | 456 |
| 460 // remove this glyph from the vertices we need to allocate | 457 // remove this glyph from the vertices we need to allocate |
| 461 fTotalVertexCount -= kVerticesPerGlyph; | 458 fTotalVertexCount -= kVerticesPerGlyph; |
| 462 return; | 459 return; |
| 463 } | 460 } |
| 464 | 461 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 477 fCurrMaskFormat = glyph->fMaskFormat; | 474 fCurrMaskFormat = glyph->fMaskFormat; |
| 478 } | 475 } |
| 479 | 476 |
| 480 if (NULL == fVertices) { | 477 if (NULL == fVertices) { |
| 481 int maxQuadVertices = kVerticesPerGlyph * fContext->getQuadIndexBuffer()
->maxQuads(); | 478 int maxQuadVertices = kVerticesPerGlyph * fContext->getQuadIndexBuffer()
->maxQuads(); |
| 482 fAllocVertexCount = SkMin32(fTotalVertexCount, maxQuadVertices); | 479 fAllocVertexCount = SkMin32(fTotalVertexCount, maxQuadVertices); |
| 483 fVertices = alloc_vertices(fDrawTarget, fAllocVertexCount, fCurrMaskForm
at); | 480 fVertices = alloc_vertices(fDrawTarget, fAllocVertexCount, fCurrMaskForm
at); |
| 484 } | 481 } |
| 485 | 482 |
| 486 SkRect r; | 483 SkRect r; |
| 487 r.fLeft = SkFixedToFloat(vx); | 484 r.fLeft = SkIntToScalar(x); |
| 488 r.fTop = SkFixedToFloat(vy); | 485 r.fTop = SkIntToScalar(y); |
| 489 r.fRight = r.fLeft + width; | 486 r.fRight = r.fLeft + SkIntToScalar(width); |
| 490 r.fBottom = r.fTop + height; | 487 r.fBottom = r.fTop + SkIntToScalar(height); |
| 491 | 488 |
| 492 fVertexBounds.joinNonEmptyArg(r); | 489 fVertexBounds.joinNonEmptyArg(r); |
| 493 | 490 |
| 494 int u0 = glyph->fAtlasLocation.fX; | 491 int u0 = glyph->fAtlasLocation.fX; |
| 495 int v0 = glyph->fAtlasLocation.fY; | 492 int v0 = glyph->fAtlasLocation.fY; |
| 496 int u1 = u0 + width; | 493 int u1 = u0 + width; |
| 497 int v1 = v0 + height; | 494 int v1 = v0 + height; |
| 498 | 495 |
| 499 size_t vertSize = get_vertex_stride(fCurrMaskFormat); | 496 size_t vertSize = get_vertex_stride(fCurrMaskFormat); |
| 500 intptr_t vertex = reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVe
rtex; | 497 intptr_t vertex = reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVe
rtex; |
| 501 | 498 |
| 502 // V0 | 499 // V0 |
| 503 SkPoint* position = reinterpret_cast<SkPoint*>(vertex); | 500 SkPoint* position = reinterpret_cast<SkPoint*>(vertex); |
| 504 position->set(r.fLeft, r.fTop); | 501 position->set(r.fLeft, r.fTop); |
| 505 if (kA8_GrMaskFormat == fCurrMaskFormat) { | 502 if (kA8_GrMaskFormat == fCurrMaskFormat) { |
| 506 SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); | 503 SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); |
| 507 *color = fPaint.getColor(); | 504 *color = fPaint.getColor(); |
| 508 } | 505 } |
| 509 SkIPoint16* textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize
- | 506 SkIPoint16* textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize
- |
| 510 sizeof(SkIPoint16)
); | 507 sizeof(SkIPoint16)
); |
| 511 textureCoords->set(u0, v0); | 508 textureCoords->set(u0, v0); |
| 512 vertex += vertSize; | 509 vertex += vertSize; |
| 513 | 510 |
| 514 // V1 | 511 // V1 |
| 515 position = reinterpret_cast<SkPoint*>(vertex); | 512 position = reinterpret_cast<SkPoint*>(vertex); |
| 516 position->set(r.fLeft, r.fBottom); | 513 position->set(r.fLeft, r.fBottom); |
| 517 if (kA8_GrMaskFormat == fCurrMaskFormat) { | 514 if (kA8_GrMaskFormat == fCurrMaskFormat) { |
| 518 SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); | 515 SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); |
| 519 *color = fPaint.getColor(); | 516 *color = fPaint.getColor(); |
| 520 } | 517 } |
| 521 textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize - sizeof(Sk
IPoint16)); | 518 textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize - sizeof(Sk
IPoint16)); |
| 522 textureCoords->set(u0, v1); | 519 textureCoords->set(u0, v1); |
| 523 vertex += vertSize; | 520 vertex += vertSize; |
| 524 | 521 |
| 525 // V2 | 522 // V2 |
| 526 position = reinterpret_cast<SkPoint*>(vertex); | 523 position = reinterpret_cast<SkPoint*>(vertex); |
| 527 position->set(r.fRight, r.fBottom); | 524 position->set(r.fRight, r.fBottom); |
| 528 if (kA8_GrMaskFormat == fCurrMaskFormat) { | 525 if (kA8_GrMaskFormat == fCurrMaskFormat) { |
| 529 SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); | 526 SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); |
| 530 *color = fPaint.getColor(); | 527 *color = fPaint.getColor(); |
| 531 } | 528 } |
| 532 textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize - sizeof(Sk
IPoint16)); | 529 textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize - sizeof(Sk
IPoint16)); |
| 533 textureCoords->set(u1, v1); | 530 textureCoords->set(u1, v1); |
| 534 vertex += vertSize; | 531 vertex += vertSize; |
| 535 | 532 |
| 536 // V3 | 533 // V3 |
| 537 position = reinterpret_cast<SkPoint*>(vertex); | 534 position = reinterpret_cast<SkPoint*>(vertex); |
| 538 position->set(r.fRight, r.fTop); | 535 position->set(r.fRight, r.fTop); |
| 539 if (kA8_GrMaskFormat == fCurrMaskFormat) { | 536 if (kA8_GrMaskFormat == fCurrMaskFormat) { |
| 540 SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); | 537 SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); |
| 541 *color = fPaint.getColor(); | 538 *color = fPaint.getColor(); |
| 542 } | 539 } |
| 543 textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize - sizeof(Sk
IPoint16)); | 540 textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize - sizeof(Sk
IPoint16)); |
| 544 textureCoords->set(u1, v0); | 541 textureCoords->set(u1, v0); |
| 545 | 542 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 } | 620 } |
| 624 } | 621 } |
| 625 | 622 |
| 626 inline void GrBitmapTextContext::finish() { | 623 inline void GrBitmapTextContext::finish() { |
| 627 this->flush(); | 624 this->flush(); |
| 628 fTotalVertexCount = 0; | 625 fTotalVertexCount = 0; |
| 629 | 626 |
| 630 GrTextContext::finish(); | 627 GrTextContext::finish(); |
| 631 } | 628 } |
| 632 | 629 |
| OLD | NEW |