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

Side by Side Diff: Source/WebKit/chromium/src/WebFontImpl.cpp

Issue 14707008: Remove WebKit::GraphicsContextBuilder, which was trivial. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Undo whitespace change 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
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 21 matching lines...) Expand all
32 #include "WebFontImpl.h" 32 #include "WebFontImpl.h"
33 33
34 #include <skia/ext/platform_canvas.h> 34 #include <skia/ext/platform_canvas.h>
35 #include "WebFontDescription.h" 35 #include "WebFontDescription.h"
36 #include "WebTextRun.h" 36 #include "WebTextRun.h"
37 #include "core/platform/graphics/Font.h" 37 #include "core/platform/graphics/Font.h"
38 #include "core/platform/graphics/FontCache.h" 38 #include "core/platform/graphics/FontCache.h"
39 #include "core/platform/graphics/FontDescription.h" 39 #include "core/platform/graphics/FontDescription.h"
40 #include "core/platform/graphics/GraphicsContext.h" 40 #include "core/platform/graphics/GraphicsContext.h"
41 #include "core/platform/graphics/TextRun.h" 41 #include "core/platform/graphics/TextRun.h"
42 #include "painting/GraphicsContextBuilder.h"
43 #include <public/WebFloatPoint.h> 42 #include <public/WebFloatPoint.h>
44 #include <public/WebFloatRect.h> 43 #include <public/WebFloatRect.h>
45 #include <public/WebRect.h> 44 #include <public/WebRect.h>
46 45
47 using namespace WebCore; 46 using namespace WebCore;
48 47
49 namespace WebKit { 48 namespace WebKit {
50 49
51 WebFont* WebFont::create(const WebFontDescription& desc) 50 WebFont* WebFont::create(const WebFontDescription& desc)
52 { 51 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 float WebFontImpl::xHeight() const 86 float WebFontImpl::xHeight() const
88 { 87 {
89 return m_font.fontMetrics().xHeight(); 88 return m_font.fontMetrics().xHeight();
90 } 89 }
91 90
92 void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFl oatPoint& leftBaseline, 91 void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFl oatPoint& leftBaseline,
93 WebColor color, const WebRect& clip, bool canvasIsOpa que, 92 WebColor color, const WebRect& clip, bool canvasIsOpa que,
94 int from, int to) const 93 int from, int to) const
95 { 94 {
96 FontCachePurgePreventer fontCachePurgePreventer; 95 FontCachePurgePreventer fontCachePurgePreventer;
97 96 GraphicsContext gc(canvas);
98 GraphicsContextBuilder builder(canvas);
99 GraphicsContext& gc = builder.context();
100 97
101 gc.save(); 98 gc.save();
102 gc.setShouldSmoothFonts(canvasIsOpaque); 99 gc.setShouldSmoothFonts(canvasIsOpaque);
103 gc.setFillColor(color, ColorSpaceDeviceRGB); 100 gc.setFillColor(color, ColorSpaceDeviceRGB);
104 gc.clip(WebCore::FloatRect(clip)); 101 gc.clip(WebCore::FloatRect(clip));
105 m_font.drawText(&gc, run, leftBaseline, from, to); 102 m_font.drawText(&gc, run, leftBaseline, from, to);
106 gc.restore(); 103 gc.restore();
107 104
108 #if defined(WIN32) 105 #if defined(WIN32)
109 if (canvasIsOpaque && SkColorGetA(color) == 0xFF && !canvas->isDrawingToLaye r()) { 106 if (canvasIsOpaque && SkColorGetA(color) == 0xFF && !canvas->isDrawingToLaye r()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 FontCachePurgePreventer fontCachePurgePreventer; 144 FontCachePurgePreventer fontCachePurgePreventer;
148 int totalWidth = m_font.width(run, 0); 145 int totalWidth = m_font.width(run, 0);
149 const WebCore::FontMetrics& fontMetrics = m_font.fontMetrics(); 146 const WebCore::FontMetrics& fontMetrics = m_font.fontMetrics();
150 return WebRect(leftBaseline.x - (fontMetrics.ascent() + fontMetrics.descent( )) / 2, 147 return WebRect(leftBaseline.x - (fontMetrics.ascent() + fontMetrics.descent( )) / 2,
151 leftBaseline.y - fontMetrics.ascent() - fontMetrics.lineGap() , 148 leftBaseline.y - fontMetrics.ascent() - fontMetrics.lineGap() ,
152 totalWidth + fontMetrics.ascent() + fontMetrics.descent(), 149 totalWidth + fontMetrics.ascent() + fontMetrics.descent(),
153 fontMetrics.lineSpacing()); 150 fontMetrics.lineSpacing());
154 } 151 }
155 152
156 } // namespace WebKit 153 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/PageWidgetDelegate.cpp ('k') | Source/WebKit/chromium/src/WebFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698