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

Side by Side Diff: Source/platform/fonts/Font.cpp

Issue 692643006: Restore webkit-font-smoothing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Actually suppress flaky tests. Created 6 years, 1 month 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 | « Source/platform/fonts/Font.h ('k') | Source/platform/fonts/FontPlatformData.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 (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 return 0; 742 return 0;
743 743
744 const SimpleFontData* markFontData = markGlyphData.fontData; 744 const SimpleFontData* markFontData = markGlyphData.fontData;
745 ASSERT(markFontData); 745 ASSERT(markFontData);
746 if (!markFontData) 746 if (!markFontData)
747 return 0; 747 return 0;
748 748
749 return markFontData->fontMetrics().height(); 749 return markFontData->fontMetrics().height();
750 } 750 }
751 751
752 static SkPaint textFillPaint(GraphicsContext* gc, const SimpleFontData* font) 752 SkPaint Font::textFillPaint(GraphicsContext* gc, const SimpleFontData* font) con st
753 { 753 {
754 SkPaint paint = gc->fillPaint(); 754 SkPaint paint = gc->fillPaint();
755 font->platformData().setupPaint(&paint, gc); 755 font->platformData().setupPaint(&paint, gc, this);
756 gc->adjustTextRenderMode(&paint); 756 gc->adjustTextRenderMode(&paint);
757 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 757 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
758 return paint; 758 return paint;
759 } 759 }
760 760
761 static SkPaint textStrokePaint(GraphicsContext* gc, const SimpleFontData* font, bool isFilling) 761 SkPaint Font::textStrokePaint(GraphicsContext* gc, const SimpleFontData* font, b ool isFilling) const
762 { 762 {
763 SkPaint paint = gc->strokePaint(); 763 SkPaint paint = gc->strokePaint();
764 font->platformData().setupPaint(&paint, gc); 764 font->platformData().setupPaint(&paint, gc, this);
765 gc->adjustTextRenderMode(&paint); 765 gc->adjustTextRenderMode(&paint);
766 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 766 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
767 if (isFilling) { 767 if (isFilling) {
768 // If there is a shadow and we filled above, there will already be 768 // If there is a shadow and we filled above, there will already be
769 // a shadow. We don't want to draw it again or it will be too dark 769 // a shadow. We don't want to draw it again or it will be too dark
770 // and it will go on top of the fill. 770 // and it will go on top of the fill.
771 // 771 //
772 // Note that this isn't strictly correct, since the stroke could be 772 // Note that this isn't strictly correct, since the stroke could be
773 // very thick and the shadow wouldn't account for this. The "right" 773 // very thick and the shadow wouldn't account for this. The "right"
774 // thing would be to draw to a new layer and then draw that layer 774 // thing would be to draw to a new layer and then draw that layer
775 // with a shadow. But this is a lot of extra work for something 775 // with a shadow. But this is a lot of extra work for something
776 // that isn't normally an issue. 776 // that isn't normally an issue.
777 paint.setLooper(0); 777 paint.setLooper(0);
778 } 778 }
779 return paint; 779 return paint;
780 } 780 }
781 781
782 static void paintGlyphs(GraphicsContext* gc, const SimpleFontData* font, 782 void Font::paintGlyphs(GraphicsContext* gc, const SimpleFontData* font,
783 const Glyph glyphs[], unsigned numGlyphs, 783 const Glyph glyphs[], unsigned numGlyphs,
784 const SkPoint pos[], const FloatRect& textRect) 784 const SkPoint pos[], const FloatRect& textRect) const
785 { 785 {
786 TextDrawingModeFlags textMode = gc->textDrawingMode(); 786 TextDrawingModeFlags textMode = gc->textDrawingMode();
787 787
788 // We draw text up to two times (once for fill, once for stroke). 788 // We draw text up to two times (once for fill, once for stroke).
789 if (textMode & TextModeFill) { 789 if (textMode & TextModeFill) {
790 SkPaint paint = textFillPaint(gc, font); 790 SkPaint paint = textFillPaint(gc, font);
791 gc->drawPosText(glyphs, numGlyphs * sizeof(Glyph), pos, textRect, paint) ; 791 gc->drawPosText(glyphs, numGlyphs * sizeof(Glyph), pos, textRect, paint) ;
792 } 792 }
793 793
794 if ((textMode & TextModeStroke) && gc->hasStroke()) { 794 if ((textMode & TextModeStroke) && gc->hasStroke()) {
795 SkPaint paint = textStrokePaint(gc, font, textMode & TextModeFill); 795 SkPaint paint = textStrokePaint(gc, font, textMode & TextModeFill);
796 gc->drawPosText(glyphs, numGlyphs * sizeof(Glyph), pos, textRect, paint) ; 796 gc->drawPosText(glyphs, numGlyphs * sizeof(Glyph), pos, textRect, paint) ;
797 } 797 }
798 } 798 }
799 799
800 static void paintGlyphsHorizontal(GraphicsContext* gc, const SimpleFontData* fon t, 800 void Font::paintGlyphsHorizontal(GraphicsContext* gc, const SimpleFontData* font ,
801 const Glyph glyphs[], unsigned numGlyphs, 801 const Glyph glyphs[], unsigned numGlyphs,
802 const SkScalar xpos[], SkScalar constY, const FloatRect& textRect) 802 const SkScalar xpos[], SkScalar constY, const FloatRect& textRect) const
803 { 803 {
804 TextDrawingModeFlags textMode = gc->textDrawingMode(); 804 TextDrawingModeFlags textMode = gc->textDrawingMode();
805 805
806 if (textMode & TextModeFill) { 806 if (textMode & TextModeFill) {
807 SkPaint paint = textFillPaint(gc, font); 807 SkPaint paint = textFillPaint(gc, font);
808 gc->drawPosTextH(glyphs, numGlyphs * sizeof(Glyph), xpos, constY, textRe ct, paint); 808 gc->drawPosTextH(glyphs, numGlyphs * sizeof(Glyph), xpos, constY, textRe ct, paint);
809 } 809 }
810 810
811 if ((textMode & TextModeStroke) && gc->hasStroke()) { 811 if ((textMode & TextModeStroke) && gc->hasStroke()) {
812 SkPaint paint = textStrokePaint(gc, font, textMode & TextModeFill); 812 SkPaint paint = textStrokePaint(gc, font, textMode & TextModeFill);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 if (delta <= 0) 1096 if (delta <= 0)
1097 break; 1097 break;
1098 } 1098 }
1099 } 1099 }
1100 } 1100 }
1101 1101
1102 return offset; 1102 return offset;
1103 } 1103 }
1104 1104
1105 } // namespace blink 1105 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/Font.h ('k') | Source/platform/fonts/FontPlatformData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698