Chromium Code Reviews| 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 } else { | 630 } else { |
| 631 filteredColor = fSkPaint.getColor(); | 631 filteredColor = fSkPaint.getColor(); |
| 632 } | 632 } |
| 633 this->setupCoverageEffect(filteredColor); | 633 this->setupCoverageEffect(filteredColor); |
| 634 | 634 |
| 635 // Effects could be stored with one of the cache objects (atlas?) | 635 // Effects could be stored with one of the cache objects (atlas?) |
| 636 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); | 636 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); |
| 637 | 637 |
| 638 // Set draw state | 638 // Set draw state |
| 639 if (fUseLCDText) { | 639 if (fUseLCDText) { |
| 640 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or); | 640 //GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredC olor); |
|
bsalomon
2014/12/08 15:38:51
remove this?
egdaniel
2014/12/08 16:24:01
Done.
| |
| 641 | 641 |
| 642 // TODO: move supportsRGBCoverage check to setupCoverageEffect and o nly add LCD | 642 // 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 | 643 // 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. | 644 // fUseLCDText is true, then we have a known color output. |
| 645 if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorC omponentFlags)) { | 645 if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorC omponentFlags)) { |
| 646 SkDebugf("LCD Text will not draw correctly.\n"); | 646 SkDebugf("LCD Text will not draw correctly.\n"); |
| 647 } | 647 } |
| 648 SkASSERT(!drawState.hasColorVertexAttribute()); | 648 SkASSERT(!drawState.hasColorVertexAttribute()); |
| 649 // We don't use the GrPaint's color in this case because it's been p remultiplied by | |
| 650 // alpha. Instead we feed in a non-premultiplied color, and multiply its alpha by | |
| 651 // the mask texture color. The end result is that we get | |
| 652 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstCo lor | |
| 653 int a = SkColorGetA(fSkPaint.getColor()); | |
| 654 // paintAlpha | |
| 655 drawState.setColor(SkColorSetARGB(a, a, a, a)); | |
| 656 // paintColor | |
| 657 drawState.setBlendConstant(colorNoPreMul); | |
| 658 drawState.setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff); | |
| 659 } else { | 649 } else { |
| 660 if (0xFF == GrColorUnpackA(fPaint.getColor())) { | 650 if (0xFF == GrColorUnpackA(fPaint.getColor())) { |
| 661 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true ); | 651 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true ); |
| 662 } | 652 } |
| 663 // set back to normal in case we took LCD path previously. | |
| 664 drawState.setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlend Coeff()); | |
| 665 // We're using per-vertex color. | 653 // We're using per-vertex color. |
| 666 SkASSERT(drawState.hasColorVertexAttribute()); | 654 SkASSERT(drawState.hasColorVertexAttribute()); |
| 667 } | 655 } |
| 668 int nGlyphs = fCurrVertex / kVerticesPerGlyph; | 656 int nGlyphs = fCurrVertex / kVerticesPerGlyph; |
| 669 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 657 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
| 670 fDrawTarget->drawIndexedInstances(&drawState, | 658 fDrawTarget->drawIndexedInstances(&drawState, |
| 671 kTriangles_GrPrimitiveType, | 659 kTriangles_GrPrimitiveType, |
| 672 nGlyphs, | 660 nGlyphs, |
| 673 kVerticesPerGlyph, | 661 kVerticesPerGlyph, |
| 674 kIndicesPerGlyph, | 662 kIndicesPerGlyph, |
| 675 &fVertexBounds); | 663 &fVertexBounds); |
| 676 fDrawTarget->resetVertexSource(); | 664 fDrawTarget->resetVertexSource(); |
| 677 fVertices = NULL; | 665 fVertices = NULL; |
| 678 fTotalVertexCount -= fCurrVertex; | 666 fTotalVertexCount -= fCurrVertex; |
| 679 fCurrVertex = 0; | 667 fCurrVertex = 0; |
| 680 SkSafeSetNull(fCurrTexture); | 668 SkSafeSetNull(fCurrTexture); |
| 681 fVertexBounds.setLargestInverted(); | 669 fVertexBounds.setLargestInverted(); |
| 682 } | 670 } |
| 683 } | 671 } |
| 684 | 672 |
| 685 inline void GrDistanceFieldTextContext::finish() { | 673 inline void GrDistanceFieldTextContext::finish() { |
| 686 this->flush(); | 674 this->flush(); |
| 687 fTotalVertexCount = 0; | 675 fTotalVertexCount = 0; |
| 688 | 676 |
| 689 GrTextContext::finish(); | 677 GrTextContext::finish(); |
| 690 } | 678 } |
| 691 | 679 |
| OLD | NEW |