Cherry-pick: Pass resourceless software mode in SetExternalConstraints

Cherry-pick of chromium r282445

Conflicts:
	cc/layers/picture_layer_impl.cc
	cc/layers/picture_layer_impl_unittest.cc

Original description:

This fixes the bug that resourceless software mode not
dirtying the draw properties.

This allows OutputSurface::ForcedDrawToSoftwareDevice to be
removed. And merged the valid_for_tile_management parameter
into resourceless_software_draw. This effectively reverses
the last bool parameter on SetExternalDrawConstraints.

BUG: 15770662
Change-Id: I3c8895f7092ecbe9ebf79287f5721352ffb40312
diff --git a/android_webview/browser/parent_output_surface.cc b/android_webview/browser/parent_output_surface.cc
index 0150eaa..54b7f97 100644
--- a/android_webview/browser/parent_output_surface.cc
+++ b/android_webview/browser/parent_output_surface.cc
@@ -27,9 +27,10 @@
                                              const gfx::Rect& clip) {
   DCHECK(client_);
   surface_size_ = surface_size;
-  gfx::Transform identity;
-  gfx::Rect empty;
-  SetExternalDrawConstraints(identity, empty, clip, true);
+  const gfx::Transform identity;
+  const gfx::Rect empty;
+  const bool resourceless_software_draw = false;
+  SetExternalDrawConstraints(identity, empty, clip, resourceless_software_draw);
 }
 
 }  // namespace android_webview
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index f90c6da..52b1658 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -394,7 +394,9 @@
 
   DoPostCommitInitializationIfNeeded();
 
-  if (layer_tree_impl()->device_viewport_valid_for_tile_management()) {
+  // Transforms and viewport are invalid for tile management inside a
+  // resourceless software draw, so don't update them.
+  if (!layer_tree_impl()->resourceless_software_draw()) {
     visible_rect_for_tile_priority_ = visible_content_rect();
     viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize();
     screen_space_transform_for_tile_priority_ = screen_space_transform();
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index bb61f4e..83b775e 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -319,11 +319,13 @@
   SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
 
   // UpdateTiles with valid viewport. Should update tile viewport.
-  bool valid_for_tile_management = true;
+  // Note viewport is considered invalid if and only if in resourceless
+  // software draw.
+  bool resourceless_software_draw = false;
   gfx::Rect viewport = gfx::Rect(layer_bounds);
   gfx::Transform transform;
   host_impl_.SetExternalDrawConstraints(
-      transform, viewport, viewport, valid_for_tile_management);
+      transform, viewport, viewport, resourceless_software_draw);
   active_layer_->draw_properties().visible_content_rect = viewport;
   active_layer_->draw_properties().screen_space_transform = transform;
   active_layer_->UpdateTiles();
@@ -341,13 +343,13 @@
   // Should not update tile viewport.
   time_ticks += base::TimeDelta::FromMilliseconds(200);
   host_impl_.SetCurrentFrameTimeTicks(time_ticks);
-  valid_for_tile_management = false;
+  resourceless_software_draw = true;
   viewport = gfx::ScaleToEnclosingRect(viewport, 2);
   transform.Translate(1.f, 1.f);
   active_layer_->draw_properties().visible_content_rect = viewport;
   active_layer_->draw_properties().screen_space_transform = transform;
   host_impl_.SetExternalDrawConstraints(
-      transform, viewport, viewport, valid_for_tile_management);
+      transform, viewport, viewport, resourceless_software_draw);
   active_layer_->UpdateTiles();
 
   EXPECT_RECT_EQ(visible_rect_for_tile_priority,
@@ -361,9 +363,9 @@
   // Keep expanded viewport but mark it valid. Should update tile viewport.
   time_ticks += base::TimeDelta::FromMilliseconds(200);
   host_impl_.SetCurrentFrameTimeTicks(time_ticks);
-  valid_for_tile_management = true;
+  resourceless_software_draw = false;
   host_impl_.SetExternalDrawConstraints(
-      transform, viewport, viewport, valid_for_tile_management);
+      transform, viewport, viewport, resourceless_software_draw);
   active_layer_->UpdateTiles();
 
   EXPECT_FALSE(visible_rect_for_tile_priority ==
@@ -391,10 +393,10 @@
   Region invalidation;
   AddDefaultTilingsWithInvalidation(invalidation);
 
-  bool valid_for_tile_management = false;
+  bool resourceless_software_draw = true;
   gfx::Rect viewport = gfx::Rect(layer_bounds);
   host_impl_.SetExternalDrawConstraints(
-      gfx::Transform(), viewport, viewport, valid_for_tile_management);
+      gfx::Transform(), viewport, viewport, resourceless_software_draw);
   ResetTilingsAndRasterScales();
   host_impl_.pending_tree()->UpdateDrawProperties();
   host_impl_.active_tree()->UpdateDrawProperties();
@@ -2413,11 +2415,13 @@
   SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
 
   // UpdateTiles with valid viewport. Should update tile viewport.
-  bool valid_for_tile_management = true;
+  // Note viewport is considered invalid if and only if in resourceless
+  // software draw.
+  bool resourceless_software_draw = false;
   gfx::Rect viewport = gfx::Rect(layer_bounds);
   gfx::Transform transform;
   host_impl_.SetExternalDrawConstraints(
-      transform, viewport, viewport, valid_for_tile_management);
+      transform, viewport, viewport, resourceless_software_draw);
   active_layer_->draw_properties().visible_content_rect = viewport;
   active_layer_->draw_properties().screen_space_transform = transform;
   active_layer_->UpdateTiles();
@@ -2435,13 +2439,13 @@
   // Should not update tile viewport.
   time_ticks += base::TimeDelta::FromMilliseconds(200);
   host_impl_.SetCurrentFrameTimeTicks(time_ticks);
-  valid_for_tile_management = false;
+  resourceless_software_draw = true;
   viewport = gfx::ScaleToEnclosingRect(viewport, 2);
   transform.Translate(1.f, 1.f);
   active_layer_->draw_properties().visible_content_rect = viewport;
   active_layer_->draw_properties().screen_space_transform = transform;
   host_impl_.SetExternalDrawConstraints(
-      transform, viewport, viewport, valid_for_tile_management);
+      transform, viewport, viewport, resourceless_software_draw);
   active_layer_->UpdateTiles();
 
   EXPECT_RECT_EQ(visible_rect_for_tile_priority,
@@ -2455,9 +2459,9 @@
   // Keep expanded viewport but mark it valid. Should update tile viewport.
   time_ticks += base::TimeDelta::FromMilliseconds(200);
   host_impl_.SetCurrentFrameTimeTicks(time_ticks);
-  valid_for_tile_management = true;
+  resourceless_software_draw = false;
   host_impl_.SetExternalDrawConstraints(
-      transform, viewport, viewport, valid_for_tile_management);
+      transform, viewport, viewport, resourceless_software_draw);
   active_layer_->UpdateTiles();
 
   EXPECT_FALSE(visible_rect_for_tile_priority ==
@@ -2485,10 +2489,10 @@
   Region invalidation;
   AddDefaultTilingsWithInvalidation(invalidation);
 
-  bool valid_for_tile_management = false;
+  bool resourceless_software_draw = true;
   gfx::Rect viewport = gfx::Rect(layer_bounds);
   host_impl_.SetExternalDrawConstraints(
-      gfx::Transform(), viewport, viewport, valid_for_tile_management);
+      gfx::Transform(), viewport, viewport, resourceless_software_draw);
   ResetTilingsAndRasterScales();
   host_impl_.pending_tree()->UpdateDrawProperties();
   host_impl_.active_tree()->UpdateDrawProperties();
diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc
index 46096d2..4b6b5af 100644
--- a/cc/output/output_surface.cc
+++ b/cc/output/output_surface.cc
@@ -104,12 +104,13 @@
   external_stencil_test_enabled_ = enabled;
 }
 
-void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform,
-                                               const gfx::Rect& viewport,
-                                               const gfx::Rect& clip,
-                                               bool valid_for_tile_management) {
+void OutputSurface::SetExternalDrawConstraints(
+    const gfx::Transform& transform,
+    const gfx::Rect& viewport,
+    const gfx::Rect& clip,
+    bool resourceless_software_draw) {
   client_->SetExternalDrawConstraints(
-      transform, viewport, clip, valid_for_tile_management);
+      transform, viewport, clip, resourceless_software_draw);
 }
 
 OutputSurface::~OutputSurface() {
@@ -120,8 +121,6 @@
   return external_stencil_test_enabled_;
 }
 
-bool OutputSurface::ForcedDrawToSoftwareDevice() const { return false; }
-
 bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
   DCHECK(client);
   client_ = client;
diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h
index 98a4830..01fdd72 100644
--- a/cc/output/output_surface.h
+++ b/cc/output/output_surface.h
@@ -94,11 +94,6 @@
     return software_device_.get();
   }
 
-  // In the case where both the context3d and software_device are present
-  // (namely Android WebView), this is called to determine whether the software
-  // device should be used on the current frame.
-  virtual bool ForcedDrawToSoftwareDevice() const;
-
   // Called by the compositor on the compositor thread. This is a place where
   // thread-specific data for the output surface can be initialized, since from
   // this point on the output surface will only be used on the compositor
@@ -175,7 +170,7 @@
   void SetExternalDrawConstraints(const gfx::Transform& transform,
                                   const gfx::Rect& viewport,
                                   const gfx::Rect& clip,
-                                  bool valid_for_tile_management);
+                                  bool resourceless_software_draw);
 
  private:
   void SetUpContext3d();
diff --git a/cc/output/output_surface_client.h b/cc/output/output_surface_client.h
index 9742a6f..2c6c128 100644
--- a/cc/output/output_surface_client.h
+++ b/cc/output/output_surface_client.h
@@ -41,7 +41,7 @@
   virtual void SetExternalDrawConstraints(const gfx::Transform& transform,
                                           const gfx::Rect& viewport,
                                           const gfx::Rect& clip,
-                                          bool valid_for_tile_management) = 0;
+                                          bool resourceless_software_draw) = 0;
   virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;
   // If set, |callback| will be called subsequent to each new tree activation,
   // regardless of the compositor visibility or damage. |callback| must remain
diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc
index 61b3253..2897a0c 100644
--- a/cc/output/software_renderer.cc
+++ b/cc/output/software_renderer.cc
@@ -472,7 +472,9 @@
 
 void SoftwareRenderer::DrawTileQuad(const DrawingFrame* frame,
                                     const TileDrawQuad* quad) {
-  DCHECK(!output_surface_->ForcedDrawToSoftwareDevice());
+  // |resource_provider_| can be NULL in resourceless software draws, which
+  // should never produce tile quads in the first place.
+  DCHECK(resource_provider_);
   DCHECK(IsSoftwareResource(quad->resource_id));
 
   ResourceProvider::ScopedReadLockSoftware lock(resource_provider_,
diff --git a/cc/surfaces/display.h b/cc/surfaces/display.h
index 191b28d..673178b 100644
--- a/cc/surfaces/display.h
+++ b/cc/surfaces/display.h
@@ -57,7 +57,7 @@
       const gfx::Transform& transform,
       const gfx::Rect& viewport,
       const gfx::Rect& clip,
-      bool valid_for_tile_management) OVERRIDE {}
+      bool resourceless_software_draw) OVERRIDE {}
   virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {}
   virtual void SetTreeActivationCallback(
       const base::Closure& callback) OVERRIDE {}
diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc
index 3346b56..9c027ea 100644
--- a/cc/test/fake_output_surface.cc
+++ b/cc/test/fake_output_surface.cc
@@ -21,7 +21,6 @@
       client_(NULL),
       num_sent_frames_(0),
       needs_begin_frame_(false),
-      forced_draw_to_software_device_(false),
       has_external_stencil_test_(false),
       fake_weak_ptr_factory_(this) {
   if (delegated_rendering) {
@@ -36,7 +35,6 @@
     : OutputSurface(software_device.Pass()),
       client_(NULL),
       num_sent_frames_(0),
-      forced_draw_to_software_device_(false),
       has_external_stencil_test_(false),
       fake_weak_ptr_factory_(this) {
   if (delegated_rendering) {
@@ -52,7 +50,6 @@
     : OutputSurface(context_provider, software_device.Pass()),
       client_(NULL),
       num_sent_frames_(0),
-      forced_draw_to_software_device_(false),
       has_external_stencil_test_(false),
       fake_weak_ptr_factory_(this) {
   if (delegated_rendering) {
@@ -103,10 +100,6 @@
 }
 
 
-bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const {
-  return forced_draw_to_software_device_;
-}
-
 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) {
   if (OutputSurface::BindToClient(client)) {
     client_ = client;
diff --git a/cc/test/fake_output_surface.h b/cc/test/fake_output_surface.h
index f8acc1d..4fd0d72 100644
--- a/cc/test/fake_output_surface.h
+++ b/cc/test/fake_output_surface.h
@@ -97,11 +97,6 @@
   virtual void SetNeedsBeginFrame(bool enable) OVERRIDE;
   bool needs_begin_frame() const { return needs_begin_frame_; }
 
-  void set_forced_draw_to_software_device(bool forced) {
-    forced_draw_to_software_device_ = forced;
-  }
-  virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE;
-
   virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE;
 
   using OutputSurface::ReleaseGL;
@@ -144,7 +139,6 @@
   CompositorFrame last_sent_frame_;
   size_t num_sent_frames_;
   bool needs_begin_frame_;
-  bool forced_draw_to_software_device_;
   bool has_external_stencil_test_;
   TransferableResourceArray resources_held_by_parent_;
   base::WeakPtrFactory<FakeOutputSurface> fake_weak_ptr_factory_;
diff --git a/cc/test/fake_output_surface_client.h b/cc/test/fake_output_surface_client.h
index 7058e52..5e887b8 100644
--- a/cc/test/fake_output_surface_client.h
+++ b/cc/test/fake_output_surface_client.h
@@ -42,7 +42,7 @@
       const gfx::Transform& transform,
       const gfx::Rect& viewport,
       const gfx::Rect& clip,
-      bool valid_for_tile_management) OVERRIDE {}
+      bool resourceless_software_draw) OVERRIDE {}
   virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE;
   virtual void SetTreeActivationCallback(const base::Closure&) OVERRIDE {}
 
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc
index 0e5f50b..f85cac3 100644
--- a/cc/test/layer_tree_pixel_test.cc
+++ b/cc/test/layer_tree_pixel_test.cc
@@ -75,7 +75,9 @@
   EXPECT_EQ(gfx::Point().ToString(), viewport.origin().ToString());
   // Be that influence!
   viewport += gfx::Vector2d(20, 10);
-  impl->SetExternalDrawConstraints(gfx::Transform(), viewport, viewport, true);
+  bool resourceless_software_draw = false;
+  impl->SetExternalDrawConstraints(
+      gfx::Transform(), viewport, viewport, resourceless_software_draw);
   EXPECT_EQ(viewport.ToString(), impl->DeviceViewport().ToString());
 }
 
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index bb7ceec..e06cadf 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -245,7 +245,7 @@
       device_scale_factor_(1.f),
       overhang_ui_resource_id_(0),
       overdraw_bottom_height_(0.f),
-      device_viewport_valid_for_tile_management_(true),
+      resourceless_software_draw_(false),
       begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()),
       animation_registrar_(AnimationRegistrar::Create()),
       rendering_stats_instrumentation_(rendering_stats_instrumentation),
@@ -553,17 +553,17 @@
   render_passes.push_back(render_pass.Pass());
 }
 
-static DrawMode GetDrawMode(OutputSurface* output_surface) {
-  if (output_surface->ForcedDrawToSoftwareDevice()) {
+DrawMode LayerTreeHostImpl::GetDrawMode() const {
+  if (resourceless_software_draw_) {
     return DRAW_MODE_RESOURCELESS_SOFTWARE;
-  } else if (output_surface->context_provider()) {
+  } else if (output_surface_->context_provider()) {
     return DRAW_MODE_HARDWARE;
   } else {
-    DCHECK_EQ(!output_surface->software_device(),
-              output_surface->capabilities().delegated_rendering &&
-                  !output_surface->capabilities().deferred_gl_initialization)
-        << output_surface->capabilities().delegated_rendering << " "
-        << output_surface->capabilities().deferred_gl_initialization;
+    DCHECK_EQ(!output_surface_->software_device(),
+              output_surface_->capabilities().delegated_rendering &&
+                  !output_surface_->capabilities().deferred_gl_initialization)
+        << output_surface_->capabilities().delegated_rendering << " "
+        << output_surface_->capabilities().deferred_gl_initialization;
     return DRAW_MODE_SOFTWARE;
   }
 }
@@ -784,7 +784,7 @@
 
   int layers_drawn = 0;
 
-  const DrawMode draw_mode = GetDrawMode(output_surface_.get());
+  const DrawMode draw_mode = GetDrawMode();
 
   LayerIteratorType end =
       LayerIteratorType::End(frame->render_surface_layer_list);
@@ -921,8 +921,9 @@
   DCHECK(!frame->render_passes.empty());
 
   // Should only have one render pass in resourceless software mode.
-  if (output_surface_->ForcedDrawToSoftwareDevice())
-    DCHECK_EQ(1u, frame->render_passes.size());
+  DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE ||
+         frame->render_passes.size() == 1u)
+      << frame->render_passes.size();
 
   return draw_result;
 }
@@ -1311,15 +1312,16 @@
     const gfx::Transform& transform,
     const gfx::Rect& viewport,
     const gfx::Rect& clip,
-    bool valid_for_tile_management) {
-  if (external_transform_ != transform || external_viewport_ != viewport) {
+    bool resourceless_software_draw) {
+  if (external_transform_ != transform || external_viewport_ != viewport ||
+      resourceless_software_draw_ != resourceless_software_draw) {
     active_tree_->set_needs_update_draw_properties();
   }
 
   external_transform_ = transform;
   external_viewport_ = viewport;
   external_clip_ = clip;
-  device_viewport_valid_for_tile_management_ = valid_for_tile_management;
+  resourceless_software_draw_ = resourceless_software_draw;
 }
 
 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) {
@@ -1456,16 +1458,18 @@
       id_,
       TracedValue::FromValue(AsValueWithFrame(frame).release()));
 
+  const DrawMode draw_mode = GetDrawMode();
+
   // Because the contents of the HUD depend on everything else in the frame, the
   // contents of its texture are updated as the last thing before the frame is
   // drawn.
   if (active_tree_->hud_layer()) {
     TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture");
-    active_tree_->hud_layer()->UpdateHudTexture(
-        GetDrawMode(output_surface_.get()), resource_provider_.get());
+    active_tree_->hud_layer()->UpdateHudTexture(draw_mode,
+                                                resource_provider_.get());
   }
 
-  if (output_surface_->ForcedDrawToSoftwareDevice()) {
+  if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) {
     bool disable_picture_quad_image_filtering =
         IsCurrentlyScrolling() || needs_animate_layers();
 
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index fe9afc2..f53001a 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -213,9 +213,7 @@
   // Resets all of the trees to an empty state.
   void ResetTreesForTesting();
 
-  bool device_viewport_valid_for_tile_management() const {
-    return device_viewport_valid_for_tile_management_;
-  }
+  DrawMode GetDrawMode() const;
 
   // Viewport size in draw space: this size is in physical pixels and is used
   // for draw properties, tilings, quads and render passes.
@@ -252,7 +250,7 @@
       const gfx::Transform& transform,
       const gfx::Rect& viewport,
       const gfx::Rect& clip,
-      bool valid_for_tile_management) OVERRIDE;
+      bool resourceless_software_draw) OVERRIDE;
   virtual void DidLoseOutputSurface() OVERRIDE;
   virtual void DidSwapBuffers() OVERRIDE;
   virtual void DidSwapBuffersComplete() OVERRIDE;
@@ -661,7 +659,7 @@
   gfx::Transform external_transform_;
   gfx::Rect external_viewport_;
   gfx::Rect external_clip_;
-  bool device_viewport_valid_for_tile_management_;
+  bool resourceless_software_draw_;
 
   gfx::Rect viewport_damage_rect_;
 
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 9ada402..4a132cd 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -5565,8 +5565,14 @@
 
   SetupScrollAndContentsLayers(gfx::Size(100, 100));
 
-  output_surface->set_forced_draw_to_software_device(true);
-  EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice());
+  const gfx::Transform external_transform;
+  const gfx::Rect external_viewport;
+  const gfx::Rect external_clip;
+  const bool resourceless_software_draw = true;
+  host_impl_->SetExternalDrawConstraints(external_transform,
+                                         external_viewport,
+                                         external_clip,
+                                         resourceless_software_draw);
 
   EXPECT_EQ(0, software_device->frames_began_);
   EXPECT_EQ(0, software_device->frames_ended_);
@@ -5592,8 +5598,14 @@
   EXPECT_TRUE(CreateHostImpl(DefaultSettings(),
                              scoped_ptr<OutputSurface>(output_surface)));
 
-  output_surface->set_forced_draw_to_software_device(true);
-  EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice());
+  const gfx::Transform external_transform;
+  const gfx::Rect external_viewport;
+  const gfx::Rect external_clip;
+  const bool resourceless_software_draw = true;
+  host_impl_->SetExternalDrawConstraints(external_transform,
+                                         external_viewport,
+                                         external_clip,
+                                         resourceless_software_draw);
 
   // SolidColorLayerImpl will be drawn.
   scoped_ptr<SolidColorLayerImpl> root_layer =
@@ -6578,13 +6590,13 @@
   gfx::Transform external_transform;
   const gfx::Rect external_viewport(layer_size);
   const gfx::Rect external_clip(layer_size);
-  const bool valid_for_tile_management = true;
+  const bool resourceless_software_draw = false;
   LayerImpl* layer = SetupScrollAndContentsLayers(layer_size);
 
   host_impl_->SetExternalDrawConstraints(external_transform,
                                          external_viewport,
                                          external_clip,
-                                         valid_for_tile_management);
+                                         resourceless_software_draw);
   DrawFrame();
   EXPECT_TRANSFORMATION_MATRIX_EQ(
       external_transform, layer->draw_properties().target_space_transform);
@@ -6593,7 +6605,7 @@
   host_impl_->SetExternalDrawConstraints(external_transform,
                                          external_viewport,
                                          external_clip,
-                                         valid_for_tile_management);
+                                         resourceless_software_draw);
   DrawFrame();
   EXPECT_TRANSFORMATION_MATRIX_EQ(
       external_transform, layer->draw_properties().target_space_transform);
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index d5ec804..9327257 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -459,8 +459,7 @@
                  source_frame_number_);
     LayerImpl* page_scale_layer =
         page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer();
-    bool can_render_to_separate_surface =
-        !output_surface()->ForcedDrawToSoftwareDevice();
+    bool can_render_to_separate_surface = !resourceless_software_draw();
 
     ++render_surface_layer_list_id_;
     LayerTreeHostCommon::CalcDrawPropsImplInputs inputs(
@@ -659,8 +658,9 @@
   return layer_tree_host_impl_->memory_history();
 }
 
-bool LayerTreeImpl::device_viewport_valid_for_tile_management() const {
-  return layer_tree_host_impl_->device_viewport_valid_for_tile_management();
+bool LayerTreeImpl::resourceless_software_draw() const {
+  return layer_tree_host_impl_->GetDrawMode() ==
+         DRAW_MODE_RESOURCELESS_SOFTWARE;
 }
 
 gfx::Size LayerTreeImpl::device_viewport_size() const {
diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h
index 3b3c6cf..66d1f49 100644
--- a/cc/trees/layer_tree_impl.h
+++ b/cc/trees/layer_tree_impl.h
@@ -73,7 +73,7 @@
   FrameRateCounter* frame_rate_counter() const;
   PaintTimeCounter* paint_time_counter() const;
   MemoryHistory* memory_history() const;
-  bool device_viewport_valid_for_tile_management() const;
+  bool resourceless_software_draw() const;
   gfx::Size device_viewport_size() const;
   bool IsActiveTree() const;
   bool IsPendingTree() const;
diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.cc b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
index 041de4d..4e8ff8d 100644
--- a/content/browser/android/in_process/synchronous_compositor_output_surface.cc
+++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
@@ -95,14 +95,6 @@
     delegate->DidDestroySynchronousOutputSurface(this);
 }
 
-bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const {
-  // |current_sw_canvas_| indicates we're in a DemandDrawSw call. In addition
-  // |invoking_composite_| == false indicates an attempt to draw outside of
-  // the synchronous compositor's control: force it into SW path and hence to
-  // the null canvas (and will log a warning there).
-  return current_sw_canvas_ != NULL || !invoking_composite_;
-}
-
 bool SynchronousCompositorOutputSurface::BindToClient(
     cc::OutputSurfaceClient* surface_client) {
   DCHECK(CalledOnValidThread());
@@ -207,7 +199,7 @@
     const gfx::Transform& transform,
     gfx::Rect viewport,
     gfx::Rect clip,
-    bool valid_for_tile_management) {
+    bool hardware_draw) {
   DCHECK(!invoking_composite_);
   DCHECK(!frame_holder_.get());
   base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true);
@@ -215,20 +207,23 @@
   gfx::Transform adjusted_transform = transform;
   AdjustTransform(&adjusted_transform, viewport);
   SetExternalDrawConstraints(
-      adjusted_transform, viewport, clip, valid_for_tile_management);
+      adjusted_transform, viewport, clip, !hardware_draw);
   SetNeedsRedrawRect(gfx::Rect(viewport.size()));
   client_->BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor());
 
   // After software draws (which might move the viewport arbitrarily), restore
   // the previous hardware viewport to allow CC's tile manager to prioritize
   // properly.
-  if (valid_for_tile_management) {
+  if (hardware_draw) {
     cached_hw_transform_ = adjusted_transform;
     cached_hw_viewport_ = viewport;
     cached_hw_clip_ = clip;
   } else {
-    SetExternalDrawConstraints(
-        cached_hw_transform_, cached_hw_viewport_, cached_hw_clip_, true);
+    bool resourceless_software_draw = false;
+    SetExternalDrawConstraints(cached_hw_transform_,
+                               cached_hw_viewport_,
+                               cached_hw_clip_,
+                               resourceless_software_draw);
   }
 
   if (frame_holder_.get())
diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.h b/content/browser/android/in_process/synchronous_compositor_output_surface.h
index 3a456a4..2c04ed2 100644
--- a/content/browser/android/in_process/synchronous_compositor_output_surface.h
+++ b/content/browser/android/in_process/synchronous_compositor_output_surface.h
@@ -55,7 +55,6 @@
   virtual ~SynchronousCompositorOutputSurface();
 
   // OutputSurface.
-  virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE;
   virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) OVERRIDE;
   virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE;
   virtual void SetNeedsBeginFrame(bool enable) OVERRIDE;
@@ -80,7 +79,7 @@
   void InvokeComposite(const gfx::Transform& transform,
                        gfx::Rect viewport,
                        gfx::Rect clip,
-                       bool valid_for_tile_management);
+                       bool hardware_draw);
   bool CalledOnValidThread() const;
   SynchronousCompositorOutputSurfaceDelegate* GetDelegate();