render_widget_compositor.cc revision a3f7b4e666c476898878fa745f637129375cd889
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>
890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <string>
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/command_line.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/logging.h"
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string_number_conversions.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/synchronization/lock.h"
14eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/base/switches.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"
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "third_party/WebKit/public/platform/WebSize.h"
247d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebWidget.h"
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gl/gl_switches.h"
2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace cc {
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Layer;
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)using WebKit::WebFloatPoint;
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)using WebKit::WebSize;
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)using WebKit::WebRect;
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace content {
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace {
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool GetSwitchValueAsInt(
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const CommandLine& command_line,
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const std::string& switch_string,
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int min_value,
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int max_value,
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int* result) {
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  std::string string_value = command_line.GetSwitchValueASCII(switch_string);
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int int_value;
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (base::StringToInt(string_value, &int_value) &&
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      int_value >= min_value && int_value <= max_value) {
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    *result = int_value;
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return true;
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  } else {
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    LOG(WARNING) << "Failed to parse switch " << switch_string  << ": " <<
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        string_value;
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return false;
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool GetSwitchValueAsFloat(
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const CommandLine& command_line,
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const std::string& switch_string,
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float min_value,
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float max_value,
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float* result) {
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  std::string string_value = command_line.GetSwitchValueASCII(switch_string);
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  double double_value;
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (base::StringToDouble(string_value, &double_value) &&
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      double_value >= min_value && double_value <= max_value) {
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    *result = static_cast<float>(double_value);
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return true;
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  } else {
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    LOG(WARNING) << "Failed to parse switch " << switch_string  << ": " <<
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        string_value;
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return false;
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create(
82ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    RenderWidget* widget,
83ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    bool threaded) {
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<RenderWidgetCompositor> compositor(
85ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      new RenderWidgetCompositor(widget, threaded));
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)
9590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  settings.throttle_frame_production =
9690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      !cmd->HasSwitch(switches::kDisableGpuVsync);
97868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  settings.begin_frame_scheduling_enabled =
98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      cmd->HasSwitch(switches::kEnableBeginFrameScheduling);
9990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  settings.using_synchronous_renderer_compositor =
10090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      widget->UsingSynchronousRendererCompositor();
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);
10590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  settings.force_direct_layer_drawing =
10690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kForceDirectLayerDrawing);
1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1087d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // Android WebView does not support forced draw and this is to prevent
1097d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // crashes. Adding support for forced draw is tracked in crbug.com/250909.
1107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  settings.timeout_and_draw_when_animation_checkerboards =
1117d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)      !widget->UsingSynchronousRendererCompositor();
1127d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int default_tile_width = settings.default_tile_size.width();
1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(switches::kDefaultTileWidth)) {
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(*cmd, switches::kDefaultTileWidth, 1,
1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        std::numeric_limits<int>::max(), &default_tile_width);
1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int default_tile_height = settings.default_tile_size.height();
1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(switches::kDefaultTileHeight)) {
1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(*cmd, switches::kDefaultTileHeight, 1,
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        std::numeric_limits<int>::max(), &default_tile_height);
1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.default_tile_size = gfx::Size(default_tile_width,
1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                         default_tile_height);
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int max_untiled_layer_width = settings.max_untiled_layer_size.width();
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(switches::kMaxUntiledLayerWidth)) {
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(*cmd, switches::kMaxUntiledLayerWidth, 1,
1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        std::numeric_limits<int>::max(),
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        &max_untiled_layer_width);
1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int max_untiled_layer_height = settings.max_untiled_layer_size.height();
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(switches::kMaxUntiledLayerHeight)) {
1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(*cmd, switches::kMaxUntiledLayerHeight, 1,
1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        std::numeric_limits<int>::max(),
1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        &max_untiled_layer_height);
1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.max_untiled_layer_size = gfx::Size(max_untiled_layer_width,
1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                           max_untiled_layer_height);
1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.impl_side_painting = cc::switches::IsImplSidePaintingEnabled();
1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.calculate_top_controls_position =
1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnableTopControlsPositionCalculation);
1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kTopControlsHeight)) {
1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    std::string controls_height_str =
1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        cmd->GetSwitchValueASCII(cc::switches::kTopControlsHeight);
1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    double controls_height;
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    if (base::StringToDouble(controls_height_str, &controls_height) &&
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        controls_height > 0)
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      settings.top_controls_height = controls_height;
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (settings.calculate_top_controls_position &&
1565e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)      settings.top_controls_height <= 0) {
1575e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)    DCHECK(false)
1585e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)        << "Top controls repositioning enabled without valid height set.";
1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    settings.calculate_top_controls_position = false;
1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kTopControlsShowThreshold)) {
1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::string top_threshold_str =
1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          cmd->GetSwitchValueASCII(cc::switches::kTopControlsShowThreshold);
1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      double show_threshold;
1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      if (base::StringToDouble(top_threshold_str, &show_threshold) &&
1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          show_threshold >= 0.f && show_threshold <= 1.f)
1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        settings.top_controls_show_threshold = show_threshold;
1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kTopControlsHideThreshold)) {
1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::string top_threshold_str =
1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          cmd->GetSwitchValueASCII(cc::switches::kTopControlsHideThreshold);
1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      double hide_threshold;
1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      if (base::StringToDouble(top_threshold_str, &hide_threshold) &&
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          hide_threshold >= 0.f && hide_threshold <= 1.f)
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        settings.top_controls_hide_threshold = hide_threshold;
1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.partial_swap_enabled = widget->AllowPartialSwap() &&
1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnablePartialSwap);
1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.background_color_instead_of_checkerboard =
1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kBackgroundColorInsteadOfCheckerboard);
1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.show_overdraw_in_tracing =
1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kTraceOverdraw);
18690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  settings.use_pinch_virtual_viewport =
18790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport);
188ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  settings.allow_antialiasing &=
189ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      !cmd->HasSwitch(cc::switches::kDisableCompositedAntialiasing);
190c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // These flags should be mirrored by UI versions in ui/compositor/.
1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_debug_borders =
1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowCompositedLayerBorders);
1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_fps_counter =
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowFPSCounter);
1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_paint_rects =
1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(switches::kShowPaintRects);
1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_property_changed_rects =
1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowPropertyChangedRects);
2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_surface_damage_rects =
2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowSurfaceDamageRects);
2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_screen_space_rects =
2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowScreenSpaceRects);
2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_replica_screen_space_rects =
2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowReplicaScreenSpaceRects);
2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_occluding_rects =
2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowOccludingRects);
2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.show_non_occluding_rects =
2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kShowNonOccludingRects);
2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.initial_debug_state.SetRecordRenderingStats(
2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      cmd->HasSwitch(switches::kEnableGpuBenchmarking));
2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kSlowDownRasterScaleFactor)) {
2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMinSlowDownScaleFactor = 0;
2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMaxSlowDownScaleFactor = INT_MAX;
2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsInt(
2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        *cmd,
2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        cc::switches::kSlowDownRasterScaleFactor,
2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        kMinSlowDownScaleFactor,
2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        kMaxSlowDownScaleFactor,
2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        &settings.initial_debug_state.slow_down_raster_scale_factor);
2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kNumRasterThreads)) {
2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMinRasterThreads = 1;
2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMaxRasterThreads = 64;
2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int num_raster_threads;
2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    if (GetSwitchValueAsInt(*cmd, cc::switches::kNumRasterThreads,
2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                            kMinRasterThreads, kMaxRasterThreads,
2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                            &num_raster_threads))
2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      settings.num_raster_threads = num_raster_threads;
2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kLowResolutionContentsScaleFactor)) {
2362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMinScaleFactor = settings.minimum_contents_scale;
2372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int kMaxScaleFactor = 1;
2382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    GetSwitchValueAsFloat(*cmd,
2392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          cc::switches::kLowResolutionContentsScaleFactor,
2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          kMinScaleFactor, kMaxScaleFactor,
2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          &settings.low_res_contents_scale_factor);
2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
244c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kMaxTilesForInterestArea)) {
245c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    int max_tiles_for_interest_area;
246c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    if (GetSwitchValueAsInt(*cmd,
247c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                            cc::switches::kMaxTilesForInterestArea,
248c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                            1, std::numeric_limits<int>::max(),
249c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                            &max_tiles_for_interest_area))
250c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      settings.max_tiles_for_interest_area = max_tiles_for_interest_area;
251c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
252c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
253c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (cmd->HasSwitch(cc::switches::kMaxUnusedResourceMemoryUsagePercentage)) {
254c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    int max_unused_resource_memory_percentage;
255c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    if (GetSwitchValueAsInt(
256c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            *cmd,
257c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            cc::switches::kMaxUnusedResourceMemoryUsagePercentage,
258c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            0, 100,
259c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            &max_unused_resource_memory_percentage)) {
260c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      settings.max_unused_resource_memory_percentage =
261c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)          max_unused_resource_memory_percentage;
262c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    }
263c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
264c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
265c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  settings.strict_layer_property_change_checking =
266c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking);
267c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
26890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  settings.use_map_image = cmd->HasSwitch(cc::switches::kUseMapImage);
26990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
2702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_ANDROID)
2712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // TODO(danakj): Move these to the android code.
2722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.can_use_lcd_text = false;
2732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.max_partial_texture_updates = 0;
2742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.use_linear_fade_scrollbar_animator = true;
2752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.solid_color_scrollbars = true;
2767dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  settings.solid_color_scrollbar_color =
2777dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch      cmd->HasSwitch(switches::kHideScrollbars)
2787dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch          ? SK_ColorTRANSPARENT
2797dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch          : SkColorSetARGB(128, 128, 128, 128);
2802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  settings.solid_color_scrollbar_thickness_dip = 3;
281c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  settings.highp_threshold_min = 2048;
2822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
2832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!compositor->initialize(settings))
2852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return scoped_ptr<RenderWidgetCompositor>();
2862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return compositor.Pass();
2882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
2892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
290ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben MurdochRenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget,
291ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch                                               bool threaded)
292ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    : threaded_(threaded),
293ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      suppress_schedule_composite_(false),
294ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      widget_(widget) {
2952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
2962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)RenderWidgetCompositor::~RenderWidgetCompositor() {}
2982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
29990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)const base::WeakPtr<cc::InputHandler>&
30090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)RenderWidgetCompositor::GetInputHandler() {
30190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  return layer_tree_host_->GetInputHandler();
30290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}
30390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
3042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) {
3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (suppress_schedule_composite_ == suppress)
3062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return;
3072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (suppress)
3092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    TRACE_EVENT_ASYNC_BEGIN0("gpu",
3102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
3112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  else
3122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    TRACE_EVENT_ASYNC_END0("gpu",
3132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
3142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  suppress_schedule_composite_ = suppress;
3152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::Animate(base::TimeTicks time) {
318b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  layer_tree_host_->UpdateClientAnimations(time);
3192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::Composite(base::TimeTicks frame_begin_time) {
3222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->Composite(frame_begin_time);
3232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
325c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() {
326c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  layer_tree_host_->SetNeedsDisplayOnAllLayers();
327c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
328c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
32990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() {
33090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  cc::LayerTreeDebugState current = layer_tree_host_->debug_state();
33190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  current.rasterize_only_visible_content = true;
33290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  layer_tree_host_->SetDebugState(current);
33390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}
33490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
3352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::GetRenderingStats(cc::RenderingStats* stats) {
3362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->CollectRenderingStats(stats);
3372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
33990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void RenderWidgetCompositor::UpdateTopControlsState(
34090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    cc::TopControlsState constraints,
34190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    cc::TopControlsState current,
34290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    bool animate) {
34390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  layer_tree_host_->UpdateTopControlsState(constraints,
34490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           current,
345c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                           animate);
3462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::SetOverdrawBottomHeight(
3492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float overdraw_bottom_height) {
3502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetOverdrawBottomHeight(overdraw_bottom_height);
3512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
353c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) {
354c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  layer_tree_host_->SetNeedsRedrawRect(damage_rect);
355c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
356c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
357b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)void RenderWidgetCompositor::SetLatencyInfo(
35890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    const ui::LatencyInfo& latency_info) {
359b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  layer_tree_host_->SetLatencyInfo(latency_info);
360b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)}
361b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
362a3f7b4e666c476898878fa745f637129375cd889Ben Murdochint RenderWidgetCompositor::GetLayerTreeId() const {
363a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch  return layer_tree_host_->id();
364a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch}
365a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
3662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool RenderWidgetCompositor::initialize(cc::LayerTreeSettings settings) {
3672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy =
3682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      RenderThreadImpl::current()->compositor_message_loop_proxy();
3692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_ = cc::LayerTreeHost::Create(this,
3702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                               settings,
371eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch                                               compositor_message_loop_proxy);
3722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_;
3732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setSurfaceReady() {
376b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  layer_tree_host_->SetLayerTreeHostClientReady();
3772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setRootLayer(const WebKit::WebLayer& layer) {
3802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetRootLayer(
3812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      static_cast<const webkit::WebLayerImpl*>(&layer)->layer());
3822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::clearRootLayer() {
3852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>());
3862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setViewportSize(
389c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const WebSize&,
3902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const WebSize& device_viewport_size) {
391c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  layer_tree_host_->SetViewportSize(device_viewport_size);
3922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WebSize RenderWidgetCompositor::layoutViewportSize() const {
395c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  return layer_tree_host_->device_viewport_size();
3962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
3972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WebSize RenderWidgetCompositor::deviceViewportSize() const {
3992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_->device_viewport_size();
4002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WebFloatPoint RenderWidgetCompositor::adjustEventPointForPinchZoom(
4032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const WebFloatPoint& point) const {
4042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return point;
4052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setDeviceScaleFactor(float device_scale) {
4082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDeviceScaleFactor(device_scale);
4092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)float RenderWidgetCompositor::deviceScaleFactor() const {
4122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_->device_scale_factor();
4132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setBackgroundColor(WebKit::WebColor color) {
4162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->set_background_color(color);
4172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setHasTransparentBackground(bool transparent) {
4202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->set_has_transparent_background(transparent);
4212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setVisible(bool visible) {
4242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetVisible(visible);
4252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setPageScaleFactorAndLimits(
4282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float page_scale_factor, float minimum, float maximum) {
4292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetPageScaleFactorAndLimits(
4302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      page_scale_factor, minimum, maximum);
4312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::startPageScaleAnimation(
4342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const WebKit::WebPoint& destination,
4352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    bool use_anchor,
4362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    float new_page_scale,
4372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    double duration_sec) {
4382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::TimeDelta duration = base::TimeDelta::FromMicroseconds(
4392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      duration_sec * base::Time::kMicrosecondsPerSecond);
4402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->StartPageScaleAnimation(
4412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      gfx::Vector2d(destination.x, destination.y),
4422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      use_anchor,
4432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      new_page_scale,
4442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      duration);
4452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setNeedsAnimate() {
4482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetNeedsAnimate();
4492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setNeedsRedraw() {
4522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (threaded_)
4532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    layer_tree_host_->SetNeedsAnimate();
4542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  else
4552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    widget_->scheduleAnimation();
4562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool RenderWidgetCompositor::commitRequested() const {
4592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_->CommitRequested();
4602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::didStopFlinging() {
4632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->DidStopFlinging();
4642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::registerForAnimations(WebKit::WebLayer* layer) {
4672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::Layer* cc_layer = static_cast<webkit::WebLayerImpl*>(layer)->layer();
4682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc_layer->layer_animation_controller()->SetAnimationRegistrar(
4692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      layer_tree_host_->animation_registrar());
4702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool RenderWidgetCompositor::compositeAndReadback(
4732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    void *pixels, const WebRect& rect_in_device_viewport) {
4742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return layer_tree_host_->CompositeAndReadback(pixels,
4752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                                rect_in_device_viewport);
4762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::finishAllRendering() {
4792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->FinishAllRendering();
4802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setDeferCommits(bool defer_commits) {
4832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDeferCommits(defer_commits);
4842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setShowFPSCounter(bool show) {
4872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state();
4882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  debug_state.show_fps_counter = show;
4892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDebugState(debug_state);
4902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setShowPaintRects(bool show) {
4932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state();
4942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  debug_state.show_paint_rects = show;
4952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDebugState(debug_state);
4962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
4972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setShowDebugBorders(bool show) {
4992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state();
5002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  debug_state.show_debug_borders = show;
5012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDebugState(debug_state);
5022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::setContinuousPaintingEnabled(bool enabled) {
5052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state();
5062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  debug_state.continuous_painting = enabled;
5072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  layer_tree_host_->SetDebugState(debug_state);
5082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5107dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochvoid RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) {
5117dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state();
5127dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  debug_state.show_touch_event_handler_rects = show;
5137dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  debug_state.show_wheel_event_handler_rects = show;
5147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  debug_state.show_non_fast_scrollable_rects = show;
5157dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  layer_tree_host_->SetDebugState(debug_state);
5167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch}
5177dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
5182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::WillBeginFrame() {
5192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->InstrumentWillBeginFrame();
5202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->willBeginCompositorFrame();
5212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::DidBeginFrame() {
5242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->InstrumentDidBeginFrame();
5252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::Animate(double frame_begin_time) {
5282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->webwidget()->animate(frame_begin_time);
5292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::Layout() {
5322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->webwidget()->layout();
5332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::ApplyScrollAndScale(gfx::Vector2d scroll_delta,
5362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                                 float page_scale) {
5372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->webwidget()->applyScrollAndScale(scroll_delta, page_scale);
5382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)scoped_ptr<cc::OutputSurface> RenderWidgetCompositor::CreateOutputSurface() {
5412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return widget_->CreateOutputSurface();
5422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
544b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)void RenderWidgetCompositor::DidInitializeOutputSurface(bool success) {
5452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!success)
5462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    widget_->webwidget()->didExitCompositingMode();
5472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::WillCommit() {
5502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->InstrumentWillComposite();
5512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::DidCommit() {
5542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->DidCommitCompositorFrame();
5552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->didBecomeReadyForAdditionalInput();
5562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::DidCommitAndDrawFrame() {
5592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->didCommitAndDrawCompositorFrame();
5602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::DidCompleteSwapBuffers() {
5632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  widget_->didCompleteSwapBuffers();
5642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RenderWidgetCompositor::ScheduleComposite() {
5672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!suppress_schedule_composite_)
5682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    widget_->scheduleComposite();
5692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)scoped_refptr<cc::ContextProvider>
5722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)RenderWidgetCompositor::OffscreenContextProviderForMainThread() {
5732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return RenderThreadImpl::current()->OffscreenContextProviderForMainThread();
5742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)scoped_refptr<cc::ContextProvider>
5772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() {
5782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return RenderThreadImpl::current()->
5792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      OffscreenContextProviderForCompositorThread();
5802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
5812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace content
583