diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 19:19:19 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 19:19:19 +0000 |
commit | d7af8e7d98ab79ad46707b08b6dd7f6ef272cbbe (patch) | |
tree | afd72795ba73b8b88e60371f2b1b7959cf227e12 /webkit | |
parent | 3975e6e094b6557215748d91c89394cb54532c23 (diff) | |
download | chromium_src-d7af8e7d98ab79ad46707b08b6dd7f6ef272cbbe.zip chromium_src-d7af8e7d98ab79ad46707b08b6dd7f6ef272cbbe.tar.gz chromium_src-d7af8e7d98ab79ad46707b08b6dd7f6ef272cbbe.tar.bz2 |
Cache the GdkSkia object in PlatformContextSkia so that we aren't creating
and deleting them for every widget drawn.
Review URL: http://codereview.chromium.org/9757
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5195 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/SConscript | 1 | ||||
-rw-r--r-- | webkit/SConscript.port | 6 | ||||
-rw-r--r-- | webkit/port/platform/chromium/RenderThemeGtk.cpp | 8 | ||||
-rw-r--r-- | webkit/port/platform/graphics/PlatformContextSkia.cpp | 13 | ||||
-rw-r--r-- | webkit/port/platform/graphics/PlatformContextSkia.h | 11 | ||||
-rw-r--r-- | webkit/port/platform/graphics/skia/GdkSkia.cc (renamed from webkit/port/platform/chromium/gdkskiadrawable.cc) | 2 | ||||
-rw-r--r-- | webkit/port/platform/graphics/skia/GdkSkia.h (renamed from webkit/port/platform/chromium/gdkskiadrawable.h) | 0 |
7 files changed, 31 insertions, 10 deletions
diff --git a/webkit/SConscript b/webkit/SConscript index 72cf78b..6238f35 100644 --- a/webkit/SConscript +++ b/webkit/SConscript @@ -118,6 +118,7 @@ env.Prepend( '$WEBKIT_DIR/port/platform/chromium', '$WEBKIT_DIR/port/platform/graphics', '$WEBKIT_DIR/port/platform/graphics/chromium', + '$WEBKIT_DIR/port/platform/graphics/skia', '$WEBKIT_DIR/port/platform/$WEBKIT_PLATFORM_SUBDIR', '$WEBKIT_DIR/port/svg/graphics', '$WEBKIT_DIR/port/platform/network', diff --git a/webkit/SConscript.port b/webkit/SConscript.port index 7f4d01b..312a713 100644 --- a/webkit/SConscript.port +++ b/webkit/SConscript.port @@ -124,10 +124,11 @@ if env['PLATFORM'] == 'posix': # Linux specific implementations input_files.extend([ - '$PORT_DIR/platform/chromium/ScreenLinux.cpp', '$PORT_DIR/platform/chromium/IconLinux.cpp', - '$PORT_DIR/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp', '$PORT_DIR/platform/chromium/PasteboardLinux.cpp', + '$PORT_DIR/platform/chromium/ScreenLinux.cpp', + '$PORT_DIR/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp', + '$PORT_DIR/platform/graphics/skia/GdkSkia.cc', ]) if env['PLATFORM'] == 'darwin': @@ -175,7 +176,6 @@ if env['PLATFORM'] == 'posix': '$PORT_DIR/platform/graphics/chromium/FontPlatformDataLinux.cpp', '$PORT_DIR/platform/graphics/chromium/SimpleFontDataLinux.cpp', '$PORT_DIR/platform/chromium/gtk2drawing.c', - '$PORT_DIR/platform/chromium/gdkskiadrawable.cc', '$PORT_DIR/platform/chromium/RenderThemeGtk.cpp' ]) diff --git a/webkit/port/platform/chromium/RenderThemeGtk.cpp b/webkit/port/platform/chromium/RenderThemeGtk.cpp index 54b3254..9d2f2cd 100644 --- a/webkit/port/platform/chromium/RenderThemeGtk.cpp +++ b/webkit/port/platform/chromium/RenderThemeGtk.cpp @@ -29,7 +29,7 @@ #include "PlatformContextSkia.h" #include "RenderObject.h" #include "gtkdrawing.h" -#include "gdkskiadrawable.h" +#include "GdkSkia.h" #include <gdk/gdk.h> @@ -183,13 +183,9 @@ static bool paintMozWidget(RenderTheme* theme, GtkThemeWidgetType type, RenderOb gdk_rectangle_intersect(&gdkRect, &gdkClipRect, &gdkClipRect); - // TODO(agl): we should look at not creating this anew every time. - GdkSkia* skiadrawable = gdk_skia_new(canvas); - const gint r = - moz_gtk_widget_paint(type, skiadrawable, &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS; + moz_gtk_widget_paint(type, pcs->gdk_skia(), &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS; - g_object_unref(skiadrawable); return r; } diff --git a/webkit/port/platform/graphics/PlatformContextSkia.cpp b/webkit/port/platform/graphics/PlatformContextSkia.cpp index dd50cb0..fd5cf91 100644 --- a/webkit/port/platform/graphics/PlatformContextSkia.cpp +++ b/webkit/port/platform/graphics/PlatformContextSkia.cpp @@ -43,6 +43,10 @@ #include "SkShader.h" #include "SkDashPathEffect.h" +#if defined(OS_LINUX) +#include "GdkSkia.h" +#endif + // State ----------------------------------------------------------------------- // Encapsulates the additional painting state information we store for each @@ -145,10 +149,19 @@ PlatformContextSkia::PlatformContextSkia(gfx::PlatformCanvas* canvas) { m_stateStack.append(State()); m_state = &m_stateStack.last(); +#if defined(OS_LINUX) + m_gdkskia = m_canvas ? gdk_skia_new(m_canvas) : NULL; +#endif } PlatformContextSkia::~PlatformContextSkia() { +#if defined(OS_LINUX) + if (m_gdkskia) { + g_object_unref(m_gdkskia); + m_gdkskia = NULL; + } +#endif } void PlatformContextSkia::setCanvas(gfx::PlatformCanvas* canvas) diff --git a/webkit/port/platform/graphics/PlatformContextSkia.h b/webkit/port/platform/graphics/PlatformContextSkia.h index a0c72e0..c7a16da 100644 --- a/webkit/port/platform/graphics/PlatformContextSkia.h +++ b/webkit/port/platform/graphics/PlatformContextSkia.h @@ -40,6 +40,8 @@ #include "GraphicsContext.h" #include "wtf/Vector.h" +typedef struct _GdkDrawable GdkSkia; + // This class holds the platform-specific state for GraphicsContext. We put // most of our Skia wrappers on this class. In theory, a lot of this stuff could // be moved to GraphicsContext directly, except that some code external to this @@ -137,6 +139,10 @@ public: // possible quality. bool IsPrinting(); +#if defined(OS_LINUX) + GdkSkia* gdk_skia() const { return m_gdkskia; } +#endif + private: // Defines drawing style. struct State; @@ -157,6 +163,11 @@ private: // Disallow these. PlatformContextSkia(const PlatformContextSkia&); void operator=(const PlatformContextSkia&); + +#if defined(OS_LINUX) + // A pointer to a GDK Drawable wrapping of this Skia canvas + GdkSkia* m_gdkskia; +#endif }; #endif // PlatformContextSkia_h diff --git a/webkit/port/platform/chromium/gdkskiadrawable.cc b/webkit/port/platform/graphics/skia/GdkSkia.cc index d780014..4774aaf 100644 --- a/webkit/port/platform/chromium/gdkskiadrawable.cc +++ b/webkit/port/platform/graphics/skia/GdkSkia.cc @@ -34,7 +34,7 @@ #include <SkBitmap.h> #include <SkDevice.h> -#include "gdkskiadrawable.h" +#include "GdkSkia.h" static GdkGC *gdk_skia_create_gc (GdkDrawable *drawable, GdkGCValues *values, diff --git a/webkit/port/platform/chromium/gdkskiadrawable.h b/webkit/port/platform/graphics/skia/GdkSkia.h index 6e6b76a..6e6b76a 100644 --- a/webkit/port/platform/chromium/gdkskiadrawable.h +++ b/webkit/port/platform/graphics/skia/GdkSkia.h |