OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "ChromiumBridge.h" | 29 #include "ChromiumBridge.h" |
30 #include "Font.h" | 30 #include "Font.h" |
31 #include "FontFallbackList.h" | 31 #include "FontFallbackList.h" |
32 #include "GlyphBuffer.h" | 32 #include "GlyphBuffer.h" |
33 #include "PlatformContextSkia.h" | 33 #include "PlatformContextSkia.h" |
34 #include "SimpleFontData.h" | 34 #include "SimpleFontData.h" |
35 #include "SkiaUtils.h" | 35 #include "SkiaUtils.h" |
36 #include "UniscribeHelperTextRun.h" | 36 #include "UniscribeHelperTextRun.h" |
37 | 37 |
38 #include "base/gfx/skia_utils.h" // TODO(brettw) remove this dependency. | |
39 #include "skia/ext/platform_canvas_win.h" | 38 #include "skia/ext/platform_canvas_win.h" |
| 39 #include "skia/ext/skia_utils_win.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 void Font::drawGlyphs(GraphicsContext* graphicsContext, | 43 void Font::drawGlyphs(GraphicsContext* graphicsContext, |
44 const SimpleFontData* font, | 44 const SimpleFontData* font, |
45 const GlyphBuffer& glyphBuffer, | 45 const GlyphBuffer& glyphBuffer, |
46 int from, | 46 int from, |
47 int numGlyphs, | 47 int numGlyphs, |
48 const FloatPoint& point) const | 48 const FloatPoint& point) const |
49 { | 49 { |
(...skipping 12 matching lines...) Expand all Loading... |
62 | 62 |
63 // Set up our graphics context. | 63 // Set up our graphics context. |
64 HDC hdc = context->canvas()->beginPlatformPaint(); | 64 HDC hdc = context->canvas()->beginPlatformPaint(); |
65 HGDIOBJ oldFont = SelectObject(hdc, font->platformData().hfont()); | 65 HGDIOBJ oldFont = SelectObject(hdc, font->platformData().hfont()); |
66 | 66 |
67 // TODO(maruel): http://b/700464 SetTextColor doesn't support transparency. | 67 // TODO(maruel): http://b/700464 SetTextColor doesn't support transparency. |
68 // Enforce non-transparent color. | 68 // Enforce non-transparent color. |
69 color = SkColorSetRGB(SkColorGetR(color), | 69 color = SkColorSetRGB(SkColorGetR(color), |
70 SkColorGetG(color), | 70 SkColorGetG(color), |
71 SkColorGetB(color)); | 71 SkColorGetB(color)); |
72 SetTextColor(hdc, gfx::SkColorToCOLORREF(color)); | 72 SetTextColor(hdc, skia::SkColorToCOLORREF(color)); |
73 SetBkMode(hdc, TRANSPARENT); | 73 SetBkMode(hdc, TRANSPARENT); |
74 | 74 |
75 // Windows needs the characters and the advances in nice contiguous | 75 // Windows needs the characters and the advances in nice contiguous |
76 // buffers, which we build here. | 76 // buffers, which we build here. |
77 Vector<WORD, kDefaultBufferLength> glyphs; | 77 Vector<WORD, kDefaultBufferLength> glyphs; |
78 Vector<int, kDefaultBufferLength> advances; | 78 Vector<int, kDefaultBufferLength> advances; |
79 | 79 |
80 // Compute the coordinate. The 'origin' represents the baseline, so we need | 80 // Compute the coordinate. The 'origin' represents the baseline, so we need |
81 // to move it up to the top of the bounding square. | 81 // to move it up to the top of the bounding square. |
82 int x = static_cast<int>(point.x()); | 82 int x = static_cast<int>(point.x()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 if (!alpha) | 161 if (!alpha) |
162 return; | 162 return; |
163 | 163 |
164 HDC hdc = context->canvas()->beginPlatformPaint(); | 164 HDC hdc = context->canvas()->beginPlatformPaint(); |
165 | 165 |
166 // TODO(maruel): http://b/700464 SetTextColor doesn't support transparency. | 166 // TODO(maruel): http://b/700464 SetTextColor doesn't support transparency. |
167 // Enforce non-transparent color. | 167 // Enforce non-transparent color. |
168 color = SkColorSetRGB(SkColorGetR(color), | 168 color = SkColorSetRGB(SkColorGetR(color), |
169 SkColorGetG(color), | 169 SkColorGetG(color), |
170 SkColorGetB(color)); | 170 SkColorGetB(color)); |
171 SetTextColor(hdc, gfx::SkColorToCOLORREF(color)); | 171 SetTextColor(hdc, skia::SkColorToCOLORREF(color)); |
172 SetBkMode(hdc, TRANSPARENT); | 172 SetBkMode(hdc, TRANSPARENT); |
173 | 173 |
174 // Uniscribe counts the coordinates from the upper left, while WebKit uses | 174 // Uniscribe counts the coordinates from the upper left, while WebKit uses |
175 // the baseline, so we have to subtract off the ascent. | 175 // the baseline, so we have to subtract off the ascent. |
176 state.Draw(hdc, | 176 state.Draw(hdc, |
177 static_cast<int>(point.x()), | 177 static_cast<int>(point.x()), |
178 static_cast<int>(point.y() - ascent()), | 178 static_cast<int>(point.y() - ascent()), |
179 from, | 179 from, |
180 to); | 180 to); |
181 context->canvas()->endPlatformPaint(); | 181 context->canvas()->endPlatformPaint(); |
(...skipping 14 matching lines...) Expand all Loading... |
196 int char_index = state.XToCharacter(x); | 196 int char_index = state.XToCharacter(x); |
197 | 197 |
198 // XToCharacter will return -1 if the position is before the first | 198 // XToCharacter will return -1 if the position is before the first |
199 // character (we get called like this sometimes). | 199 // character (we get called like this sometimes). |
200 if (char_index < 0) | 200 if (char_index < 0) |
201 char_index = 0; | 201 char_index = 0; |
202 return char_index; | 202 return char_index; |
203 } | 203 } |
204 | 204 |
205 } // namespace WebCore | 205 } // namespace WebCore |
OLD | NEW |