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

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

Issue 817853002: Remove localcoordchange functions off paint (Closed) Base URL: https://skia.googlesource.com/skia.git@local-matrix-on-gp
Patch Set: changing ignores Created 5 years, 12 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/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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 fxMask = 0; 147 fxMask = 0;
148 halfSampleX = SK_FixedHalf; 148 halfSampleX = SK_FixedHalf;
149 } 149 }
150 } else { 150 } else {
151 halfSampleX = halfSampleY = SK_FixedHalf; 151 halfSampleX = halfSampleY = SK_FixedHalf;
152 } 152 }
153 153
154 SkFixed fx = SkScalarToFixed(x) + halfSampleX; 154 SkFixed fx = SkScalarToFixed(x) + halfSampleX;
155 SkFixed fy = SkScalarToFixed(y) + halfSampleY; 155 SkFixed fy = SkScalarToFixed(y) + halfSampleY;
156 156
157 if (!fPaint.localCoordChangeInverse(viewMatrix)) { 157 // if we have RGB, then we won't have any SkShaders so no need to use a loca lmatrix
158 if (kARGB_GrMaskFormat != fCurrMaskFormat && !viewMatrix.invert(&fLocalMatri x)) {
158 SkDebugf("Cannot invert viewmatrix\n"); 159 SkDebugf("Cannot invert viewmatrix\n");
159 } 160 }
160 161
161 while (text < stop) { 162 while (text < stop) {
162 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy Mask); 163 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy Mask);
163 164
164 fx += autokern.adjust(glyph); 165 fx += autokern.adjust(glyph);
165 166
166 if (glyph.fWidth) { 167 if (glyph.fWidth) {
167 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 168 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
(...skipping 27 matching lines...) Expand all
195 this->init(paint, skPaint); 196 this->init(paint, skPaint);
196 197
197 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); 198 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
198 199
199 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); 200 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix);
200 SkGlyphCache* cache = autoCache.getCache(); 201 SkGlyphCache* cache = autoCache.getCache();
201 GrFontScaler* fontScaler = GetGrFontScaler(cache); 202 GrFontScaler* fontScaler = GetGrFontScaler(cache);
202 203
203 // store original matrix before we reset, so we can use it to transform posi tions 204 // store original matrix before we reset, so we can use it to transform posi tions
204 SkMatrix ctm = viewMatrix; 205 SkMatrix ctm = viewMatrix;
205 if (!fPaint.localCoordChangeInverse(viewMatrix)) { 206
207 // if we have RGB, then we won't have any SkShaders so no need to use a loca lmatrix
208 if (kARGB_GrMaskFormat != fCurrMaskFormat && !viewMatrix.invert(&fLocalMatri x)) {
206 SkDebugf("Cannot invert viewmatrix\n"); 209 SkDebugf("Cannot invert viewmatrix\n");
207 } 210 }
208 211
209 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); 212 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL);
210 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; 213 fTotalVertexCount = kVerticesPerGlyph*numGlyphs;
211 214
212 const char* stop = text + byteLength; 215 const char* stop = text + byteLength;
213 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); 216 SkTextAlignProc alignProc(fSkPaint.getTextAlign());
214 SkTextMapStateProc tmsProc(ctm, offset, scalarsPerPosition); 217 SkTextMapStateProc tmsProc(ctm, offset, scalarsPerPosition);
215 SkFixed halfSampleX = 0, halfSampleY = 0; 218 SkFixed halfSampleX = 0, halfSampleY = 0;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 break; 555 break;
553 } 556 }
554 // Grayscale/BW text 557 // Grayscale/BW text
555 case kA8_GrMaskFormat: 558 case kA8_GrMaskFormat:
556 break; 559 break;
557 default: 560 default:
558 SkFAIL("Unexpected mask format."); 561 SkFAIL("Unexpected mask format.");
559 } 562 }
560 563
561 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon e_FilterMode); 564 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon e_FilterMode);
562 // TODO cache these GPs
563 if (kARGB_GrMaskFormat == fCurrMaskFormat) { 565 if (kARGB_GrMaskFormat == fCurrMaskFormat) {
564 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); 566 uint32_t textureUniqueID = fCurrTexture->getUniqueID();
565 if (textureUniqueID != fEffectTextureUniqueID || 567 if (textureUniqueID != fEffectTextureUniqueID ||
566 fCachedGeometryProcessor->color() != color) { 568 fCachedGeometryProcessor->color() != color) {
567 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; 569 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType;
568 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(c olor, flags)); 570 fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(c olor, flags));
569 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur rTexture, 571 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCur rTexture,
570 SkMa trix::I(), 572 SkMa trix::I(),
571 para ms)); 573 para ms));
574 fEffectTextureUniqueID = textureUniqueID;
572 } 575 }
573 drawState.addColorProcessor(fCachedTextureProcessor.get()); 576 drawState.addColorProcessor(fCachedTextureProcessor.get());
574 } else { 577 } else {
575 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); 578 uint32_t textureUniqueID = fCurrTexture->getUniqueID();
576 if (textureUniqueID != fEffectTextureUniqueID || 579 if (textureUniqueID != fEffectTextureUniqueID ||
577 fCachedGeometryProcessor->color() != color) { 580 fCachedGeometryProcessor->color() != color ||
581 !fCachedGeometryProcessor->localMatrix().cheapEqualTo(fLocalMatr ix)) {
578 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; 582 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat;
579 bool opaqueVertexColors = GrColorIsOpaque(fPaint.getColor()); 583 bool opaqueVertexColors = GrColorIsOpaque(fPaint.getColor());
580 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color , 584 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color ,
581 fCurr Texture, 585 fCurr Texture,
582 param s, 586 param s,
583 hasCo lor, 587 hasCo lor,
584 opaqu eVertexColors)); 588 opaqu eVertexColors,
589 fLoca lMatrix));
585 fEffectTextureUniqueID = textureUniqueID; 590 fEffectTextureUniqueID = textureUniqueID;
586 } 591 }
587 } 592 }
588 593
589 int nGlyphs = fCurrVertex / kVerticesPerGlyph; 594 int nGlyphs = fCurrVertex / kVerticesPerGlyph;
590 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); 595 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
591 fDrawTarget->drawIndexedInstances(&drawState, 596 fDrawTarget->drawIndexedInstances(&drawState,
592 fCachedGeometryProcessor.get(), 597 fCachedGeometryProcessor.get(),
593 kTriangles_GrPrimitiveType, 598 kTriangles_GrPrimitiveType,
594 nGlyphs, 599 nGlyphs,
(...skipping 12 matching lines...) Expand all
607 } 612 }
608 } 613 }
609 614
610 inline void GrBitmapTextContext::finish() { 615 inline void GrBitmapTextContext::finish() {
611 this->flush(); 616 this->flush();
612 fTotalVertexCount = 0; 617 fTotalVertexCount = 0;
613 618
614 GrTextContext::finish(); 619 GrTextContext::finish();
615 } 620 }
616 621
OLDNEW
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698