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

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

Issue 125109: Refactor the PlatformContext layer to have only one class. (Closed)
Patch Set: Created 11 years, 6 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
« no previous file with comments | « app/gfx/canvas.h ('k') | app/gfx/canvas_paint.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/gfx/canvas.h" 5 #include "app/gfx/canvas.h"
6 6
7 #include <cairo/cairo.h>
7 #include <pango/pango.h> 8 #include <pango/pango.h>
9 #include <pango/pangocairo.h>
8 10
9 #include "app/gfx/font.h" 11 #include "app/gfx/font.h"
10 #include "base/gfx/rect.h" 12 #include "base/gfx/rect.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/string_util.h" 14 #include "base/string_util.h"
13 15
14 namespace { 16 namespace {
15 17
16 // Returns a new pango font, free with pango_font_description_free(). 18 // Returns a new pango font, free with pango_font_description_free().
17 PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& gfx_font) { 19 PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& gfx_font) {
(...skipping 19 matching lines...) Expand all
37 } 39 }
38 40
39 return pfd; 41 return pfd;
40 } 42 }
41 43
42 } // namespace 44 } // namespace
43 45
44 namespace gfx { 46 namespace gfx {
45 47
46 Canvas::Canvas(int width, int height, bool is_opaque) 48 Canvas::Canvas(int width, int height, bool is_opaque)
47 : skia::PlatformCanvasLinux(width, height, is_opaque) { 49 : skia::PlatformCanvas(width, height, is_opaque) {
48 } 50 }
49 51
50 Canvas::Canvas() : skia::PlatformCanvasLinux() { 52 Canvas::Canvas() : skia::PlatformCanvas() {
51 } 53 }
52 54
53 Canvas::~Canvas() { 55 Canvas::~Canvas() {
54 } 56 }
55 57
56 // static 58 // static
57 void Canvas::SizeStringInt(const std::wstring& text, 59 void Canvas::SizeStringInt(const std::wstring& text,
58 const gfx::Font& font, 60 const gfx::Font& font,
59 int* width, int* height, int flags) { 61 int* width, int* height, int flags) {
60 cairo_surface_t* surface = 62 cairo_surface_t* surface =
61 cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0); 63 cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0);
62 cairo_t* cr = cairo_create(surface); 64 cairo_t* cr = cairo_create(surface);
63 PangoLayout* layout = pango_cairo_create_layout(cr); 65 PangoLayout* layout = pango_cairo_create_layout(cr);
64 66
65 if (flags & NO_ELLIPSIS) { 67 if (flags & NO_ELLIPSIS) {
66 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); 68 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
67 } else { 69 } else {
68 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); 70 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
69 } 71 }
70 72
71 if (flags & TEXT_ALIGN_CENTER) { 73 if (flags & TEXT_ALIGN_CENTER) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 166
165 cairo_move_to(cr, x, y); 167 cairo_move_to(cr, x, y);
166 pango_cairo_show_layout(cr, layout); 168 pango_cairo_show_layout(cr, layout);
167 169
168 g_object_unref(layout); 170 g_object_unref(layout);
169 cairo_destroy(cr); 171 cairo_destroy(cr);
170 // NOTE: beginPlatformPaint returned its surface, we shouldn't destroy it. 172 // NOTE: beginPlatformPaint returned its surface, we shouldn't destroy it.
171 } 173 }
172 174
173 } // namespace gfx 175 } // namespace gfx
OLDNEW
« no previous file with comments | « app/gfx/canvas.h ('k') | app/gfx/canvas_paint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698