Introduce Tile Versions

BUG=155209


Review URL: https://chromiumcodereview.appspot.com/11364194

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167079 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/tile_priority.h b/cc/tile_priority.h
index 357fb9e..41c30acc 100644
--- a/cc/tile_priority.h
+++ b/cc/tile_priority.h
@@ -7,21 +7,23 @@
 
 #include "base/memory/ref_counted.h"
 #include "cc/picture_pile.h"
-#include "cc/tile_priority.h"
 #include "ui/gfx/rect.h"
 #include "ui/gfx/size.h"
 
 namespace cc {
 
 struct TilePriority {
+  // Set to true for tiles that should be favored during, for example,
+  // scrolls.
+  bool on_primary_tree;
+
   // A given layer may have multiple tilings, of differing quality.
   // would_be_drawn is set for the tiles that are visible that would be
   // drawn if they were chosen.
   bool would_be_drawn;
 
-  // Set to true for tiles that should be favored during, for example,
-  // scrolls.
-  bool on_primary_tree;
+  // We expect it to be useful soon.
+  bool nice_to_have;
 
   // Used to prefer tiles near to the viewport.
   float distance_to_viewport;
@@ -29,10 +31,46 @@
   // TODO(enne): some metric that penalizes blurriness.
 };
 
+enum TileMemoryLimitPolicy {
+  // Nothing.
+  ALLOW_NOTHING,
+
+  // Use as little as possible.
+  ALLOW_ONLY_REQUIRED, // On primary tree, would be drawn.
+
+  // Use as little as possible.
+  ALLOW_NICE_TO_HAVE, // On either tree, nice to have
+
+  // Use as much memory, up to memory size.
+  ALLOW_ANYTHING,
+};
+
+class GlobalStateThatImpactsTilePriority {
+public:
+  GlobalStateThatImpactsTilePriority()
+    : memory_limit_policy(ALLOW_NOTHING)
+    , memory_limit_in_bytes(0)
+    , smoothness_takes_priority(false)
+    , pending_tree_frame_number(-1)
+    , active_tree_frame_number(-1) {
+  }
+
+  TileMemoryLimitPolicy memory_limit_policy;
+
+  size_t memory_limit_in_bytes;
+
+  // Set when scrolling.
+  bool smoothness_takes_priority;
+
+  // Use -1 if no tree.
+  int pending_tree_frame_number;
+  int active_tree_frame_number;
+};
+
 class TilePriorityComparator {
  public:
-  TilePriorityComparator(bool currently_scrolling)
-   : currently_scrolling_(currently_scrolling) {}
+  TilePriorityComparator(GlobalStateThatImpactsTilePriority& global_state)
+   : global_state_(global_state) {}
 
   int compare(const TilePriority& a, const TilePriority& b) {
     // TODO(nduca,enne): Implement a comparator using the attributes here.
@@ -40,7 +78,7 @@
   }
 
  private:
-  bool currently_scrolling_;
+  GlobalStateThatImpactsTilePriority global_state_;
 };
 
 }  // namespace cc