| 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 "GrDistanceFieldTextContext.h" | 8 #include "GrDistanceFieldTextContext.h" | 
| 9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" | 
| 10 #include "GrBitmapTextContext.h" | 10 #include "GrBitmapTextContext.h" | 
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 630         // get our current color | 630         // get our current color | 
| 631         SkColor filteredColor; | 631         SkColor filteredColor; | 
| 632         SkColorFilter* colorFilter = fSkPaint.getColorFilter(); | 632         SkColorFilter* colorFilter = fSkPaint.getColorFilter(); | 
| 633         if (colorFilter) { | 633         if (colorFilter) { | 
| 634             filteredColor = colorFilter->filterColor(fSkPaint.getColor()); | 634             filteredColor = colorFilter->filterColor(fSkPaint.getColor()); | 
| 635         } else { | 635         } else { | 
| 636             filteredColor = fSkPaint.getColor(); | 636             filteredColor = fSkPaint.getColor(); | 
| 637         } | 637         } | 
| 638         this->setupCoverageEffect(filteredColor); | 638         this->setupCoverageEffect(filteredColor); | 
| 639 | 639 | 
| 640         // Effects could be stored with one of the cache objects (atlas?) |  | 
| 641         drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); |  | 
| 642 |  | 
| 643         // Set draw state | 640         // Set draw state | 
| 644         if (fUseLCDText) { | 641         if (fUseLCDText) { | 
| 645             // TODO: move supportsRGBCoverage check to setupCoverageEffect and o
     nly add LCD | 642             // TODO: move supportsRGBCoverage check to setupCoverageEffect and o
     nly add LCD | 
| 646             // processor if the xp can support it. For now we will simply assume
      that if | 643             // processor if the xp can support it. For now we will simply assume
      that if | 
| 647             // fUseLCDText is true, then we have a known color output. | 644             // fUseLCDText is true, then we have a known color output. | 
| 648             if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorC
     omponentFlags)) { | 645             if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorC
     omponentFlags)) { | 
| 649                 SkDebugf("LCD Text will not draw correctly.\n"); | 646                 SkDebugf("LCD Text will not draw correctly.\n"); | 
| 650             } | 647             } | 
| 651             SkASSERT(!drawState.hasColorVertexAttribute()); | 648             SkASSERT(!fCachedGeometryProcessor->hasVertexColor()); | 
| 652         } else { | 649         } else { | 
| 653             if (0xFF == GrColorUnpackA(fPaint.getColor())) { | 650             if (0xFF == GrColorUnpackA(fPaint.getColor())) { | 
| 654                 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true
     ); | 651                 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true
     ); | 
| 655             } | 652             } | 
| 656             // We're using per-vertex color. | 653             // We're using per-vertex color. | 
| 657             SkASSERT(drawState.hasColorVertexAttribute()); | 654             SkASSERT(fCachedGeometryProcessor->hasVertexColor()); | 
| 658         } | 655         } | 
| 659         int nGlyphs = fCurrVertex / kVerticesPerGlyph; | 656         int nGlyphs = fCurrVertex / kVerticesPerGlyph; | 
| 660         fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 657         fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 
| 661         fDrawTarget->drawIndexedInstances(&drawState, | 658         fDrawTarget->drawIndexedInstances(&drawState, | 
|  | 659                                           fCachedGeometryProcessor.get(), | 
| 662                                           kTriangles_GrPrimitiveType, | 660                                           kTriangles_GrPrimitiveType, | 
| 663                                           nGlyphs, | 661                                           nGlyphs, | 
| 664                                           kVerticesPerGlyph, | 662                                           kVerticesPerGlyph, | 
| 665                                           kIndicesPerGlyph, | 663                                           kIndicesPerGlyph, | 
| 666                                           &fVertexBounds); | 664                                           &fVertexBounds); | 
| 667         fDrawTarget->resetVertexSource(); | 665         fDrawTarget->resetVertexSource(); | 
| 668         fVertices = NULL; | 666         fVertices = NULL; | 
| 669         fTotalVertexCount -= fCurrVertex; | 667         fTotalVertexCount -= fCurrVertex; | 
| 670         fCurrVertex = 0; | 668         fCurrVertex = 0; | 
| 671         SkSafeSetNull(fCurrTexture); | 669         SkSafeSetNull(fCurrTexture); | 
| 672         fVertexBounds.setLargestInverted(); | 670         fVertexBounds.setLargestInverted(); | 
| 673     } | 671     } | 
| 674 } | 672 } | 
| 675 | 673 | 
| 676 inline void GrDistanceFieldTextContext::finish() { | 674 inline void GrDistanceFieldTextContext::finish() { | 
| 677     this->flush(); | 675     this->flush(); | 
| 678     fTotalVertexCount = 0; | 676     fTotalVertexCount = 0; | 
| 679 | 677 | 
| 680     GrTextContext::finish(); | 678     GrTextContext::finish(); | 
| 681 } | 679 } | 
| 682 | 680 | 
| OLD | NEW | 
|---|