| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef GrAtlasTextBlob_DEFINED | 8 #ifndef GrAtlasTextBlob_DEFINED |
| 9 #define GrAtlasTextBlob_DEFINED | 9 #define GrAtlasTextBlob_DEFINED |
| 10 | 10 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 switch (maskFormat) { | 166 switch (maskFormat) { |
| 167 case kA8_GrMaskFormat: | 167 case kA8_GrMaskFormat: |
| 168 return kGrayTextVASize; | 168 return kGrayTextVASize; |
| 169 case kARGB_GrMaskFormat: | 169 case kARGB_GrMaskFormat: |
| 170 return kColorTextVASize; | 170 return kColorTextVASize; |
| 171 default: | 171 default: |
| 172 return kLCDTextVASize; | 172 return kLCDTextVASize; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool mustRegenerate(SkScalar* outTransX, SkScalar* outTransY, const SkPaint&
paint, | 176 bool mustRegenerate(const SkPaint& paint, GrColor color, const SkMaskFilter:
:BlurRec& blurRec, |
| 177 GrColor color, const SkMaskFilter::BlurRec& blurRec, | |
| 178 const SkMatrix& viewMatrix, SkScalar x, SkScalar y); | 177 const SkMatrix& viewMatrix, SkScalar x, SkScalar y); |
| 179 | 178 |
| 180 // flush a GrAtlasTextBlob associated with a SkTextBlob | 179 // flush a GrAtlasTextBlob associated with a SkTextBlob |
| 181 void flushCached(GrContext* context, | 180 void flushCached(GrContext* context, |
| 182 GrDrawContext* dc, | 181 GrDrawContext* dc, |
| 183 const SkTextBlob* blob, | 182 const SkTextBlob* blob, |
| 184 const SkSurfaceProps& props, | 183 const SkSurfaceProps& props, |
| 185 const GrDistanceFieldAdjustTable* distanceAdjustTable, | 184 const GrDistanceFieldAdjustTable* distanceAdjustTable, |
| 186 const SkPaint& skPaint, | 185 const SkPaint& skPaint, |
| 187 const GrPaint& grPaint, | 186 const GrPaint& grPaint, |
| 188 SkDrawFilter* drawFilter, | 187 SkDrawFilter* drawFilter, |
| 189 const GrClip& clip, | 188 const GrClip& clip, |
| 190 const SkMatrix& viewMatrix, | 189 const SkMatrix& viewMatrix, |
| 191 const SkIRect& clipBounds, | 190 const SkIRect& clipBounds, |
| 192 SkScalar x, SkScalar y, | 191 SkScalar x, SkScalar y); |
| 193 SkScalar transX, SkScalar transY); | |
| 194 | 192 |
| 195 // flush a throwaway GrAtlasTextBlob *not* associated with an SkTextBlob | 193 // flush a throwaway GrAtlasTextBlob *not* associated with an SkTextBlob |
| 196 void flushThrowaway(GrContext* context, | 194 void flushThrowaway(GrContext* context, |
| 197 GrDrawContext* dc, | 195 GrDrawContext* dc, |
| 198 const SkSurfaceProps& props, | 196 const SkSurfaceProps& props, |
| 199 const GrDistanceFieldAdjustTable* distanceAdjustTable, | 197 const GrDistanceFieldAdjustTable* distanceAdjustTable, |
| 200 const SkPaint& skPaint, | 198 const SkPaint& skPaint, |
| 201 const GrPaint& grPaint, | 199 const GrPaint& grPaint, |
| 202 const GrClip& clip, | 200 const GrClip& clip, |
| 203 const SkIRect& clipBounds); | 201 const SkMatrix& viewMatrix, |
| 202 const SkIRect& clipBounds, |
| 203 SkScalar x, SkScalar y); |
| 204 | 204 |
| 205 void computeSubRunBounds(SkRect* outBounds, int runIndex, int subRunIndex) { | 205 void computeSubRunBounds(SkRect* outBounds, int runIndex, int subRunIndex, |
| 206 const SkMatrix& viewMatrix, SkScalar x, SkScalar y)
{ |
| 206 // We don't yet position distance field text on the cpu, so we have to m
ap the vertex bounds | 207 // We don't yet position distance field text on the cpu, so we have to m
ap the vertex bounds |
| 207 // into device space. | 208 // into device space. |
| 208 // We handle vertex bounds differently for distance field text and bitma
p text because | 209 // We handle vertex bounds differently for distance field text and bitma
p text because |
| 209 // the vertex bounds of bitmap text are in device space. If we are flus
hing multiple runs | 210 // the vertex bounds of bitmap text are in device space. If we are flus
hing multiple runs |
| 210 // from one blob then we are going to pay the price here of mapping the
rect for each run. | 211 // from one blob then we are going to pay the price here of mapping the
rect for each run. |
| 211 const Run& run = fRuns[runIndex]; | 212 const Run& run = fRuns[runIndex]; |
| 212 const Run::SubRunInfo& subRun = run.fSubRunInfo[subRunIndex]; | 213 const Run::SubRunInfo& subRun = run.fSubRunInfo[subRunIndex]; |
| 213 *outBounds = subRun.vertexBounds(); | 214 *outBounds = subRun.vertexBounds(); |
| 214 if (subRun.drawAsDistanceFields()) { | 215 if (subRun.drawAsDistanceFields()) { |
| 215 // Distance field text is positioned with the (X,Y) as part of the g
lyph position, | 216 // Distance field text is positioned with the (X,Y) as part of the g
lyph position, |
| 216 // and currently the view matrix is applied on the GPU | 217 // and currently the view matrix is applied on the GPU |
| 217 outBounds->offset(fX - fInitialX, fY - fInitialY); | 218 outBounds->offset(x - fInitialX, y - fInitialY); |
| 218 fViewMatrix.mapRect(outBounds); | 219 viewMatrix.mapRect(outBounds); |
| 219 } else { | 220 } else { |
| 220 // Bitmap text is fully positioned on the CPU, and offset by an (X,Y
) translate in | 221 // Bitmap text is fully positioned on the CPU, and offset by an (X,Y
) translate in |
| 221 // device space. | 222 // device space. |
| 222 SkMatrix boundsMatrix = fInitialViewMatrixInverse; | 223 SkMatrix boundsMatrix = fInitialViewMatrixInverse; |
| 223 | 224 |
| 224 boundsMatrix.postTranslate(-fInitialX, -fInitialY); | 225 boundsMatrix.postTranslate(-fInitialX, -fInitialY); |
| 225 | 226 |
| 226 boundsMatrix.postTranslate(fX, fY); | 227 boundsMatrix.postTranslate(x, y); |
| 227 | 228 |
| 228 boundsMatrix.postConcat(fViewMatrix); | 229 boundsMatrix.postConcat(viewMatrix); |
| 229 boundsMatrix.mapRect(outBounds); | 230 boundsMatrix.mapRect(outBounds); |
| 230 | 231 |
| 231 // Due to floating point numerical inaccuracies, we have to round ou
t here | 232 // Due to floating point numerical inaccuracies, we have to round ou
t here |
| 232 outBounds->roundOut(outBounds); | 233 outBounds->roundOut(outBounds); |
| 233 } | 234 } |
| 234 } | 235 } |
| 235 | 236 |
| 236 const SkMatrix& viewMatrix() const { return fViewMatrix; } | |
| 237 | |
| 238 | |
| 239 // position + local coord | 237 // position + local coord |
| 240 static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16); | 238 static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16); |
| 241 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + si
zeof(SkIPoint16); | 239 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + si
zeof(SkIPoint16); |
| 242 static const size_t kLCDTextVASize = kGrayTextVASize; | 240 static const size_t kLCDTextVASize = kGrayTextVASize; |
| 243 static const size_t kMaxVASize = kGrayTextVASize; | 241 static const size_t kMaxVASize = kGrayTextVASize; |
| 244 static const int kVerticesPerGlyph = 4; | 242 static const int kVerticesPerGlyph = 4; |
| 245 | 243 |
| 246 static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&); | 244 static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&); |
| 247 | 245 |
| 248 // The color here is the GrPaint color, and it is used to determine whether
we | 246 // The color here is the GrPaint color, and it is used to determine whether
we |
| 249 // have to regenerate LCD text blobs. | 247 // have to regenerate LCD text blobs. |
| 250 // We use this color vs the SkPaint color because it has the colorfilter app
lied. | 248 // We use this color vs the SkPaint color because it has the colorfilter app
lied. |
| 251 void initReusableBlob(GrColor color, const SkMatrix& viewMatrix, SkScalar x,
SkScalar y) { | 249 void initReusableBlob(GrColor color, const SkMatrix& viewMatrix, SkScalar x,
SkScalar y) { |
| 252 fPaintColor = color; | 250 fPaintColor = color; |
| 253 this->setupViewMatrix(viewMatrix, x, y); | 251 this->setupViewMatrix(viewMatrix, x, y); |
| 254 } | 252 } |
| 255 | 253 |
| 256 void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { | 254 void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
| 257 this->setupViewMatrix(viewMatrix, x, y); | 255 this->setupViewMatrix(viewMatrix, x, y); |
| 258 } | 256 } |
| 259 | 257 |
| 260 void regenInBatch(GrDrawBatch::Target* target, GrBatchFontCache* fontCache, | 258 void regenInBatch(GrDrawBatch::Target* target, GrBatchFontCache* fontCache, |
| 261 GrBlobRegenHelper *helper, int run, int subRun, SkGlyphCac
he** cache, | 259 GrBlobRegenHelper *helper, int run, int subRun, SkGlyphCac
he** cache, |
| 262 SkTypeface** typeface, GrFontScaler** scaler, | 260 SkTypeface** typeface, GrFontScaler** scaler, |
| 263 const SkDescriptor** desc, size_t vertexStride, | 261 const SkDescriptor** desc, size_t vertexStride, |
| 264 GrColor color, SkScalar transX, SkScalar transY, | 262 const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
| 263 GrColor color, |
| 265 void** vertices, size_t* byteCount, int* glyphCount); | 264 void** vertices, size_t* byteCount, int* glyphCount); |
| 266 | 265 |
| 267 const Key& key() const { return fKey; } | 266 const Key& key() const { return fKey; } |
| 268 | 267 |
| 269 ~GrAtlasTextBlob() { | 268 ~GrAtlasTextBlob() { |
| 270 for (int i = 0; i < fRunCount; i++) { | 269 for (int i = 0; i < fRunCount; i++) { |
| 271 fRuns[i].~Run(); | 270 fRuns[i].~Run(); |
| 272 } | 271 } |
| 273 } | 272 } |
| 274 | 273 |
| 275 ////////////////////////////////////////////////////////////////////////////
//////////////////// | 274 ////////////////////////////////////////////////////////////////////////////
//////////////////// |
| 276 // Internal test methods | 275 // Internal test methods |
| 277 GrDrawBatch* test_createBatch(int glyphCount, int run, int subRun, | 276 GrDrawBatch* test_createBatch(int glyphCount, int run, int subRun, |
| 278 GrColor color, SkScalar transX, SkScalar trans
Y, | 277 const SkMatrix& viewMatrix, SkScalar x, SkScal
ar y, GrColor color, |
| 279 const SkPaint& skPaint, const SkSurfaceProps&
props, | 278 const SkPaint& skPaint, const SkSurfaceProps&
props, |
| 280 const GrDistanceFieldAdjustTable* distanceAdju
stTable, | 279 const GrDistanceFieldAdjustTable* distanceAdju
stTable, |
| 281 GrBatchFontCache* cache); | 280 GrBatchFontCache* cache); |
| 282 | 281 |
| 283 private: | 282 private: |
| 284 GrAtlasTextBlob() | 283 GrAtlasTextBlob() |
| 285 : fMaxMinScale(-SK_ScalarMax) | 284 : fMaxMinScale(-SK_ScalarMax) |
| 286 , fMinMaxScale(SK_ScalarMax) | 285 , fMinMaxScale(SK_ScalarMax) |
| 287 , fTextType(0) {} | 286 , fTextType(0) {} |
| 288 | 287 |
| 289 void appendLargeGlyph(GrGlyph* glyph, GrFontScaler* scaler, const SkGlyph& s
kGlyph, | 288 void appendLargeGlyph(GrGlyph* glyph, GrFontScaler* scaler, const SkGlyph& s
kGlyph, |
| 290 SkScalar x, SkScalar y, SkScalar scale, bool applyVM); | 289 SkScalar x, SkScalar y, SkScalar scale, bool applyVM); |
| 291 | 290 |
| 292 inline void flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBuilder, | 291 inline void flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBuilder, |
| 293 int run, GrColor color, | 292 int run, const SkMatrix& viewMatrix, SkScalar x, SkScal
ar y, GrColor color, |
| 294 SkScalar transX, SkScalar transY, | |
| 295 const SkPaint& skPaint, const SkSurfaceProps& props, | 293 const SkPaint& skPaint, const SkSurfaceProps& props, |
| 296 const GrDistanceFieldAdjustTable* distanceAdjustTable, | 294 const GrDistanceFieldAdjustTable* distanceAdjustTable, |
| 297 GrBatchFontCache* cache); | 295 GrBatchFontCache* cache); |
| 298 | 296 |
| 299 void flushBigGlyphs(GrContext* context, GrDrawContext* dc, | 297 void flushBigGlyphs(GrContext* context, GrDrawContext* dc, |
| 300 const GrClip& clip, const SkPaint& skPaint, | 298 const GrClip& clip, const SkPaint& skPaint, |
| 301 SkScalar transX, SkScalar transY, | 299 const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
| 302 const SkIRect& clipBounds); | 300 const SkIRect& clipBounds); |
| 303 | 301 |
| 304 void flushRunAsPaths(GrContext* context, | 302 void flushRunAsPaths(GrContext* context, |
| 305 GrDrawContext* dc, | 303 GrDrawContext* dc, |
| 306 const SkSurfaceProps& props, | 304 const SkSurfaceProps& props, |
| 307 const SkTextBlobRunIterator& it, | 305 const SkTextBlobRunIterator& it, |
| 308 const GrClip& clip, const SkPaint& skPaint, | 306 const GrClip& clip, const SkPaint& skPaint, |
| 309 SkDrawFilter* drawFilter, const SkMatrix& viewMatrix, | 307 SkDrawFilter* drawFilter, const SkMatrix& viewMatrix, |
| 310 const SkIRect& clipBounds, SkScalar x, SkScalar y); | 308 const SkIRect& clipBounds, SkScalar x, SkScalar y); |
| 311 | 309 |
| 312 // This function will only be called when we are regenerating a blob from sc
ratch. We record the | 310 // This function will only be called when we are generating a blob from scra
tch. We record the |
| 313 // initial view matrix and initial offsets(x,y), because we record vertex bo
unds relative to | 311 // initial view matrix and initial offsets(x,y), because we record vertex bo
unds relative to |
| 314 // these numbers. When blobs are reused with new matrices, we need to retur
n to model space so | 312 // these numbers. When blobs are reused with new matrices, we need to retur
n to model space so |
| 315 // we can update the vertex bounds appropriately. | 313 // we can update the vertex bounds appropriately. |
| 316 void setupViewMatrix(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { | 314 void setupViewMatrix(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
| 317 fViewMatrix = viewMatrix; | 315 fInitialViewMatrix = viewMatrix; |
| 318 if (!viewMatrix.invert(&fInitialViewMatrixInverse)) { | 316 if (!viewMatrix.invert(&fInitialViewMatrixInverse)) { |
| 319 fInitialViewMatrixInverse = SkMatrix::I(); | 317 fInitialViewMatrixInverse = SkMatrix::I(); |
| 320 SkDebugf("Could not invert viewmatrix\n"); | 318 SkDebugf("Could not invert viewmatrix\n"); |
| 321 } | 319 } |
| 322 fX = fInitialX = x; | 320 fInitialX = x; |
| 323 fY = fInitialY = y; | 321 fInitialY = y; |
| 322 |
| 323 // make sure all initial subruns have the correct VM and X/Y applied |
| 324 for (int i = 0; i < fRunCount; i++) { |
| 325 fRuns[i].fSubRunInfo[0].init(fInitialViewMatrix, x, y); |
| 326 } |
| 324 } | 327 } |
| 325 | 328 |
| 326 /* | 329 /* |
| 327 * Each Run inside of the blob can have its texture coordinates regenerated
if required. | 330 * Each Run inside of the blob can have its texture coordinates regenerated
if required. |
| 328 * To determine if regeneration is necessary, fAtlasGeneration is used. If
there have been | 331 * To determine if regeneration is necessary, fAtlasGeneration is used. If
there have been |
| 329 * any evictions inside of the atlas, then we will simply regenerate Runs.
We could track | 332 * any evictions inside of the atlas, then we will simply regenerate Runs.
We could track |
| 330 * this at a more fine grained level, but its not clear if this is worth it,
as evictions | 333 * this at a more fine grained level, but its not clear if this is worth it,
as evictions |
| 331 * should be fairly rare. | 334 * should be fairly rare. |
| 332 * | 335 * |
| 333 * One additional point, each run can contain glyphs with any of the three m
ask formats. | 336 * One additional point, each run can contain glyphs with any of the three m
ask formats. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 362 , fGlyphEndIndex(0) | 365 , fGlyphEndIndex(0) |
| 363 , fColor(GrColor_ILLEGAL) | 366 , fColor(GrColor_ILLEGAL) |
| 364 , fMaskFormat(kA8_GrMaskFormat) | 367 , fMaskFormat(kA8_GrMaskFormat) |
| 365 , fDrawAsDistanceFields(false) | 368 , fDrawAsDistanceFields(false) |
| 366 , fUseLCDText(false) { | 369 , fUseLCDText(false) { |
| 367 fVertexBounds.setLargestInverted(); | 370 fVertexBounds.setLargestInverted(); |
| 368 } | 371 } |
| 369 SubRunInfo(const SubRunInfo& that) | 372 SubRunInfo(const SubRunInfo& that) |
| 370 : fBulkUseToken(that.fBulkUseToken) | 373 : fBulkUseToken(that.fBulkUseToken) |
| 371 , fStrike(SkSafeRef(that.fStrike.get())) | 374 , fStrike(SkSafeRef(that.fStrike.get())) |
| 375 , fCurrentViewMatrix(that.fCurrentViewMatrix) |
| 372 , fVertexBounds(that.fVertexBounds) | 376 , fVertexBounds(that.fVertexBounds) |
| 373 , fAtlasGeneration(that.fAtlasGeneration) | 377 , fAtlasGeneration(that.fAtlasGeneration) |
| 374 , fVertexStartIndex(that.fVertexStartIndex) | 378 , fVertexStartIndex(that.fVertexStartIndex) |
| 375 , fVertexEndIndex(that.fVertexEndIndex) | 379 , fVertexEndIndex(that.fVertexEndIndex) |
| 376 , fGlyphStartIndex(that.fGlyphStartIndex) | 380 , fGlyphStartIndex(that.fGlyphStartIndex) |
| 377 , fGlyphEndIndex(that.fGlyphEndIndex) | 381 , fGlyphEndIndex(that.fGlyphEndIndex) |
| 382 , fX(that.fX) |
| 383 , fY(that.fY) |
| 378 , fColor(that.fColor) | 384 , fColor(that.fColor) |
| 379 , fMaskFormat(that.fMaskFormat) | 385 , fMaskFormat(that.fMaskFormat) |
| 380 , fDrawAsDistanceFields(that.fDrawAsDistanceFields) | 386 , fDrawAsDistanceFields(that.fDrawAsDistanceFields) |
| 381 , fUseLCDText(that.fUseLCDText) { | 387 , fUseLCDText(that.fUseLCDText) { |
| 382 } | 388 } |
| 383 | 389 |
| 384 // TODO when this object is more internal, drop the privacy | 390 // TODO when this object is more internal, drop the privacy |
| 385 void resetBulkUseToken() { fBulkUseToken.reset(); } | 391 void resetBulkUseToken() { fBulkUseToken.reset(); } |
| 386 GrBatchAtlas::BulkUseTokenUpdater* bulkUseToken() { return &fBulkUse
Token; } | 392 GrBatchAtlas::BulkUseTokenUpdater* bulkUseToken() { return &fBulkUse
Token; } |
| 387 void setStrike(GrBatchTextStrike* strike) { fStrike.reset(SkRef(stri
ke)); } | 393 void setStrike(GrBatchTextStrike* strike) { fStrike.reset(SkRef(stri
ke)); } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 405 GrColor color() const { return fColor; } | 411 GrColor color() const { return fColor; } |
| 406 void setMaskFormat(GrMaskFormat format) { fMaskFormat = format; } | 412 void setMaskFormat(GrMaskFormat format) { fMaskFormat = format; } |
| 407 GrMaskFormat maskFormat() const { return fMaskFormat; } | 413 GrMaskFormat maskFormat() const { return fMaskFormat; } |
| 408 | 414 |
| 409 void setAsSuccessor(const SubRunInfo& prev) { | 415 void setAsSuccessor(const SubRunInfo& prev) { |
| 410 fGlyphStartIndex = prev.glyphEndIndex(); | 416 fGlyphStartIndex = prev.glyphEndIndex(); |
| 411 fGlyphEndIndex = prev.glyphEndIndex(); | 417 fGlyphEndIndex = prev.glyphEndIndex(); |
| 412 | 418 |
| 413 fVertexStartIndex = prev.vertexEndIndex(); | 419 fVertexStartIndex = prev.vertexEndIndex(); |
| 414 fVertexEndIndex = prev.vertexEndIndex(); | 420 fVertexEndIndex = prev.vertexEndIndex(); |
| 421 |
| 422 // copy over viewmatrix settings |
| 423 this->init(prev.fCurrentViewMatrix, prev.fX, prev.fY); |
| 415 } | 424 } |
| 416 | 425 |
| 417 const SkRect& vertexBounds() const { return fVertexBounds; } | 426 const SkRect& vertexBounds() const { return fVertexBounds; } |
| 418 void joinGlyphBounds(const SkRect& glyphBounds) { | 427 void joinGlyphBounds(const SkRect& glyphBounds) { |
| 419 fVertexBounds.joinNonEmptyArg(glyphBounds); | 428 fVertexBounds.joinNonEmptyArg(glyphBounds); |
| 420 } | 429 } |
| 421 | 430 |
| 431 void init(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
| 432 fCurrentViewMatrix = viewMatrix; |
| 433 fX = x; |
| 434 fY = y; |
| 435 } |
| 436 |
| 437 // This function assumes the translation will be applied before it i
s called again |
| 438 void computeTranslation(const SkMatrix& viewMatrix, SkScalar x, SkSc
alar y, |
| 439 SkScalar*transX, SkScalar* transY); |
| 440 |
| 422 // df properties | 441 // df properties |
| 423 void setUseLCDText(bool useLCDText) { fUseLCDText = useLCDText; } | 442 void setUseLCDText(bool useLCDText) { fUseLCDText = useLCDText; } |
| 424 bool hasUseLCDText() const { return fUseLCDText; } | 443 bool hasUseLCDText() const { return fUseLCDText; } |
| 425 void setDrawAsDistanceFields() { fDrawAsDistanceFields = true; } | 444 void setDrawAsDistanceFields() { fDrawAsDistanceFields = true; } |
| 426 bool drawAsDistanceFields() const { return fDrawAsDistanceFields; } | 445 bool drawAsDistanceFields() const { return fDrawAsDistanceFields; } |
| 427 | 446 |
| 428 private: | 447 private: |
| 429 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; | 448 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; |
| 430 SkAutoTUnref<GrBatchTextStrike> fStrike; | 449 SkAutoTUnref<GrBatchTextStrike> fStrike; |
| 450 SkMatrix fCurrentViewMatrix; |
| 431 SkRect fVertexBounds; | 451 SkRect fVertexBounds; |
| 432 uint64_t fAtlasGeneration; | 452 uint64_t fAtlasGeneration; |
| 433 size_t fVertexStartIndex; | 453 size_t fVertexStartIndex; |
| 434 size_t fVertexEndIndex; | 454 size_t fVertexEndIndex; |
| 435 uint32_t fGlyphStartIndex; | 455 uint32_t fGlyphStartIndex; |
| 436 uint32_t fGlyphEndIndex; | 456 uint32_t fGlyphEndIndex; |
| 457 SkScalar fX; |
| 458 SkScalar fY; |
| 437 GrColor fColor; | 459 GrColor fColor; |
| 438 GrMaskFormat fMaskFormat; | 460 GrMaskFormat fMaskFormat; |
| 439 bool fDrawAsDistanceFields; // df property | 461 bool fDrawAsDistanceFields; // df property |
| 440 bool fUseLCDText; // df property | 462 bool fUseLCDText; // df property |
| 441 }; | 463 }; |
| 442 | 464 |
| 443 SubRunInfo& push_back() { | 465 SubRunInfo& push_back() { |
| 444 // Forward glyph / vertex information to seed the new sub run | 466 // Forward glyph / vertex information to seed the new sub run |
| 445 SubRunInfo& newSubRun = fSubRunInfo.push_back(); | 467 SubRunInfo& newSubRun = fSubRunInfo.push_back(); |
| 446 const SubRunInfo& prevSubRun = fSubRunInfo.fromBack(1); | 468 const SubRunInfo& prevSubRun = fSubRunInfo.fromBack(1); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 468 GrBlobRegenHelper* helper, | 490 GrBlobRegenHelper* helper, |
| 469 Run* run, Run::SubRunInfo* info, SkGlyphCache** cache, | 491 Run* run, Run::SubRunInfo* info, SkGlyphCache** cache, |
| 470 SkTypeface** typeface, GrFontScaler** scaler, | 492 SkTypeface** typeface, GrFontScaler** scaler, |
| 471 const SkDescriptor** desc, | 493 const SkDescriptor** desc, |
| 472 int glyphCount, size_t vertexStride, | 494 int glyphCount, size_t vertexStride, |
| 473 GrColor color, SkScalar transX, | 495 GrColor color, SkScalar transX, |
| 474 SkScalar transY) const; | 496 SkScalar transY) const; |
| 475 | 497 |
| 476 inline GrDrawBatch* createBatch(const Run::SubRunInfo& info, | 498 inline GrDrawBatch* createBatch(const Run::SubRunInfo& info, |
| 477 int glyphCount, int run, int subRun, | 499 int glyphCount, int run, int subRun, |
| 478 GrColor color, SkScalar transX, SkScalar tra
nsY, | 500 const SkMatrix& viewMatrix, SkScalar x, SkSc
alar y, |
| 501 GrColor color, |
| 479 const SkPaint& skPaint, const SkSurfaceProps
& props, | 502 const SkPaint& skPaint, const SkSurfaceProps
& props, |
| 480 const GrDistanceFieldAdjustTable* distanceAd
justTable, | 503 const GrDistanceFieldAdjustTable* distanceAd
justTable, |
| 481 GrBatchFontCache* cache); | 504 GrBatchFontCache* cache); |
| 482 | 505 |
| 483 struct BigGlyph { | 506 struct BigGlyph { |
| 484 BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy, SkScalar scale, b
ool applyVM) | 507 BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy, SkScalar scale, b
ool applyVM) |
| 485 : fPath(path) | 508 : fPath(path) |
| 486 , fVx(vx) | |
| 487 , fVy(vy) | |
| 488 , fScale(scale) | 509 , fScale(scale) |
| 510 , fX(vx) |
| 511 , fY(vy) |
| 489 , fApplyVM(applyVM) {} | 512 , fApplyVM(applyVM) {} |
| 490 SkPath fPath; | 513 SkPath fPath; |
| 491 SkScalar fVx; | |
| 492 SkScalar fVy; | |
| 493 SkScalar fScale; | 514 SkScalar fScale; |
| 515 SkScalar fX; |
| 516 SkScalar fY; |
| 494 bool fApplyVM; | 517 bool fApplyVM; |
| 495 }; | 518 }; |
| 496 | 519 |
| 497 struct StrokeInfo { | 520 struct StrokeInfo { |
| 498 SkScalar fFrameWidth; | 521 SkScalar fFrameWidth; |
| 499 SkScalar fMiterLimit; | 522 SkScalar fMiterLimit; |
| 500 SkPaint::Join fJoin; | 523 SkPaint::Join fJoin; |
| 501 }; | 524 }; |
| 502 | 525 |
| 503 enum TextType { | 526 enum TextType { |
| 504 kHasDistanceField_TextType = 0x1, | 527 kHasDistanceField_TextType = 0x1, |
| 505 kHasBitmap_TextType = 0x2, | 528 kHasBitmap_TextType = 0x2, |
| 506 }; | 529 }; |
| 507 | 530 |
| 508 // all glyph / vertex offsets are into these pools. | 531 // all glyph / vertex offsets are into these pools. |
| 509 unsigned char* fVertices; | 532 unsigned char* fVertices; |
| 510 GrGlyph** fGlyphs; | 533 GrGlyph** fGlyphs; |
| 511 Run* fRuns; | 534 Run* fRuns; |
| 512 GrMemoryPool* fPool; | 535 GrMemoryPool* fPool; |
| 513 SkMaskFilter::BlurRec fBlurRec; | 536 SkMaskFilter::BlurRec fBlurRec; |
| 514 StrokeInfo fStrokeInfo; | 537 StrokeInfo fStrokeInfo; |
| 515 SkTArray<BigGlyph> fBigGlyphs; | 538 SkTArray<BigGlyph> fBigGlyphs; |
| 516 Key fKey; | 539 Key fKey; |
| 517 SkMatrix fViewMatrix; | 540 SkMatrix fInitialViewMatrix; |
| 518 SkMatrix fInitialViewMatrixInverse; | 541 SkMatrix fInitialViewMatrixInverse; |
| 519 size_t fSize; | 542 size_t fSize; |
| 520 GrColor fPaintColor; | 543 GrColor fPaintColor; |
| 521 SkScalar fInitialX; | 544 SkScalar fInitialX; |
| 522 SkScalar fInitialY; | 545 SkScalar fInitialY; |
| 523 SkScalar fX; | |
| 524 SkScalar fY; | |
| 525 | 546 |
| 526 // We can reuse distance field text, but only if the new viewmatrix would no
t result in | 547 // We can reuse distance field text, but only if the new viewmatrix would no
t result in |
| 527 // a mip change. Because there can be multiple runs in a blob, we track the
overall | 548 // a mip change. Because there can be multiple runs in a blob, we track the
overall |
| 528 // maximum minimum scale, and minimum maximum scale, we can support before w
e need to regen | 549 // maximum minimum scale, and minimum maximum scale, we can support before w
e need to regen |
| 529 SkScalar fMaxMinScale; | 550 SkScalar fMaxMinScale; |
| 530 SkScalar fMinMaxScale; | 551 SkScalar fMinMaxScale; |
| 531 int fRunCount; | 552 int fRunCount; |
| 532 uint8_t fTextType; | 553 uint8_t fTextType; |
| 533 }; | 554 }; |
| 534 | 555 |
| 535 #endif | 556 #endif |
| OLD | NEW |