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

Side by Side Diff: Source/WebKit/chromium/src/WebFontImpl.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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 { 95 {
96 FontCachePurgePreventer fontCachePurgePreventer; 96 FontCachePurgePreventer fontCachePurgePreventer;
97 97
98 GraphicsContextBuilder builder(canvas); 98 GraphicsContextBuilder builder(canvas);
99 GraphicsContext& gc = builder.context(); 99 GraphicsContext& gc = builder.context();
100 100
101 gc.save(); 101 gc.save();
102 gc.setShouldSmoothFonts(canvasIsOpaque); 102 gc.setShouldSmoothFonts(canvasIsOpaque);
103 gc.setFillColor(color, ColorSpaceDeviceRGB); 103 gc.setFillColor(color, ColorSpaceDeviceRGB);
104 gc.clip(WebCore::FloatRect(clip)); 104 gc.clip(WebCore::FloatRect(clip));
105 m_font.drawText(&gc, run, leftBaseline, from, to); 105 m_font.drawText(&gc, run, leftBaseline, WebCore::FloatRect(clip), from, to);
eseidel 2013/04/18 21:04:38 nit: Seems like a local would be useful. We do th
alokp 2013/04/18 22:22:37 Done.
106 gc.restore(); 106 gc.restore();
107 107
108 #if defined(WIN32) 108 #if defined(WIN32)
109 if (canvasIsOpaque && SkColorGetA(color) == 0xFF && !canvas->isDrawingToLaye r()) { 109 if (canvasIsOpaque && SkColorGetA(color) == 0xFF && !canvas->isDrawingToLaye r()) {
110 // The text drawing logic on Windows ignores the alpha component 110 // The text drawing logic on Windows ignores the alpha component
111 // intentionally, for performance reasons. 111 // intentionally, for performance reasons.
112 // (Please see TransparencyAwareFontPainter::initializeForGDI in 112 // (Please see TransparencyAwareFontPainter::initializeForGDI in
113 // FontChromiumWin.cpp.) 113 // FontChromiumWin.cpp.)
114 const SkBitmap& bitmap = canvas->getTopDevice()->accessBitmap(true); 114 const SkBitmap& bitmap = canvas->getTopDevice()->accessBitmap(true);
115 IntRect textBounds = estimateTextBounds(run, leftBaseline); 115 IntRect textBounds = estimateTextBounds(run, leftBaseline);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 FontCachePurgePreventer fontCachePurgePreventer; 147 FontCachePurgePreventer fontCachePurgePreventer;
148 int totalWidth = m_font.width(run, 0); 148 int totalWidth = m_font.width(run, 0);
149 const WebCore::FontMetrics& fontMetrics = m_font.fontMetrics(); 149 const WebCore::FontMetrics& fontMetrics = m_font.fontMetrics();
150 return WebRect(leftBaseline.x - (fontMetrics.ascent() + fontMetrics.descent( )) / 2, 150 return WebRect(leftBaseline.x - (fontMetrics.ascent() + fontMetrics.descent( )) / 2,
151 leftBaseline.y - fontMetrics.ascent() - fontMetrics.lineGap() , 151 leftBaseline.y - fontMetrics.ascent() - fontMetrics.lineGap() ,
152 totalWidth + fontMetrics.ascent() + fontMetrics.descent(), 152 totalWidth + fontMetrics.ascent() + fontMetrics.descent(),
153 fontMetrics.lineSpacing()); 153 fontMetrics.lineSpacing());
154 } 154 }
155 155
156 } // namespace WebKit 156 } // namespace WebKit
OLDNEW
« no previous file with comments | « no previous file | Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp » ('j') | Source/core/platform/graphics/Font.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698