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