| 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  | 
|  640         // Set draw state |  643         // Set draw state | 
|  641         if (fUseLCDText) { |  644         if (fUseLCDText) { | 
|  642             // TODO: move supportsRGBCoverage check to setupCoverageEffect and o
     nly add LCD |  645             // TODO: move supportsRGBCoverage check to setupCoverageEffect and o
     nly add LCD | 
|  643             // processor if the xp can support it. For now we will simply assume
      that if |  646             // processor if the xp can support it. For now we will simply assume
      that if | 
|  644             // fUseLCDText is true, then we have a known color output. |  647             // fUseLCDText is true, then we have a known color output. | 
|  645             if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorC
     omponentFlags)) { |  648             if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorC
     omponentFlags)) { | 
|  646                 SkDebugf("LCD Text will not draw correctly.\n"); |  649                 SkDebugf("LCD Text will not draw correctly.\n"); | 
|  647             } |  650             } | 
|  648             SkASSERT(!fCachedGeometryProcessor->hasVertexColor()); |  651             SkASSERT(!drawState.hasColorVertexAttribute()); | 
|  649         } else { |  652         } else { | 
|  650             if (0xFF == GrColorUnpackA(fPaint.getColor())) { |  653             if (0xFF == GrColorUnpackA(fPaint.getColor())) { | 
|  651                 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true
     ); |  654                 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true
     ); | 
|  652             } |  655             } | 
|  653             // We're using per-vertex color. |  656             // We're using per-vertex color. | 
|  654             SkASSERT(fCachedGeometryProcessor->hasVertexColor()); |  657             SkASSERT(drawState.hasColorVertexAttribute()); | 
|  655         } |  658         } | 
|  656         int nGlyphs = fCurrVertex / kVerticesPerGlyph; |  659         int nGlyphs = fCurrVertex / kVerticesPerGlyph; | 
|  657         fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |  660         fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 
|  658         fDrawTarget->drawIndexedInstances(&drawState, |  661         fDrawTarget->drawIndexedInstances(&drawState, | 
|  659                                           fCachedGeometryProcessor.get(), |  | 
|  660                                           kTriangles_GrPrimitiveType, |  662                                           kTriangles_GrPrimitiveType, | 
|  661                                           nGlyphs, |  663                                           nGlyphs, | 
|  662                                           kVerticesPerGlyph, |  664                                           kVerticesPerGlyph, | 
|  663                                           kIndicesPerGlyph, |  665                                           kIndicesPerGlyph, | 
|  664                                           &fVertexBounds); |  666                                           &fVertexBounds); | 
|  665         fDrawTarget->resetVertexSource(); |  667         fDrawTarget->resetVertexSource(); | 
|  666         fVertices = NULL; |  668         fVertices = NULL; | 
|  667         fTotalVertexCount -= fCurrVertex; |  669         fTotalVertexCount -= fCurrVertex; | 
|  668         fCurrVertex = 0; |  670         fCurrVertex = 0; | 
|  669         SkSafeSetNull(fCurrTexture); |  671         SkSafeSetNull(fCurrTexture); | 
|  670         fVertexBounds.setLargestInverted(); |  672         fVertexBounds.setLargestInverted(); | 
|  671     } |  673     } | 
|  672 } |  674 } | 
|  673  |  675  | 
|  674 inline void GrDistanceFieldTextContext::finish() { |  676 inline void GrDistanceFieldTextContext::finish() { | 
|  675     this->flush(); |  677     this->flush(); | 
|  676     fTotalVertexCount = 0; |  678     fTotalVertexCount = 0; | 
|  677  |  679  | 
|  678     GrTextContext::finish(); |  680     GrTextContext::finish(); | 
|  679 } |  681 } | 
|  680  |  682  | 
| OLD | NEW |