| 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 #include "GrAtlasTextContext.h" | 7 #include "GrAtlasTextContext.h" | 
| 8 | 8 | 
| 9 #include "GrBatch.h" | 9 #include "GrBatch.h" | 
| 10 #include "GrBatchFontCache.h" | 10 #include "GrBatchFontCache.h" | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 90     return GrColorPackRGBA(r, g, b, 0xff); | 90     return GrColorPackRGBA(r, g, b, 0xff); | 
| 91 } | 91 } | 
| 92 | 92 | 
| 93 }; | 93 }; | 
| 94 | 94 | 
| 95 // TODO | 95 // TODO | 
| 96 // Distance field text in textblobs | 96 // Distance field text in textblobs | 
| 97 | 97 | 
| 98 GrAtlasTextContext::GrAtlasTextContext(GrContext* context, | 98 GrAtlasTextContext::GrAtlasTextContext(GrContext* context, | 
| 99                                        GrDrawContext* drawContext, | 99                                        GrDrawContext* drawContext, | 
| 100                                        const SkDeviceProperties& properties) | 100                                        const SkSurfaceProps& surfaceProps) | 
| 101     : INHERITED(context, drawContext, properties) | 101     : INHERITED(context, drawContext, surfaceProps) | 
| 102     , fDistanceAdjustTable(SkNEW(DistanceAdjustTable)) { | 102     , fDistanceAdjustTable(SkNEW(DistanceAdjustTable)) { | 
| 103     // We overallocate vertices in our textblobs based on the assumption that A8
       has the greatest | 103     // We overallocate vertices in our textblobs based on the assumption that A8
       has the greatest | 
| 104     // vertexStride | 104     // vertexStride | 
| 105     SK_COMPILE_ASSERT(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >= 
      kLCDTextVASize, | 105     SK_COMPILE_ASSERT(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >= 
      kLCDTextVASize, | 
| 106                       vertex_attribute_changed); | 106                       vertex_attribute_changed); | 
| 107     fCurrStrike = NULL; | 107     fCurrStrike = NULL; | 
| 108     fCache = context->getTextBlobCache(); | 108     fCache = context->getTextBlobCache(); | 
| 109 } | 109 } | 
| 110 | 110 | 
| 111 void GrAtlasTextContext::DistanceAdjustTable::buildDistanceAdjustTable() { | 111 void GrAtlasTextContext::DistanceAdjustTable::buildDistanceAdjustTable() { | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 185 | 185 | 
| 186                 fTable[row] = d; | 186                 fTable[row] = d; | 
| 187                 break; | 187                 break; | 
| 188             } | 188             } | 
| 189         } | 189         } | 
| 190     } | 190     } | 
| 191 } | 191 } | 
| 192 | 192 | 
| 193 GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context, | 193 GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context, | 
| 194                                                GrDrawContext* drawContext, | 194                                                GrDrawContext* drawContext, | 
| 195                                                const SkDeviceProperties& props) 
      { | 195                                                const SkSurfaceProps& surfaceProp
      s) { | 
| 196     return SkNEW_ARGS(GrAtlasTextContext, (context, drawContext, props)); | 196     return SkNEW_ARGS(GrAtlasTextContext, (context, drawContext, surfaceProps)); | 
| 197 } | 197 } | 
| 198 | 198 | 
| 199 bool GrAtlasTextContext::canDraw(const GrRenderTarget*, | 199 bool GrAtlasTextContext::canDraw(const GrRenderTarget*, | 
| 200                                  const GrClip&, | 200                                  const GrClip&, | 
| 201                                  const GrPaint&, | 201                                  const GrPaint&, | 
| 202                                  const SkPaint& skPaint, | 202                                  const SkPaint& skPaint, | 
| 203                                  const SkMatrix& viewMatrix) { | 203                                  const SkMatrix& viewMatrix) { | 
| 204     return this->canDrawAsDistanceFields(skPaint, viewMatrix) || | 204     return this->canDrawAsDistanceFields(skPaint, viewMatrix) || | 
| 205            !SkDraw::ShouldDrawTextAsPaths(skPaint, viewMatrix); | 205            !SkDraw::ShouldDrawTextAsPaths(skPaint, viewMatrix); | 
| 206 } | 206 } | 
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 327     // the blob anyways at flush time, so no need to regenerate explicitly | 327     // the blob anyways at flush time, so no need to regenerate explicitly | 
| 328 | 328 | 
| 329     return false; | 329     return false; | 
| 330 } | 330 } | 
| 331 | 331 | 
| 332 | 332 | 
| 333 inline SkGlyphCache* GrAtlasTextContext::setupCache(BitmapTextBlob::Run* run, | 333 inline SkGlyphCache* GrAtlasTextContext::setupCache(BitmapTextBlob::Run* run, | 
| 334                                                     const SkPaint& skPaint, | 334                                                     const SkPaint& skPaint, | 
| 335                                                     const SkMatrix* viewMatrix, | 335                                                     const SkMatrix* viewMatrix, | 
| 336                                                     bool noGamma) { | 336                                                     bool noGamma) { | 
| 337     skPaint.getScalerContextDescriptor(&run->fDescriptor, &fDeviceProperties, vi
      ewMatrix, noGamma); | 337     skPaint.getScalerContextDescriptor(&run->fDescriptor, fSurfaceProps, viewMat
      rix, noGamma); | 
| 338     run->fTypeface.reset(SkSafeRef(skPaint.getTypeface())); | 338     run->fTypeface.reset(SkSafeRef(skPaint.getTypeface())); | 
| 339     return SkGlyphCache::DetachCache(run->fTypeface, run->fDescriptor.getDesc())
      ; | 339     return SkGlyphCache::DetachCache(run->fTypeface, run->fDescriptor.getDesc())
      ; | 
| 340 } | 340 } | 
| 341 | 341 | 
| 342 void GrAtlasTextContext::drawTextBlob(GrRenderTarget* rt, | 342 void GrAtlasTextContext::drawTextBlob(GrRenderTarget* rt, | 
| 343                                       const GrClip& clip, const SkPaint& skPaint
      , | 343                                       const GrClip& clip, const SkPaint& skPaint
      , | 
| 344                                       const SkMatrix& viewMatrix, const SkTextBl
      ob* blob, | 344                                       const SkMatrix& viewMatrix, const SkTextBl
      ob* blob, | 
| 345                                       SkScalar x, SkScalar y, | 345                                       SkScalar x, SkScalar y, | 
| 346                                       SkDrawFilter* drawFilter, const SkIRect& c
      lipBounds) { | 346                                       SkDrawFilter* drawFilter, const SkIRect& c
      lipBounds) { | 
| 347     // If we have been abandoned, then don't draw | 347     // If we have been abandoned, then don't draw | 
| 348     if (fContext->abandoned()) { | 348     if (fContext->abandoned()) { | 
| 349         return; | 349         return; | 
| 350     } | 350     } | 
| 351 | 351 | 
| 352     SkAutoTUnref<BitmapTextBlob> cacheBlob; | 352     SkAutoTUnref<BitmapTextBlob> cacheBlob; | 
| 353     SkMaskFilter::BlurRec blurRec; | 353     SkMaskFilter::BlurRec blurRec; | 
| 354     BitmapTextBlob::Key key; | 354     BitmapTextBlob::Key key; | 
| 355     // It might be worth caching these things, but its not clear at this time | 355     // It might be worth caching these things, but its not clear at this time | 
| 356     // TODO for animated mask filters, this will fill up our cache.  We need a s
      afeguard here | 356     // TODO for animated mask filters, this will fill up our cache.  We need a s
      afeguard here | 
| 357     const SkMaskFilter* mf = skPaint.getMaskFilter(); | 357     const SkMaskFilter* mf = skPaint.getMaskFilter(); | 
| 358     bool canCache = !(skPaint.getPathEffect() || | 358     bool canCache = !(skPaint.getPathEffect() || | 
| 359                       (mf && !mf->asABlur(&blurRec)) || | 359                       (mf && !mf->asABlur(&blurRec)) || | 
| 360                       drawFilter); | 360                       drawFilter); | 
| 361 | 361 | 
| 362     if (canCache) { | 362     if (canCache) { | 
| 363         bool hasLCD = HasLCD(blob); | 363         bool hasLCD = HasLCD(blob); | 
| 364 | 364 | 
| 365         // We canonicalize all non-lcd draws to use kUnknown_SkPixelGeometry | 365         // We canonicalize all non-lcd draws to use kUnknown_SkPixelGeometry | 
| 366         SkPixelGeometry pixelGeometry = hasLCD ? fDeviceProperties.pixelGeometry
      () : | 366         SkPixelGeometry pixelGeometry = hasLCD ? fSurfaceProps.pixelGeometry() : | 
| 367                                                  kUnknown_SkPixelGeometry; | 367                                                  kUnknown_SkPixelGeometry; | 
| 368 | 368 | 
| 369         // TODO we want to figure out a way to be able to use the canonical colo
      r on LCD text, | 369         // TODO we want to figure out a way to be able to use the canonical colo
      r on LCD text, | 
| 370         // see the note on ComputeCanonicalColor above.  We pick a dummy value f
      or LCD text to | 370         // see the note on ComputeCanonicalColor above.  We pick a dummy value f
      or LCD text to | 
| 371         // ensure we always match the same key | 371         // ensure we always match the same key | 
| 372         GrColor canonicalColor = hasLCD ? SK_ColorTRANSPARENT : | 372         GrColor canonicalColor = hasLCD ? SK_ColorTRANSPARENT : | 
| 373                                           ComputeCanonicalColor(skPaint, hasLCD)
      ; | 373                                           ComputeCanonicalColor(skPaint, hasLCD)
      ; | 
| 374 | 374 | 
| 375         key.fPixelGeometry = pixelGeometry; | 375         key.fPixelGeometry = pixelGeometry; | 
| 376         key.fUniqueID = blob->uniqueID(); | 376         key.fUniqueID = blob->uniqueID(); | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 435     } | 435     } | 
| 436 | 436 | 
| 437     SkScalar maxScale = viewMatrix.getMaxScale(); | 437     SkScalar maxScale = viewMatrix.getMaxScale(); | 
| 438     SkScalar scaledTextSize = maxScale*skPaint.getTextSize(); | 438     SkScalar scaledTextSize = maxScale*skPaint.getTextSize(); | 
| 439     // Hinted text looks far better at small resolutions | 439     // Hinted text looks far better at small resolutions | 
| 440     // Scaling up beyond 2x yields undesireable artifacts | 440     // Scaling up beyond 2x yields undesireable artifacts | 
| 441     if (scaledTextSize < kMinDFFontSize || scaledTextSize > kLargeDFFontLimit) { | 441     if (scaledTextSize < kMinDFFontSize || scaledTextSize > kLargeDFFontLimit) { | 
| 442         return false; | 442         return false; | 
| 443     } | 443     } | 
| 444 | 444 | 
| 445     bool useDFT = fDeviceProperties.useDFT(); | 445     bool useDFT = fSurfaceProps.isUseDistanceFieldFonts(); | 
| 446 #if SK_FORCE_DISTANCE_FIELD_TEXT | 446 #if SK_FORCE_DISTANCE_FIELD_TEXT | 
| 447     useDFT = true; | 447     useDFT = true; | 
| 448 #endif | 448 #endif | 
| 449 | 449 | 
| 450     if (!useDFT && !skPaint.isDistanceFieldTextTEMP() && scaledTextSize < kLarge
      DFFontSize) { | 450     if (!useDFT && !skPaint.isDistanceFieldTextTEMP() && scaledTextSize < kLarge
      DFFontSize) { | 
| 451         return false; | 451         return false; | 
| 452     } | 452     } | 
| 453 | 453 | 
| 454     // rasterizers and mask filters modify alpha, which doesn't | 454     // rasterizers and mask filters modify alpha, which doesn't | 
| 455     // translate well to distance | 455     // translate well to distance | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 487         // applyFontToPaint() always overwrites the exact same attributes, | 487         // applyFontToPaint() always overwrites the exact same attributes, | 
| 488         // so it is safe to not re-seed the paint for this reason. | 488         // so it is safe to not re-seed the paint for this reason. | 
| 489         it.applyFontToPaint(&runPaint); | 489         it.applyFontToPaint(&runPaint); | 
| 490 | 490 | 
| 491         if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Typ
      e)) { | 491         if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Typ
      e)) { | 
| 492             // A false return from filter() means we should abort the current dr
      aw. | 492             // A false return from filter() means we should abort the current dr
      aw. | 
| 493             runPaint = skPaint; | 493             runPaint = skPaint; | 
| 494             continue; | 494             continue; | 
| 495         } | 495         } | 
| 496 | 496 | 
| 497         runPaint.setFlags(FilterTextFlags(fDeviceProperties, runPaint)); | 497         runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint)); | 
| 498 | 498 | 
| 499         // setup vertex / glyphIndex for the new run | 499         // setup vertex / glyphIndex for the new run | 
| 500         if (run > 0) { | 500         if (run > 0) { | 
| 501             PerSubRunInfo& newRun = cacheBlob->fRuns[run].fSubRunInfo.back(); | 501             PerSubRunInfo& newRun = cacheBlob->fRuns[run].fSubRunInfo.back(); | 
| 502             PerSubRunInfo& lastRun = cacheBlob->fRuns[run - 1].fSubRunInfo.back(
      ); | 502             PerSubRunInfo& lastRun = cacheBlob->fRuns[run - 1].fSubRunInfo.back(
      ); | 
| 503 | 503 | 
| 504             newRun.fVertexStartIndex = lastRun.fVertexEndIndex; | 504             newRun.fVertexStartIndex = lastRun.fVertexEndIndex; | 
| 505             newRun.fVertexEndIndex = lastRun.fVertexEndIndex; | 505             newRun.fVertexEndIndex = lastRun.fVertexEndIndex; | 
| 506 | 506 | 
| 507             newRun.fGlyphStartIndex = lastRun.fGlyphEndIndex; | 507             newRun.fGlyphStartIndex = lastRun.fGlyphEndIndex; | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 655                                                     int scalarsPerPosition, | 655                                                     int scalarsPerPosition, | 
| 656                                                     const SkPoint& offset, | 656                                                     const SkPoint& offset, | 
| 657                                                     const SkIRect& clipRect) { | 657                                                     const SkIRect& clipRect) { | 
| 658     SkASSERT(fallbackTxt.count()); | 658     SkASSERT(fallbackTxt.count()); | 
| 659     blob->setHasBitmap(); | 659     blob->setHasBitmap(); | 
| 660     Run& run = blob->fRuns[runIndex]; | 660     Run& run = blob->fRuns[runIndex]; | 
| 661     // Push back a new subrun to fill and set the override descriptor | 661     // Push back a new subrun to fill and set the override descriptor | 
| 662     run.push_back(); | 662     run.push_back(); | 
| 663     run.fOverrideDescriptor.reset(SkNEW(SkAutoDescriptor)); | 663     run.fOverrideDescriptor.reset(SkNEW(SkAutoDescriptor)); | 
| 664     skPaint.getScalerContextDescriptor(run.fOverrideDescriptor, | 664     skPaint.getScalerContextDescriptor(run.fOverrideDescriptor, | 
| 665                                        &fDeviceProperties, &viewMatrix, false); | 665                                        fSurfaceProps, &viewMatrix, false); | 
| 666     SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface, | 666     SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface, | 
| 667                                                     run.fOverrideDescriptor->get
      Desc()); | 667                                                     run.fOverrideDescriptor->get
      Desc()); | 
| 668     this->internalDrawBMPPosText(blob, runIndex, cache, skPaint, paint.getColor(
      ), viewMatrix, | 668     this->internalDrawBMPPosText(blob, runIndex, cache, skPaint, paint.getColor(
      ), viewMatrix, | 
| 669                                  fallbackTxt.begin(), fallbackTxt.count(), | 669                                  fallbackTxt.begin(), fallbackTxt.count(), | 
| 670                                  fallbackPos.begin(), scalarsPerPosition, offset
      , clipRect); | 670                                  fallbackPos.begin(), scalarsPerPosition, offset
      , clipRect); | 
| 671     SkGlyphCache::AttachCache(cache); | 671     SkGlyphCache::AttachCache(cache); | 
| 672 } | 672 } | 
| 673 | 673 | 
| 674 inline GrAtlasTextContext::BitmapTextBlob* | 674 inline GrAtlasTextContext::BitmapTextBlob* | 
| 675 GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint, | 675 GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint, | 
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1066                                             const SkPaint& origPaint) { | 1066                                             const SkPaint& origPaint) { | 
| 1067     SkASSERT(byteLength == 0 || text != NULL); | 1067     SkASSERT(byteLength == 0 || text != NULL); | 
| 1068 | 1068 | 
| 1069     // nothing to draw | 1069     // nothing to draw | 
| 1070     if (text == NULL || byteLength == 0) { | 1070     if (text == NULL || byteLength == 0) { | 
| 1071         return; | 1071         return; | 
| 1072     } | 1072     } | 
| 1073 | 1073 | 
| 1074     SkDrawCacheProc glyphCacheProc = origPaint.getDrawCacheProc(); | 1074     SkDrawCacheProc glyphCacheProc = origPaint.getDrawCacheProc(); | 
| 1075     SkAutoDescriptor desc; | 1075     SkAutoDescriptor desc; | 
| 1076     origPaint.getScalerContextDescriptor(&desc, &fDeviceProperties, NULL, true); | 1076     origPaint.getScalerContextDescriptor(&desc, fSurfaceProps, NULL, true); | 
| 1077     SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypefa
      ce(), | 1077     SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypefa
      ce(), | 
| 1078                                                              desc.getDesc()); | 1078                                                              desc.getDesc()); | 
| 1079 | 1079 | 
| 1080     SkTArray<SkScalar> positions; | 1080     SkTArray<SkScalar> positions; | 
| 1081 | 1081 | 
| 1082     const char* textPtr = text; | 1082     const char* textPtr = text; | 
| 1083     SkFixed stopX = 0; | 1083     SkFixed stopX = 0; | 
| 1084     SkFixed stopY = 0; | 1084     SkFixed stopY = 0; | 
| 1085     SkFixed origin = 0; | 1085     SkFixed origin = 0; | 
| 1086     switch (origPaint.getTextAlign()) { | 1086     switch (origPaint.getTextAlign()) { | 
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2035 | 2035 | 
| 2036     size_t textLen = it.glyphCount() * sizeof(uint16_t); | 2036     size_t textLen = it.glyphCount() * sizeof(uint16_t); | 
| 2037     const SkPoint& offset = it.offset(); | 2037     const SkPoint& offset = it.offset(); | 
| 2038 | 2038 | 
| 2039     it.applyFontToPaint(&runPaint); | 2039     it.applyFontToPaint(&runPaint); | 
| 2040 | 2040 | 
| 2041     if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Type)) 
      { | 2041     if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Type)) 
      { | 
| 2042         return; | 2042         return; | 
| 2043     } | 2043     } | 
| 2044 | 2044 | 
| 2045     runPaint.setFlags(FilterTextFlags(fDeviceProperties, runPaint)); | 2045     runPaint.setFlags(FilterTextFlags(fSurfaceProps, runPaint)); | 
| 2046 | 2046 | 
| 2047     switch (it.positioning()) { | 2047     switch (it.positioning()) { | 
| 2048         case SkTextBlob::kDefault_Positioning: | 2048         case SkTextBlob::kDefault_Positioning: | 
| 2049             this->drawTextAsPath(rt, clip, runPaint, viewMatrix, | 2049             this->drawTextAsPath(rt, clip, runPaint, viewMatrix, | 
| 2050                                  (const char *)it.glyphs(), | 2050                                  (const char *)it.glyphs(), | 
| 2051                                  textLen, x + offset.x(), y + offset.y(), clipBo
      unds); | 2051                                  textLen, x + offset.x(), y + offset.y(), clipBo
      unds); | 
| 2052             break; | 2052             break; | 
| 2053         case SkTextBlob::kHorizontal_Positioning: | 2053         case SkTextBlob::kHorizontal_Positioning: | 
| 2054             this->drawPosTextAsPath(rt, clip, runPaint, viewMatrix, | 2054             this->drawPosTextAsPath(rt, clip, runPaint, viewMatrix, | 
| 2055                                     (const char*)it.glyphs(), | 2055                                     (const char*)it.glyphs(), | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 2081 | 2081 | 
| 2082     BitmapTextBatch* batch; | 2082     BitmapTextBatch* batch; | 
| 2083     if (info.fDrawAsDistanceFields) { | 2083     if (info.fDrawAsDistanceFields) { | 
| 2084         SkColor filteredColor; | 2084         SkColor filteredColor; | 
| 2085         SkColorFilter* colorFilter = skPaint.getColorFilter(); | 2085         SkColorFilter* colorFilter = skPaint.getColorFilter(); | 
| 2086         if (colorFilter) { | 2086         if (colorFilter) { | 
| 2087             filteredColor = colorFilter->filterColor(skPaint.getColor()); | 2087             filteredColor = colorFilter->filterColor(skPaint.getColor()); | 
| 2088         } else { | 2088         } else { | 
| 2089             filteredColor = skPaint.getColor(); | 2089             filteredColor = skPaint.getColor(); | 
| 2090         } | 2090         } | 
| 2091         bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.pixelGeometry()); | 2091         bool useBGR = SkPixelGeometryIsBGR(fSurfaceProps.pixelGeometry()); | 
| 2092         batch = BitmapTextBatch::Create(format, glyphCount, fContext->getBatchFo
      ntCache(), | 2092         batch = BitmapTextBatch::Create(format, glyphCount, fContext->getBatchFo
      ntCache(), | 
| 2093                                         fDistanceAdjustTable, filteredColor, | 2093                                         fDistanceAdjustTable, filteredColor, | 
| 2094                                         info.fUseLCDText, useBGR); | 2094                                         info.fUseLCDText, useBGR); | 
| 2095     } else { | 2095     } else { | 
| 2096         batch = BitmapTextBatch::Create(format, glyphCount, fContext->getBatchFo
      ntCache()); | 2096         batch = BitmapTextBatch::Create(format, glyphCount, fContext->getBatchFo
      ntCache()); | 
| 2097     } | 2097     } | 
| 2098     BitmapTextBatch::Geometry& geometry = batch->geometry(); | 2098     BitmapTextBatch::Geometry& geometry = batch->geometry(); | 
| 2099     geometry.fBlob = SkRef(cacheBlob); | 2099     geometry.fBlob = SkRef(cacheBlob); | 
| 2100     geometry.fRun = run; | 2100     geometry.fRun = run; | 
| 2101     geometry.fSubRun = subRun; | 2101     geometry.fSubRun = subRun; | 
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2203     this->flushBigGlyphs(cacheBlob, rt, clip, skPaint, 0, 0, clipBounds); | 2203     this->flushBigGlyphs(cacheBlob, rt, clip, skPaint, 0, 0, clipBounds); | 
| 2204 } | 2204 } | 
| 2205 | 2205 | 
| 2206 ////////////////////////////////////////////////////////////////////////////////
      /////////////////// | 2206 ////////////////////////////////////////////////////////////////////////////////
      /////////////////// | 
| 2207 | 2207 | 
| 2208 #ifdef GR_TEST_UTILS | 2208 #ifdef GR_TEST_UTILS | 
| 2209 | 2209 | 
| 2210 BATCH_TEST_DEFINE(TextBlobBatch) { | 2210 BATCH_TEST_DEFINE(TextBlobBatch) { | 
| 2211     static uint32_t gContextID = SK_InvalidGenID; | 2211     static uint32_t gContextID = SK_InvalidGenID; | 
| 2212     static GrAtlasTextContext* gTextContext = NULL; | 2212     static GrAtlasTextContext* gTextContext = NULL; | 
| 2213     static SkDeviceProperties gDevProperties; | 2213     static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType
      ); | 
| 2214 | 2214 | 
| 2215     if (context->uniqueID() != gContextID) { | 2215     if (context->uniqueID() != gContextID) { | 
| 2216         gContextID = context->uniqueID(); | 2216         gContextID = context->uniqueID(); | 
| 2217         SkDELETE(gTextContext); | 2217         SkDELETE(gTextContext); | 
| 2218 | 2218 | 
| 2219         // We don't yet test the fall back to paths in the GrTextContext base cl
      ass.  This is mostly | 2219         // We don't yet test the fall back to paths in the GrTextContext base cl
      ass.  This is mostly | 
| 2220         // because we don't really want to have a gpu device here. | 2220         // because we don't really want to have a gpu device here. | 
| 2221         // We enable distance fields by twiddling a knob on the paint | 2221         // We enable distance fields by twiddling a knob on the paint | 
| 2222         GrDrawContext* drawContext = context->drawContext(&gDevProperties); | 2222         GrDrawContext* drawContext = context->drawContext(&gSurfaceProps); | 
| 2223 | 2223 | 
| 2224         gTextContext = GrAtlasTextContext::Create(context, drawContext, gDevProp
      erties); | 2224         gTextContext = GrAtlasTextContext::Create(context, drawContext, gSurface
      Props); | 
| 2225     } | 2225     } | 
| 2226 | 2226 | 
| 2227     // create dummy render target | 2227     // create dummy render target | 
| 2228     GrSurfaceDesc desc; | 2228     GrSurfaceDesc desc; | 
| 2229     desc.fFlags = kRenderTarget_GrSurfaceFlag; | 2229     desc.fFlags = kRenderTarget_GrSurfaceFlag; | 
| 2230     desc.fWidth = 1024; | 2230     desc.fWidth = 1024; | 
| 2231     desc.fHeight = 1024; | 2231     desc.fHeight = 1024; | 
| 2232     desc.fConfig = kRGBA_8888_GrPixelConfig; | 2232     desc.fConfig = kRGBA_8888_GrPixelConfig; | 
| 2233     desc.fSampleCnt = 0; | 2233     desc.fSampleCnt = 0; | 
| 2234     SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de
      sc, true, NULL, 0)); | 2234     SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de
      sc, true, NULL, 0)); | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 2264             gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
      rix, text, | 2264             gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
      rix, text, | 
| 2265                                              static_cast<size_t>(textLen), 0, 0,
       noClip)); | 2265                                              static_cast<size_t>(textLen), 0, 0,
       noClip)); | 
| 2266 | 2266 | 
| 2267     SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2267     SkScalar transX = static_cast<SkScalar>(random->nextU()); | 
| 2268     SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2268     SkScalar transY = static_cast<SkScalar>(random->nextU()); | 
| 2269     const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
      s[0].fSubRunInfo[0]; | 2269     const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
      s[0].fSubRunInfo[0]; | 
| 2270     return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
      ransY, skPaint); | 2270     return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
      ransY, skPaint); | 
| 2271 } | 2271 } | 
| 2272 | 2272 | 
| 2273 #endif | 2273 #endif | 
| OLD | NEW | 
|---|