Surface Synchronization: Implement Fallback behavior

Introduced in https://codereview.chromium.org/2676373004/, a
CompositorFrame can refer to surface Ids that don't yet have
corresponding CompositorFrames. CompositorFrames with unresolved
dependencies are considered "pending" until they are activated. A
CompositorFrame can be activated if all its dependencies are resolved:
they all submit CompositorFrames which are themselves active or have
been activated.

A CompositorFrame may also be activated if a deadline hits. In that
case, the display compositor will attempt to process a CompositorFrame
with unresolved dependencies. This CL defines fallback behavior in the
event there are unresolved dependencies during surface aggregation
(producing a display frame). A SurfaceLayer has a primary and fallback
SurfaceInfo. That translates, ultimately, into a primary and fallback
SurfaceDrawQuad which is shipped over IPC.

SurfaceAggregator attempts to resolve the primary, and if it fails, it
uses the fallback. If the primary resolves, then SurfaceAggregator
ignores the fallback.

BUG=672962
[email protected], [email protected], [email protected], [email protected]
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2690853007
Cr-Commit-Position: refs/heads/master@{#450794}
diff --git a/cc/layers/surface_layer_impl.h b/cc/layers/surface_layer_impl.h
index 22798cd..a8523cdc 100644
--- a/cc/layers/surface_layer_impl.h
+++ b/cc/layers/surface_layer_impl.h
@@ -11,6 +11,7 @@
 #include "base/memory/ptr_util.h"
 #include "cc/base/cc_export.h"
 #include "cc/layers/layer_impl.h"
+#include "cc/quads/surface_draw_quad.h"
 #include "cc/surfaces/surface_id.h"
 #include "cc/surfaces/surface_info.h"
 
@@ -24,8 +25,16 @@
   }
   ~SurfaceLayerImpl() override;
 
-  void SetSurfaceInfo(const SurfaceInfo& surface_info);
-  const SurfaceInfo& surface_info() const { return surface_info_; }
+  void SetPrimarySurfaceInfo(const SurfaceInfo& surface_info);
+  const SurfaceInfo& primary_surface_info() const {
+    return primary_surface_info_;
+  }
+
+  void SetFallbackSurfaceInfo(const SurfaceInfo& surface_info);
+  const SurfaceInfo& fallback_surface_info() const {
+    return fallback_surface_info_;
+  }
+
   void SetStretchContentToFillBounds(bool stretch_content);
 
   // LayerImpl overrides.
@@ -38,12 +47,19 @@
   SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id);
 
  private:
+  SurfaceDrawQuad* CreateSurfaceDrawQuad(
+      RenderPass* render_pass,
+      SurfaceDrawQuadType surface_draw_quad_type,
+      const SurfaceInfo& surface_info);
+
   void GetDebugBorderProperties(SkColor* color, float* width) const override;
   void AppendRainbowDebugBorder(RenderPass* render_pass);
   void AsValueInto(base::trace_event::TracedValue* dict) const override;
   const char* LayerTypeAsString() const override;
 
-  SurfaceInfo surface_info_;
+  SurfaceInfo primary_surface_info_;
+  SurfaceInfo fallback_surface_info_;
+
   bool stretch_content_to_fill_bounds_ = false;
 
   DISALLOW_COPY_AND_ASSIGN(SurfaceLayerImpl);