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

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

Issue 338093005: Cache the GrEffect used for text rendering in GrBitmapTextContext. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix typo Created 6 years, 6 months 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/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrCacheable.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 "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 }; 50 };
51 51
52 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, 52 GrBitmapTextContext::GrBitmapTextContext(GrContext* context,
53 const SkDeviceProperties& properties) 53 const SkDeviceProperties& properties)
54 : GrTextContext(context, properties) { 54 : GrTextContext(context, properties) {
55 fStrike = NULL; 55 fStrike = NULL;
56 56
57 fCurrTexture = NULL; 57 fCurrTexture = NULL;
58 fCurrVertex = 0; 58 fCurrVertex = 0;
59 fEffectTextureGenID = 0;
59 60
60 fVertices = NULL; 61 fVertices = NULL;
61 fMaxVertices = 0; 62 fMaxVertices = 0;
62 63
63 fVertexBounds.setLargestInverted(); 64 fVertexBounds.setLargestInverted();
64 } 65 }
65 66
66 GrBitmapTextContext::~GrBitmapTextContext() { 67 GrBitmapTextContext::~GrBitmapTextContext() {
67 this->flushGlyphs(); 68 this->flushGlyphs();
68 } 69 }
(...skipping 17 matching lines...) Expand all
86 GrDrawState* drawState = fDrawTarget->drawState(); 87 GrDrawState* drawState = fDrawTarget->drawState();
87 GrDrawState::AutoRestoreEffects are(drawState); 88 GrDrawState::AutoRestoreEffects are(drawState);
88 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); 89 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget());
89 90
90 if (fCurrVertex > 0) { 91 if (fCurrVertex > 0) {
91 // setup our sampler state for our text texture/atlas 92 // setup our sampler state for our text texture/atlas
92 SkASSERT(SkIsAlign4(fCurrVertex)); 93 SkASSERT(SkIsAlign4(fCurrVertex));
93 SkASSERT(fCurrTexture); 94 SkASSERT(fCurrTexture);
94 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon e_FilterMode); 95 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon e_FilterMode);
95 96
97 uint32_t textureGenID = fCurrTexture->getGenerationID();
98
99 if (textureGenID != fEffectTextureGenID) {
100 fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture , params));
101 fEffectTextureGenID = textureGenID;
102 }
103
96 // This effect could be stored with one of the cache objects (atlas?) 104 // This effect could be stored with one of the cache objects (atlas?)
97 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC olorAttributeIndex : 105 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC olorAttributeIndex :
98 kGlyphCoordsNoCol orAttributeIndex; 106 kGlyphCoordsNoCol orAttributeIndex;
99 drawState->addCoverageEffect( 107 drawState->addCoverageEffect(fCachedEffect.get(), coordsIdx);
100 GrCustomCoordsTextureEffect::Create(fCurrTexture , params),
101 coordsIdx)->unref();
102 SkASSERT(NULL != fStrike); 108 SkASSERT(NULL != fStrike);
103 switch (fStrike->getMaskFormat()) { 109 switch (fStrike->getMaskFormat()) {
104 // Color bitmap text 110 // Color bitmap text
105 case kARGB_GrMaskFormat: 111 case kARGB_GrMaskFormat:
106 SkASSERT(!drawState->hasColorVertexAttribute()); 112 SkASSERT(!drawState->hasColorVertexAttribute());
107 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst BlendCoeff()); 113 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst BlendCoeff());
108 drawState->setColor(0xffffffff); 114 drawState->setColor(0xffffffff);
109 break; 115 break;
110 // LCD text 116 // LCD text
111 case kA888_GrMaskFormat: 117 case kA888_GrMaskFormat:
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 if (useColorVerts) { 596 if (useColorVerts) {
591 // color comes after position. 597 // color comes after position.
592 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); 598 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1);
593 for (int i = 0; i < 4; ++i) { 599 for (int i = 0; i < 4; ++i) {
594 *colors = fPaint.getColor(); 600 *colors = fPaint.getColor();
595 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors ) + vertSize); 601 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors ) + vertSize);
596 } 602 }
597 } 603 }
598 fCurrVertex += 4; 604 fCurrVertex += 4;
599 } 605 }
OLDNEW
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrCacheable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698