Changeset 211363 in webkit
- Timestamp:
- Jan 30, 2017, 5:50:37 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r211357 r211363 1 2017-01-30 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add API to handle the accelerated compositing policy 4 https://bugs.webkit.org/show_bug.cgi?id=167509 5 6 Reviewed by Michael Catanzaro. 7 8 Now that we have brought back the on demand mode, we should allow applications to choose the policy, without 9 having to deal with environment variables. Settings also allows to set different policy depending on the web 10 view, so for example evolution could disable AC for the composer, but leave the on demand mode for the email 11 viewer. This patch adds a single new setting hardware-acceleration-policy to handle both 12 acceleratedCompositingEnabled and forceCompositingMode preferences using an enum with values 13 WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS and 14 WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER. 15 16 * UIProcess/API/gtk/WebKitSettings.cpp: 17 (webKitSettingsSetProperty): Add setter for hardware-acceleration-policy property. 18 (webKitSettingsGetProperty): Add getter for hardware-acceleration-policy property. 19 (webkit_settings_class_init): Add hardware-acceleration-policy property. 20 (webkit_settings_get_hardware_acceleration_policy): Return policy according to the preferences. 21 (webkit_settings_set_hardware_acceleration_policy): set preferences according to the given policy. 22 * UIProcess/API/gtk/WebKitSettings.h: 23 * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols. 24 * WebProcess/WebPage/DrawingAreaImpl.cpp: 25 (WebKit::DrawingAreaImpl::updatePreferences): 26 1 27 2017-01-29 Carlos Garcia Campos <cgarcia@igalia.com> 2 28 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
r211138 r211363 33 33 34 34 #include "ExperimentalFeatures.h" 35 #include "WebKitEnumTypes.h" 35 36 #include "WebKitPrivate.h" 36 37 #include "WebKitSettingsPrivate.h" … … 146 147 PROP_ENABLE_MEDIASOURCE, 147 148 PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS, 148 PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS 149 PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS, 150 PROP_HARDWARE_ACCELERATION_POLICY, 149 151 }; 150 152 … … 324 326 webkit_settings_set_allow_universal_access_from_file_urls(settings, g_value_get_boolean(value)); 325 327 break; 328 case PROP_HARDWARE_ACCELERATION_POLICY: 329 webkit_settings_set_hardware_acceleration_policy(settings, static_cast<WebKitHardwareAccelerationPolicy>(g_value_get_enum(value))); 330 break; 326 331 default: 327 332 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); … … 486 491 case PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS: 487 492 g_value_set_boolean(value, webkit_settings_get_allow_universal_access_from_file_urls(settings)); 493 break; 494 case PROP_HARDWARE_ACCELERATION_POLICY: 495 g_value_set_enum(value, webkit_settings_get_hardware_acceleration_policy(settings)); 488 496 break; 489 497 default: … … 1280 1288 FALSE, 1281 1289 readWriteConstructParamFlags)); 1290 1291 /** 1292 * WebKitSettings:hardware-acceleration-policy: 1293 * 1294 * The #WebKitHardwareAccelerationPolicy to decide how to enable and disable 1295 * hardware acceleration. The default value %WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND 1296 * enables the hardware acceleration when the web contents request it, disabling it again 1297 * when no longer needed. It's possible to enfore hardware acceleration to be always enabled 1298 * by using %WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS. And it's also posible to disable it 1299 * completely using %WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER. Note that disabling hardware 1300 * acceleration might cause some websites to not render correctly or consume more CPU. 1301 * 1302 * Since: 2.16 1303 */ 1304 g_object_class_install_property(gObjectClass, 1305 PROP_HARDWARE_ACCELERATION_POLICY, 1306 g_param_spec_enum("hardware-acceleration-policy", 1307 _("Hardware Acceleration Policy"), 1308 _("The policy to decide how to enable and disable hardware acceleration"), 1309 WEBKIT_TYPE_HARDWARE_ACCELERATION_POLICY, 1310 WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND, 1311 readWriteConstructParamFlags)); 1282 1312 } 1283 1313 … … 3143 3173 g_object_notify(G_OBJECT(settings), "allow-universal-access-from-file-urls"); 3144 3174 } 3175 3176 /** 3177 * webkit_settings_get_hardware_acceleration_policy: 3178 * @settings: a #WebKitSettings 3179 * 3180 * Get the #WebKitSettings:hardware-acceleration-policy property. 3181 * 3182 * Return: a #WebKitHardwareAccelerationPolicy 3183 * 3184 * Since: 2.16 3185 */ 3186 WebKitHardwareAccelerationPolicy webkit_settings_get_hardware_acceleration_policy(WebKitSettings* settings) 3187 { 3188 g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND); 3189 3190 WebKitSettingsPrivate* priv = settings->priv; 3191 if (!priv->preferences->acceleratedCompositingEnabled()) 3192 return WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER; 3193 3194 if (priv->preferences->forceCompositingMode()) 3195 return WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS; 3196 3197 return WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND; 3198 } 3199 3200 /** 3201 * webkit_settings_set_hardware_acceleration_policy: 3202 * @settings: a #WebKitSettings 3203 * @policy: a #WebKitHardwareAccelerationPolicy 3204 * 3205 * Set the #WebKitSettings:hardware-acceleration-policy property. 3206 * 3207 * Since: 2.16 3208 */ 3209 void webkit_settings_set_hardware_acceleration_policy(WebKitSettings* settings, WebKitHardwareAccelerationPolicy policy) 3210 { 3211 g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); 3212 3213 WebKitSettingsPrivate* priv = settings->priv; 3214 bool changed = false; 3215 switch (policy) { 3216 case WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS: 3217 if (!priv->preferences->acceleratedCompositingEnabled()) { 3218 priv->preferences->setAcceleratedCompositingEnabled(true); 3219 changed = true; 3220 } 3221 if (!priv->preferences->forceCompositingMode()) { 3222 priv->preferences->setForceCompositingMode(true); 3223 changed = true; 3224 } 3225 break; 3226 case WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER: 3227 if (priv->preferences->acceleratedCompositingEnabled()) { 3228 priv->preferences->setAcceleratedCompositingEnabled(false); 3229 changed = true; 3230 } 3231 3232 if (priv->preferences->forceCompositingMode()) { 3233 priv->preferences->setForceCompositingMode(false); 3234 changed = true; 3235 } 3236 break; 3237 3238 case WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND: 3239 if (!priv->preferences->acceleratedCompositingEnabled()) { 3240 priv->preferences->setAcceleratedCompositingEnabled(true); 3241 changed = true; 3242 } 3243 3244 if (priv->preferences->forceCompositingMode()) { 3245 priv->preferences->setForceCompositingMode(false); 3246 changed = true; 3247 } 3248 3249 break; 3250 } 3251 3252 if (changed) 3253 g_object_notify(G_OBJECT(settings), "hardware-acceleration-policy"); 3254 } -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
r211138 r211363 48 48 #define WEBKIT_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_SETTINGS, WebKitSettingsClass)) 49 49 50 /** 51 * WebKitHardwareAccelerationPolicy: 52 * @WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND: Hardware acceleration is enabled/disabled as request by web contents. 53 * @WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS: Hardware acceleration is always enabled, even for websites not requesting it. 54 * @WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER: Hardware acceleration is always disabled, even for websites requesting it. 55 * 56 * Enum values used for determining the hardware acceleration policy. 57 * 58 * Since: 2.16 59 */ 60 typedef enum { 61 WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND, 62 WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS, 63 WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER 64 } WebKitHardwareAccelerationPolicy; 65 50 66 typedef struct _WebKitSettings WebKitSettings; 51 67 typedef struct _WebKitSettingsClass WebKitSettingsClass; … … 429 445 gboolean allowed); 430 446 447 WEBKIT_API WebKitHardwareAccelerationPolicy 448 webkit_settings_get_hardware_acceleration_policy (WebKitSettings *settings); 449 450 WEBKIT_API void 451 webkit_settings_set_hardware_acceleration_policy (WebKitSettings *settings, 452 WebKitHardwareAccelerationPolicy policy); 453 431 454 G_END_DECLS 432 455 -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
r211138 r211363 359 359 <FILE>WebKitSettings</FILE> 360 360 WebKitSettings 361 WebKitHardwareAccelerationPolicy 361 362 webkit_settings_new 362 363 webkit_settings_new_with_settings … … 462 463 webkit_settings_get_allow_universal_access_from_file_urls 463 464 webkit_settings_set_allow_universal_access_from_file_urls 465 webkit_settings_get_hardware_acceleration_policy 466 webkit_settings_set_hardware_acceleration_policy 464 467 465 468 <SUBSECTION Standard> -
trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
r211346 r211363 178 178 // Fixed position elements need to be composited and create stacking contexts 179 179 // in order to be scrolled by the ScrollingCoordinator. 180 settings.setAcceleratedCompositingForFixedPositionEnabled( true);181 settings.setFixedPositionCreatesStackingContext( true);180 settings.setAcceleratedCompositingForFixedPositionEnabled(settings.acceleratedCompositingEnabled()); 181 settings.setFixedPositionCreatesStackingContext(settings.acceleratedCompositingEnabled()); 182 182 #endif 183 183 -
trunk/Tools/ChangeLog
r211355 r211363 1 2017-01-30 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add API to handle the accelerated compositing policy 4 https://bugs.webkit.org/show_bug.cgi?id=167509 5 6 Reviewed by Michael Catanzaro. 7 8 Handle new setting in MiniBrowser. The settings dialog doesn't support enum settings so it needs to be handled 9 as a special case. Also add test cases to the get/set API. 10 11 * MiniBrowser/gtk/BrowserSettingsDialog.c: 12 (hardwareAccelerationPolicyToString): 13 (stringToHardwareAccelerationPolicy): 14 (cellRendererChanged): 15 (browserSettingsDialogConstructed): 16 * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp: 17 (testWebKitSettings): 18 1 19 2017-01-29 Andy Estes <aestes@apple.com> 2 20 -
trunk/Tools/MiniBrowser/gtk/BrowserSettingsDialog.c
r104018 r211363 56 56 G_DEFINE_TYPE(BrowserSettingsDialog, browser_settings_dialog, GTK_TYPE_DIALOG) 57 57 58 static const char *hardwareAccelerationPolicyToString(WebKitHardwareAccelerationPolicy policy) 59 { 60 switch (policy) { 61 case WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS: 62 return "always"; 63 case WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER: 64 return "never"; 65 case WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND: 66 return "ondemand"; 67 } 68 69 g_assert_not_reached(); 70 return "ondemand"; 71 } 72 73 static int stringToHardwareAccelerationPolicy(const char *policy) 74 { 75 if (!g_ascii_strcasecmp(policy, "always")) 76 return WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS; 77 if (!g_ascii_strcasecmp(policy, "never")) 78 return WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER; 79 if (!g_ascii_strcasecmp(policy, "ondemand")) 80 return WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND; 81 82 g_warning("Invalid value %s for hardware-acceleration-policy setting valid values are always, never and ondemand", policy); 83 return -1; 84 } 85 58 86 static void cellRendererChanged(GtkCellRenderer *renderer, const char *path, const GValue *value, BrowserSettingsDialog *dialog) 59 87 { … … 63 91 gtk_tree_model_get_iter(model, &iter, treePath); 64 92 93 gboolean updateTreeStore = TRUE; 65 94 char *name; 66 95 gtk_tree_model_get(model, &iter, SETTINGS_LIST_COLUMN_NAME, &name, -1); 67 g_object_set_property(G_OBJECT(dialog->settings), name, value); 96 if (!g_strcmp0(name, "hardware-acceleration-policy")) { 97 int policy = stringToHardwareAccelerationPolicy(g_value_get_string(value)); 98 if (policy != -1) 99 webkit_settings_set_hardware_acceleration_policy(dialog->settings, policy); 100 else 101 updateTreeStore = FALSE; 102 } else 103 g_object_set_property(G_OBJECT(dialog->settings), name, value); 68 104 g_free(name); 69 105 70 gtk_list_store_set(GTK_LIST_STORE(model), &iter, SETTINGS_LIST_COLUMN_VALUE, value, -1); 106 if (updateTreeStore) 107 gtk_list_store_set(GTK_LIST_STORE(model), &iter, SETTINGS_LIST_COLUMN_VALUE, value, -1); 71 108 gtk_tree_path_free(treePath); 72 109 } … … 135 172 const char *name = g_param_spec_get_name(property); 136 173 const char *nick = g_param_spec_get_nick(property); 174 char *blurb = g_markup_escape_text(g_param_spec_get_blurb(property), -1); 137 175 138 176 GValue value = { 0, { { 0 } } }; 139 g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(property)); 140 g_object_get_property(G_OBJECT(settings), name, &value); 177 if (!g_strcmp0(name, "hardware-acceleration-policy")) { 178 g_value_init(&value, G_TYPE_STRING); 179 g_value_set_string(&value, hardwareAccelerationPolicyToString(webkit_settings_get_hardware_acceleration_policy(settings))); 180 char *extendedBlutb = g_strdup_printf("%s (always, never or ondemand)", blurb); 181 g_free(blurb); 182 blurb = extendedBlutb; 183 } else { 184 g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(property)); 185 g_object_get_property(G_OBJECT(settings), name, &value); 186 } 141 187 142 188 GtkAdjustment *adjustment = NULL; … … 147 193 } 148 194 149 char *blurb = g_markup_escape_text(g_param_spec_get_blurb(property), -1);150 195 GtkTreeIter iter; 151 196 gtk_list_store_append(model, &iter); -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp
r211138 r211363 286 286 g_assert(webkit_settings_get_allow_universal_access_from_file_urls(settings)); 287 287 288 // Ondemand is the default hardware acceleration policy. 289 g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND); 290 webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER); 291 g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER); 292 webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS); 293 g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS); 294 webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND); 295 g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND); 296 288 297 g_object_unref(G_OBJECT(settings)); 289 298 }
Note:
See TracChangeset
for help on using the changeset viewer.