render_widget_compositor.cc revision b2df76ea8fec9e32f6f3718986dba0d95315b29c
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/renderer/gpu/render_widget_compositor.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <limits>
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/command_line.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/logging.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/string_number_conversions.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/synchronization/lock.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/time.h"
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/base/switches.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/base/thread_impl.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/debug/layer_tree_debug_state.h"
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/layers/layer.h"
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/trees/layer_tree_host.h"
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/common/gpu/client/context_provider_command_buffer.h"
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/common/content_switches.h"
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/renderer/gpu/input_handler_manager.h"
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/renderer/render_thread_impl.h"
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
24b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gl/gl_switches.h"
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "webkit/compositor_bindings/web_layer_impl.h"
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h"
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace cc {
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Layer;
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)using WebKit::WebFloatPoint;
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)using WebKit::WebSize;
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)using WebKit::WebRect;
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace content {
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace {
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool GetSwitchValueAsInt(
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const CommandLine& command_line,
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const std::string& switch_string,
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int min_value,
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int max_value,
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int* result) {
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  std::string string_value = command_line.GetSwitchValueASCII(switch_string);
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int int_value;
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (base::StringToInt(string_value, &int_value) &&
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      int_value >= min_value && int_value <= max_value) {
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    *result = int_value;
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return true;
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  } else {
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    LOG(WARNING) << "Failed to parse switch " << switch_string  << ": " <<
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        string_value;
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return false;
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool GetSwitchValueAsFloat(
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const CommandLine& command_line,
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const std::string& switch_string,
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float min_value,
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float max_value,
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float* result) {
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  std::string string_value = command_line.GetSwitchValueASCII(switch_string);
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  double double_value;
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (base::StringToDouble(string_value, &double_value) &&
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      double_value >= min_value && double_value <= max_value) {
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    *result = static_cast<float>(double_value);
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return true;
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  } else {
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    LOG(WARNING) << "Failed to parse switch " << switch_string  << ": " <<
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        string_value;
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return false;
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create(
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      RenderWidget* widget) {
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<RenderWidgetCompositor> compositor(
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      new RenderWidgetCompositor(widget));
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CommandLine* cmd = CommandLine::ForCurrentProcess();
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::LayerTreeSettings settings;
90b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
91b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // For web contents, layer transforms should scale up the contents of layers
92b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // to keep content always crisp when possible.
93b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  settings.layer_transforms_should_scale_layer_contents = true;
94b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.accelerate_painting =
962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(switches::kEnableAcceleratedPainting);
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.render_vsync_enabled = !cmd->HasSwitch(switches::kDisableGpuVsync);
98c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  settings.render_vsync_notification_enabled =
99c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      cmd->HasSwitch(switches::kEnableVsyncNotification);
100c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  settings.synchronously_disable_vsync = widget->SynchronouslyDisableVSync();
1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.per_tile_painting_enabled =
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnablePerTilePainting);
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.accelerated_animation_enabled =
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      !cmd->HasSwitch(cc::switches::kDisableThreadedAnimation);
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int default_tile_width = settings.default_tile_size.width();
1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(switches::kDefaultTileWidth)) {
1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(*cmd, switches::kDefaultTileWidth, 1,
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        std::numeric_limits<int>::max(), &default_tile_width);
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int default_tile_height = settings.default_tile_size.height();
1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(switches::kDefaultTileHeight)) {
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(*cmd, switches::kDefaultTileHeight, 1,
1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        std::numeric_limits<int>::max(), &default_tile_height);
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.default_tile_size = gfx::Size(default_tile_width,
1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                         default_tile_height);
1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int max_untiled_layer_width = settings.max_untiled_layer_size.width();
1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(switches::kMaxUntiledLayerWidth)) {
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(*cmd, switches::kMaxUntiledLayerWidth, 1,
1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        std::numeric_limits<int>::max(),
1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        &max_untiled_layer_width);
1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int max_untiled_layer_height = settings.max_untiled_layer_size.height();
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(switches::kMaxUntiledLayerHeight)) {
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(*cmd, switches::kMaxUntiledLayerHeight, 1,
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        std::numeric_limits<int>::max(),
1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        &max_untiled_layer_height);
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.max_untiled_layer_size = gfx::Size(max_untiled_layer_width,
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                           max_untiled_layer_height);
1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.right_aligned_scheduling_enabled =
1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnableRightAlignedScheduling);
1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.impl_side_painting = cc::switches::IsImplSidePaintingEnabled();
1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.use_color_estimator =
139c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      !cmd->HasSwitch(cc::switches::kDisableColorEstimator);
1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.prediction_benchmarking =
1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnablePredictionBenchmarking);
1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.calculate_top_controls_position =
1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnableTopControlsPositionCalculation);
1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kTopControlsHeight)) {
1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    std::string controls_height_str =
1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        cmd->GetSwitchValueASCII(cc::switches::kTopControlsHeight);
1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    double controls_height;
1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    if (base::StringToDouble(controls_height_str, &controls_height) &&
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        controls_height > 0)
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      settings.top_controls_height = controls_height;
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.compositor_frame_message =
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnableCompositorFrameMessage);
1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (settings.calculate_top_controls_position &&
1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      (settings.top_controls_height <= 0 ||
1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)       !settings.compositor_frame_message)) {
1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    DCHECK(false) << "Top controls repositioning enabled without valid height "
1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                     "or compositor_frame_message set.";
1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    settings.calculate_top_controls_position = false;
1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kTopControlsShowThreshold)) {
1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::string top_threshold_str =
1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          cmd->GetSwitchValueASCII(cc::switches::kTopControlsShowThreshold);
1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      double show_threshold;
1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      if (base::StringToDouble(top_threshold_str, &show_threshold) &&
1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          show_threshold >= 0.f && show_threshold <= 1.f)
1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        settings.top_controls_show_threshold = show_threshold;
1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kTopControlsHideThreshold)) {
1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::string top_threshold_str =
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          cmd->GetSwitchValueASCII(cc::switches::kTopControlsHideThreshold);
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      double hide_threshold;
1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      if (base::StringToDouble(top_threshold_str, &hide_threshold) &&
1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          hide_threshold >= 0.f && hide_threshold <= 1.f)
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        settings.top_controls_hide_threshold = hide_threshold;
1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.partial_swap_enabled = widget->AllowPartialSwap() &&
1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnablePartialSwap);
1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.background_color_instead_of_checkerboard =
1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kBackgroundColorInsteadOfCheckerboard);
1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.show_overdraw_in_tracing =
1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kTraceOverdraw);
1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
190c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS)
191c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  settings.use_pinch_zoom_scrollbars =
192c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnablePinchZoomScrollbars);
193c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif
194c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // These flags should be mirrored by UI versions in ui/compositor/.
1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_debug_borders =
1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowCompositedLayerBorders);
1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_fps_counter =
1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowFPSCounter);
2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_paint_rects =
2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(switches::kShowPaintRects);
2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_platform_layer_tree =
2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowCompositedLayerTree);
2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_property_changed_rects =
2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowPropertyChangedRects);
2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_surface_damage_rects =
2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowSurfaceDamageRects);
2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_screen_space_rects =
2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowScreenSpaceRects);
2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_replica_screen_space_rects =
2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowReplicaScreenSpaceRects);
2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_occluding_rects =
2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowOccludingRects);
2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_non_occluding_rects =
2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowNonOccludingRects);
2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.SetRecordRenderingStats(
2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(switches::kEnableGpuBenchmarking));
2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.trace_all_rendered_frames =
2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kTraceAllRenderedFrames);
2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kSlowDownRasterScaleFactor)) {
2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMinSlowDownScaleFactor = 0;
2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMaxSlowDownScaleFactor = INT_MAX;
2252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(
2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        *cmd,
2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        cc::switches::kSlowDownRasterScaleFactor,
2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        kMinSlowDownScaleFactor,
2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        kMaxSlowDownScaleFactor,
2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        &settings.initial_debug_state.slow_down_raster_scale_factor);
2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kNumRasterThreads)) {
2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMinRasterThreads = 1;
2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMaxRasterThreads = 64;
2362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int num_raster_threads;
2372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    if (GetSwitchValueAsInt(*cmd, cc::switches::kNumRasterThreads,
2382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                            kMinRasterThreads, kMaxRasterThreads,
2392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                            &num_raster_threads))
2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      settings.num_raster_threads = num_raster_threads;
2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kLowResolutionContentsScaleFactor)) {
2442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMinScaleFactor = settings.minimum_contents_scale;
2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMaxScaleFactor = 1;
2462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsFloat(*cmd,
2472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          cc::switches::kLowResolutionContentsScaleFactor,
2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          kMinScaleFactor, kMaxScaleFactor,
2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          &settings.low_res_contents_scale_factor);
2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
252c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kMaxTilesForInterestArea)) {
253c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    int max_tiles_for_interest_area;
254c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    if (GetSwitchValueAsInt(*cmd,
255c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                            cc::switches::kMaxTilesForInterestArea,
256c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                            1, std::numeric_limits<int>::max(),
257c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                            &max_tiles_for_interest_area))
258c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      settings.max_tiles_for_interest_area = max_tiles_for_interest_area;
259c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
260c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
261c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kMaxUnusedResourceMemoryUsagePercentage)) {
262c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    int max_unused_resource_memory_percentage;
263c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    if (GetSwitchValueAsInt(
264c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            *cmd,
265c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            cc::switches::kMaxUnusedResourceMemoryUsagePercentage,
266c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            0, 100,
267c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            &max_unused_resource_memory_percentage)) {
268c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      settings.max_unused_resource_memory_percentage =
269c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)          max_unused_resource_memory_percentage;
270c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    }
271c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
272c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
273c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  settings.strict_layer_property_change_checking =
274c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking);
275c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_ANDROID)
2772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // TODO(danakj): Move these to the android code.
2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.can_use_lcd_text = false;
2792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.max_partial_texture_updates = 0;
2802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.use_linear_fade_scrollbar_animator = true;
2812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.solid_color_scrollbars = true;
2822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128);
2832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.solid_color_scrollbar_thickness_dip = 3;
284c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  settings.highp_threshold_min = 2048;
2852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
2862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!compositor->initialize(settings))
2882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return scoped_ptr<RenderWidgetCompositor>();
2892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return compositor.Pass();
2912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
2922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget)
2942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  : suppress_schedule_composite_(false),
2952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    widget_(widget) {
2962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
2972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)RenderWidgetCompositor::~RenderWidgetCompositor() {}
2992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) {
3012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (suppress_schedule_composite_ == suppress)
3022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return;
3032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (suppress)
3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    TRACE_EVENT_ASYNC_BEGIN0("gpu",
3062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
3072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  else
3082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    TRACE_EVENT_ASYNC_END0("gpu",
3092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
3102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  suppress_schedule_composite_ = suppress;
3112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::Animate(base::TimeTicks time) {
314b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  layer_tree_host_->UpdateClientAnimations(time);
3152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::Composite(base::TimeTicks frame_begin_time) {
3182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->Composite(frame_begin_time);
3192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
321c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() {
322c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  layer_tree_host_->SetNeedsDisplayOnAllLayers();
323c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
324c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
3252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::GetRenderingStats(cc::RenderingStats* stats) {
3262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->CollectRenderingStats(stats);
3272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)skia::RefPtr<SkPicture> RenderWidgetCompositor::CapturePicture() {
3302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_->CapturePicture();
3312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
333c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void RenderWidgetCompositor::UpdateTopControlsState(bool enable_hiding,
334c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                                    bool enable_showing,
335c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                                    bool animate) {
336c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  layer_tree_host_->UpdateTopControlsState(enable_hiding,
337c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                           enable_showing,
338c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                           animate);
3392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::SetOverdrawBottomHeight(
3422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float overdraw_bottom_height) {
3432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetOverdrawBottomHeight(overdraw_bottom_height);
3442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
346c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) {
347c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  layer_tree_host_->SetNeedsRedrawRect(damage_rect);
348c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
349c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
350b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)void RenderWidgetCompositor::SetLatencyInfo(
351b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)    const cc::LatencyInfo& latency_info) {
352b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  layer_tree_host_->SetLatencyInfo(latency_info);
353b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)}
354b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
3552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool RenderWidgetCompositor::initialize(cc::LayerTreeSettings settings) {
3562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<cc::Thread> impl_thread;
3572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy =
3582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      RenderThreadImpl::current()->compositor_message_loop_proxy();
3592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  threaded_ = !!compositor_message_loop_proxy;
3602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (threaded_) {
3612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    impl_thread = cc::ThreadImpl::CreateForDifferentThread(
3622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        compositor_message_loop_proxy);
3632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
3642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_ = cc::LayerTreeHost::Create(this,
3652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                               settings,
3662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                               impl_thread.Pass());
3672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_;
3682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setSurfaceReady() {
371b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  layer_tree_host_->SetLayerTreeHostClientReady();
3722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setRootLayer(const WebKit::WebLayer& layer) {
3752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetRootLayer(
3762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      static_cast<const webkit::WebLayerImpl*>(&layer)->layer());
3772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::clearRootLayer() {
3802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>());
3812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setViewportSize(
384c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const WebSize&,
3852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const WebSize& device_viewport_size) {
386c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  layer_tree_host_->SetViewportSize(device_viewport_size);
3872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WebSize RenderWidgetCompositor::layoutViewportSize() const {
390c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  return layer_tree_host_->device_viewport_size();
3912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WebSize RenderWidgetCompositor::deviceViewportSize() const {
3942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_->device_viewport_size();
3952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WebFloatPoint RenderWidgetCompositor::adjustEventPointForPinchZoom(
3982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const WebFloatPoint& point) const {
3992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return point;
4002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setDeviceScaleFactor(float device_scale) {
4032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDeviceScaleFactor(device_scale);
4042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)float RenderWidgetCompositor::deviceScaleFactor() const {
4072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_->device_scale_factor();
4082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setBackgroundColor(WebKit::WebColor color) {
4112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->set_background_color(color);
4122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setHasTransparentBackground(bool transparent) {
4152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->set_has_transparent_background(transparent);
4162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setVisible(bool visible) {
4192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetVisible(visible);
4202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setPageScaleFactorAndLimits(
4232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float page_scale_factor, float minimum, float maximum) {
4242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetPageScaleFactorAndLimits(
4252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      page_scale_factor, minimum, maximum);
4262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::startPageScaleAnimation(
4292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const WebKit::WebPoint& destination,
4302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    bool use_anchor,
4312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float new_page_scale,
4322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    double duration_sec) {
4332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::TimeDelta duration = base::TimeDelta::FromMicroseconds(
4342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      duration_sec * base::Time::kMicrosecondsPerSecond);
4352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->StartPageScaleAnimation(
4362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      gfx::Vector2d(destination.x, destination.y),
4372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      use_anchor,
4382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      new_page_scale,
4392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      duration);
4402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setNeedsAnimate() {
4432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetNeedsAnimate();
4442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setNeedsRedraw() {
4472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (threaded_)
4482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    layer_tree_host_->SetNeedsAnimate();
4492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  else
4502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    widget_->scheduleAnimation();
4512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool RenderWidgetCompositor::commitRequested() const {
4542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_->CommitRequested();
4552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::didStopFlinging() {
4582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->DidStopFlinging();
4592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::registerForAnimations(WebKit::WebLayer* layer) {
4622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::Layer* cc_layer = static_cast<webkit::WebLayerImpl*>(layer)->layer();
4632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc_layer->layer_animation_controller()->SetAnimationRegistrar(
4642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      layer_tree_host_->animation_registrar());
4652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool RenderWidgetCompositor::compositeAndReadback(
4682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    void *pixels, const WebRect& rect_in_device_viewport) {
4692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_->CompositeAndReadback(pixels,
4702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                                rect_in_device_viewport);
4712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::finishAllRendering() {
4742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->FinishAllRendering();
4752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setDeferCommits(bool defer_commits) {
4782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDeferCommits(defer_commits);
4792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setShowFPSCounter(bool show) {
4822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state();
4832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  debug_state.show_fps_counter = show;
4842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDebugState(debug_state);
4852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setShowPaintRects(bool show) {
4882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state();
4892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  debug_state.show_paint_rects = show;
4902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDebugState(debug_state);
4912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setShowDebugBorders(bool show) {
4942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state();
4952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  debug_state.show_debug_borders = show;
4962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDebugState(debug_state);
4972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setContinuousPaintingEnabled(bool enabled) {
5002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state();
5012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  debug_state.continuous_painting = enabled;
5022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDebugState(debug_state);
5032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::WillBeginFrame() {
5062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->InstrumentWillBeginFrame();
5072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->willBeginCompositorFrame();
5082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::DidBeginFrame() {
5112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->InstrumentDidBeginFrame();
5122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::Animate(double frame_begin_time) {
5152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->webwidget()->animate(frame_begin_time);
5162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::Layout() {
5192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->webwidget()->layout();
5202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::ApplyScrollAndScale(gfx::Vector2d scroll_delta,
5232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                                 float page_scale) {
5242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->webwidget()->applyScrollAndScale(scroll_delta, page_scale);
5252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)scoped_ptr<cc::OutputSurface> RenderWidgetCompositor::CreateOutputSurface() {
5282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return widget_->CreateOutputSurface();
5292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
531b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)void RenderWidgetCompositor::DidInitializeOutputSurface(bool success) {
5322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!success)
5332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    widget_->webwidget()->didExitCompositingMode();
5342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
536c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)scoped_ptr<cc::InputHandlerClient>
537c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)RenderWidgetCompositor::CreateInputHandlerClient() {
538c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  scoped_ptr<cc::InputHandlerClient> ret;
5392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<WebKit::WebInputHandler> web_handler(
5402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      widget_->webwidget()->createInputHandler());
5412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (web_handler)
5422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)     ret = WebKit::WebToCCInputHandlerAdapter::create(web_handler.Pass());
5432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return ret.Pass();
5442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::WillCommit() {
5472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->InstrumentWillComposite();
5482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::DidCommit() {
5512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->DidCommitCompositorFrame();
5522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->didBecomeReadyForAdditionalInput();
5532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::DidCommitAndDrawFrame() {
5562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->didCommitAndDrawCompositorFrame();
5572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::DidCompleteSwapBuffers() {
5602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->didCompleteSwapBuffers();
5612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::ScheduleComposite() {
5642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!suppress_schedule_composite_)
5652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    widget_->scheduleComposite();
5662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)scoped_refptr<cc::ContextProvider>
5692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)RenderWidgetCompositor::OffscreenContextProviderForMainThread() {
5702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return RenderThreadImpl::current()->OffscreenContextProviderForMainThread();
5712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)scoped_refptr<cc::ContextProvider>
5742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() {
5752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return RenderThreadImpl::current()->
5762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      OffscreenContextProviderForCompositorThread();
5772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace content
580