summaryrefslogtreecommitdiffstats
path: root/chrome/common/gfx
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-02 11:24:03 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-02 11:24:03 +0000
commit42b4c09d80d9962c9b373b02ad00ec307732822b (patch)
tree9e075f356e85af0982101173581517253b26d2f7 /chrome/common/gfx
parent8b03e8d6baf5f5e6432486435d2974b54b12c9d6 (diff)
downloadchromium_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/common/gfx')
-rw-r--r--chrome/common/gfx/path.h26
-rw-r--r--chrome/common/gfx/path_gtk.cc27
-rw-r--r--chrome/common/gfx/path_win.cc (renamed from chrome/common/gfx/path.cc)10
3 files changed, 47 insertions, 16 deletions
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