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

Side by Side Diff: Source/core/platform/graphics/mac/FontMac.cpp

Issue 14160005: Track the region where text is painted. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed build on win and mac Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 Google Inc. All rights reserved. 2 * Copyright (c) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 if (font->fontDescription().textRenderingMode() == GeometricPrecision) 82 if (font->fontDescription().textRenderingMode() == GeometricPrecision)
83 paint->setHinting(SkPaint::kNo_Hinting); 83 paint->setHinting(SkPaint::kNo_Hinting);
84 } 84 }
85 85
86 // TODO: This needs to be split into helper functions to better scope the 86 // TODO: This needs to be split into helper functions to better scope the
87 // inputs/outputs, and reduce duplicate code. 87 // inputs/outputs, and reduce duplicate code.
88 // This issue is tracked in https://bugs.webkit.org/show_bug.cgi?id=62989 88 // This issue is tracked in https://bugs.webkit.org/show_bug.cgi?id=62989
89 void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, 89 void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
90 const GlyphBuffer& glyphBuffer, int from, int numGlyphs, 90 const GlyphBuffer& glyphBuffer, int from, int numGlyphs,
91 const FloatPoint& point) const { 91 const FloatPoint& point, const FloatRect& textRect) const {
92 COMPILE_ASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t), GlyphBufferGlyp hSize_equals_uint16_t); 92 COMPILE_ASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t), GlyphBufferGlyp hSize_equals_uint16_t);
93 93
94 bool shouldSmoothFonts = true; 94 bool shouldSmoothFonts = true;
95 bool shouldAntialias = true; 95 bool shouldAntialias = true;
96 96
97 switch (fontDescription().fontSmoothing()) { 97 switch (fontDescription().fontSmoothing()) {
98 case Antialiased: 98 case Antialiased:
99 shouldSmoothFonts = false; 99 shouldSmoothFonts = false;
100 break; 100 break;
101 case SubpixelAntialiased: 101 case SubpixelAntialiased:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 TextDrawingModeFlags textMode = gc->textDrawingModeSkia(); 145 TextDrawingModeFlags textMode = gc->textDrawingModeSkia();
146 146
147 // We draw text up to two times (once for fill, once for stroke). 147 // We draw text up to two times (once for fill, once for stroke).
148 if (textMode & TextModeFill) { 148 if (textMode & TextModeFill) {
149 SkPaint paint; 149 SkPaint paint;
150 gc->setupPaintForFilling(&paint); 150 gc->setupPaintForFilling(&paint);
151 setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts); 151 setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts);
152 gc->adjustTextRenderMode(&paint); 152 gc->adjustTextRenderMode(&paint);
153 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 153 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
154 154
155 gc->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint); 155 gc->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, textRect, pai nt);
156 } 156 }
157 157
158 if ((textMode & TextModeStroke) 158 if ((textMode & TextModeStroke)
159 && gc->strokeStyleSkia() != NoStroke 159 && gc->strokeStyleSkia() != NoStroke
160 && gc->strokeThicknessSkia() > 0) { 160 && gc->strokeThicknessSkia() > 0) {
161 161
162 SkPaint paint; 162 SkPaint paint;
163 gc->setupPaintForStroking(&paint, 0, 0); 163 gc->setupPaintForStroking(&paint, 0, 0);
164 setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts); 164 setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts);
165 gc->adjustTextRenderMode(&paint); 165 gc->adjustTextRenderMode(&paint);
166 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 166 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
167 167
168 if (textMode & TextModeFill) { 168 if (textMode & TextModeFill) {
169 // If we also filled, we don't want to draw shadows twice. 169 // If we also filled, we don't want to draw shadows twice.
170 // See comment in FontChromiumWin.cpp::paintSkiaText() for more deta ils. 170 // See comment in FontChromiumWin.cpp::paintSkiaText() for more deta ils.
171 paint.setLooper(0); 171 paint.setLooper(0);
172 } 172 }
173 173
174 gc->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint); 174 gc->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, textRect, pai nt);
175 } 175 }
176 if (font->platformData().orientation() == Vertical) 176 if (font->platformData().orientation() == Vertical)
177 gc->restore(); 177 gc->restore();
178 } 178 }
179 179
180 } // namespace WebCore 180 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/mac/FontComplexTextMac.cpp ('k') | Source/core/platform/graphics/skia/SkiaFontWin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698