| 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 #if defined(OS_ANDROID) | 10 #if defined(OS_ANDROID) |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 #elif !defined(OS_MACOSX) | 272 #elif !defined(OS_MACOSX) |
| 273 if (cmd->HasSwitch(switches::kEnableOverlayScrollbars)) { | 273 if (cmd->HasSwitch(switches::kEnableOverlayScrollbars)) { |
| 274 settings.scrollbar_animator = cc::LayerTreeSettings::Thinning; | 274 settings.scrollbar_animator = cc::LayerTreeSettings::Thinning; |
| 275 } | 275 } |
| 276 if (cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport) || | 276 if (cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport) || |
| 277 cmd->HasSwitch(switches::kEnableOverlayScrollbars)) { | 277 cmd->HasSwitch(switches::kEnableOverlayScrollbars)) { |
| 278 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); | 278 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); |
| 279 } | 279 } |
| 280 #endif | 280 #endif |
| 281 | 281 |
| 282 compositor->Initialize(settings); | 282 if (!compositor->Initialize(settings)) |
| 283 return scoped_ptr<RenderWidgetCompositor>(); |
| 283 | 284 |
| 284 return compositor.Pass(); | 285 return compositor.Pass(); |
| 285 } | 286 } |
| 286 | 287 |
| 287 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, | 288 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, |
| 288 bool threaded) | 289 bool threaded) |
| 289 : threaded_(threaded), | 290 : threaded_(threaded), |
| 290 suppress_schedule_composite_(false), | 291 suppress_schedule_composite_(false), |
| 291 widget_(widget) { | 292 widget_(widget) { |
| 292 } | 293 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 return layer_tree_host_->root_layer(); | 380 return layer_tree_host_->root_layer(); |
| 380 } | 381 } |
| 381 | 382 |
| 382 bool RenderWidgetCompositor::ScheduleMicroBenchmark( | 383 bool RenderWidgetCompositor::ScheduleMicroBenchmark( |
| 383 const std::string& name, | 384 const std::string& name, |
| 384 scoped_ptr<base::Value> value, | 385 scoped_ptr<base::Value> value, |
| 385 const base::Callback<void(scoped_ptr<base::Value>)>& callback) { | 386 const base::Callback<void(scoped_ptr<base::Value>)>& callback) { |
| 386 return layer_tree_host_->ScheduleMicroBenchmark(name, value.Pass(), callback); | 387 return layer_tree_host_->ScheduleMicroBenchmark(name, value.Pass(), callback); |
| 387 } | 388 } |
| 388 | 389 |
| 389 void RenderWidgetCompositor::Initialize(cc::LayerTreeSettings settings) { | 390 bool RenderWidgetCompositor::Initialize(cc::LayerTreeSettings settings) { |
| 390 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy = | 391 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy = |
| 391 RenderThreadImpl::current()->compositor_message_loop_proxy(); | 392 RenderThreadImpl::current()->compositor_message_loop_proxy(); |
| 392 if (compositor_message_loop_proxy.get()) { | 393 if (compositor_message_loop_proxy.get()) { |
| 393 layer_tree_host_ = cc::LayerTreeHost::CreateThreaded( | 394 layer_tree_host_ = cc::LayerTreeHost::CreateThreaded( |
| 394 this, NULL, settings, compositor_message_loop_proxy); | 395 this, NULL, settings, compositor_message_loop_proxy); |
| 395 } else { | 396 } else { |
| 396 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( | 397 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( |
| 397 this, this, NULL, settings); | 398 this, this, NULL, settings); |
| 398 } | 399 } |
| 399 DCHECK(layer_tree_host_); | 400 return layer_tree_host_; |
| 400 } | 401 } |
| 401 | 402 |
| 402 void RenderWidgetCompositor::setSurfaceReady() { | 403 void RenderWidgetCompositor::setSurfaceReady() { |
| 403 layer_tree_host_->SetLayerTreeHostClientReady(); | 404 layer_tree_host_->SetLayerTreeHostClientReady(); |
| 404 } | 405 } |
| 405 | 406 |
| 406 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { | 407 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { |
| 407 layer_tree_host_->SetRootLayer( | 408 layer_tree_host_->SetRootLayer( |
| 408 static_cast<const webkit::WebLayerImpl*>(&layer)->layer()); | 409 static_cast<const webkit::WebLayerImpl*>(&layer)->layer()); |
| 409 } | 410 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 widget_->OnSwapBuffersAborted(); | 634 widget_->OnSwapBuffersAborted(); |
| 634 } | 635 } |
| 635 | 636 |
| 636 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 637 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
| 637 cc::ContextProvider* provider = | 638 cc::ContextProvider* provider = |
| 638 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 639 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
| 639 provider->Context3d()->rateLimitOffscreenContextCHROMIUM(); | 640 provider->Context3d()->rateLimitOffscreenContextCHROMIUM(); |
| 640 } | 641 } |
| 641 | 642 |
| 642 } // namespace content | 643 } // namespace content |
| OLD | NEW |