| 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 <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 using blink::WebBeginFrameArgs; | 60 using blink::WebBeginFrameArgs; |
| 61 using blink::WebFloatPoint; | 61 using blink::WebFloatPoint; |
| 62 using blink::WebRect; | 62 using blink::WebRect; |
| 63 using blink::WebSelectionBound; | 63 using blink::WebSelectionBound; |
| 64 using blink::WebSize; | 64 using blink::WebSize; |
| 65 | 65 |
| 66 namespace content { | 66 namespace content { |
| 67 namespace { | 67 namespace { |
| 68 | 68 |
| 69 bool GetSwitchValueAsInt( | 69 bool GetSwitchValueAsInt(const base::CommandLine& command_line, |
| 70 const CommandLine& command_line, | 70 const std::string& switch_string, |
| 71 const std::string& switch_string, | 71 int min_value, |
| 72 int min_value, | 72 int max_value, |
| 73 int max_value, | 73 int* result) { |
| 74 int* result) { | |
| 75 std::string string_value = command_line.GetSwitchValueASCII(switch_string); | 74 std::string string_value = command_line.GetSwitchValueASCII(switch_string); |
| 76 int int_value; | 75 int int_value; |
| 77 if (base::StringToInt(string_value, &int_value) && | 76 if (base::StringToInt(string_value, &int_value) && |
| 78 int_value >= min_value && int_value <= max_value) { | 77 int_value >= min_value && int_value <= max_value) { |
| 79 *result = int_value; | 78 *result = int_value; |
| 80 return true; | 79 return true; |
| 81 } else { | 80 } else { |
| 82 LOG(WARNING) << "Failed to parse switch " << switch_string << ": " << | 81 LOG(WARNING) << "Failed to parse switch " << switch_string << ": " << |
| 83 string_value; | 82 string_value; |
| 84 return false; | 83 return false; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 166 } |
| 168 | 167 |
| 169 RenderWidgetCompositor::RenderWidgetCompositor( | 168 RenderWidgetCompositor::RenderWidgetCompositor( |
| 170 RenderWidget* widget, | 169 RenderWidget* widget, |
| 171 CompositorDependencies* compositor_deps) | 170 CompositorDependencies* compositor_deps) |
| 172 : num_failed_recreate_attempts_(0), | 171 : num_failed_recreate_attempts_(0), |
| 173 widget_(widget), | 172 widget_(widget), |
| 174 compositor_deps_(compositor_deps), | 173 compositor_deps_(compositor_deps), |
| 175 send_v8_idle_notification_after_commit_(true), | 174 send_v8_idle_notification_after_commit_(true), |
| 176 weak_factory_(this) { | 175 weak_factory_(this) { |
| 177 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 176 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 178 | 177 |
| 179 if (cmd->HasSwitch(switches::kEnableV8IdleNotificationAfterCommit)) | 178 if (cmd->HasSwitch(switches::kEnableV8IdleNotificationAfterCommit)) |
| 180 send_v8_idle_notification_after_commit_ = true; | 179 send_v8_idle_notification_after_commit_ = true; |
| 181 if (cmd->HasSwitch(switches::kDisableV8IdleNotificationAfterCommit)) | 180 if (cmd->HasSwitch(switches::kDisableV8IdleNotificationAfterCommit)) |
| 182 send_v8_idle_notification_after_commit_ = false; | 181 send_v8_idle_notification_after_commit_ = false; |
| 183 } | 182 } |
| 184 | 183 |
| 185 void RenderWidgetCompositor::Initialize() { | 184 void RenderWidgetCompositor::Initialize() { |
| 186 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 185 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 187 | 186 |
| 188 cc::LayerTreeSettings settings; | 187 cc::LayerTreeSettings settings; |
| 189 | 188 |
| 190 // For web contents, layer transforms should scale up the contents of layers | 189 // For web contents, layer transforms should scale up the contents of layers |
| 191 // to keep content always crisp when possible. | 190 // to keep content always crisp when possible. |
| 192 settings.layer_transforms_should_scale_layer_contents = true; | 191 settings.layer_transforms_should_scale_layer_contents = true; |
| 193 | 192 |
| 194 settings.throttle_frame_production = | 193 settings.throttle_frame_production = |
| 195 !cmd->HasSwitch(switches::kDisableGpuVsync); | 194 !cmd->HasSwitch(switches::kDisableGpuVsync); |
| 196 settings.use_external_begin_frame_source = | 195 settings.use_external_begin_frame_source = |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 widget_->OnSwapBuffersAborted(); | 892 widget_->OnSwapBuffersAborted(); |
| 894 } | 893 } |
| 895 | 894 |
| 896 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 895 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
| 897 cc::ContextProvider* provider = | 896 cc::ContextProvider* provider = |
| 898 compositor_deps_->GetSharedMainThreadContextProvider(); | 897 compositor_deps_->GetSharedMainThreadContextProvider(); |
| 899 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 898 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
| 900 } | 899 } |
| 901 | 900 |
| 902 } // namespace content | 901 } // namespace content |
| OLD | NEW |