diff options
Diffstat (limited to 'app/gfx')
-rw-r--r-- | app/gfx/native_widget_types.h | 3 | ||||
-rw-r--r-- | app/gfx/path.cc | 18 | ||||
-rw-r--r-- | app/gfx/path.h | 43 | ||||
-rw-r--r-- | app/gfx/path_gtk.cc | 23 | ||||
-rw-r--r-- | app/gfx/path_win.cc | 23 |
5 files changed, 17 insertions, 93 deletions
diff --git a/app/gfx/native_widget_types.h b/app/gfx/native_widget_types.h index eda722d..0153194 100644 --- a/app/gfx/native_widget_types.h +++ b/app/gfx/native_widget_types.h @@ -51,7 +51,6 @@ typedef struct _GdkCursor GdkCursor; typedef struct _GtkWidget GtkWidget; typedef struct _GtkWindow GtkWindow; typedef struct _cairo cairo_t; -typedef struct _GdkRegion GdkRegion; #endif namespace gfx { @@ -63,7 +62,6 @@ typedef HWND NativeEditView; typedef HDC NativeDrawingContext; typedef HCURSOR NativeCursor; typedef HMENU NativeMenu; -typedef HRGN NativeRegion; #elif defined(OS_MACOSX) typedef NSView* NativeView; typedef NSWindow* NativeWindow; @@ -78,7 +76,6 @@ typedef GtkWidget* NativeEditView; typedef cairo_t* NativeDrawingContext; typedef GdkCursor* NativeCursor; typedef GtkWidget* NativeMenu; -typedef GdkRegion* NativeRegion; #endif // Note: for test_shell we're packing a pointer into the NativeViewId. So, if diff --git a/app/gfx/path.cc b/app/gfx/path.cc deleted file mode 100644 index b5eeeca..0000000 --- a/app/gfx/path.cc +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2009 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 "app/gfx/path.h" - -#include "base/logging.h" - -namespace gfx { - -Path::Path(const Point* points, size_t count) { - DCHECK(count > 1); - moveTo(SkIntToScalar(points[0].x), SkIntToScalar(points[0].y)); - for (size_t i = 1; i < count; ++i) - lineTo(SkIntToScalar(points[i].x), SkIntToScalar(points[i].y)); -} - -} // namespace gfx diff --git a/app/gfx/path.h b/app/gfx/path.h index bc84ca8..e2150c2 100644 --- a/app/gfx/path.h +++ b/app/gfx/path.h @@ -5,44 +5,31 @@ #ifndef APP_GFX_PATH_H_ #define APP_GFX_PATH_H_ -#include "app/gfx/native_widget_types.h" #include "base/basictypes.h" +#if defined(OS_WIN) +#include <windows.h> +#elif defined(OS_LINUX) +typedef struct _GdkRegion GdkRegion; +#endif + #include "third_party/skia/include/core/SkPath.h" namespace gfx { class Path : public SkPath { public: - // Used by Path(Point,size_t) constructor. - struct Point { - int x; - int y; - }; - Path() : SkPath() { moveTo(0, 0); } - // Creates a path populated with the specified points. - Path(const Point* points, size_t count); - -#if defined(OS_WIN) || defined(USE_X11) - // Creates a NativeRegion from the path. The caller is responsible for freeing - // resources used by this region. This only supports polygon paths. - NativeRegion CreateNativeRegion() const; - - // Returns the intersection of the two regions. The caller owns the returned - // object. - static gfx::NativeRegion IntersectRegions(gfx::NativeRegion r1, - gfx::NativeRegion r2); - - // Returns the union of the two regions. The caller owns the returned object. - static gfx::NativeRegion CombineRegions(gfx::NativeRegion r1, - gfx::NativeRegion r2); - - // Returns the difference of the two regions. The caller owns the returned - // object. - static gfx::NativeRegion SubtractRegion(gfx::NativeRegion r1, - gfx::NativeRegion r2); +#if defined(OS_WIN) + // Creates a HRGN from the path. The caller is responsible for freeing + // 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. + // WARNING: this returns NULL for an empty Path. + GdkRegion* CreateGdkRegion() const; #endif private: diff --git a/app/gfx/path_gtk.cc b/app/gfx/path_gtk.cc index e9aee05..9a2b92c 100644 --- a/app/gfx/path_gtk.cc +++ b/app/gfx/path_gtk.cc @@ -11,7 +11,7 @@ namespace gfx { -GdkRegion* Path::CreateNativeRegion() const { +GdkRegion* Path::CreateGdkRegion() const { int point_count = getPoints(NULL, 0); if (point_count <= 1) { // NOTE: ideally this would return gdk_empty_region, but that returns a @@ -31,25 +31,4 @@ GdkRegion* Path::CreateNativeRegion() const { 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/app/gfx/path_win.cc b/app/gfx/path_win.cc index 5a337bb..72fce71 100644 --- a/app/gfx/path_win.cc +++ b/app/gfx/path_win.cc @@ -8,7 +8,7 @@ namespace gfx { -HRGN Path::CreateNativeRegion() const { +HRGN Path::CreateHRGN() const { int point_count = getPoints(NULL, 0); scoped_array<SkPoint> points(new SkPoint[point_count]); getPoints(points.get(), point_count); @@ -21,25 +21,4 @@ HRGN Path::CreateNativeRegion() const { return ::CreatePolygonRgn(windows_points.get(), point_count, ALTERNATE); } -// static -NativeRegion Path::IntersectRegions(NativeRegion r1, NativeRegion r2) { - HRGN dest = CreateRectRgn(0, 0, 1, 1); - CombineRgn(dest, r1, r2, RGN_AND); - return dest; -} - -// static -NativeRegion Path::CombineRegions(NativeRegion r1, NativeRegion r2) { - HRGN dest = CreateRectRgn(0, 0, 1, 1); - CombineRgn(dest, r1, r2, RGN_OR); - return dest; -} - -// static -NativeRegion Path::SubtractRegion(NativeRegion r1, NativeRegion r2) { - HRGN dest = CreateRectRgn(0, 0, 1, 1); - CombineRgn(dest, r1, r2, RGN_DIFF); - return dest; -} - } // namespace gfx |