| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 if (cmd.HasSwitch(cc::switches::kSlowDownRasterScaleFactor)) { | 424 if (cmd.HasSwitch(cc::switches::kSlowDownRasterScaleFactor)) { |
| 425 const int kMinSlowDownScaleFactor = 0; | 425 const int kMinSlowDownScaleFactor = 0; |
| 426 const int kMaxSlowDownScaleFactor = INT_MAX; | 426 const int kMaxSlowDownScaleFactor = INT_MAX; |
| 427 GetSwitchValueAsInt( | 427 GetSwitchValueAsInt( |
| 428 cmd, cc::switches::kSlowDownRasterScaleFactor, kMinSlowDownScaleFactor, | 428 cmd, cc::switches::kSlowDownRasterScaleFactor, kMinSlowDownScaleFactor, |
| 429 kMaxSlowDownScaleFactor, | 429 kMaxSlowDownScaleFactor, |
| 430 &settings.initial_debug_state.slow_down_raster_scale_factor); | 430 &settings.initial_debug_state.slow_down_raster_scale_factor); |
| 431 } | 431 } |
| 432 | 432 |
| 433 // This is default overlay scrollbar settings for Android and DevTools mobile |
| 434 // emulator. Aura Overlay Scrollbar will override below. |
| 435 settings.scrollbar_animator = cc::LayerTreeSettings::ANDROID_OVERLAY; |
| 436 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); |
| 437 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(300); |
| 438 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); |
| 439 |
| 433 #if defined(OS_ANDROID) | 440 #if defined(OS_ANDROID) |
| 434 bool using_synchronous_compositor = | 441 bool using_synchronous_compositor = |
| 435 GetContentClient()->UsingSynchronousCompositing(); | 442 GetContentClient()->UsingSynchronousCompositing(); |
| 436 | 443 |
| 437 settings.use_stream_video_draw_quad = true; | 444 settings.use_stream_video_draw_quad = true; |
| 438 settings.using_synchronous_renderer_compositor = using_synchronous_compositor; | 445 settings.using_synchronous_renderer_compositor = using_synchronous_compositor; |
| 439 if (using_synchronous_compositor) { | 446 if (using_synchronous_compositor) { |
| 440 // Android WebView uses system scrollbars, so make ours invisible. | 447 // Android WebView uses system scrollbars, so make ours invisible. |
| 441 // http://crbug.com/677348: This can't be done using hide_scrollbars | 448 // http://crbug.com/677348: This can't be done using hide_scrollbars |
| 442 // setting because supporting -webkit custom scrollbars is still desired | 449 // setting because supporting -webkit custom scrollbars is still desired |
| 443 // on sublayers. | 450 // on sublayers. |
| 444 settings.scrollbar_animator = cc::LayerTreeSettings::NO_ANIMATOR; | 451 settings.scrollbar_animator = cc::LayerTreeSettings::NO_ANIMATOR; |
| 445 settings.solid_color_scrollbar_color = SK_ColorTRANSPARENT; | 452 settings.solid_color_scrollbar_color = SK_ColorTRANSPARENT; |
| 446 } else { | |
| 447 settings.scrollbar_animator = cc::LayerTreeSettings::ANDROID_OVERLAY; | |
| 448 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(300); | |
| 449 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); | |
| 450 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); | |
| 451 } | 453 } |
| 452 settings.renderer_settings.highp_threshold_min = 2048; | 454 settings.renderer_settings.highp_threshold_min = 2048; |
| 453 // Android WebView handles root layer flings itself. | 455 // Android WebView handles root layer flings itself. |
| 454 settings.ignore_root_layer_flings = using_synchronous_compositor; | 456 settings.ignore_root_layer_flings = using_synchronous_compositor; |
| 455 // Memory policy on Android WebView does not depend on whether device is | 457 // Memory policy on Android WebView does not depend on whether device is |
| 456 // low end, so always use default policy. | 458 // low end, so always use default policy. |
| 457 bool use_low_memory_policy = | 459 bool use_low_memory_policy = |
| 458 base::SysInfo::IsLowEndDevice() && !using_synchronous_compositor; | 460 base::SysInfo::IsLowEndDevice() && !using_synchronous_compositor; |
| 459 if (use_low_memory_policy) { | 461 if (use_low_memory_policy) { |
| 460 // On low-end we want to be very carefull about killing other | 462 // On low-end we want to be very carefull about killing other |
| (...skipping 19 matching lines...) Expand all Loading... |
| 480 if (base::SysInfo::IsLowEndDevice()) { | 482 if (base::SysInfo::IsLowEndDevice()) { |
| 481 // When running on a low end device, we limit cached bytes to 2MB. | 483 // When running on a low end device, we limit cached bytes to 2MB. |
| 482 // This allows a typical page to fit its images in cache, but prevents | 484 // This allows a typical page to fit its images in cache, but prevents |
| 483 // most long-term caching. | 485 // most long-term caching. |
| 484 settings.decoded_image_cache_budget_bytes = 2 * 1024 * 1024; | 486 settings.decoded_image_cache_budget_bytes = 2 * 1024 * 1024; |
| 485 } | 487 } |
| 486 | 488 |
| 487 // TODO(danakj): Only do this on low end devices. | 489 // TODO(danakj): Only do this on low end devices. |
| 488 settings.create_low_res_tiling = true; | 490 settings.create_low_res_tiling = true; |
| 489 #else // defined(OS_ANDROID) | 491 #else // defined(OS_ANDROID) |
| 490 #if !defined(OS_MACOSX) | |
| 491 if (ui::IsOverlayScrollbarEnabled()) { | 492 if (ui::IsOverlayScrollbarEnabled()) { |
| 492 settings.scrollbar_animator = cc::LayerTreeSettings::AURA_OVERLAY; | 493 settings.scrollbar_animator = cc::LayerTreeSettings::AURA_OVERLAY; |
| 493 settings.scrollbar_fade_delay = ui::kOverlayScrollbarFadeDelay; | 494 settings.scrollbar_fade_delay = ui::kOverlayScrollbarFadeDelay; |
| 494 settings.scrollbar_fade_duration = ui::kOverlayScrollbarFadeDuration; | 495 settings.scrollbar_fade_duration = ui::kOverlayScrollbarFadeDuration; |
| 495 settings.scrollbar_thinning_duration = | 496 settings.scrollbar_thinning_duration = |
| 496 ui::kOverlayScrollbarThinningDuration; | 497 ui::kOverlayScrollbarThinningDuration; |
| 497 } else { | |
| 498 // TODO(bokan): This section is probably unneeded? We don't use scrollbar | |
| 499 // animations for non overlay scrollbars. | |
| 500 settings.scrollbar_animator = cc::LayerTreeSettings::ANDROID_OVERLAY; | |
| 501 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); | |
| 502 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); | |
| 503 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); | |
| 504 } | 498 } |
| 505 #endif // !defined(OS_MACOSX) | |
| 506 | 499 |
| 507 // On desktop, if there's over 4GB of memory on the machine, increase the | 500 // On desktop, if there's over 4GB of memory on the machine, increase the |
| 508 // image decode budget to 256MB for both gpu and software. | 501 // image decode budget to 256MB for both gpu and software. |
| 509 const int kImageDecodeMemoryThresholdMB = 4 * 1024; | 502 const int kImageDecodeMemoryThresholdMB = 4 * 1024; |
| 510 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= | 503 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= |
| 511 kImageDecodeMemoryThresholdMB) { | 504 kImageDecodeMemoryThresholdMB) { |
| 512 settings.decoded_image_cache_budget_bytes = 256 * 1024 * 1024; | 505 settings.decoded_image_cache_budget_bytes = 256 * 1024 * 1024; |
| 513 settings.decoded_image_working_set_budget_bytes = 256 * 1024 * 1024; | 506 settings.decoded_image_working_set_budget_bytes = 256 * 1024 * 1024; |
| 514 } else { | 507 } else { |
| 515 // These are the defaults, but recorded here as well. | 508 // These are the defaults, but recorded here as well. |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 const cc::LocalSurfaceId& local_surface_id) { | 1206 const cc::LocalSurfaceId& local_surface_id) { |
| 1214 layer_tree_host_->SetLocalSurfaceId(local_surface_id); | 1207 layer_tree_host_->SetLocalSurfaceId(local_surface_id); |
| 1215 } | 1208 } |
| 1216 | 1209 |
| 1217 void RenderWidgetCompositor::NotifySwapTime(ReportTimeCallback callback) { | 1210 void RenderWidgetCompositor::NotifySwapTime(ReportTimeCallback callback) { |
| 1218 QueueSwapPromise(base::MakeUnique<ReportTimeSwapPromise>( | 1211 QueueSwapPromise(base::MakeUnique<ReportTimeSwapPromise>( |
| 1219 std::move(callback), base::ThreadTaskRunnerHandle::Get())); | 1212 std::move(callback), base::ThreadTaskRunnerHandle::Get())); |
| 1220 } | 1213 } |
| 1221 | 1214 |
| 1222 } // namespace content | 1215 } // namespace content |
| OLD | NEW |