diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-02 11:24:03 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-02 11:24:03 +0000 |
commit | 42b4c09d80d9962c9b373b02ad00ec307732822b (patch) | |
tree | 9e075f356e85af0982101173581517253b26d2f7 /chrome | |
parent | 8b03e8d6baf5f5e6432486435d2974b54b12c9d6 (diff) | |
download | chromium_src-42b4c09d80d9962c9b373b02ad00ec307732822b.zip chromium_src-42b4c09d80d9962c9b373b02ad00ec307732822b.tar.gz chromium_src-42b4c09d80d9962c9b373b02ad00ec307732822b.tar.bz2 |
Implement gfx::Path on GTK.
Review URL: http://codereview.chromium.org/28297
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/chrome.gyp | 4 | ||||
-rw-r--r-- | chrome/common/common.scons | 6 | ||||
-rw-r--r-- | chrome/common/common.vcproj | 2 | ||||
-rw-r--r-- | chrome/common/gfx/path.h | 26 | ||||
-rw-r--r-- | chrome/common/gfx/path_gtk.cc | 27 | ||||
-rw-r--r-- | chrome/common/gfx/path_win.cc (renamed from chrome/common/gfx/path.cc) | 10 |
6 files changed, 54 insertions, 21 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 81aa3c4..3756118 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -112,7 +112,8 @@ 'common/gfx/icon_util.cc', 'common/gfx/icon_util.h', 'common/gfx/insets.h', - 'common/gfx/path.cc', + 'common/gfx/path_gtk.cc', + 'common/gfx/path_win.cc', 'common/gfx/path.h', 'common/gfx/text_elider.cc', 'common/gfx/text_elider.h', @@ -294,7 +295,6 @@ 'sources!': [ 'common/gfx/emf.cc', 'common/gfx/icon_util.cc', - 'common/gfx/path.cc', 'common/chrome_process_filter.cc', 'common/classfactory.cc', 'common/drag_drop_types.cc', diff --git a/chrome/common/common.scons b/chrome/common/common.scons index b6b43aa..86b43a9 100644 --- a/chrome/common/common.scons +++ b/chrome/common/common.scons @@ -73,7 +73,8 @@ input_files = ChromeFileList([ 'gfx/icon_util.cc', 'gfx/icon_util.h', 'gfx/insets.h', - 'gfx/path.cc', + 'gfx/path_gtk.cc', + 'gfx/path_win.cc', 'gfx/path.h', 'gfx/text_elider.cc', 'gfx/text_elider.h', @@ -237,7 +238,6 @@ if not env.Bit('windows'): 'drag_drop_types.cc', 'gfx/emf.cc', 'gfx/icon_util.cc', - 'gfx/path.cc', 'os_exchange_data.cc', 'process_watcher.cc', ) @@ -249,6 +249,7 @@ if not env.Bit('windows'): 'classfactory.cc', 'gfx/chrome_canvas_win.cc', 'gfx/chrome_font_win.cc', + 'gfx/path_win.cc', 'ipc_channel_win.cc', 'resource_bundle_win.cc', 'win_safe_util.cc', @@ -264,6 +265,7 @@ if not env.Bit('linux'): 'gfx/chrome_canvas_skia.cc', 'gfx/chrome_font_gtk.cc', 'gfx/chrome_font_skia.cc', + 'gfx/path_gtk.cc', ) if not env.Bit('mac'): diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj index d44bcf1..d91438c 100644 --- a/chrome/common/common.vcproj +++ b/chrome/common/common.vcproj @@ -201,7 +201,7 @@ > </File> <File - RelativePath=".\gfx\path.cc" + RelativePath=".\gfx\path_win.cc" > </File> <File diff --git a/chrome/common/gfx/path.h b/chrome/common/gfx/path.h index c23ecd1..5003132 100644 --- a/chrome/common/gfx/path.h +++ b/chrome/common/gfx/path.h @@ -2,29 +2,39 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_GFX_CHROME_PATH_H__ -#define CHROME_COMMON_GFX_CHROME_PATH_H__ +#ifndef CHROME_COMMON_GFX_CHROME_PATH_H_ +#define CHROME_COMMON_GFX_CHROME_PATH_H_ +#include "base/basictypes.h" + +#if defined(OS_WIN) #include <windows.h> +#elif defined(OS_LINUX) +typedef struct _GdkRegion GdkRegion; +#endif -#include "base/basictypes.h" #include "SkPath.h" namespace gfx { class Path : public SkPath { public: - Path(); + Path() : SkPath() { moveTo(0, 0); } +#if defined(OS_WIN) // Creates a HRGN from the path. The caller is responsible for freeing - // resources used by this region. + // resources used by this region. This only supports polygon paths. HRGN CreateHRGN() const; +#elif defined(OS_LINUX) + // Creates a Gdkregion from the path. The caller is responsible for freeing + // resources used by this region. This only supports polygon paths. + GdkRegion* CreateGdkRegion() const; +#endif private: - DISALLOW_EVIL_CONSTRUCTORS(Path); + DISALLOW_COPY_AND_ASSIGN(Path); }; } -#endif // #ifndef CHROME_COMMON_GFX_CHROME_PATH_H__ - +#endif // #ifndef CHROME_COMMON_GFX_CHROME_PATH_H_ diff --git a/chrome/common/gfx/path_gtk.cc b/chrome/common/gfx/path_gtk.cc new file mode 100644 index 0000000..aeab76f --- /dev/null +++ b/chrome/common/gfx/path_gtk.cc @@ -0,0 +1,27 @@ +// Copyright (c) 2006-2008 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 "chrome/common/gfx/path.h" + +#include <gdk/gdk.h> + +#include "base/scoped_ptr.h" + +namespace gfx { + +GdkRegion* Path::CreateGdkRegion() const { + int point_count = getPoints(NULL, 0); + scoped_array<SkPoint> points(new SkPoint[point_count]); + getPoints(points.get(), point_count); + + scoped_array<GdkPoint> gdk_points(new GdkPoint[point_count]); + for (int i = 0; i < point_count; ++i) { + gdk_points[i].x = SkScalarRound(points[i].fX); + gdk_points[i].y = SkScalarRound(points[i].fY); + } + + return gdk_region_polygon(gdk_points.get(), point_count, GDK_EVEN_ODD_RULE); +} + +} // namespace gfx diff --git a/chrome/common/gfx/path.cc b/chrome/common/gfx/path_win.cc index 43efc34..aa2fe02 100644 --- a/chrome/common/gfx/path.cc +++ b/chrome/common/gfx/path_win.cc @@ -8,10 +8,6 @@ namespace gfx { -Path::Path() : SkPath() { - moveTo(0, 0); -} - HRGN Path::CreateHRGN() const { int point_count = getPoints(NULL, 0); scoped_array<SkPoint> points(new SkPoint[point_count]); @@ -21,10 +17,8 @@ HRGN Path::CreateHRGN() const { windows_points[i].x = SkScalarRound(points[i].fX); windows_points[i].y = SkScalarRound(points[i].fY); } - HRGN region = ::CreatePolygonRgn(windows_points.get(), point_count, ALTERNATE); - return region; + return ::CreatePolygonRgn(windows_points.get(), point_count, ALTERNATE); } -}; - +} // namespace gfx |