summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 22:20:52 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 22:20:52 +0000
commitdcc2977772bdd296d8bfbcaedafd4441def78e3d (patch)
treecb0bdc148cff3f5a221b89ad2c055212d58bb976 /ui/gfx
parent404d9a54ceae52b741b3e173af12fb7fd21c8548 (diff)
downloadchromium_src-dcc2977772bdd296d8bfbcaedafd4441def78e3d.zip
chromium_src-dcc2977772bdd296d8bfbcaedafd4441def78e3d.tar.gz
chromium_src-dcc2977772bdd296d8bfbcaedafd4441def78e3d.tar.bz2
Delete the GTK+ port of Chrome.
BUG=297026 R=ben@chromium.org Review URL: https://codereview.chromium.org/231733005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/canvas_paint_gtk.cc107
-rw-r--r--ui/gfx/canvas_paint_gtk.h102
-rw-r--r--ui/gfx/canvas_skia_paint.h4
-rw-r--r--ui/gfx/font_render_params_linux.cc57
-rw-r--r--ui/gfx/geometry/insets.cc13
-rw-r--r--ui/gfx/geometry/insets.h7
-rw-r--r--ui/gfx/geometry/rect.cc13
-rw-r--r--ui/gfx/geometry/rect.h6
-rw-r--r--ui/gfx/gfx.gyp6
-rw-r--r--ui/gfx/gtk_compat.h97
-rw-r--r--ui/gfx/gtk_native_view_id_manager.cc254
-rw-r--r--ui/gfx/gtk_native_view_id_manager.h138
-rw-r--r--ui/gfx/gtk_preserve_window.cc264
-rw-r--r--ui/gfx/gtk_preserve_window.h74
-rw-r--r--ui/gfx/gtk_util.cc190
-rw-r--r--ui/gfx/gtk_util.h55
-rw-r--r--ui/gfx/image/image.cc246
-rw-r--r--ui/gfx/image/image_unittest.cc28
-rw-r--r--ui/gfx/image/image_unittest_util.cc27
-rw-r--r--ui/gfx/image/image_unittest_util.h2
-rw-r--r--ui/gfx/native_widget_types.h22
-rw-r--r--ui/gfx/pango_util.cc8
-rw-r--r--ui/gfx/path_gtk.cc57
-rw-r--r--ui/gfx/render_text_unittest.cc8
-rw-r--r--ui/gfx/screen_gtk.cc210
-rw-r--r--ui/gfx/skia_utils_gtk.cc32
-rw-r--r--ui/gfx/skia_utils_gtk.h23
27 files changed, 9 insertions, 2041 deletions
diff --git a/ui/gfx/canvas_paint_gtk.cc b/ui/gfx/canvas_paint_gtk.cc
deleted file mode 100644
index aef6fc9..0000000
--- a/ui/gfx/canvas_paint_gtk.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/canvas_skia_paint.h"
-#include "ui/gfx/rect.h"
-
-namespace gfx {
-
-// CanvasSkiaPaint
-
-CanvasSkiaPaint::CanvasSkiaPaint(GdkEventExpose* event)
- : context_(NULL),
- window_(event->window),
- region_(gdk_region_copy(event->region)),
- composite_alpha_(false) {
- Init(true);
-}
-
-CanvasSkiaPaint::CanvasSkiaPaint(GdkEventExpose* event, bool opaque)
- : context_(NULL),
- window_(event->window),
- region_(gdk_region_copy(event->region)),
- composite_alpha_(false) {
- Init(opaque);
-}
-
-CanvasSkiaPaint::~CanvasSkiaPaint() {
- if (!is_empty()) {
- platform_canvas()->restoreToCount(1);
-
- // Blit the dirty rect to the window.
- CHECK(window_);
- cairo_t* cr = gdk_cairo_create(window_);
- CHECK(cr);
- if (composite_alpha_)
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_surface_t* source_surface = cairo_get_target(context_);
- CHECK(source_surface);
- // Flush cairo's cache of the surface.
- cairo_surface_mark_dirty(source_surface);
- GdkRectangle bounds = rectangle();
- cairo_set_source_surface(cr, source_surface, bounds.x, bounds.y);
- gdk_cairo_region(cr, region_);
- cairo_fill(cr);
- cairo_destroy(cr);
- }
-
- gdk_region_destroy(region_);
-}
-
-void CanvasSkiaPaint::Init(bool opaque) {
- GdkRectangle bounds = rectangle();
- RecreateBackingCanvas(Size(bounds.width, bounds.height), 1.0f, opaque);
-
- skia::PlatformCanvas* canvas = platform_canvas();
-
- // Need to translate so that the dirty region appears at the origin of the
- // surface.
- canvas->translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y));
-
- context_ = skia::BeginPlatformPaint(canvas);
-}
-
-// CanvasSkiaPaintCairo
-
-CanvasSkiaPaintCairo::CanvasSkiaPaintCairo(cairo_t* cairo,
- Size size,
- bool opaque)
- : context_(NULL),
- dest_(cairo),
- size_(size),
- composite_alpha_(false) {
- CHECK(dest_);
- Init(opaque);
-}
-
-CanvasSkiaPaintCairo::~CanvasSkiaPaintCairo() {
- if (!is_empty()) {
- platform_canvas()->restoreToCount(1);
-
- // Blit the dirty rect to the window.
- if (composite_alpha_)
- cairo_set_operator(dest_, CAIRO_OPERATOR_SOURCE);
- cairo_surface_t* source_surface = cairo_get_target(context_);
- CHECK(source_surface);
- // Flush cairo's cache of the surface.
- cairo_surface_mark_dirty(source_surface);
- cairo_set_source_surface(dest_, source_surface, 0, 0);
- GdkRectangle bounds = {0, 0, size_.width(), size_.height()};
- gdk_cairo_rectangle(dest_, &bounds);
- cairo_fill(dest_);
- }
-}
-
-void CanvasSkiaPaintCairo::Init(bool opaque) {
- RecreateBackingCanvas(size_, 1.0f, opaque);
-
- context_ = skia::BeginPlatformPaint(platform_canvas());
-}
-
-} // namespace gfx
-
-
diff --git a/ui/gfx/canvas_paint_gtk.h b/ui/gfx/canvas_paint_gtk.h
deleted file mode 100644
index 487db79f..0000000
--- a/ui/gfx/canvas_paint_gtk.h
+++ /dev/null
@@ -1,102 +0,0 @@
-
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_GFX_CANVAS_PAINT_LINUX_H_
-#define UI_GFX_CANVAS_PAINT_LINUX_H_
-
-#include "base/logging.h"
-#include "skia/ext/platform_canvas.h"
-#include "ui/gfx/canvas.h"
-#include <gdk/gdk.h>
-
-namespace gfx {
-
-// A class designed to translate skia painting into a region in a GdkWindow.
-// On construction, it will set up a context for painting into, and on
-// destruction, it will commit it to the GdkWindow.
-// Note: The created context is always inialized to (0, 0, 0, 0).
-class GFX_EXPORT CanvasSkiaPaint : public Canvas {
- public:
- // This constructor assumes the result is opaque.
- explicit CanvasSkiaPaint(GdkEventExpose* event);
- CanvasSkiaPaint(GdkEventExpose* event, bool opaque);
- virtual ~CanvasSkiaPaint();
-
- // Sets whether the bitmap is composited in such a way that the alpha channel
- // is honored. This is only useful if you've enabled an RGBA colormap on the
- // widget. The default is false.
- void set_composite_alpha(bool composite_alpha) {
- composite_alpha_ = composite_alpha;
- }
-
- // Returns true if the invalid region is empty. The caller should call this
- // function to determine if anything needs painting.
- bool is_empty() const {
- return gdk_region_empty(region_);
- }
-
- GdkRectangle rectangle() const {
- GdkRectangle bounds;
- gdk_region_get_clipbox(region_, &bounds);
- return bounds;
- }
-
- private:
- void Init(bool opaque);
-
- cairo_t* context_;
- GdkWindow* window_;
- GdkRegion* region_;
- // See description above setter.
- bool composite_alpha_;
-
- // Disallow copy and assign.
- CanvasSkiaPaint(const CanvasSkiaPaint&);
- CanvasSkiaPaint& operator=(const CanvasSkiaPaint&);
-};
-
-// A class designed to translate skia painting into a region in a Cairo context.
-// On construction, it will set up a context for painting into, and on
-// destruction, it will commit it to the Cairo context. If there are any
-// transformations applied to the Cairo context, they will affect the drawing.
-class GFX_EXPORT CanvasSkiaPaintCairo : public Canvas {
- public:
- CanvasSkiaPaintCairo(cairo_t* cairo, Size size, bool opaque);
- virtual ~CanvasSkiaPaintCairo();
-
- // Sets whether the bitmap is composited in such a way that the alpha channel
- // is honored. This is only useful if you've enabled an RGBA colormap on the
- // widget. The default is false.
- void set_composite_alpha(bool composite_alpha) {
- composite_alpha_ = composite_alpha;
- }
-
- // Returns true if size of the drawing region is empty. The caller should call
- // this function to determine if anything needs painting.
- bool is_empty() const {
- return size_.IsEmpty();
- }
-
- Size size() const {
- return size_;
- }
-
- private:
- void Init(bool opaque);
-
- cairo_t* context_;
- cairo_t* dest_;
- Size size_;
- // See description above setter.
- bool composite_alpha_;
-
- // Disallow copy and assign.
- CanvasSkiaPaintCairo(const CanvasSkiaPaintCairo&);
- CanvasSkiaPaintCairo& operator=(const CanvasSkiaPaintCairo&);
-};
-
-} // namespace gfx
-
-#endif // UI_GFX_CANVAS_PAINT_LINUX_H_
diff --git a/ui/gfx/canvas_skia_paint.h b/ui/gfx/canvas_skia_paint.h
index 3f21f5c..e9e22ff 100644
--- a/ui/gfx/canvas_skia_paint.h
+++ b/ui/gfx/canvas_skia_paint.h
@@ -12,12 +12,8 @@
#include "ui/gfx/canvas_paint_win.h"
#elif defined(__APPLE__)
#include "ui/gfx/canvas_paint_mac.h"
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
-#if defined(TOOLKIT_GTK)
-#include "ui/gfx/canvas_paint_gtk.h"
#else
#error "No canvas paint for this platform"
#endif
-#endif
#endif // UI_GFX_CANVAS_SKIA_PAINT_H_
diff --git a/ui/gfx/font_render_params_linux.cc b/ui/gfx/font_render_params_linux.cc
index 0c157d5..fdef6a9 100644
--- a/ui/gfx/font_render_params_linux.cc
+++ b/ui/gfx/font_render_params_linux.cc
@@ -9,11 +9,7 @@
#include "ui/gfx/display.h"
#include "ui/gfx/switches.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#else
#include <fontconfig/fontconfig.h>
-#endif
#if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)
#include "ui/gfx/linux_font_delegate.h"
@@ -39,58 +35,6 @@ bool SubpixelPositioningRequested(bool renderer) {
// Initializes |params| with the system's default settings. |renderer| is true
// when setting WebKit renderer defaults.
void LoadDefaults(FontRenderParams* params, bool renderer) {
-#if defined(TOOLKIT_GTK)
- params->antialiasing = true;
- // TODO(wangxianzhu): autohinter is now true to keep original behavior
- // of WebKit, but it might not be the best value.
- params->autohinter = true;
- params->use_bitmaps = true;
- params->hinting = FontRenderParams::HINTING_SLIGHT;
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
-
- GtkSettings* gtk_settings = gtk_settings_get_default();
- CHECK(gtk_settings);
- gint gtk_antialias = 0;
- gint gtk_hinting = 0;
- gchar* gtk_hint_style = NULL;
- gchar* gtk_rgba = NULL;
- g_object_get(gtk_settings,
- "gtk-xft-antialias", &gtk_antialias,
- "gtk-xft-hinting", &gtk_hinting,
- "gtk-xft-hintstyle", &gtk_hint_style,
- "gtk-xft-rgba", &gtk_rgba,
- NULL);
-
- // g_object_get() doesn't tell us whether the properties were present or not,
- // but if they aren't (because gnome-settings-daemon isn't running), we'll get
- // NULL values for the strings.
- if (gtk_hint_style && gtk_rgba) {
- params->antialiasing = gtk_antialias;
-
- if (gtk_hinting == 0 || strcmp(gtk_hint_style, "hintnone") == 0)
- params->hinting = FontRenderParams::HINTING_NONE;
- else if (strcmp(gtk_hint_style, "hintslight") == 0)
- params->hinting = FontRenderParams::HINTING_SLIGHT;
- else if (strcmp(gtk_hint_style, "hintmedium") == 0)
- params->hinting = FontRenderParams::HINTING_MEDIUM;
- else if (strcmp(gtk_hint_style, "hintfull") == 0)
- params->hinting = FontRenderParams::HINTING_FULL;
-
- if (strcmp(gtk_rgba, "none") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
- else if (strcmp(gtk_rgba, "rgb") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB;
- else if (strcmp(gtk_rgba, "bgr") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_BGR;
- else if (strcmp(gtk_rgba, "vrgb") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_VRGB;
- else if (strcmp(gtk_rgba, "vbgr") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_VBGR;
- }
-
- g_free(gtk_hint_style);
- g_free(gtk_rgba);
-#else
// For non-GTK builds (read: Aura), just use reasonable hardcoded values.
params->antialiasing = true;
params->autohinter = true;
@@ -134,7 +78,6 @@ void LoadDefaults(FontRenderParams* params, bool renderer) {
params->subpixel_rendering = delegate->GetSubpixelRenderingStyle();
}
#endif
-#endif
params->subpixel_positioning = SubpixelPositioningRequested(renderer);
diff --git a/ui/gfx/geometry/insets.cc b/ui/gfx/geometry/insets.cc
index 300de45..c29368e 100644
--- a/ui/gfx/geometry/insets.cc
+++ b/ui/gfx/geometry/insets.cc
@@ -4,10 +4,6 @@
#include "ui/gfx/geometry/insets.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#endif
-
#include "base/strings/stringprintf.h"
namespace gfx {
@@ -19,15 +15,6 @@ Insets::Insets() : InsetsBase<Insets, int>(0, 0, 0, 0) {}
Insets::Insets(int top, int left, int bottom, int right)
: InsetsBase<Insets, int>(top, left, bottom, right) {}
-#if defined(TOOLKIT_GTK)
-Insets::Insets(const GtkBorder& border)
- : InsetsBase<Insets, int>(border.top,
- border.left,
- border.bottom,
- border.right) {
-}
-#endif
-
Insets::~Insets() {}
std::string Insets::ToString() const {
diff --git a/ui/gfx/geometry/insets.h b/ui/gfx/geometry/insets.h
index d9eaed4..00b6125 100644
--- a/ui/gfx/geometry/insets.h
+++ b/ui/gfx/geometry/insets.h
@@ -12,10 +12,6 @@
#include "ui/gfx/geometry/insets_f.h"
#include "ui/gfx/gfx_export.h"
-#if defined(TOOLKIT_GTK)
-typedef struct _GtkBorder GtkBorder;
-#endif
-
namespace gfx {
// An integer version of gfx::Insets.
@@ -23,9 +19,6 @@ class GFX_EXPORT Insets : public InsetsBase<Insets, int> {
public:
Insets();
Insets(int top, int left, int bottom, int right);
-#if defined(TOOLKIT_GTK)
- explicit Insets(const GtkBorder& border);
-#endif
~Insets();
diff --git a/ui/gfx/geometry/rect.cc b/ui/gfx/geometry/rect.cc
index 4b1c6e9..f418e175 100644
--- a/ui/gfx/geometry/rect.cc
+++ b/ui/gfx/geometry/rect.cc
@@ -8,8 +8,6 @@
#if defined(OS_WIN)
#include <windows.h>
-#elif defined(TOOLKIT_GTK)
-#include <gdk/gdk.h>
#endif
#include "base/logging.h"
@@ -35,12 +33,6 @@ Rect::Rect(const CGRect& r)
set_width(r.size.width);
set_height(r.size.height);
}
-#elif defined(TOOLKIT_GTK)
-Rect::Rect(const GdkRectangle& r)
- : RectBaseT(gfx::Point(r.x, r.y)) {
- set_width(r.width);
- set_height(r.height);
-}
#endif
#if defined(OS_WIN)
@@ -56,11 +48,6 @@ RECT Rect::ToRECT() const {
CGRect Rect::ToCGRect() const {
return CGRectMake(x(), y(), width(), height());
}
-#elif defined(TOOLKIT_GTK)
-GdkRectangle Rect::ToGdkRectangle() const {
- GdkRectangle r = {x(), y(), width(), height()};
- return r;
-}
#endif
std::string Rect::ToString() const {
diff --git a/ui/gfx/geometry/rect.h b/ui/gfx/geometry/rect.h
index 7272a1c..28d37bc 100644
--- a/ui/gfx/geometry/rect.h
+++ b/ui/gfx/geometry/rect.h
@@ -23,8 +23,6 @@
#if defined(OS_WIN)
typedef struct tagRECT RECT;
-#elif defined(TOOLKIT_GTK)
-typedef struct _GdkRectangle GdkRectangle;
#elif defined(OS_IOS)
#include <CoreGraphics/CoreGraphics.h>
#elif defined(OS_MACOSX)
@@ -52,8 +50,6 @@ class GFX_EXPORT Rect
explicit Rect(const RECT& r);
#elif defined(OS_MACOSX)
explicit Rect(const CGRect& r);
-#elif defined(TOOLKIT_GTK)
- explicit Rect(const GdkRectangle& r);
#endif
explicit Rect(const gfx::Size& size)
@@ -67,8 +63,6 @@ class GFX_EXPORT Rect
#if defined(OS_WIN)
// Construct an equivalent Win32 RECT object.
RECT ToRECT() const;
-#elif defined(TOOLKIT_GTK)
- GdkRectangle ToGdkRectangle() const;
#elif defined(OS_MACOSX)
// Construct an equivalent CoreGraphics object.
CGRect ToCGRect() const;
diff --git a/ui/gfx/gfx.gyp b/ui/gfx/gfx.gyp
index 8c6ca19..7c4e8bf 100644
--- a/ui/gfx/gfx.gyp
+++ b/ui/gfx/gfx.gyp
@@ -125,8 +125,6 @@
'canvas.cc',
'canvas.h',
'canvas_android.cc',
- 'canvas_paint_gtk.cc',
- 'canvas_paint_gtk.h',
'canvas_paint_mac.h',
'canvas_paint_mac.mm',
'canvas_paint_win.cc',
@@ -228,7 +226,6 @@
'path.cc',
'path.h',
'path_aura.cc',
- 'path_gtk.cc',
'path_win.cc',
'path_win.h',
'path_x11.cc',
@@ -267,7 +264,6 @@
'screen.h',
'screen_android.cc',
'screen_aura.cc',
- 'screen_gtk.cc',
'screen_ios.mm',
'screen_mac.mm',
'screen_win.cc',
@@ -284,8 +280,6 @@
'skbitmap_operations.h',
'skia_util.cc',
'skia_util.h',
- 'skia_utils_gtk.cc',
- 'skia_utils_gtk.h',
'switches.cc',
'switches.h',
'sys_color_change_listener.cc',
diff --git a/ui/gfx/gtk_compat.h b/ui/gfx/gtk_compat.h
deleted file mode 100644
index ca14a27..0000000
--- a/ui/gfx/gtk_compat.h
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_GFX_GTK_COMPAT_H_
-#define UI_GFX_GTK_COMPAT_H_
-
-#include <gtk/gtk.h>
-
-// Google Chrome must depend on GTK 2.18, at least until the next LTS drops
-// (and we might have to extend which version of GTK we want to target due to
-// RHEL). To make our porting job for GTK3 easier, we define all the methods
-// that replace deprecated APIs in this file and then include it everywhere.
-//
-// This file is organized first by version, and then with each version,
-// alphabetically by method.
-//
-// For Google Chrome builds, we want to support RHEL 6, which uses GTK 2.18,
-// but the official builder is Ubuntu Lucid with GTK 2.20. Thus for Google
-// Chrome builds, we define the GTK 2.20.0 compatibility functions even though
-// the system GTK provides the functions.
-
-#if !GTK_CHECK_VERSION(2, 20, 0) || defined(GOOGLE_CHROME_BUILD)
-inline gboolean gtk_widget_get_mapped(GtkWidget* widget) {
- return GTK_WIDGET_MAPPED(widget);
-}
-
-inline gboolean gtk_widget_get_realized(GtkWidget* widget) {
- return GTK_WIDGET_REALIZED(widget);
-}
-
-inline gboolean gtk_widget_is_toplevel(GtkWidget* widget) {
- return GTK_WIDGET_TOPLEVEL(widget);
-}
-
-inline void gtk_widget_set_mapped(GtkWidget* widget,
- gboolean mapped) {
- if (mapped)
- GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED);
- else
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_MAPPED);
-}
-
-inline void gtk_widget_set_realized(GtkWidget* widget,
- gboolean realized) {
- if (realized)
- GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
- else
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
-}
-
-inline void gtk_widget_style_attach(GtkWidget* widget) {
- widget->style = gtk_style_attach(widget->style, widget->window);
-}
-#endif // !GTK_CHECK_VERSION(2, 20, 0) || defined(GOOGLE_CHROME_BUILD)
-
-#if !GTK_CHECK_VERSION(2, 22, 0)
-inline GdkWindow* gdk_drag_context_get_source_window(GdkDragContext *context) {
- return context->source_window;
-}
-
-inline gint gdk_visual_get_depth(GdkVisual* visual) {
- return visual->depth;
-}
-
-inline GdkWindow* gtk_button_get_event_window(GtkButton* button) {
- return button->event_window;
-}
-#endif // !GTK_CHECK_VERSION(2, 22, 0)
-
-#if !GTK_CHECK_VERSION(2, 24, 0)
-inline void gdk_pixmap_get_size(GdkPixmap* pixmap, gint* width, gint* height) {
- gdk_drawable_get_size(GDK_DRAWABLE(pixmap), width, height);
-}
-
-inline GdkDisplay* gdk_window_get_display(GdkWindow* window) {
- return gdk_drawable_get_display(GDK_DRAWABLE(window));
-}
-
-inline int gdk_window_get_height(GdkWindow* window) {
- int height;
- gdk_drawable_get_size(GDK_DRAWABLE(window), NULL, &height);
- return height;
-}
-
-inline GdkScreen* gdk_window_get_screen(GdkWindow* window) {
- return gdk_drawable_get_screen(GDK_DRAWABLE(window));
-}
-
-inline int gdk_window_get_width(GdkWindow* window) {
- int width;
- gdk_drawable_get_size(GDK_DRAWABLE(window), &width, NULL);
- return width;
-}
-#endif // !GTK_CHECK_VERSION(2, 24, 0)
-
-#endif // UI_GFX_GTK_COMPAT_H_
diff --git a/ui/gfx/gtk_native_view_id_manager.cc b/ui/gfx/gtk_native_view_id_manager.cc
deleted file mode 100644
index 0844b190..0000000
--- a/ui/gfx/gtk_native_view_id_manager.cc
+++ /dev/null
@@ -1,254 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/gtk_native_view_id_manager.h"
-
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-#include "base/logging.h"
-#include "base/memory/singleton.h"
-#include "base/rand_util.h"
-#include "ui/gfx/gdk_compat.h"
-#include "ui/gfx/gtk_compat.h"
-#include "ui/gfx/gtk_preserve_window.h"
-
-// -----------------------------------------------------------------------------
-// Bounce functions for GTK to callback into a C++ object...
-
-void OnRealize(gfx::NativeView widget, void* arg) {
- GtkNativeViewManager* manager = reinterpret_cast<GtkNativeViewManager*>(arg);
- manager->OnRealize(widget);
-}
-
-void OnUnrealize(gfx::NativeView widget, void *arg) {
- GtkNativeViewManager* manager = reinterpret_cast<GtkNativeViewManager*>(arg);
- manager->OnUnrealize(widget);
-}
-
-static void OnDestroy(GtkObject* obj, void* arg) {
- GtkNativeViewManager* manager = reinterpret_cast<GtkNativeViewManager*>(arg);
- manager->OnDestroy(reinterpret_cast<GtkWidget*>(obj));
-}
-
-// -----------------------------------------------------------------------------
-
-
-// -----------------------------------------------------------------------------
-// Public functions...
-
-GtkNativeViewManager::GtkNativeViewManager() {
-}
-
-GtkNativeViewManager::~GtkNativeViewManager() {
-}
-
-// static
-GtkNativeViewManager* GtkNativeViewManager::GetInstance() {
- return Singleton<GtkNativeViewManager>::get();
-}
-
-gfx::NativeViewId GtkNativeViewManager::GetIdForWidget(gfx::NativeView widget) {
- // This is just for unit tests:
- if (!widget)
- return 0;
-
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeView, gfx::NativeViewId>::const_iterator i =
- native_view_to_id_.find(widget);
-
- if (i != native_view_to_id_.end())
- return i->second;
-
- gfx::NativeViewId new_id =
- static_cast<gfx::NativeViewId>(base::RandUint64());
- while (id_to_info_.find(new_id) != id_to_info_.end())
- new_id = static_cast<gfx::NativeViewId>(base::RandUint64());
-
- NativeViewInfo info;
- info.widget = widget;
- if (gtk_widget_get_realized(widget)) {
- GdkWindow *gdk_window = gtk_widget_get_window(widget);
- DCHECK(gdk_window);
- info.x_window_id = GDK_WINDOW_XID(gdk_window);
- }
-
- native_view_to_id_[widget] = new_id;
- id_to_info_[new_id] = info;
-
- g_signal_connect(widget, "realize", G_CALLBACK(::OnRealize), this);
- g_signal_connect(widget, "unrealize", G_CALLBACK(::OnUnrealize), this);
- g_signal_connect(widget, "destroy", G_CALLBACK(::OnDestroy), this);
-
- return new_id;
-}
-
-bool GtkNativeViewManager::GetXIDForId(XID* output, gfx::NativeViewId id) {
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeViewId, NativeViewInfo>::const_iterator i =
- id_to_info_.find(id);
-
- if (i == id_to_info_.end())
- return false;
-
- *output = i->second.x_window_id;
- return true;
-}
-
-bool GtkNativeViewManager::GetNativeViewForId(gfx::NativeView* output,
- gfx::NativeViewId id) {
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeViewId, NativeViewInfo>::const_iterator i =
- id_to_info_.find(id);
-
- if (i == id_to_info_.end())
- return false;
-
- *output = i->second.widget;
- return true;
-}
-
-bool GtkNativeViewManager::GetPermanentXIDForId(XID* output,
- gfx::NativeViewId id) {
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeViewId, NativeViewInfo>::iterator i =
- id_to_info_.find(id);
-
- if (i == id_to_info_.end())
- return false;
-
- // We only return permanent XIDs for widgets that allow us to guarantee that
- // the XID will not change.
- DCHECK(GTK_IS_PRESERVE_WINDOW(i->second.widget));
- GtkPreserveWindow* widget =
- reinterpret_cast<GtkPreserveWindow*>(i->second.widget);
- gtk_preserve_window_set_preserve(widget, TRUE);
-
- *output = GDK_WINDOW_XID(gtk_widget_get_window(i->second.widget));
-
- // Update the reference count on the permanent XID.
- PermanentXIDInfo info;
- info.widget = widget;
- info.ref_count = 1;
- std::pair<std::map<XID, PermanentXIDInfo>::iterator, bool> ret =
- perm_xid_to_info_.insert(std::make_pair(*output, info));
-
- if (!ret.second) {
- DCHECK(ret.first->second.widget == widget);
- ret.first->second.ref_count++;
- }
-
- return true;
-}
-
-bool GtkNativeViewManager::AddRefPermanentXID(XID xid) {
- base::AutoLock locked(lock_);
-
- std::map<XID, PermanentXIDInfo>::iterator i =
- perm_xid_to_info_.find(xid);
-
- if (i == perm_xid_to_info_.end())
- return false;
-
- i->second.ref_count++;
-
- return true;
-}
-
-void GtkNativeViewManager::ReleasePermanentXID(XID xid) {
- base::AutoLock locked(lock_);
-
- std::map<XID, PermanentXIDInfo>::iterator i =
- perm_xid_to_info_.find(xid);
-
- if (i == perm_xid_to_info_.end())
- return;
-
- if (i->second.ref_count > 1) {
- i->second.ref_count--;
- } else {
- if (i->second.widget) {
- gtk_preserve_window_set_preserve(i->second.widget, FALSE);
- } else {
- GdkWindow* window = reinterpret_cast<GdkWindow*>(
- gdk_x11_window_lookup_for_display(gdk_display_get_default(), xid));
- DCHECK(window);
- gdk_window_destroy(window);
- }
- perm_xid_to_info_.erase(i);
- }
-}
-
-// -----------------------------------------------------------------------------
-
-
-// -----------------------------------------------------------------------------
-// Private functions...
-
-gfx::NativeViewId GtkNativeViewManager::GetWidgetId(gfx::NativeView widget) {
- lock_.AssertAcquired();
-
- std::map<gfx::NativeView, gfx::NativeViewId>::const_iterator i =
- native_view_to_id_.find(widget);
-
- CHECK(i != native_view_to_id_.end());
- return i->second;
-}
-
-void GtkNativeViewManager::OnRealize(gfx::NativeView widget) {
- base::AutoLock locked(lock_);
-
- const gfx::NativeViewId id = GetWidgetId(widget);
- std::map<gfx::NativeViewId, NativeViewInfo>::iterator i =
- id_to_info_.find(id);
-
- CHECK(i != id_to_info_.end());
-
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- CHECK(gdk_window);
- i->second.x_window_id = GDK_WINDOW_XID(gdk_window);
-}
-
-void GtkNativeViewManager::OnUnrealize(gfx::NativeView widget) {
- base::AutoLock locked(lock_);
-
- const gfx::NativeViewId id = GetWidgetId(widget);
- std::map<gfx::NativeViewId, NativeViewInfo>::iterator i =
- id_to_info_.find(id);
-
- CHECK(i != id_to_info_.end());
-}
-
-void GtkNativeViewManager::OnDestroy(gfx::NativeView widget) {
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeView, gfx::NativeViewId>::iterator i =
- native_view_to_id_.find(widget);
- CHECK(i != native_view_to_id_.end());
-
- std::map<gfx::NativeViewId, NativeViewInfo>::iterator j =
- id_to_info_.find(i->second);
- CHECK(j != id_to_info_.end());
-
- // If the XID is supposed to outlive the widget, mark it
- // in the lookup table.
- if (GTK_IS_PRESERVE_WINDOW(widget) &&
- gtk_preserve_window_get_preserve(
- reinterpret_cast<GtkPreserveWindow*>(widget))) {
- std::map<XID, PermanentXIDInfo>::iterator k =
- perm_xid_to_info_.find(GDK_WINDOW_XID(gtk_widget_get_window(widget)));
-
- if (k != perm_xid_to_info_.end())
- k->second.widget = NULL;
- }
-
- native_view_to_id_.erase(i);
- id_to_info_.erase(j);
-}
-
-// -----------------------------------------------------------------------------
diff --git a/ui/gfx/gtk_native_view_id_manager.h b/ui/gfx/gtk_native_view_id_manager.h
deleted file mode 100644
index 4421920..0000000
--- a/ui/gfx/gtk_native_view_id_manager.h
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_
-#define UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_
-
-#include <map>
-
-#include "base/synchronization/lock.h"
-#include "ui/gfx/gfx_export.h"
-#include "ui/gfx/native_widget_types.h"
-
-template <typename T> struct DefaultSingletonTraits;
-
-typedef unsigned long XID;
-struct _GtkPreserveWindow;
-
-// NativeViewIds are the opaque values which the renderer holds as a reference
-// to a window.
-//
-// We could make NativeViewIds be the X id of the window. However, at the
-// time when we need to tell the renderer about its NativeViewId, an XID isn't
-// availible and it goes very much against the grain of the code to make it so.
-// Also, we worry that GTK might choose to change the underlying X window id
-// when, say, the widget is hidden or repacked. Finally, if we used XIDs then a
-// compromised renderer could start asking questions about any X windows on the
-// system.
-//
-// Thus, we have this object. It produces random NativeViewIds from GtkWidget
-// pointers and observes the various signals from the widget for when an X
-// window is created, destroyed etc. Thus it provides a thread safe mapping
-// from NativeViewIds to the current XID for that widget.
-class GFX_EXPORT GtkNativeViewManager {
- public:
- // Returns the singleton instance.
- static GtkNativeViewManager* GetInstance();
-
- // Must be called from the UI thread:
- //
- // Return a NativeViewId for the given widget and attach to the various
- // signals emitted by that widget. The NativeViewId is pseudo-randomly
- // allocated so that a compromised renderer trying to guess values will fail
- // with high probability. The NativeViewId will not be reused for the
- // lifetime of the GtkWidget.
- gfx::NativeViewId GetIdForWidget(gfx::NativeView widget);
-
- // May be called from any thread:
- //
- // xid: (output) the resulting X window ID, or 0
- // id: a value previously returned from GetIdForWidget
- // returns: true if |id| is a valid id, false otherwise.
- //
- // If the widget referenced by |id| does not current have an X window id,
- // |*xid| is set to 0.
- bool GetXIDForId(XID* xid, gfx::NativeViewId id);
-
- // May be called from the UI thread:
- //
- // Same as GetXIDForId except it returns the NativeView (GtkWidget*).
- bool GetNativeViewForId(gfx::NativeView* xid, gfx::NativeViewId id);
-
- // Must be called from the UI thread because we may need the associated
- // widget to create a window.
- //
- // Keeping the XID permanent requires a bit of overhead, so it must
- // be explicitly requested.
- //
- // xid: (output) the resulting X window
- // id: a value previously returned from GetIdForWidget
- // returns: true if |id| is a valid id, false otherwise.
- bool GetPermanentXIDForId(XID* xid, gfx::NativeViewId id);
-
- // Can be called from any thread.
- // Will return false if the given XID isn't permanent or has already been
- // released.
- bool AddRefPermanentXID(XID xid);
-
- // Must be called from the UI thread because we may need to access a
- // GtkWidget or destroy a GdkWindow.
- //
- // If the widget associated with the XID is still alive, allow the widget
- // to destroy the associated XID when it wants. Otherwise, destroy the
- // GdkWindow associated with the XID.
- void ReleasePermanentXID(XID xid);
-
- // These are actually private functions, but need to be called from statics.
- void OnRealize(gfx::NativeView widget);
- void OnUnrealize(gfx::NativeView widget);
- void OnDestroy(gfx::NativeView widget);
-
- private:
- // This object is a singleton:
- GtkNativeViewManager();
- ~GtkNativeViewManager();
- friend struct DefaultSingletonTraits<GtkNativeViewManager>;
-
- struct NativeViewInfo {
- NativeViewInfo() : widget(NULL), x_window_id(0) {
- }
- gfx::NativeView widget;
- XID x_window_id;
- };
-
- gfx::NativeViewId GetWidgetId(gfx::NativeView id);
-
- // protects native_view_to_id_ and id_to_info_
- base::Lock lock_;
-
- // If asked for an id for the same widget twice, we want to return the same
- // id. So this records the current mapping.
- std::map<gfx::NativeView, gfx::NativeViewId> native_view_to_id_;
- std::map<gfx::NativeViewId, NativeViewInfo> id_to_info_;
-
- struct PermanentXIDInfo {
- PermanentXIDInfo() : widget(NULL), ref_count(0) {
- }
- _GtkPreserveWindow* widget;
- int ref_count;
- };
-
- // Used to maintain the reference count for permanent XIDs
- // (referenced by GetPermanentXIDForId and dereferenced by
- // ReleasePermanentXID). Only those XIDs with a positive reference count
- // will be in the table.
- //
- // In general, several GTK widgets may share the same X window. We assume
- // that is not true of the widgets stored in this registry.
- //
- // An XID will map to NULL, if there is an outstanding reference but the
- // widget was destroyed. In this case, the destruction of the X window
- // is deferred to the dropping of all references.
- std::map<XID, PermanentXIDInfo> perm_xid_to_info_;
-
- DISALLOW_COPY_AND_ASSIGN(GtkNativeViewManager);
-};
-
-#endif // UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_
diff --git a/ui/gfx/gtk_preserve_window.cc b/ui/gfx/gtk_preserve_window.cc
deleted file mode 100644
index 78a49c2..0000000
--- a/ui/gfx/gtk_preserve_window.cc
+++ /dev/null
@@ -1,264 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/gtk_preserve_window.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include "ui/gfx/gtk_compat.h"
-
-G_BEGIN_DECLS
-
-#define GTK_PRESERVE_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- GTK_TYPE_PRESERVE_WINDOW, \
- GtkPreserveWindowPrivate))
-
-typedef struct _GtkPreserveWindowPrivate GtkPreserveWindowPrivate;
-
-struct _GtkPreserveWindowPrivate {
- // If true, don't create/destroy windows on realize/unrealize.
- gboolean preserve_window;
-
- // Whether or not we delegate the resize of the GdkWindow
- // to someone else.
- gboolean delegate_resize;
-
- // Accessible factory and userdata.
- AtkObject* (*accessible_factory)(void* userdata);
- void* accessible_factory_userdata;
-};
-
-G_DEFINE_TYPE(GtkPreserveWindow, gtk_preserve_window, GTK_TYPE_FIXED)
-
-static void gtk_preserve_window_destroy(GtkObject* object);
-static void gtk_preserve_window_realize(GtkWidget* widget);
-static void gtk_preserve_window_unrealize(GtkWidget* widget);
-static void gtk_preserve_window_size_allocate(GtkWidget* widget,
- GtkAllocation* allocation);
-static AtkObject* gtk_preserve_window_get_accessible(GtkWidget* widget);
-
-static void gtk_preserve_window_class_init(GtkPreserveWindowClass *klass) {
- GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(klass);
- widget_class->realize = gtk_preserve_window_realize;
- widget_class->unrealize = gtk_preserve_window_unrealize;
- widget_class->size_allocate = gtk_preserve_window_size_allocate;
- widget_class->get_accessible = gtk_preserve_window_get_accessible;
-
- GtkObjectClass* object_class = reinterpret_cast<GtkObjectClass*>(klass);
- object_class->destroy = gtk_preserve_window_destroy;
-
- GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
- g_type_class_add_private(gobject_class, sizeof(GtkPreserveWindowPrivate));
-}
-
-static void gtk_preserve_window_init(GtkPreserveWindow* widget) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- priv->preserve_window = FALSE;
- priv->accessible_factory = NULL;
- priv->accessible_factory_userdata = NULL;
-
- // These widgets always have their own window.
- gtk_widget_set_has_window(GTK_WIDGET(widget), TRUE);
-}
-
-GtkWidget* gtk_preserve_window_new() {
- return GTK_WIDGET(g_object_new(GTK_TYPE_PRESERVE_WINDOW, NULL));
-}
-
-static void gtk_preserve_window_destroy(GtkObject* object) {
- GtkWidget* widget = reinterpret_cast<GtkWidget*>(object);
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
-
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- if (gdk_window) {
- gdk_window_set_user_data(gdk_window, NULL);
- // If the window is preserved, someone else must destroy it.
- if (!priv->preserve_window)
- gdk_window_destroy(gdk_window);
- gtk_widget_set_window(widget, NULL);
- }
-
- GTK_OBJECT_CLASS(gtk_preserve_window_parent_class)->destroy(object);
-}
-
-static void gtk_preserve_window_realize(GtkWidget* widget) {
- g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget));
-
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- if (gdk_window) {
- GtkAllocation allocation;
- gtk_widget_get_allocation(widget, &allocation);
-
- gdk_window_reparent(gdk_window,
- gtk_widget_get_parent_window(widget),
- allocation.x,
- allocation.y);
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- if (!priv->delegate_resize) {
- gdk_window_resize(gdk_window,
- allocation.width,
- allocation.height);
- }
- gint event_mask = gtk_widget_get_events(widget);
- event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
- gdk_window_set_events(gdk_window, (GdkEventMask) event_mask);
- gdk_window_set_user_data(gdk_window, widget);
-
- gtk_widget_set_realized(widget, TRUE);
-
- gtk_widget_style_attach(widget);
- gtk_style_set_background(gtk_widget_get_style(widget),
- gdk_window, GTK_STATE_NORMAL);
- } else {
- GTK_WIDGET_CLASS(gtk_preserve_window_parent_class)->realize(widget);
- }
-}
-
-static void gtk_preserve_window_unrealize(GtkWidget* widget) {
- g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget));
-
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- if (priv->preserve_window) {
- GtkWidgetClass* widget_class =
- GTK_WIDGET_CLASS(gtk_preserve_window_parent_class);
- GtkContainerClass* container_class =
- GTK_CONTAINER_CLASS(gtk_preserve_window_parent_class);
-
- if (gtk_widget_get_mapped(widget)) {
- widget_class->unmap(widget);
-
- gtk_widget_set_mapped(widget, FALSE);
- }
-
- // This is the behavior from GtkWidget, inherited by GtkFixed.
- // It is unclear why we should not call the potentially overridden
- // unrealize method (via the callback), but doing so causes errors.
- container_class->forall(
- GTK_CONTAINER(widget), FALSE,
- reinterpret_cast<GtkCallback>(gtk_widget_unrealize), NULL);
-
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
-
- // TODO(erg): Almost all style handling will need to be overhauled in GTK3.
- gtk_style_detach(gtk_widget_get_style(widget));
- gdk_window_reparent(gdk_window, gdk_get_default_root_window(), 0, 0);
- gtk_selection_remove_all(widget);
- gdk_window_set_user_data(gdk_window, NULL);
-
- gtk_widget_set_realized(widget, FALSE);
- } else {
- GTK_WIDGET_CLASS(gtk_preserve_window_parent_class)->unrealize(widget);
- }
-}
-
-gboolean gtk_preserve_window_get_preserve(GtkPreserveWindow* window) {
- g_return_val_if_fail(GTK_IS_PRESERVE_WINDOW(window), FALSE);
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(window);
-
- return priv->preserve_window;
-}
-
-void gtk_preserve_window_set_preserve(GtkPreserveWindow* window,
- gboolean value) {
- g_return_if_fail(GTK_IS_PRESERVE_WINDOW(window));
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(window);
- priv->preserve_window = value;
-
- GtkWidget* widget = GTK_WIDGET(window);
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- if (value && !gdk_window) {
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- // We may not know the width and height, so we rely on the fact
- // that a size-allocation will resize it later.
- attributes.width = 1;
- attributes.height = 1;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.override_redirect = TRUE;
-
- attributes.visual = gtk_widget_get_visual(widget);
- attributes.colormap = gtk_widget_get_colormap(widget);
-
- attributes.event_mask = gtk_widget_get_events(widget);
- attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
-
- attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_NOREDIR;
- gdk_window = gdk_window_new(
- gdk_get_default_root_window(), &attributes, attributes_mask);
- gtk_widget_set_window(widget, gdk_window);
- } else if (!value && gdk_window && !gtk_widget_get_realized(widget)) {
- gdk_window_destroy(gdk_window);
- gtk_widget_set_window(widget, NULL);
- }
-}
-
-void gtk_preserve_window_size_allocate(GtkWidget* widget,
- GtkAllocation* allocation) {
- g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget));
-
- gtk_widget_set_allocation(widget, allocation);
-
- if (gtk_widget_get_realized(widget)) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- if (priv->delegate_resize) {
- gdk_window_move(gdk_window, allocation->x, allocation->y);
- } else {
- gdk_window_move_resize(
- gdk_window, allocation->x, allocation->y,
- allocation->width, allocation->height);
- }
- }
-
- // Propagate resize to children
- guint16 border_width = gtk_container_get_border_width(GTK_CONTAINER(widget));
- GList *children = GTK_FIXED(widget)->children;
- while (children) {
- GtkFixedChild *child = reinterpret_cast<GtkFixedChild*>(children->data);
- if (gtk_widget_get_visible(child->widget)) {
- GtkRequisition child_requisition;
- gtk_widget_get_child_requisition(child->widget, &child_requisition);
-
- GtkAllocation child_allocation;
- child_allocation.x = child->x + border_width;
- child_allocation.y = child->y + border_width;
- child_allocation.width = child_requisition.width;
- child_allocation.height = child_requisition.height;
-
- gtk_widget_size_allocate(child->widget, &child_allocation);
- }
- children = children->next;
- }
-}
-
-void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget,
- gboolean delegate) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- priv->delegate_resize = delegate;
-}
-
-void gtk_preserve_window_set_accessible_factory(
- GtkPreserveWindow* widget,
- AtkObject* (*factory)(void* userdata),
- gpointer userdata) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- priv->accessible_factory = factory;
- priv->accessible_factory_userdata = userdata;
-}
-
-AtkObject* gtk_preserve_window_get_accessible(GtkWidget* widget) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- if (priv->accessible_factory) {
- return priv->accessible_factory(priv->accessible_factory_userdata);
- } else {
- return GTK_WIDGET_CLASS(gtk_preserve_window_parent_class)
- ->get_accessible(widget);
- }
-}
-
-G_END_DECLS
diff --git a/ui/gfx/gtk_preserve_window.h b/ui/gfx/gtk_preserve_window.h
deleted file mode 100644
index 5b5198b..0000000
--- a/ui/gfx/gtk_preserve_window.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_GFX_GTK_PRESERVE_WINDOW_H_
-#define UI_GFX_GTK_PRESERVE_WINDOW_H_
-
-#include <atk/atk.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include "ui/gfx/gfx_export.h"
-
-// GtkFixed creates an X window when realized and destroys an X window
-// when unrealized. GtkPreserveWindow allows overrides this
-// behaviour. When preserve is set (via gtk_preserve_window_set_preserve),
-// the X window is only destroyed when the widget is destroyed.
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_PRESERVE_WINDOW \
- (gtk_preserve_window_get_type())
-#define GTK_PRESERVE_WINDOW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_PRESERVE_WINDOW, \
- GtkPreserveWindow))
-#define GTK_PRESERVE_WINDOW_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_PRESERVE_WINDOW, \
- GtkPreserveWindowClass))
-#define GTK_IS_PRESERVE_WINDOW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_PRESERVE_WINDOW))
-#define GTK_IS_PRESERVE_WINDOW_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_PRESERVE_WINDOW))
-#define GTK_PRESERVE_WINDOW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_PRESERVE_WINDOW, \
- GtkPreserveWindowClass))
-
-typedef struct _GtkPreserveWindow GtkPreserveWindow;
-typedef struct _GtkPreserveWindowClass GtkPreserveWindowClass;
-
-struct _GtkPreserveWindow {
- // Parent class.
- GtkFixed fixed;
-};
-
-struct _GtkPreserveWindowClass {
- GtkFixedClass parent_class;
-};
-
-GFX_EXPORT GType gtk_preserve_window_get_type() G_GNUC_CONST;
-GFX_EXPORT GtkWidget* gtk_preserve_window_new();
-
-// Whether or not we should preserve associated windows as the widget
-// is realized or unrealized.
-GFX_EXPORT gboolean gtk_preserve_window_get_preserve(GtkPreserveWindow* widget);
-GFX_EXPORT void gtk_preserve_window_set_preserve(GtkPreserveWindow* widget,
- gboolean value);
-
-// Whether or not someone else will gdk_window_resize the GdkWindow associated
-// with this widget (needed by the GPU process to synchronize resizing
-// with swapped between front and back buffer).
-GFX_EXPORT void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget,
- gboolean delegate);
-
-// Provide a function to return an AtkObject* when calls to get_accessible
-// are made on this widget. The parameter |userdata| will be passed to the
-// factory function.
-GFX_EXPORT void gtk_preserve_window_set_accessible_factory(
- GtkPreserveWindow* widget,
- AtkObject* (*factory)(void* userdata),
- gpointer userdata);
-
-G_END_DECLS
-
-#endif // UI_GFX_GTK_PRESERVE_WINDOW_H_
diff --git a/ui/gfx/gtk_util.cc b/ui/gfx/gtk_util.cc
deleted file mode 100644
index 0c11168..0000000
--- a/ui/gfx/gtk_util.cc
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/gtk_util.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <stdlib.h>
-
-#include "base/basictypes.h"
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "third_party/skia/include/core/SkUnPreMultiply.h"
-#include "ui/gfx/rect.h"
-
-namespace {
-
-// A process wide singleton that manages our usage of gdk cursors.
-// gdk_cursor_new() hits the disk in several places and GdkCursor instances can
-// be reused throughout the process.
-class GdkCursorCache {
- public:
- GdkCursorCache() {}
- ~GdkCursorCache() {
- for (GdkCursorMap::iterator i(cursors_.begin()); i != cursors_.end(); ++i) {
- gdk_cursor_unref(i->second);
- }
- cursors_.clear();
- }
-
- GdkCursor* GetCursorImpl(GdkCursorType type) {
- GdkCursorMap::iterator it = cursors_.find(type);
- GdkCursor* cursor = NULL;
- if (it == cursors_.end()) {
- cursor = gdk_cursor_new(type);
- cursors_.insert(std::make_pair(type, cursor));
- } else {
- cursor = it->second;
- }
-
- // It is not necessary to add a reference here. The callers can ref the
- // cursor if they need it for something.
- return cursor;
- }
-
- private:
- typedef std::map<GdkCursorType, GdkCursor*> GdkCursorMap;
- GdkCursorMap cursors_;
-
- DISALLOW_COPY_AND_ASSIGN(GdkCursorCache);
-};
-
-} // namespace
-
-namespace gfx {
-
-static void CommonInitFromCommandLine(const CommandLine& command_line,
- void (*init_func)(gint*, gchar***)) {
- const std::vector<std::string>& args = command_line.argv();
- int argc = args.size();
- scoped_ptr<char *[]> argv(new char *[argc + 1]);
- for (size_t i = 0; i < args.size(); ++i) {
- // TODO(piman@google.com): can gtk_init modify argv? Just being safe
- // here.
- argv[i] = strdup(args[i].c_str());
- }
- argv[argc] = NULL;
- char **argv_pointer = argv.get();
-
- init_func(&argc, &argv_pointer);
- for (size_t i = 0; i < args.size(); ++i) {
- free(argv[i]);
- }
-}
-
-void GtkInitFromCommandLine(const CommandLine& command_line) {
- CommonInitFromCommandLine(command_line, gtk_init);
-}
-
-void GdkInitFromCommandLine(const CommandLine& command_line) {
- CommonInitFromCommandLine(command_line, gdk_init);
-}
-
-GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap) {
- if (bitmap.isNull())
- return NULL;
-
- SkAutoLockPixels lock_pixels(bitmap);
-
- int width = bitmap.width();
- int height = bitmap.height();
-
- GdkPixbuf* pixbuf = gdk_pixbuf_new(
- GDK_COLORSPACE_RGB, // The only colorspace gtk supports.
- TRUE, // There is an alpha channel.
- 8,
- width, height);
-
- // SkBitmaps are premultiplied, we need to unpremultiply them.
- const int kBytesPerPixel = 4;
- uint8* divided = gdk_pixbuf_get_pixels(pixbuf);
-
- for (int y = 0, i = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- uint32 pixel = bitmap.getAddr32(0, y)[x];
-
- int alpha = SkColorGetA(pixel);
- if (alpha != 0 && alpha != 255) {
- SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel);
- divided[i + 0] = SkColorGetR(unmultiplied);
- divided[i + 1] = SkColorGetG(unmultiplied);
- divided[i + 2] = SkColorGetB(unmultiplied);
- divided[i + 3] = alpha;
- } else {
- divided[i + 0] = SkColorGetR(pixel);
- divided[i + 1] = SkColorGetG(pixel);
- divided[i + 2] = SkColorGetB(pixel);
- divided[i + 3] = alpha;
- }
- i += kBytesPerPixel;
- }
- }
-
- return pixbuf;
-}
-
-void SubtractRectanglesFromRegion(GdkRegion* region,
- const std::vector<Rect>& cutouts) {
- for (size_t i = 0; i < cutouts.size(); ++i) {
- GdkRectangle rect = cutouts[i].ToGdkRectangle();
- GdkRegion* rect_region = gdk_region_rectangle(&rect);
- gdk_region_subtract(region, rect_region);
- // TODO(deanm): It would be nice to be able to reuse the GdkRegion here.
- gdk_region_destroy(rect_region);
- }
-}
-
-GdkCursor* GetCursor(int type) {
- CR_DEFINE_STATIC_LOCAL(GdkCursorCache, impl, ());
- return impl.GetCursorImpl(static_cast<GdkCursorType>(type));
-}
-
-void InitRCStyles() {
- static const char kRCText[] =
- // Make our dialogs styled like the GNOME HIG.
- //
- // TODO(evanm): content-area-spacing was introduced in a later
- // version of GTK, so we need to set that manually on all dialogs.
- // Perhaps it would make sense to have a shared FixupDialog() function.
- "style \"gnome-dialog\" {\n"
- " xthickness = 12\n"
- " GtkDialog::action-area-border = 0\n"
- " GtkDialog::button-spacing = 6\n"
- " GtkDialog::content-area-spacing = 18\n"
- " GtkDialog::content-area-border = 12\n"
- "}\n"
- // Note we set it at the "application" priority, so users can override.
- "widget \"GtkDialog\" style : application \"gnome-dialog\"\n"
-
- // Make our about dialog special, so the image is flush with the edge.
- "style \"about-dialog\" {\n"
- " GtkDialog::action-area-border = 12\n"
- " GtkDialog::button-spacing = 6\n"
- " GtkDialog::content-area-spacing = 18\n"
- " GtkDialog::content-area-border = 0\n"
- "}\n"
- "widget \"about-dialog\" style : application \"about-dialog\"\n";
-
- gtk_rc_parse_string(kRCText);
-}
-
-base::TimeDelta GetCursorBlinkCycle() {
- // From http://library.gnome.org/devel/gtk/unstable/GtkSettings.html, this is
- // the default value for gtk-cursor-blink-time.
- static const gint kGtkDefaultCursorBlinkTime = 1200;
-
- gint cursor_blink_time = kGtkDefaultCursorBlinkTime;
- gboolean cursor_blink = TRUE;
- g_object_get(gtk_settings_get_default(),
- "gtk-cursor-blink-time", &cursor_blink_time,
- "gtk-cursor-blink", &cursor_blink,
- NULL);
- return cursor_blink ?
- base::TimeDelta::FromMilliseconds(cursor_blink_time) :
- base::TimeDelta();
-}
-
-} // namespace gfx
diff --git a/ui/gfx/gtk_util.h b/ui/gfx/gtk_util.h
deleted file mode 100644
index 7607603..0000000
--- a/ui/gfx/gtk_util.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_GFX_GTK_UTIL_H_
-#define UI_GFX_GTK_UTIL_H_
-
-#include <vector>
-
-#include "base/time/time.h"
-#include "ui/gfx/gfx_export.h"
-
-typedef struct _GdkPixbuf GdkPixbuf;
-typedef struct _GdkRegion GdkRegion;
-typedef struct _GdkCursor GdkCursor;
-
-class SkBitmap;
-
-namespace base {
-class CommandLine;
-}
-
-namespace gfx {
-
-class Rect;
-
-// Call gtk_init() / gdk_init() using the argc and argv from command_line.
-// These init functions want an argc and argv that they can mutate; we provide
-// those, but leave the original CommandLine unaltered.
-GFX_EXPORT void GtkInitFromCommandLine(const base::CommandLine& command_line);
-GFX_EXPORT void GdkInitFromCommandLine(const base::CommandLine& command_line);
-
-// Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so
-// it is an expensive operation. The returned GdkPixbuf will have a refcount of
-// 1, and the caller is responsible for unrefing it when done.
-GFX_EXPORT GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap);
-
-// Modify the given region by subtracting the given rectangles.
-GFX_EXPORT void SubtractRectanglesFromRegion(GdkRegion* region,
- const std::vector<Rect>& cutouts);
-
-// Returns a static instance of a GdkCursor* object, sharable across the
-// process. Caller must gdk_cursor_ref() it if they want to assume ownership.
-GFX_EXPORT GdkCursor* GetCursor(int type);
-
-// Initialize some GTK settings so that our dialogs are consistent.
-GFX_EXPORT void InitRCStyles();
-
-// Queries GtkSettings for the cursor blink cycle time. Returns a 0 duration if
-// blinking is disabled.
-GFX_EXPORT base::TimeDelta GetCursorBlinkCycle();
-
-} // namespace gfx
-
-#endif // UI_GFX_GTK_UTIL_H_
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
index 21fc7fb..6ee817b 100644
--- a/ui/gfx/image/image.cc
+++ b/ui/gfx/image/image.cc
@@ -18,15 +18,7 @@
#include "ui/gfx/codec/png_codec.h"
#endif
-#if defined(TOOLKIT_GTK)
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gdk/gdk.h>
-#include <glib-object.h>
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/gtk_util.h"
-#include "ui/gfx/image/cairo_cached_surface.h"
-#include "ui/gfx/scoped_gobject.h"
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
#include "base/mac/foundation_util.h"
#include "ui/gfx/image/image_skia_util_ios.h"
#elif defined(OS_MACOSX)
@@ -38,81 +30,6 @@ namespace gfx {
namespace internal {
-#if defined(TOOLKIT_GTK)
-const ImageSkia ImageSkiaFromGdkPixbuf(GdkPixbuf* pixbuf) {
- CHECK(pixbuf);
- gfx::Canvas canvas(gfx::Size(gdk_pixbuf_get_width(pixbuf),
- gdk_pixbuf_get_height(pixbuf)),
- 1.0f,
- false);
- skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
- cairo_t* cr = scoped_platform_paint.GetPlatformSurface();
- gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
- cairo_paint(cr);
- return ImageSkia(canvas.ExtractImageRep());
-}
-
-// Returns a 16x16 red pixbuf to visually show error in decoding PNG.
-// Also logs error to console.
-GdkPixbuf* GetErrorPixbuf() {
- LOG(ERROR) << "Unable to decode PNG.";
- GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 16, 16);
- gdk_pixbuf_fill(pixbuf, 0xff0000ff);
- return pixbuf;
-}
-
-GdkPixbuf* GdkPixbufFromPNG(
- const std::vector<gfx::ImagePNGRep>& image_png_reps) {
- scoped_refptr<base::RefCountedMemory> png_bytes(NULL);
- for (size_t i = 0; i < image_png_reps.size(); ++i) {
- if (image_png_reps[i].scale == 1.0f)
- png_bytes = image_png_reps[i].raw_data;
- }
-
- if (!png_bytes.get())
- return GetErrorPixbuf();
-
- GdkPixbuf* pixbuf = NULL;
- ui::ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new());
-
- bool ok = gdk_pixbuf_loader_write(loader.get(),
- reinterpret_cast<const guint8*>(png_bytes->front()), png_bytes->size(),
- NULL);
-
- // Calling gdk_pixbuf_loader_close forces the data to be parsed by the
- // loader. This must be done before calling gdk_pixbuf_loader_get_pixbuf.
- if (ok)
- ok = gdk_pixbuf_loader_close(loader.get(), NULL);
- if (ok)
- pixbuf = gdk_pixbuf_loader_get_pixbuf(loader.get());
-
- if (pixbuf) {
- // The pixbuf is owned by the scoped loader which will delete its ref when
- // it goes out of scope. Add a ref so that the pixbuf still exists.
- g_object_ref(pixbuf);
- } else {
- return GetErrorPixbuf();
- }
-
- return pixbuf;
-}
-
-scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromPixbuf(
- GdkPixbuf* pixbuf) {
- gchar* image = NULL;
- gsize image_size;
- GError* error = NULL;
- CHECK(gdk_pixbuf_save_to_buffer(
- pixbuf, &image, &image_size, "png", &error, NULL));
- scoped_refptr<base::RefCountedBytes> png_bytes(
- new base::RefCountedBytes());
- png_bytes->data().assign(image, image + image_size);
- g_free(image);
- return png_bytes;
-}
-
-#endif // defined(TOOLKIT_GTK)
-
#if defined(OS_IOS)
scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromUIImage(
UIImage* uiimage);
@@ -213,18 +130,6 @@ class ImageRep {
return reinterpret_cast<ImageRepSkia*>(this);
}
-#if defined(TOOLKIT_GTK)
- ImageRepGdk* AsImageRepGdk() {
- CHECK_EQ(type_, Image::kImageRepGdk);
- return reinterpret_cast<ImageRepGdk*>(this);
- }
-
- ImageRepCairo* AsImageRepCairo() {
- CHECK_EQ(type_, Image::kImageRepCairo);
- return reinterpret_cast<ImageRepCairo*>(this);
- }
-#endif
-
#if defined(OS_IOS)
ImageRepCocoaTouch* AsImageRepCocoaTouch() {
CHECK_EQ(type_, Image::kImageRepCocoaTouch);
@@ -326,77 +231,6 @@ class ImageRepSkia : public ImageRep {
DISALLOW_COPY_AND_ASSIGN(ImageRepSkia);
};
-#if defined(TOOLKIT_GTK)
-class ImageRepGdk : public ImageRep {
- public:
- explicit ImageRepGdk(GdkPixbuf* pixbuf)
- : ImageRep(Image::kImageRepGdk),
- pixbuf_(pixbuf) {
- CHECK(pixbuf);
- }
-
- virtual ~ImageRepGdk() {
- if (pixbuf_) {
- g_object_unref(pixbuf_);
- pixbuf_ = NULL;
- }
- }
-
- virtual int Width() const OVERRIDE {
- return gdk_pixbuf_get_width(pixbuf_);
- }
-
- virtual int Height() const OVERRIDE {
- return gdk_pixbuf_get_height(pixbuf_);
- }
-
- virtual gfx::Size Size() const OVERRIDE {
- return gfx::Size(Width(), Height());
- }
-
- GdkPixbuf* pixbuf() const { return pixbuf_; }
-
- private:
- GdkPixbuf* pixbuf_;
-
- DISALLOW_COPY_AND_ASSIGN(ImageRepGdk);
-};
-
-// Represents data that lives on the display server instead of in the client.
-class ImageRepCairo : public ImageRep {
- public:
- explicit ImageRepCairo(GdkPixbuf* pixbuf)
- : ImageRep(Image::kImageRepCairo),
- cairo_cache_(new CairoCachedSurface) {
- CHECK(pixbuf);
- cairo_cache_->UsePixbuf(pixbuf);
- }
-
- virtual ~ImageRepCairo() {
- delete cairo_cache_;
- }
-
- virtual int Width() const OVERRIDE {
- return cairo_cache_->Width();
- }
-
- virtual int Height() const OVERRIDE {
- return cairo_cache_->Height();
- }
-
- virtual gfx::Size Size() const OVERRIDE {
- return gfx::Size(Width(), Height());
- }
-
- CairoCachedSurface* surface() const { return cairo_cache_; }
-
- private:
- CairoCachedSurface* cairo_cache_;
-
- DISALLOW_COPY_AND_ASSIGN(ImageRepCairo);
-};
-#endif // defined(TOOLKIT_GTK)
-
#if defined(OS_IOS)
class ImageRepCocoaTouch : public ImageRep {
public:
@@ -550,16 +384,6 @@ Image::Image(const ImageSkia& image) {
}
}
-#if defined(TOOLKIT_GTK)
-Image::Image(GdkPixbuf* pixbuf) {
- if (pixbuf) {
- storage_ = new internal::ImageStorage(Image::kImageRepGdk);
- internal::ImageRepGdk* rep = new internal::ImageRepGdk(pixbuf);
- AddRepresentation(rep);
- }
-}
-#endif
-
#if defined(OS_IOS)
Image::Image(UIImage* image)
: storage_(new internal::ImageStorage(Image::kImageRepCocoaTouch)) {
@@ -632,15 +456,7 @@ const ImageSkia* Image::ToImageSkia() const {
internal::ImageSkiaFromPNG(png_rep->image_reps()));
break;
}
-#if defined(TOOLKIT_GTK)
- case kImageRepGdk: {
- internal::ImageRepGdk* native_rep =
- GetRepresentation(kImageRepGdk, true)->AsImageRepGdk();
- rep = new internal::ImageRepSkia(new ImageSkia(
- internal::ImageSkiaFromGdkPixbuf(native_rep->pixbuf())));
- break;
- }
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
case kImageRepCocoaTouch: {
internal::ImageRepCocoaTouch* native_rep =
GetRepresentation(kImageRepCocoaTouch, true)
@@ -667,47 +483,6 @@ const ImageSkia* Image::ToImageSkia() const {
return rep->AsImageRepSkia()->image();
}
-#if defined(TOOLKIT_GTK)
-GdkPixbuf* Image::ToGdkPixbuf() const {
- internal::ImageRep* rep = GetRepresentation(kImageRepGdk, false);
- if (!rep) {
- switch (DefaultRepresentationType()) {
- case kImageRepPNG: {
- internal::ImageRepPNG* png_rep =
- GetRepresentation(kImageRepPNG, true)->AsImageRepPNG();
- rep = new internal::ImageRepGdk(internal::GdkPixbufFromPNG(
- png_rep->image_reps()));
- break;
- }
- case kImageRepSkia: {
- internal::ImageRepSkia* skia_rep =
- GetRepresentation(kImageRepSkia, true)->AsImageRepSkia();
- rep = new internal::ImageRepGdk(gfx::GdkPixbufFromSkBitmap(
- *skia_rep->image()->bitmap()));
- break;
- }
- default:
- NOTREACHED();
- }
- CHECK(rep);
- AddRepresentation(rep);
- }
- return rep->AsImageRepGdk()->pixbuf();
-}
-
-CairoCachedSurface* const Image::ToCairo() const {
- internal::ImageRep* rep = GetRepresentation(kImageRepCairo, false);
- if (!rep) {
- // Handle any-to-Cairo conversion. This may create and cache an intermediate
- // pixbuf before sending the data to the display server.
- rep = new internal::ImageRepCairo(ToGdkPixbuf());
- CHECK(rep);
- AddRepresentation(rep);
- }
- return rep->AsImageRepCairo()->surface();
-}
-#endif
-
#if defined(OS_IOS)
UIImage* Image::ToUIImage() const {
internal::ImageRep* rep = GetRepresentation(kImageRepCocoaTouch, false);
@@ -788,14 +563,7 @@ scoped_refptr<base::RefCountedMemory> Image::As1xPNGBytes() const {
scoped_refptr<base::RefCountedMemory> png_bytes(NULL);
switch (DefaultRepresentationType()) {
-#if defined(TOOLKIT_GTK)
- case kImageRepGdk: {
- internal::ImageRepGdk* gdk_rep =
- GetRepresentation(kImageRepGdk, true)->AsImageRepGdk();
- png_bytes = internal::Get1xPNGBytesFromPixbuf(gdk_rep->pixbuf());
- break;
- }
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
case kImageRepCocoaTouch: {
internal::ImageRepCocoaTouch* cocoa_touch_rep =
GetRepresentation(kImageRepCocoaTouch, true)
@@ -870,14 +638,6 @@ SkBitmap* Image::CopySkBitmap() const {
return new SkBitmap(*ToSkBitmap());
}
-#if defined(TOOLKIT_GTK)
-GdkPixbuf* Image::CopyGdkPixbuf() const {
- GdkPixbuf* pixbuf = ToGdkPixbuf();
- g_object_ref(pixbuf);
- return pixbuf;
-}
-#endif
-
#if defined(OS_IOS)
UIImage* Image::CopyUIImage() const {
UIImage* image = ToUIImage();
diff --git a/ui/gfx/image/image_unittest.cc b/ui/gfx/image/image_unittest.cc
index 2ff88c7..1e137e0 100644
--- a/ui/gfx/image/image_unittest.cc
+++ b/ui/gfx/image/image_unittest.cc
@@ -10,10 +10,7 @@
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_unittest_util.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#include "ui/gfx/gtk_util.h"
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
#include "base/mac/foundation_util.h"
#include "skia/ext/skia_utils_ios.h"
#elif defined(OS_MACOSX)
@@ -75,7 +72,7 @@ TEST_F(ImageTest, EmptyImage) {
// Test constructing a gfx::Image from an empty PlatformImage.
TEST_F(ImageTest, EmptyImageFromEmptyPlatformImage) {
-#if defined(OS_IOS) || defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+#if defined(OS_IOS) || defined(OS_MACOSX)
gfx::Image image1(NULL);
EXPECT_TRUE(image1.IsEmpty());
EXPECT_EQ(0, image1.Width());
@@ -436,27 +433,6 @@ TEST_F(ImageTest, PlatformToSkiaToCopy) {
delete bitmap;
}
-#if defined(TOOLKIT_GTK)
-TEST_F(ImageTest, SkiaToGdkCopy) {
- GdkPixbuf* pixbuf;
-
- {
- gfx::Image image(gt::CreateImageSkia(25, 25));
- pixbuf = image.CopyGdkPixbuf();
- }
-
- EXPECT_TRUE(pixbuf);
- g_object_unref(pixbuf);
-}
-
-TEST_F(ImageTest, SkiaToCairoCreatesGdk) {
- gfx::Image image(gt::CreateImageSkia(25, 25));
- EXPECT_FALSE(image.HasRepresentation(gfx::Image::kImageRepGdk));
- EXPECT_TRUE(image.ToCairo());
- EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepGdk));
-}
-#endif
-
#if defined(OS_IOS)
TEST_F(ImageTest, SkiaToCocoaTouchCopy) {
UIImage* ui_image;
diff --git a/ui/gfx/image/image_unittest_util.cc b/ui/gfx/image/image_unittest_util.cc
index 4baf30a..aa7094c 100644
--- a/ui/gfx/image/image_unittest_util.cc
+++ b/ui/gfx/image/image_unittest_util.cc
@@ -15,10 +15,7 @@
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image_skia.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#include "ui/gfx/gtk_util.h"
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "skia/ext/skia_utils_ios.h"
@@ -192,8 +189,6 @@ PlatformImage CreatePlatformImage() {
NSImage* image = gfx::SkBitmapToNSImage(bitmap);
base::mac::NSObjectRetain(image);
return image;
-#elif defined(TOOLKIT_GTK)
- return gfx::GdkPixbufFromSkBitmap(bitmap);
#else
return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
#endif
@@ -204,8 +199,6 @@ gfx::Image::RepresentationType GetPlatformRepresentationType() {
return gfx::Image::kImageRepCocoaTouch;
#elif defined(OS_MACOSX)
return gfx::Image::kImageRepCocoa;
-#elif defined(TOOLKIT_GTK)
- return gfx::Image::kImageRepGdk;
#else
return gfx::Image::kImageRepSkia;
#endif
@@ -216,8 +209,6 @@ PlatformImage ToPlatformType(const gfx::Image& image) {
return image.ToUIImage();
#elif defined(OS_MACOSX)
return image.ToNSImage();
-#elif defined(TOOLKIT_GTK)
- return image.ToGdkPixbuf();
#else
return image.AsImageSkia();
#endif
@@ -228,8 +219,6 @@ PlatformImage CopyPlatformType(const gfx::Image& image) {
return image.CopyUIImage();
#elif defined(OS_MACOSX)
return image.CopyNSImage();
-#elif defined(TOOLKIT_GTK)
- return image.CopyGdkPixbuf();
#else
return image.AsImageSkia();
#endif
@@ -237,16 +226,6 @@ PlatformImage CopyPlatformType(const gfx::Image& image) {
#if defined(OS_MACOSX)
// Defined in image_unittest_util_mac.mm.
-#elif defined(TOOLKIT_GTK)
-SkColor GetPlatformImageColor(PlatformImage image, int x, int y) {
- int n_channels = gdk_pixbuf_get_n_channels(image);
- int rowstride = gdk_pixbuf_get_rowstride(image);
- guchar* gdk_pixels = gdk_pixbuf_get_pixels(image);
-
- guchar* pixel = gdk_pixels + (y * rowstride) + (x * n_channels);
- guchar alpha = gdk_pixbuf_get_has_alpha(image) ? pixel[3] : 255;
- return SkColorSetARGB(alpha, pixel[0], pixel[1], pixel[2]);
-}
#else
SkColor GetPlatformImageColor(PlatformImage image, int x, int y) {
SkBitmap bitmap = *image.bitmap();
@@ -264,7 +243,7 @@ void CheckIsTransparent(SkColor color) {
}
bool IsPlatformImageValid(PlatformImage image) {
-#if defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+#if defined(OS_MACOSX)
return image != NULL;
#else
return !image.isNull();
@@ -272,7 +251,7 @@ bool IsPlatformImageValid(PlatformImage image) {
}
bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) {
-#if defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+#if defined(OS_MACOSX)
return image1 == image2;
#else
return image1.BackedBySameObjectAs(image2);
diff --git a/ui/gfx/image/image_unittest_util.h b/ui/gfx/image/image_unittest_util.h
index 4788e4e..cac8015 100644
--- a/ui/gfx/image/image_unittest_util.h
+++ b/ui/gfx/image/image_unittest_util.h
@@ -18,8 +18,6 @@ namespace test {
typedef UIImage* PlatformImage;
#elif defined(OS_MACOSX)
typedef NSImage* PlatformImage;
-#elif defined(TOOLKIT_GTK)
-typedef GdkPixbuf* PlatformImage;
#else
typedef gfx::ImageSkia PlatformImage;
#endif
diff --git a/ui/gfx/native_widget_types.h b/ui/gfx/native_widget_types.h
index 2c3e196..f79670d 100644
--- a/ui/gfx/native_widget_types.h
+++ b/ui/gfx/native_widget_types.h
@@ -98,14 +98,7 @@ typedef struct _PangoFontDescription PangoFontDescription;
typedef struct _cairo cairo_t;
#endif
-#if defined(TOOLKIT_GTK)
-typedef struct _GdkCursor GdkCursor;
-typedef union _GdkEvent GdkEvent;
-typedef struct _GdkPixbuf GdkPixbuf;
-typedef struct _GdkRegion GdkRegion;
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-#elif defined(OS_ANDROID)
+#if defined(OS_ANDROID)
struct ANativeWindow;
namespace ui {
class WindowAndroid;
@@ -132,12 +125,6 @@ typedef NSCursor* NativeCursor;
typedef NSView* NativeView;
typedef NSWindow* NativeWindow;
typedef NSEvent* NativeEvent;
-#elif defined(TOOLKIT_GTK)
-typedef GdkCursor* NativeCursor;
-typedef GtkWidget* NativeView;
-typedef GtkWindow* NativeWindow;
-typedef GdkRegion* NativeRegion;
-typedef GdkEvent* NativeEvent;
#elif defined(OS_ANDROID)
typedef void* NativeCursor;
typedef ui::ViewAndroid* NativeView;
@@ -160,11 +147,6 @@ typedef NSFont* NativeFont;
typedef NSTextField* NativeEditView;
typedef CGContext* NativeDrawingContext;
typedef void* NativeViewAccessible;
-#elif defined(TOOLKIT_GTK)
-typedef PangoFontDescription* NativeFont;
-typedef GtkWidget* NativeEditView;
-typedef cairo_t* NativeDrawingContext;
-typedef void* NativeViewAccessible;
#elif defined(USE_CAIRO)
typedef PangoFontDescription* NativeFont;
typedef void* NativeEditView;
@@ -188,8 +170,6 @@ const gfx::NativeCursor kNullCursor = static_cast<gfx::NativeCursor>(NULL);
typedef UIImage NativeImageType;
#elif defined(OS_MACOSX)
typedef NSImage NativeImageType;
-#elif defined(TOOLKIT_GTK)
-typedef GdkPixbuf NativeImageType;
#else
typedef SkBitmap NativeImageType;
#endif
diff --git a/ui/gfx/pango_util.cc b/ui/gfx/pango_util.cc
index 3716cf1..56503c6 100644
--- a/ui/gfx/pango_util.cc
+++ b/ui/gfx/pango_util.cc
@@ -23,10 +23,6 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/text_utils.h"
-#if defined(TOOLKIT_GTK)
-#include <gdk/gdk.h>
-#endif
-
namespace gfx {
namespace {
@@ -116,12 +112,8 @@ float GetPixelsInPoint() {
} // namespace
PangoContext* GetPangoContext() {
-#if defined(TOOLKIT_GTK)
- return gdk_pango_context_get();
-#else
PangoFontMap* font_map = pango_cairo_font_map_get_default();
return pango_font_map_create_context(font_map);
-#endif
}
double GetPangoResolution() {
diff --git a/ui/gfx/path_gtk.cc b/ui/gfx/path_gtk.cc
deleted file mode 100644
index d5c376d..0000000
--- a/ui/gfx/path_gtk.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/path.h"
-
-#include <gdk/gdk.h>
-
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-
-#error "The GTK+ port will be deleted later this week. If you are seeing this, you are trying to compile it. Please check your gyp flags for 'use_aura=0' and remove them."
-
-namespace gfx {
-
-GdkRegion* Path::CreateNativeRegion() const {
- int point_count = getPoints(NULL, 0);
- if (point_count <= 1) {
- // NOTE: ideally this would return gdk_empty_region, but that returns a
- // region with nothing in it.
- return NULL;
- }
-
- scoped_ptr<SkPoint[]> points(new SkPoint[point_count]);
- getPoints(points.get(), point_count);
-
- scoped_ptr<GdkPoint[]> gdk_points(new GdkPoint[point_count]);
- for (int i = 0; i < point_count; ++i) {
- gdk_points[i].x = SkScalarRoundToInt(points[i].fX);
- gdk_points[i].y = SkScalarRoundToInt(points[i].fY);
- }
-
- return gdk_region_polygon(gdk_points.get(), point_count, GDK_EVEN_ODD_RULE);
-}
-
-// static
-NativeRegion Path::IntersectRegions(NativeRegion r1, NativeRegion r2) {
- GdkRegion* copy = gdk_region_copy(r1);
- gdk_region_intersect(copy, r2);
- return copy;
-}
-
-// static
-NativeRegion Path::CombineRegions(NativeRegion r1, NativeRegion r2) {
- GdkRegion* copy = gdk_region_copy(r1);
- gdk_region_union(copy, r2);
- return copy;
-}
-
-// static
-NativeRegion Path::SubtractRegion(NativeRegion r1, NativeRegion r2) {
- GdkRegion* copy = gdk_region_copy(r1);
- gdk_region_subtract(copy, r2);
- return copy;
-}
-
-} // namespace gfx
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index 977cea4..cbe3dd5 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -24,10 +24,6 @@
#include "ui/gfx/render_text_pango.h"
#endif
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#endif
-
using base::ASCIIToUTF16;
using base::UTF8ToUTF16;
using base::WideToUTF16;
@@ -63,10 +59,6 @@ base::string16 GetSelectedText(RenderText* render_text) {
void SetRTL(bool rtl) {
// Override the current locale/direction.
base::i18n::SetICUDefaultLocale(rtl ? "he" : "en");
-#if defined(TOOLKIT_GTK)
- // Do the same for GTK, which does not rely on the ICU default locale.
- gtk_widget_set_default_direction(rtl ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
-#endif
EXPECT_EQ(rtl, base::i18n::IsRTL());
}
diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc
deleted file mode 100644
index ac2464b..0000000
--- a/ui/gfx/screen_gtk.cc
+++ /dev/null
@@ -1,210 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/screen.h"
-
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-#include "base/logging.h"
-#include "ui/gfx/display.h"
-
-namespace {
-
-bool GetScreenWorkArea(gfx::Rect* out_rect) {
- gboolean ok;
- guchar* raw_data = NULL;
- gint data_len = 0;
- ok = gdk_property_get(gdk_get_default_root_window(), // a gdk window
- gdk_atom_intern("_NET_WORKAREA", FALSE), // property
- gdk_atom_intern("CARDINAL", FALSE), // property type
- 0, // byte offset into property
- 0xff, // property length to retrieve
- false, // delete property after retrieval?
- NULL, // returned property type
- NULL, // returned data format
- &data_len, // returned data len
- &raw_data); // returned data
- if (!ok)
- return false;
-
- // We expect to get four longs back: x, y, width, height.
- if (data_len < static_cast<gint>(4 * sizeof(glong))) {
- NOTREACHED();
- g_free(raw_data);
- return false;
- }
-
- glong* data = reinterpret_cast<glong*>(raw_data);
- gint x = data[0];
- gint y = data[1];
- gint width = data[2];
- gint height = data[3];
- g_free(raw_data);
-
- out_rect->SetRect(x, y, width, height);
- return true;
-}
-
-gfx::Display GetDisplayForMonitorNum(GdkScreen* screen, gint monitor_num) {
- GdkRectangle bounds;
- gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds);
- // Use |monitor_num| as display id.
- gfx::Display display(monitor_num, gfx::Rect(bounds));
- if (gdk_screen_get_primary_monitor(screen) == monitor_num) {
- gfx::Rect rect;
- if (GetScreenWorkArea(&rect))
- display.set_work_area(gfx::IntersectRects(rect, display.bounds()));
- }
- return display;
-}
-
-gfx::Display GetMonitorAreaNearestWindow(gfx::NativeView view) {
- GdkScreen* screen = gdk_screen_get_default();
- gint monitor_num = 0;
- if (view && GTK_IS_WINDOW(view)) {
- GtkWidget* top_level = gtk_widget_get_toplevel(view);
- DCHECK(GTK_IS_WINDOW(top_level));
- GtkWindow* window = GTK_WINDOW(top_level);
- screen = gtk_window_get_screen(window);
- monitor_num = gdk_screen_get_monitor_at_window(
- screen,
- gtk_widget_get_window(top_level));
- }
- return GetDisplayForMonitorNum(screen, monitor_num);
-}
-
-class ScreenGtk : public gfx::Screen {
- public:
- ScreenGtk() {
- }
-
- virtual ~ScreenGtk() {
- }
-
- virtual bool IsDIPEnabled() OVERRIDE {
- return false;
- }
-
- virtual gfx::Point GetCursorScreenPoint() OVERRIDE {
- gint x, y;
- gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL);
- return gfx::Point(x, y);
- }
-
- // Returns the window under the cursor.
- virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE {
- GdkWindow* window = gdk_window_at_pointer(NULL, NULL);
- if (!window)
- return NULL;
-
- gpointer data = NULL;
- gdk_window_get_user_data(window, &data);
- GtkWidget* widget = reinterpret_cast<GtkWidget*>(data);
- if (!widget)
- return NULL;
- widget = gtk_widget_get_toplevel(widget);
- return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL;
- }
-
- virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point)
- OVERRIDE {
- NOTIMPLEMENTED();
- return NULL;
- }
-
- // Returns the number of displays.
- // Mirrored displays are excluded; this method is intended to return the
- // number of distinct, usable displays.
- virtual int GetNumDisplays() const OVERRIDE {
- // This query is kinda bogus for Linux -- do we want number of X screens?
- // The number of monitors Xinerama has? We'll just use whatever GDK uses.
- GdkScreen* screen = gdk_screen_get_default();
- return gdk_screen_get_n_monitors(screen);
- }
-
- virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE {
- GdkScreen* screen = gdk_screen_get_default();
- gint num_of_displays = gdk_screen_get_n_monitors(screen);
- std::vector<gfx::Display> all_displays;
- for (gint i = 0; i < num_of_displays; ++i)
- all_displays.push_back(GetDisplayForMonitorNum(screen, i));
- return all_displays;
- }
-
- // Returns the display nearest the specified window.
- virtual gfx::Display GetDisplayNearestWindow(
- gfx::NativeView view) const OVERRIDE {
- // Do not use the _NET_WORKAREA here, this is supposed to be an area on a
- // specific monitor, and _NET_WORKAREA is a hint from the WM that
- // generally spans across all monitors. This would make the work area
- // larger than the monitor.
- // TODO(danakj) This is a work-around as there is no standard way to get
- // this area, but it is a rect that we should be computing. The standard
- // means to compute this rect would be to watch all windows with
- // _NET_WM_STRUT(_PARTIAL) hints, and subtract their space from the
- // physical area of the display to construct a work area.
- // TODO(oshima): Implement Observer.
- return GetMonitorAreaNearestWindow(view);
- }
-
- // Returns the the display nearest the specified point.
- virtual gfx::Display GetDisplayNearestPoint(
- const gfx::Point& point) const OVERRIDE {
- GdkScreen* screen = gdk_screen_get_default();
- gint monitor = gdk_screen_get_monitor_at_point(
- screen, point.x(), point.y());
- // TODO(oshima): Implement Observer.
- return GetDisplayForMonitorNum(screen, monitor);
- }
-
- // Returns the display that most closely intersects the provided bounds.
- virtual gfx::Display GetDisplayMatching(
- const gfx::Rect& match_rect) const OVERRIDE {
- std::vector<gfx::Display> displays = GetAllDisplays();
- gfx::Display maxIntersectDisplay;
- gfx::Rect maxIntersection;
- for (std::vector<gfx::Display>::iterator it = displays.begin();
- it != displays.end(); ++it) {
- gfx::Rect displayIntersection = it->bounds();
- displayIntersection.Intersect(match_rect);
- if (displayIntersection.size().GetArea() >
- maxIntersection.size().GetArea()) {
- maxIntersectDisplay = *it;
- maxIntersection = displayIntersection;
- }
- }
- return maxIntersectDisplay.is_valid() ?
- maxIntersectDisplay : GetPrimaryDisplay();
- }
-
- // Returns the primary display.
- virtual gfx::Display GetPrimaryDisplay() const OVERRIDE {
- GdkScreen* screen = gdk_screen_get_default();
- gint primary_monitor_index = gdk_screen_get_primary_monitor(screen);
- // TODO(oshima): Implement Observer.
- return GetDisplayForMonitorNum(screen, primary_monitor_index);
- }
-
- virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE {
- // TODO(oshima): crbug.com/122863.
- }
-
- virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {
- // TODO(oshima): crbug.com/122863.
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScreenGtk);
-};
-
-} // namespace
-
-namespace gfx {
-
-Screen* CreateNativeScreen() {
- return new ScreenGtk;
-}
-
-} // namespace gfx
diff --git a/ui/gfx/skia_utils_gtk.cc b/ui/gfx/skia_utils_gtk.cc
deleted file mode 100644
index f7f3a0a..0000000
--- a/ui/gfx/skia_utils_gtk.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/skia_utils_gtk.h"
-
-#include <gdk/gdk.h>
-
-namespace gfx {
-
-const int kSkiaToGDKMultiplier = 257;
-
-// GDK_COLOR_RGB multiplies by 257 (= 0x10001) to distribute the bits evenly
-// See: http://www.mindcontrol.org/~hplus/graphics/expand-bits.html
-// To get back, we can just right shift by eight
-// (or, formulated differently, i == (i*257)/256 for all i < 256).
-
-SkColor GdkColorToSkColor(GdkColor color) {
- return SkColorSetRGB(color.red >> 8, color.green >> 8, color.blue >> 8);
-}
-
-GdkColor SkColorToGdkColor(SkColor color) {
- GdkColor gdk_color = {
- 0,
- static_cast<guint16>(SkColorGetR(color) * kSkiaToGDKMultiplier),
- static_cast<guint16>(SkColorGetG(color) * kSkiaToGDKMultiplier),
- static_cast<guint16>(SkColorGetB(color) * kSkiaToGDKMultiplier)
- };
- return gdk_color;
-}
-
-} // namespace gfx
diff --git a/ui/gfx/skia_utils_gtk.h b/ui/gfx/skia_utils_gtk.h
deleted file mode 100644
index 6b74da2..0000000
--- a/ui/gfx/skia_utils_gtk.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_GFX_SKIA_UTILS_GTK_H_
-#define UI_GFX_SKIA_UTILS_GTK_H_
-
-#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/gfx_export.h"
-
-typedef struct _GdkColor GdkColor;
-
-namespace gfx {
-
-// Converts GdkColors to the ARGB layout Skia expects.
-GFX_EXPORT SkColor GdkColorToSkColor(GdkColor color);
-
-// Converts ARGB to GdkColor.
-GFX_EXPORT GdkColor SkColorToGdkColor(SkColor color);
-
-} // namespace gfx
-
-#endif // UI_GFX_SKIA_UTILS_GTK_H_