Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: src/gpu/GrBitmapTextContext.cpp

Issue 759713002: Make all blending up to GrOptDrawState be handled by the xp/xp factory. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferFactorySolo
Patch Set: rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrBitmapTextContext.h" 8 #include "GrBitmapTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 fEffectTextureUniqueID = textureUniqueID; 554 fEffectTextureUniqueID = textureUniqueID;
555 } 555 }
556 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); 556 drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
557 } 557 }
558 558
559 SkASSERT(fStrike); 559 SkASSERT(fStrike);
560 switch (fCurrMaskFormat) { 560 switch (fCurrMaskFormat) {
561 // Color bitmap text 561 // Color bitmap text
562 case kARGB_GrMaskFormat: 562 case kARGB_GrMaskFormat:
563 SkASSERT(!drawState.hasColorVertexAttribute()); 563 SkASSERT(!drawState.hasColorVertexAttribute());
564 drawState.setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstB lendCoeff());
565 drawState.setAlpha(fSkPaint.getAlpha()); 564 drawState.setAlpha(fSkPaint.getAlpha());
566 break; 565 break;
567 // LCD text 566 // LCD text
568 case kA565_GrMaskFormat: { 567 case kA565_GrMaskFormat: {
569 // TODO: move supportsRGBCoverage check to setupCoverageEffect a nd only add LCD 568 // TODO: move supportsRGBCoverage check to setupCoverageEffect a nd only add LCD
570 // processor if the xp can support it. For now we will simply as sume that if 569 // processor if the xp can support it. For now we will simply as sume that if
571 // fUseLCDText is true, then we have a known color output. 570 // fUseLCDText is true, then we have a known color output.
572 if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrCo lorComponentFlags)) { 571 if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrCo lorComponentFlags)) {
573 SkDebugf("LCD Text will not draw correctly.\n"); 572 SkDebugf("LCD Text will not draw correctly.\n");
574 } 573 }
575 SkASSERT(!drawState.hasColorVertexAttribute()); 574 SkASSERT(!drawState.hasColorVertexAttribute());
576 // We don't use the GrPaint's color in this case because it's be en premultiplied by
577 // alpha. Instead we feed in a non-premultiplied color, and mult iply its alpha by
578 // the mask texture color. The end result is that we get
579 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*d stColor
580 int a = SkColorGetA(fSkPaint.getColor());
581 // paintAlpha
582 drawState.setColor(SkColorSetARGB(a, a, a, a));
583 // paintColor
584 drawState.setBlendConstant(skcolor_to_grcolor_nopremultiply(fSkP aint.getColor()));
585 drawState.setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff);
586 break; 575 break;
587 } 576 }
588 // Grayscale/BW text 577 // Grayscale/BW text
589 case kA8_GrMaskFormat: 578 case kA8_GrMaskFormat:
590 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint, 579 drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint,
591 0xFF == GrColorUnpackA(fPaint.getColor())); 580 0xFF == GrColorUnpackA(fPaint.getColor()));
592 // set back to normal in case we took LCD path previously.
593 drawState.setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstB lendCoeff());
594 // We're using per-vertex color. 581 // We're using per-vertex color.
595 SkASSERT(drawState.hasColorVertexAttribute()); 582 SkASSERT(drawState.hasColorVertexAttribute());
596 break; 583 break;
597 default: 584 default:
598 SkFAIL("Unexpected mask format."); 585 SkFAIL("Unexpected mask format.");
599 } 586 }
600 int nGlyphs = fCurrVertex / kVerticesPerGlyph; 587 int nGlyphs = fCurrVertex / kVerticesPerGlyph;
601 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); 588 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
602 fDrawTarget->drawIndexedInstances(&drawState, 589 fDrawTarget->drawIndexedInstances(&drawState,
603 kTriangles_GrPrimitiveType, 590 kTriangles_GrPrimitiveType,
(...skipping 13 matching lines...) Expand all
617 } 604 }
618 } 605 }
619 606
620 inline void GrBitmapTextContext::finish() { 607 inline void GrBitmapTextContext::finish() {
621 this->flush(); 608 this->flush();
622 fTotalVertexCount = 0; 609 fTotalVertexCount = 0;
623 610
624 GrTextContext::finish(); 611 GrTextContext::finish();
625 } 612 }
626 613
OLDNEW
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698