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

Unified Diff: src/gpu/GrBitmapTextContext.cpp

Issue 783763002: Initial CL to move color / coverage off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@no-static-gp
Patch Set: bug fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrClipMaskManager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrBitmapTextContext.cpp
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
index 1853fa4f934457452289ffdfed65e3013369bdcd..6a624ae23e2fc030e401e8a213b66e60e96e3e39 100755
--- a/src/gpu/GrBitmapTextContext.cpp
+++ b/src/gpu/GrBitmapTextContext.cpp
@@ -528,34 +528,15 @@ void GrBitmapTextContext::flush() {
SkASSERT(SkIsAlign4(fCurrVertex));
SkASSERT(fCurrTexture);
- // This effect could be stored with one of the cache objects (atlas?)
- GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode);
- if (kARGB_GrMaskFormat == fCurrMaskFormat) {
- uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType;
- drawState.setGeometryProcessor(GrDefaultGeoProcFactory::Create(flags))->unref();
- GrFragmentProcessor* fragProcessor = GrSimpleTextureEffect::Create(fCurrTexture,
- SkMatrix::I(),
- params);
- drawState.addColorProcessor(fragProcessor)->unref();
- } else {
- uint32_t textureUniqueID = fCurrTexture->getUniqueID();
- if (textureUniqueID != fEffectTextureUniqueID) {
- bool useColorAttrib = kA8_GrMaskFormat == fCurrMaskFormat;
- fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(fCurrTexture,
- params,
- useColorAttrib));
- fEffectTextureUniqueID = textureUniqueID;
- }
- drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
- }
-
SkASSERT(fStrike);
+ GrColor color = fPaint.getColor();
switch (fCurrMaskFormat) {
// Color bitmap text
- case kARGB_GrMaskFormat:
- SkASSERT(!drawState.hasColorVertexAttribute());
- drawState.setAlpha(fSkPaint.getAlpha());
+ case kARGB_GrMaskFormat: {
+ int a = fSkPaint.getAlpha();
+ color = SkColorSetARGB(a, a, a, a);
break;
+ }
// LCD text
case kA565_GrMaskFormat: {
// TODO: move supportsRGBCoverage check to setupCoverageEffect and only add LCD
@@ -564,19 +545,45 @@ void GrBitmapTextContext::flush() {
if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorComponentFlags)) {
SkDebugf("LCD Text will not draw correctly.\n");
}
- SkASSERT(!drawState.hasColorVertexAttribute());
break;
}
// Grayscale/BW text
case kA8_GrMaskFormat:
drawState.setHint(GrDrawState::kVertexColorsAreOpaque_Hint,
0xFF == GrColorUnpackA(fPaint.getColor()));
- // We're using per-vertex color.
- SkASSERT(drawState.hasColorVertexAttribute());
break;
default:
SkFAIL("Unexpected mask format.");
}
+
+ GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode);
+ // TODO cache these GPs
+ if (kARGB_GrMaskFormat == fCurrMaskFormat) {
+ uint32_t textureUniqueID = fCurrTexture->getUniqueID();
+ if (textureUniqueID != fEffectTextureUniqueID ||
+ fCachedGeometryProcessor->getColor() != color) {
+ uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType;
+ fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(color, flags));
+ fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCurrTexture,
+ SkMatrix::I(),
+ params));
+ }
+ drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
+ drawState.addColorProcessor(fCachedTextureProcessor.get());
+ } else {
+ uint32_t textureUniqueID = fCurrTexture->getUniqueID();
+ if (textureUniqueID != fEffectTextureUniqueID ||
+ fCachedGeometryProcessor->getColor() != color) {
+ bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat;
+ fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color,
+ fCurrTexture,
+ params,
+ hasColor));
+ fEffectTextureUniqueID = textureUniqueID;
+ }
+ drawState.setGeometryProcessor(fCachedGeometryProcessor.get());
+ }
+
int nGlyphs = fCurrVertex / kVerticesPerGlyph;
fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
fDrawTarget->drawIndexedInstances(&drawState,
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrClipMaskManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698