[GTK] [WebKit2] Add a setting to control whether or not accelerated 2D canvas is...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 May 2013 18:10:59 +0000 (18:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 May 2013 18:10:59 +0000 (18:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114394

Patch by Martin Robinson <mrobinson@igalia.com> on 2013-05-01
Reviewed by Anders Carlsson.

Add a setting to control accelerated 2D canvas, which determines whether
or not to consider rendering HTML canvas with hardware acceleration.

* UIProcess/API/gtk/WebKitSettings.cpp:
(webKitSettingsSetProperty): Added support for enable-accelerated-2d-canvas property.
(webKitSettingsGetProperty): Added support for enable-accelerated-2d-canvas property.
(webkit_settings_class_init): Added support for enable-accelerated-2d-canvas property.
(webkit_settings_get_enable_accelerated_2d_canvas): Added.
(webkit_settings_set_enable_accelerated_2d_canvas): Added.
* UIProcess/API/gtk/WebKitSettings.h: New methods.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Added new methods to the documentation.
* UIProcess/API/gtk/tests/TestWebKitSettings.cpp:
(testWebKitSettings): Added a simple test for the setting.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@149440 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp

index 2f603c5..3918da1 100644 (file)
@@ -1,3 +1,24 @@
+2013-05-01  Martin Robinson  <mrobinson@igalia.com>
+
+        [GTK] [WebKit2] Add a setting to control whether or not accelerated 2D canvas is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=114394
+
+        Reviewed by Anders Carlsson.
+
+        Add a setting to control accelerated 2D canvas, which determines whether
+        or not to consider rendering HTML canvas with hardware acceleration.
+
+        * UIProcess/API/gtk/WebKitSettings.cpp:
+        (webKitSettingsSetProperty): Added support for enable-accelerated-2d-canvas property.
+        (webKitSettingsGetProperty): Added support for enable-accelerated-2d-canvas property.
+        (webkit_settings_class_init): Added support for enable-accelerated-2d-canvas property.
+        (webkit_settings_get_enable_accelerated_2d_canvas): Added.
+        (webkit_settings_set_enable_accelerated_2d_canvas): Added.
+        * UIProcess/API/gtk/WebKitSettings.h: New methods.
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Added new methods to the documentation.
+        * UIProcess/API/gtk/tests/TestWebKitSettings.cpp:
+        (testWebKitSettings): Added a simple test for the setting.
+
 2013-04-30  Jer Noble  <jer.noble@apple.com>
 
         Entering full screen mode shows desktop linen instead of WKView the first time.
index c0f1c4f..218c04c 100644 (file)
@@ -132,7 +132,8 @@ enum {
     PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
     PROP_ENABLE_PAGE_CACHE,
     PROP_USER_AGENT,
-    PROP_ENABLE_SMOOTH_SCROLLING
+    PROP_ENABLE_SMOOTH_SCROLLING,
+    PROP_ENABLE_ACCELERATED_2D_CANVAS
 };
 
 static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
@@ -275,6 +276,9 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu
     case PROP_ENABLE_SMOOTH_SCROLLING:
         webkit_settings_set_enable_smooth_scrolling(settings, g_value_get_boolean(value));
         break;
+    case PROP_ENABLE_ACCELERATED_2D_CANVAS:
+        webkit_settings_set_enable_accelerated_2d_canvas(settings, g_value_get_boolean(value));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
         break;
@@ -415,6 +419,9 @@ static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* val
     case PROP_ENABLE_SMOOTH_SCROLLING:
         g_value_set_boolean(value, webkit_settings_get_enable_smooth_scrolling(settings));
         break;
+    case PROP_ENABLE_ACCELERATED_2D_CANVAS:
+        g_value_set_boolean(value, webkit_settings_get_enable_accelerated_2d_canvas(settings));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
         break;
@@ -1071,6 +1078,24 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
                                                          _("Whether to enable smooth scrolling"),
                                                          FALSE,
                                                          readWriteConstructParamFlags));
+
+    /**
+     * WebKitSettings:enable-accelerated-2d-canvas:
+     *
+     * Enable or disable accelerated 2D canvas. Accelerated 2D canvas is only available
+     * if WebKitGTK+ was compiled with a version of Cairo including the unstable CairoGL API.
+     * When accelerated 2D canvas is enabled, WebKit may render some 2D canvas content
+     * using hardware accelerated drawing operations.
+     *
+     * Since: 2.2
+     */
+    g_object_class_install_property(gObjectClass,
+        PROP_ENABLE_ACCELERATED_2D_CANVAS,
+        g_param_spec_boolean("enable-accelerated-2d-canvas",
+            _("Enable accelerated 2D canvas"),
+            _("Whether to enable accelerated 2D canvas"),
+            FALSE,
+            readWriteConstructParamFlags));
 }
 
 WebPreferences* webkitSettingsGetPreferences(WebKitSettings* settings)
@@ -2656,3 +2681,41 @@ void webkit_settings_set_enable_smooth_scrolling(WebKitSettings* settings, gbool
     priv->preferences->setScrollAnimatorEnabled(enabled);
     g_object_notify(G_OBJECT(settings), "enable-smooth-scrolling");
 }
+
+/**
+ * webkit_settings_get_enable_accelerated_2d_canvas:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-accelerated-2d-canvas property.
+ *
+ * Returns: %TRUE if accelerated 2D canvas is enabled or %FALSE otherwise.
+ *
+ * Since: 2.2
+ */
+gboolean webkit_settings_get_enable_accelerated_2d_canvas(WebKitSettings* settings)
+{
+    g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+    return settings->priv->preferences->accelerated2dCanvasEnabled();
+}
+
+/**
+ * webkit_settings_set_enable_accelerated_2d_canvas:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-accelerated-2d-canvas property.
+ *
+ * Since: 2.2
+ */
+void webkit_settings_set_enable_accelerated_2d_canvas(WebKitSettings* settings, gboolean enabled)
+{
+    g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+    WebKitSettingsPrivate* priv = settings->priv;
+    if (priv->preferences->accelerated2dCanvasEnabled() == enabled)
+        return;
+
+    priv->preferences->setAccelerated2dCanvasEnabled(enabled);
+    g_object_notify(G_OBJECT(settings), "enable-accelerated-2d-canvas");
+}
index a9fe86a..46d5071 100644 (file)
@@ -380,6 +380,13 @@ WEBKIT_API void
 webkit_settings_set_enable_smooth_scrolling                    (WebKitSettings *settings,
                                                                 gboolean        enabled);
 
+WEBKIT_API gboolean
+webkit_settings_get_enable_accelerated_2d_canvas               (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_accelerated_2d_canvas               (WebKitSettings *settings,
+                                                                gboolean        enabled);
+
 G_END_DECLS
 
 #endif /* WebKitSettings_h */
index 9f26261..beafac6 100644 (file)
@@ -317,6 +317,8 @@ webkit_settings_set_user_agent
 webkit_settings_set_user_agent_with_application_details
 webkit_settings_get_enable_smooth_scrolling
 webkit_settings_set_enable_smooth_scrolling
+webkit_settings_get_enable_accelerated_2d_canvas
+webkit_settings_set_enable_accelerated_2d_canvas
 
 <SUBSECTION Standard>
 WebKitSettingsClass
index f5a45d5..544200d 100644 (file)
@@ -248,6 +248,11 @@ static void testWebKitSettings(Test*, gconstpointer)
     webkit_settings_set_enable_smooth_scrolling(settings, TRUE);
     g_assert(webkit_settings_get_enable_smooth_scrolling(settings));
 
+    // By default, accelerated 2D canvas is disabled.
+    g_assert(!webkit_settings_get_enable_accelerated_2d_canvas(settings));
+    webkit_settings_set_enable_accelerated_2d_canvas(settings, TRUE);
+    g_assert(webkit_settings_get_enable_accelerated_2d_canvas(settings));
+
     g_object_unref(G_OBJECT(settings));
 }