OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/canvas_skia.h" | 5 #include "ui/gfx/canvas_skia.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include <cairo/cairo.h> | 9 #include <cairo/cairo.h> |
10 #include <pango/pango.h> | 10 #include <pango/pango.h> |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 void DrawStringContext::Draw(const SkColor& text_color) { | 109 void DrawStringContext::Draw(const SkColor& text_color) { |
110 DrawPangoLayout(cr_, layout_, font_, bounds_, text_rect_, text_color, | 110 DrawPangoLayout(cr_, layout_, font_, bounds_, text_rect_, text_color, |
111 text_direction_, flags_); | 111 text_direction_, flags_); |
112 } | 112 } |
113 | 113 |
114 void DrawStringContext::DrawWithHalo(const SkColor& text_color, | 114 void DrawStringContext::DrawWithHalo(const SkColor& text_color, |
115 const SkColor& halo_color) { | 115 const SkColor& halo_color) { |
116 gfx::Size size(bounds_.width() + 2, bounds_.height() + 2); | 116 gfx::Size size(bounds_.width() + 2, bounds_.height() + 2); |
117 gfx::CanvasSkia text_canvas(size, false); | 117 gfx::CanvasSkia text_canvas(size, false); |
118 text_canvas.FillRect(static_cast<SkColor>(0), gfx::Rect(gfx::Point(), size)); | 118 text_canvas.FillRect(gfx::Rect(gfx::Point(), size), static_cast<SkColor>(0)); |
119 | 119 |
120 { | 120 { |
121 skia::ScopedPlatformPaint scoped_platform_paint(text_canvas.sk_canvas()); | 121 skia::ScopedPlatformPaint scoped_platform_paint(text_canvas.sk_canvas()); |
122 cairo_t* text_cr = scoped_platform_paint.GetPlatformSurface(); | 122 cairo_t* text_cr = scoped_platform_paint.GetPlatformSurface(); |
123 | 123 |
124 // TODO: The current approach (stroking the text path to generate the halo | 124 // TODO: The current approach (stroking the text path to generate the halo |
125 // and then filling it for the main text) won't work if |text_color| is | 125 // and then filling it for the main text) won't work if |text_color| is |
126 // non-opaque. If we need to do this at some later point, | 126 // non-opaque. If we need to do this at some later point, |
127 // http://lists.freedesktop.org/archives/cairo/2004-September/001829.html | 127 // http://lists.freedesktop.org/archives/cairo/2004-September/001829.html |
128 // suggests "do[ing] the stroke and fill with opaque paint onto an | 128 // suggests "do[ing] the stroke and fill with opaque paint onto an |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 int flags) { | 253 int flags) { |
254 if (!IntersectsClipRectInt(x, y, w, h)) | 254 if (!IntersectsClipRectInt(x, y, w, h)) |
255 return; | 255 return; |
256 | 256 |
257 gfx::Rect bounds(x, y, w, h); | 257 gfx::Rect bounds(x, y, w, h); |
258 DrawStringContext context(this, text, font, bounds, bounds, flags); | 258 DrawStringContext context(this, text, font, bounds, bounds, flags); |
259 context.Draw(color); | 259 context.Draw(color); |
260 } | 260 } |
261 | 261 |
262 } // namespace gfx | 262 } // namespace gfx |
OLD | NEW |