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

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

Issue 1082913006: Real fix for the Mali bug. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | src/gpu/effects/GrDistanceFieldGeoProc.h » ('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 "GrDistanceFieldTextContext.h" 8 #include "GrDistanceFieldTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrAtlasTextContext.h" 10 #include "GrAtlasTextContext.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 fPaint.setColor(GrColorPackRGBA(0x7F, 0x00, 0x00, 0xFF)); 264 fPaint.setColor(GrColorPackRGBA(0x7F, 0x00, 0x00, 0xFF));
265 #endif 265 #endif
266 } 266 }
267 267
268 fUseLCDText = fSkPaint.isLCDRenderText(); 268 fUseLCDText = fSkPaint.isLCDRenderText();
269 269
270 fSkPaint.setLCDRenderText(false); 270 fSkPaint.setLCDRenderText(false);
271 fSkPaint.setAutohinted(false); 271 fSkPaint.setAutohinted(false);
272 fSkPaint.setHinting(SkPaint::kNormal_Hinting); 272 fSkPaint.setHinting(SkPaint::kNormal_Hinting);
273 fSkPaint.setSubpixelText(true); 273 fSkPaint.setSubpixelText(true);
274
275 // fix for skia:3528
276 // if we're scaling up, include any scaling to match text size in the view m atrix
277 if (fTextRatio > 1.0f) {
278 fViewMatrix.preScale(fTextRatio, fTextRatio);
279 }
280 } 274 }
281 275
282 void GrDistanceFieldTextContext::onDrawText(GrRenderTarget* rt, const GrClip& cl ip, 276 void GrDistanceFieldTextContext::onDrawText(GrRenderTarget* rt, const GrClip& cl ip,
283 const GrPaint& paint, 277 const GrPaint& paint,
284 const SkPaint& skPaint, const SkMatr ix& viewMatrix, 278 const SkPaint& skPaint, const SkMatr ix& viewMatrix,
285 const char text[], size_t byteLength , 279 const char text[], size_t byteLength ,
286 SkScalar x, SkScalar y, 280 SkScalar x, SkScalar y,
287 const SkIRect& regionClipBounds) { 281 const SkIRect& regionClipBounds) {
288 SkASSERT(byteLength == 0 || text != NULL); 282 SkASSERT(byteLength == 0 || text != NULL);
289 283
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 477
484 // set up any flags 478 // set up any flags
485 uint32_t flags = 0; 479 uint32_t flags = 0;
486 flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; 480 flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
487 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; 481 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0;
488 flags |= fUseLCDText && ctm.rectStaysRect() ? 482 flags |= fUseLCDText && ctm.rectStaysRect() ?
489 kRectToRect_DistanceFieldEffectFlag : 0; 483 kRectToRect_DistanceFieldEffectFlag : 0;
490 bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.pixelGeometry()); 484 bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.pixelGeometry());
491 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0; 485 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0;
492 486
493 // fix for skia:3528
494 // set the local matrix to correct any text size scaling for gradients et al .
495 SkMatrix localMatrix;
496 if (fTextRatio > 1.0f) {
497 localMatrix.setScale(fTextRatio, fTextRatio);
498 } else {
499 localMatrix.reset();
500 }
501
502 // see if we need to create a new effect 487 // see if we need to create a new effect
503 if (textureUniqueID != fEffectTextureUniqueID || 488 if (textureUniqueID != fEffectTextureUniqueID ||
504 filteredColor != fEffectColor || 489 filteredColor != fEffectColor ||
505 flags != fEffectFlags || 490 flags != fEffectFlags ||
506 !fCachedGeometryProcessor->viewMatrix().cheapEqualTo(fViewMatrix) || 491 !fCachedGeometryProcessor->viewMatrix().cheapEqualTo(fViewMatrix)) {
507 !fCachedGeometryProcessor->localMatrix().cheapEqualTo(localMatrix)) {
508 GrColor color = fPaint.getColor(); 492 GrColor color = fPaint.getColor();
509 493
510 if (fUseLCDText) { 494 if (fUseLCDText) {
511 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or); 495 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or);
512 496
513 float redCorrection = 497 float redCorrection =
514 fDistanceAdjustTable[GrColorUnpackR(colorNoPreMul) >> kDistanceA djustLumShift]; 498 fDistanceAdjustTable[GrColorUnpackR(colorNoPreMul) >> kDistanceA djustLumShift];
515 float greenCorrection = 499 float greenCorrection =
516 fDistanceAdjustTable[GrColorUnpackG(colorNoPreMul) >> kDistanceA djustLumShift]; 500 fDistanceAdjustTable[GrColorUnpackG(colorNoPreMul) >> kDistanceA djustLumShift];
517 float blueCorrection = 501 float blueCorrection =
518 fDistanceAdjustTable[GrColorUnpackB(colorNoPreMul) >> kDistanceA djustLumShift]; 502 fDistanceAdjustTable[GrColorUnpackB(colorNoPreMul) >> kDistanceA djustLumShift];
519 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust = 503 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
520 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrectio n, 504 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrectio n,
521 greenCorrect ion, 505 greenCorrect ion,
522 blueCorrecti on); 506 blueCorrecti on);
523 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextGeoProc::Create (color, 507 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextGeoProc::Create (color,
524 fViewMatrix, 508 fViewMatrix,
525 localMatrix,
526 fCurrTexture, 509 fCurrTexture,
527 params, 510 params,
528 widthAdjust, 511 widthAdjust,
529 flags)); 512 flags));
530 } else { 513 } else {
531 flags |= kColorAttr_DistanceFieldEffectFlag; 514 flags |= kColorAttr_DistanceFieldEffectFlag;
532 bool opaque = GrColorIsOpaque(color); 515 bool opaque = GrColorIsOpaque(color);
533 #ifdef SK_GAMMA_APPLY_TO_A8 516 #ifdef SK_GAMMA_APPLY_TO_A8
534 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie s.gamma(), 517 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie s.gamma(),
535 filteredColor); 518 filteredColor);
536 float correction = fDistanceAdjustTable[lum >> kDistanceAdjustLumShi ft]; 519 float correction = fDistanceAdjustTable[lum >> kDistanceAdjustLumShi ft];
537 fCachedGeometryProcessor.reset(GrDistanceFieldA8TextGeoProc::Create( color, 520 fCachedGeometryProcessor.reset(GrDistanceFieldA8TextGeoProc::Create( color,
538 fViewMatrix, 521 fViewMatrix,
539 localMatrix,
540 fCurrTexture, 522 fCurrTexture,
541 params, 523 params,
542 correction, 524 correction,
543 flags, 525 flags,
544 opaque)); 526 opaque));
545 #else 527 #else
546 fCachedGeometryProcessor.reset(GrDistanceFieldA8TextGeoProc::Create( color, 528 fCachedGeometryProcessor.reset(GrDistanceFieldA8TextGeoProc::Create( color,
547 fViewMatrix, 529 fViewMatrix,
548 localMatrix,
549 fCurrTexture, 530 fCurrTexture,
550 params, 531 params,
551 flags, 532 flags,
552 opaque)); 533 opaque));
553 #endif 534 #endif
554 } 535 }
555 fEffectTextureUniqueID = textureUniqueID; 536 fEffectTextureUniqueID = textureUniqueID;
556 fEffectColor = filteredColor; 537 fEffectColor = filteredColor;
557 fEffectFlags = flags; 538 fEffectFlags = flags;
558 } 539 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 if (kA8_GrMaskFormat != glyph->fMaskFormat) { 598 if (kA8_GrMaskFormat != glyph->fMaskFormat) {
618 return false; 599 return false;
619 } 600 }
620 601
621 SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft + SK_DistanceFieldInset); 602 SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft + SK_DistanceFieldInset);
622 SkScalar dy = SkIntToScalar(glyph->fBounds.fTop + SK_DistanceFieldInset); 603 SkScalar dy = SkIntToScalar(glyph->fBounds.fTop + SK_DistanceFieldInset);
623 SkScalar width = SkIntToScalar(glyph->fBounds.width() - 2*SK_DistanceFieldIn set); 604 SkScalar width = SkIntToScalar(glyph->fBounds.width() - 2*SK_DistanceFieldIn set);
624 SkScalar height = SkIntToScalar(glyph->fBounds.height() - 2*SK_DistanceField Inset); 605 SkScalar height = SkIntToScalar(glyph->fBounds.height() - 2*SK_DistanceField Inset);
625 606
626 SkScalar scale = fTextRatio; 607 SkScalar scale = fTextRatio;
627 // if we're scaling up, using fix for skia:3528 608 dx *= scale;
628 if (scale > 1.0f) { 609 dy *= scale;
629 sx /= scale; 610 width *= scale;
630 sy /= scale; 611 height *= scale;
631 } else {
632 dx *= scale;
633 dy *= scale;
634 width *= scale;
635 height *= scale;
636 }
637 sx += dx; 612 sx += dx;
638 sy += dy; 613 sy += dy;
639 SkRect glyphRect = SkRect::MakeXYWH(sx, sy, width, height); 614 SkRect glyphRect = SkRect::MakeXYWH(sx, sy, width, height);
640 615
641 // check if we clipped out 616 // check if we clipped out
642 SkRect dstRect; 617 SkRect dstRect;
643 const SkMatrix& ctm = fViewMatrix; 618 const SkMatrix& ctm = fViewMatrix;
644 (void) ctm.mapRect(&dstRect, glyphRect); 619 (void) ctm.mapRect(&dstRect, glyphRect);
645 if (fClipRect.quickReject(SkScalarTruncToInt(dstRect.left()), 620 if (fClipRect.quickReject(SkScalarTruncToInt(dstRect.left()),
646 SkScalarTruncToInt(dstRect.top()), 621 SkScalarTruncToInt(dstRect.top()),
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 } 794 }
820 } 795 }
821 796
822 inline void GrDistanceFieldTextContext::finish() { 797 inline void GrDistanceFieldTextContext::finish() {
823 this->flush(); 798 this->flush();
824 fTotalVertexCount = 0; 799 fTotalVertexCount = 0;
825 800
826 GrTextContext::finish(); 801 GrTextContext::finish();
827 } 802 }
828 803
OLDNEW
« no previous file with comments | « no previous file | src/gpu/effects/GrDistanceFieldGeoProc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698