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

Side by Side Diff: ui/gfx/canvas_linux.cc

Issue 10790128: Revert 147915 - Cleanup gfx::Canvas now that 10562027 has landed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « ui/gfx/canvas.cc ('k') | ui/gfx/canvas_skia.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "ui/gfx/canvas.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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 void DrawStringContext::Draw(SkColor text_color) { 107 void DrawStringContext::Draw(SkColor text_color) {
108 DrawPangoLayout(cr_, layout_, font_, bounds_, text_rect_, text_color, 108 DrawPangoLayout(cr_, layout_, font_, bounds_, text_rect_, text_color,
109 text_direction_, flags_); 109 text_direction_, flags_);
110 } 110 }
111 111
112 void DrawStringContext::DrawWithHalo(SkColor text_color, 112 void DrawStringContext::DrawWithHalo(SkColor text_color,
113 SkColor halo_color) { 113 SkColor halo_color) {
114 gfx::Size size(bounds_.width() + 2, bounds_.height() + 2); 114 gfx::Size size(bounds_.width() + 2, bounds_.height() + 2);
115 gfx::Canvas text_canvas(size, scale_factor(), false); 115 gfx::Canvas text_canvas(size, false);
116 text_canvas.FillRect(gfx::Rect(size), static_cast<SkColor>(0)); 116 text_canvas.FillRect(gfx::Rect(size), static_cast<SkColor>(0));
117 117
118 { 118 {
119 skia::ScopedPlatformPaint scoped_platform_paint(text_canvas.sk_canvas()); 119 skia::ScopedPlatformPaint scoped_platform_paint(text_canvas.sk_canvas());
120 cairo_t* text_cr = scoped_platform_paint.GetPlatformSurface(); 120 cairo_t* text_cr = scoped_platform_paint.GetPlatformSurface();
121 121
122 // TODO: The current approach (stroking the text path to generate the halo 122 // TODO: The current approach (stroking the text path to generate the halo
123 // and then filling it for the main text) won't work if |text_color| is 123 // and then filling it for the main text) won't work if |text_color| is
124 // non-opaque. If we need to do this at some later point, 124 // non-opaque. If we need to do this at some later point,
125 // http://lists.freedesktop.org/archives/cairo/2004-September/001829.html 125 // http://lists.freedesktop.org/archives/cairo/2004-September/001829.html
(...skipping 24 matching lines...) Expand all
150 SkColorGetB(text_color) / 255.0, 150 SkColorGetB(text_color) / 255.0,
151 SkColorGetA(text_color) / 255.0); 151 SkColorGetA(text_color) / 255.0);
152 cairo_fill(text_cr); 152 cairo_fill(text_cr);
153 153
154 if (font_.GetStyle() & gfx::Font::UNDERLINED) 154 if (font_.GetStyle() & gfx::Font::UNDERLINED)
155 DrawUnderline(text_cr, 0.0); 155 DrawUnderline(text_cr, 0.0);
156 } 156 }
157 157
158 const SkBitmap& text_bitmap = const_cast<SkBitmap&>( 158 const SkBitmap& text_bitmap = const_cast<SkBitmap&>(
159 skia::GetTopDevice(*text_canvas.sk_canvas())->accessBitmap(false)); 159 skia::GetTopDevice(*text_canvas.sk_canvas())->accessBitmap(false));
160 const gfx::ImageSkia text_image = gfx::ImageSkia(gfx::ImageSkiaRep( 160 canvas_->DrawImageInt(text_bitmap, text_rect_.x() - 1, text_rect_.y() - 1);
161 text_bitmap, text_canvas.scale_factor()));
162 canvas_->DrawImageInt(text_image, text_rect_.x() - 1, text_rect_.y() - 1);
163 } 161 }
164 162
165 void DrawStringContext::DrawUnderline(cairo_t* cr, double extra_edge_width) { 163 void DrawStringContext::DrawUnderline(cairo_t* cr, double extra_edge_width) {
166 gfx::PlatformFontPango* platform_font = 164 gfx::PlatformFontPango* platform_font =
167 static_cast<gfx::PlatformFontPango*>(font_.platform_font()); 165 static_cast<gfx::PlatformFontPango*>(font_.platform_font());
168 gfx::DrawPangoTextUnderline(cr, 166 gfx::DrawPangoTextUnderline(cr,
169 platform_font, 167 platform_font,
170 extra_edge_width, 168 extra_edge_width,
171 text_rect_); 169 text_rect_);
172 } 170 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 DLOG_IF(WARNING, !shadows.empty()) << "Text shadow not implemented."; 253 DLOG_IF(WARNING, !shadows.empty()) << "Text shadow not implemented.";
256 254
257 if (!IntersectsClipRect(text_bounds)) 255 if (!IntersectsClipRect(text_bounds))
258 return; 256 return;
259 257
260 DrawStringContext context(this, text, font, text_bounds, text_bounds, flags); 258 DrawStringContext context(this, text, font, text_bounds, text_bounds, flags);
261 context.Draw(color); 259 context.Draw(color);
262 } 260 }
263 261
264 } // namespace gfx 262 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas.cc ('k') | ui/gfx/canvas_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698