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

Side by Side Diff: Source/core/platform/graphics/skia/FontSkia.cpp

Issue 14160005: Track the region where text is painted. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase with TOT Created 7 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 | 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 if (font->fontDescription().textRenderingMode() == GeometricPrecision) 83 if (font->fontDescription().textRenderingMode() == GeometricPrecision)
84 paint->setHinting(SkPaint::kNo_Hinting); 84 paint->setHinting(SkPaint::kNo_Hinting);
85 } 85 }
86 86
87 // TODO: This needs to be split into helper functions to better scope the 87 // TODO: This needs to be split into helper functions to better scope the
88 // inputs/outputs, and reduce duplicate code. 88 // inputs/outputs, and reduce duplicate code.
89 // This issue is tracked in https://bugs.webkit.org/show_bug.cgi?id=62989 89 // This issue is tracked in https://bugs.webkit.org/show_bug.cgi?id=62989
90 void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, 90 void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
91 const GlyphBuffer& glyphBuffer, int from, int numGlyphs, 91 const GlyphBuffer& glyphBuffer, int from, int numGlyphs,
92 const FloatPoint& point) const { 92 const FloatPoint& point, const FloatRect& textRect) const {
93 COMPILE_ASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t), GlyphBufferGlyp hSize_equals_uint16_t); 93 COMPILE_ASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t), GlyphBufferGlyp hSize_equals_uint16_t);
94 94
95 bool shouldSmoothFonts = true; 95 bool shouldSmoothFonts = true;
96 bool shouldAntialias = true; 96 bool shouldAntialias = true;
97 97
98 switch (fontDescription().fontSmoothing()) { 98 switch (fontDescription().fontSmoothing()) {
99 case Antialiased: 99 case Antialiased:
100 shouldSmoothFonts = false; 100 shouldSmoothFonts = false;
101 break; 101 break;
102 case SubpixelAntialiased: 102 case SubpixelAntialiased:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 TextDrawingModeFlags textMode = gc->platformContext()->getTextDrawingMode(); 147 TextDrawingModeFlags textMode = gc->platformContext()->getTextDrawingMode();
148 148
149 // We draw text up to two times (once for fill, once for stroke). 149 // We draw text up to two times (once for fill, once for stroke).
150 if (textMode & TextModeFill) { 150 if (textMode & TextModeFill) {
151 SkPaint paint; 151 SkPaint paint;
152 gc->platformContext()->setupPaintForFilling(&paint); 152 gc->platformContext()->setupPaintForFilling(&paint);
153 setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts); 153 setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts);
154 gc->platformContext()->adjustTextRenderMode(&paint); 154 gc->platformContext()->adjustTextRenderMode(&paint);
155 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 155 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
156 156
157 platformContext->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint); 157 platformContext->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, textRect, paint);
158 } 158 }
159 159
160 if ((textMode & TextModeStroke) 160 if ((textMode & TextModeStroke)
161 && gc->platformContext()->getStrokeStyle() != NoStroke 161 && gc->platformContext()->getStrokeStyle() != NoStroke
162 && gc->platformContext()->getStrokeThickness() > 0) { 162 && gc->platformContext()->getStrokeThickness() > 0) {
163 163
164 SkPaint paint; 164 SkPaint paint;
165 gc->platformContext()->setupPaintForStroking(&paint, 0, 0); 165 gc->platformContext()->setupPaintForStroking(&paint, 0, 0);
166 setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts); 166 setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts);
167 gc->platformContext()->adjustTextRenderMode(&paint); 167 gc->platformContext()->adjustTextRenderMode(&paint);
168 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 168 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
169 169
170 if (textMode & TextModeFill) { 170 if (textMode & TextModeFill) {
171 // If we also filled, we don't want to draw shadows twice. 171 // If we also filled, we don't want to draw shadows twice.
172 // See comment in FontChromiumWin.cpp::paintSkiaText() for more deta ils. 172 // See comment in FontChromiumWin.cpp::paintSkiaText() for more deta ils.
173 paint.setLooper(0); 173 paint.setLooper(0);
174 } 174 }
175 175
176 platformContext->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint); 176 platformContext->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, textRect, paint);
177 } 177 }
178 if (font->platformData().orientation() == Vertical) 178 if (font->platformData().orientation() == Vertical)
179 platformContext->restore(); 179 platformContext->restore();
180 } 180 }
181 181
182 } // namespace WebCore 182 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698