cc: Renamed approximate{BytesUsed,OpCount} in paint op buffer.

This patch changes the names of functions as follows:
PaintOpBuffer::approximateBytesUsed -> bytes_used
PaintOpBuffer::approximateOpCount -> size

Also changes related functions in other classes where appropriate.
Also changes the return type of new size function to be size_t.

R=enne@chromium.org, danakj@chromium.org
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2884563004
Cr-Commit-Position: refs/heads/master@{#472259}
diff --git a/cc/layers/recording_source.cc b/cc/layers/recording_source.cc
index 78f31fbf..e3a477a 100644
--- a/cc/layers/recording_source.cc
+++ b/cc/layers/recording_source.cc
@@ -146,7 +146,7 @@
     return;
 
   TRACE_EVENT1("cc", "RecordingSource::DetermineIfSolidColor", "opcount",
-               display_list_->ApproximateOpCount());
+               display_list_->OpCount());
   gfx::Size layer_size = GetSize();
   skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height());
   display_list_->Raster(&canvas);
diff --git a/cc/paint/clip_display_item.h b/cc/paint/clip_display_item.h
index a969d48d..6a5bf0c 100644
--- a/cc/paint/clip_display_item.h
+++ b/cc/paint/clip_display_item.h
@@ -26,7 +26,7 @@
   size_t ExternalMemoryUsage() const {
     return rounded_clip_rects.capacity() * sizeof(rounded_clip_rects[0]);
   }
-  int ApproximateOpCount() const { return 1; }
+  int OpCount() const { return 1; }
 
   const gfx::Rect clip_rect;
   const std::vector<SkRRect> rounded_clip_rects;
@@ -38,7 +38,7 @@
   EndClipDisplayItem();
   ~EndClipDisplayItem() override;
 
-  int ApproximateOpCount() const { return 0; }
+  int OpCount() const { return 0; }
 };
 
 }  // namespace cc
diff --git a/cc/paint/clip_path_display_item.h b/cc/paint/clip_path_display_item.h
index 54de999..960697d 100644
--- a/cc/paint/clip_path_display_item.h
+++ b/cc/paint/clip_path_display_item.h
@@ -23,7 +23,7 @@
     // may well be shared anyway).
     return 0;
   }
-  int ApproximateOpCount() const { return 1; }
+  int OpCount() const { return 1; }
 
   const SkPath clip_path;
   const bool antialias;
@@ -34,7 +34,7 @@
   EndClipPathDisplayItem();
   ~EndClipPathDisplayItem() override;
 
-  int ApproximateOpCount() const { return 0; }
+  int OpCount() const { return 0; }
 };
 
 }  // namespace cc
diff --git a/cc/paint/compositing_display_item.h b/cc/paint/compositing_display_item.h
index 266ab4d..ba14de0 100644
--- a/cc/paint/compositing_display_item.h
+++ b/cc/paint/compositing_display_item.h
@@ -29,7 +29,7 @@
     // TODO(pdr): Include color_filter's memory here.
     return 0;
   }
-  int ApproximateOpCount() const { return 1; }
+  int OpCount() const { return 1; }
 
   const uint8_t alpha;
   const SkBlendMode xfermode;
@@ -44,7 +44,7 @@
   EndCompositingDisplayItem();
   ~EndCompositingDisplayItem() override;
 
-  int ApproximateOpCount() const { return 0; }
+  int OpCount() const { return 0; }
 };
 
 }  // namespace cc
diff --git a/cc/paint/display_item_list.cc b/cc/paint/display_item_list.cc
index 7844f1e..f783370 100644
--- a/cc/paint/display_item_list.cc
+++ b/cc/paint/display_item_list.cc
@@ -179,7 +179,7 @@
   // relevant here and that lcd text is preserved post merge, but I haven't
   // tested that.
   const PaintRecord* record = draw_item.picture.get();
-  if (record->approximateOpCount() != 1)
+  if (record->size() != 1u)
     return false;
 
   const PaintOp* op = record->GetFirstOp();
@@ -254,8 +254,8 @@
   return all_items_are_suitable_for_gpu_rasterization_;
 }
 
-int DisplayItemList::ApproximateOpCount() const {
-  return approximate_op_count_;
+size_t DisplayItemList::OpCount() const {
+  return op_count_;
 }
 
 size_t DisplayItemList::ApproximateMemoryUsage() const {
@@ -314,7 +314,7 @@
 }
 
 bool DisplayItemList::ShouldBeAnalyzedForSolidColor() const {
-  return ApproximateOpCount() <= kOpCountThatIsOkToAnalyze;
+  return OpCount() <= kOpCountThatIsOkToAnalyze;
 }
 
 void DisplayItemList::EmitTraceSnapshot() const {
diff --git a/cc/paint/display_item_list.h b/cc/paint/display_item_list.h
index d838a53..3a5b3f8 100644
--- a/cc/paint/display_item_list.h
+++ b/cc/paint/display_item_list.h
@@ -130,7 +130,7 @@
   }
   bool IsSuitableForGpuRasterization() const;
 
-  int ApproximateOpCount() const;
+  size_t OpCount() const;
   size_t ApproximateMemoryUsage() const;
   bool ShouldBeAnalyzedForSolidColor() const;
 
@@ -183,7 +183,7 @@
   const DisplayItemType& AllocateAndConstruct(Args&&... args) {
     auto* item = &items_.AllocateAndConstruct<DisplayItemType>(
         std::forward<Args>(args)...);
-    approximate_op_count_ += item->ApproximateOpCount();
+    op_count_ += item->OpCount();
     return *item;
   }
 
@@ -199,7 +199,7 @@
   std::vector<gfx::Rect> visual_rects_;
   std::vector<size_t> begin_item_indices_;
 
-  int approximate_op_count_ = 0;
+  size_t op_count_ = 0u;
   bool all_items_are_suitable_for_gpu_rasterization_ = true;
   // For testing purposes only. Whether to keep visual rects across calls to
   // Finalize().
diff --git a/cc/paint/display_item_list_unittest.cc b/cc/paint/display_item_list_unittest.cc
index 5197688..9e91c74 100644
--- a/cc/paint/display_item_list_unittest.cc
+++ b/cc/paint/display_item_list_unittest.cc
@@ -344,7 +344,7 @@
   for (int i = 0; i < kNumCommandsInTestSkPicture; i++)
     canvas->drawRect(SkRect(), blue_flags);
   sk_sp<PaintRecord> record = recorder.finishRecordingAsPicture();
-  size_t record_size = record->approximateBytesUsed();
+  size_t record_size = record->bytes_used();
   ASSERT_GE(record_size, kNumCommandsInTestSkPicture * sizeof(SkRect));
 
   auto list = make_scoped_refptr(new DisplayItemList);
@@ -804,7 +804,7 @@
     canvas->drawRect(gfx::RectToSkRect(kVisualRect), flags);
     record = recorder.finishRecordingAsPicture();
   }
-  EXPECT_GT(record->approximateOpCount(), 1);
+  EXPECT_GT(record->size(), 1u);
 
   auto list = make_scoped_refptr(new DisplayItemList);
 
diff --git a/cc/paint/drawing_display_item.cc b/cc/paint/drawing_display_item.cc
index 60b09ee..f8819c0 100644
--- a/cc/paint/drawing_display_item.cc
+++ b/cc/paint/drawing_display_item.cc
@@ -19,12 +19,12 @@
 DrawingDisplayItem::~DrawingDisplayItem() = default;
 
 size_t DrawingDisplayItem::ExternalMemoryUsage() const {
-  return picture->approximateBytesUsed();
+  return picture->bytes_used();
 }
 
 DISABLE_CFI_PERF
-int DrawingDisplayItem::ApproximateOpCount() const {
-  return picture->approximateOpCount();
+size_t DrawingDisplayItem::OpCount() const {
+  return picture->size();
 }
 
 }  // namespace cc
diff --git a/cc/paint/drawing_display_item.h b/cc/paint/drawing_display_item.h
index 56c7b17a..677d0b6 100644
--- a/cc/paint/drawing_display_item.h
+++ b/cc/paint/drawing_display_item.h
@@ -22,7 +22,7 @@
   ~DrawingDisplayItem() override;
 
   size_t ExternalMemoryUsage() const;
-  int ApproximateOpCount() const;
+  size_t OpCount() const;
 
   const sk_sp<const PaintRecord> picture;
 };
diff --git a/cc/paint/filter_display_item.h b/cc/paint/filter_display_item.h
index c4f18dcb..ad40ff9 100644
--- a/cc/paint/filter_display_item.h
+++ b/cc/paint/filter_display_item.h
@@ -25,7 +25,7 @@
     // enough.
     return filters.size() * sizeof(filters.at(0));
   }
-  int ApproximateOpCount() const { return 1; }
+  int OpCount() const { return 1; }
 
   const FilterOperations filters;
   const gfx::RectF bounds;
@@ -37,7 +37,7 @@
   EndFilterDisplayItem();
   ~EndFilterDisplayItem() override;
 
-  int ApproximateOpCount() const { return 0; }
+  int OpCount() const { return 0; }
 };
 
 }  // namespace cc
diff --git a/cc/paint/float_clip_display_item.h b/cc/paint/float_clip_display_item.h
index 43d751b36..b2703c8 100644
--- a/cc/paint/float_clip_display_item.h
+++ b/cc/paint/float_clip_display_item.h
@@ -19,7 +19,7 @@
   ~FloatClipDisplayItem() override;
 
   size_t ExternalMemoryUsage() const { return 0; }
-  int ApproximateOpCount() const { return 1; }
+  int OpCount() const { return 1; }
 
   const gfx::RectF clip_rect;
 };
@@ -29,7 +29,7 @@
   EndFloatClipDisplayItem();
   ~EndFloatClipDisplayItem() override;
 
-  int ApproximateOpCount() const { return 0; }
+  int OpCount() const { return 0; }
 };
 
 }  // namespace cc
diff --git a/cc/paint/paint_op_buffer.cc b/cc/paint/paint_op_buffer.cc
index a36139c..a4fad572 100644
--- a/cc/paint/paint_op_buffer.cc
+++ b/cc/paint/paint_op_buffer.cc
@@ -112,7 +112,7 @@
     // This "looking into records" optimization is done here instead of
     // in the PaintOpBuffer::Raster function as DisplayItemList calls
     // into RasterWithAlpha directly.
-    if (op->record->approximateOpCount() == 1) {
+    if (op->record->size() == 1u) {
       PaintOp* single_op = op->record->GetFirstOp();
       // RasterWithAlpha only supported for draw ops.
       if (single_op->IsDrawOp()) {
@@ -566,7 +566,7 @@
 DrawRecordOp::~DrawRecordOp() = default;
 
 size_t DrawRecordOp::AdditionalBytesUsed() const {
-  return record->approximateBytesUsed();
+  return record->bytes_used();
 }
 
 bool DrawRecordOp::HasDiscardableImages() const {
diff --git a/cc/paint/paint_op_buffer.h b/cc/paint/paint_op_buffer.h
index 9a1526a..e37c990 100644
--- a/cc/paint/paint_op_buffer.h
+++ b/cc/paint/paint_op_buffer.h
@@ -780,9 +780,11 @@
   void playback(SkCanvas* canvas) const;
   void playback(SkCanvas* canvas, SkPicture::AbortCallback* callback) const;
 
-  // TODO(enne): These are no longer approximate.  Rename these.
-  int approximateOpCount() const { return op_count_; }
-  size_t approximateBytesUsed() const {
+  // Returns the size of the paint op buffer. That is, the number of ops
+  // contained in it.
+  size_t size() const { return op_count_; }
+  // Returns the number of bytes used by the paint op buffer.
+  size_t bytes_used() const {
     return sizeof(*this) + reserved_ + subrecord_bytes_used_;
   }
   int numSlowPaths() const { return num_slow_paths_; }
@@ -873,7 +875,7 @@
     Iterator begin() { return Iterator(buffer_, buffer_->data_.get(), 0); }
     Iterator end() {
       return Iterator(buffer_, buffer_->data_.get() + buffer_->used_,
-                      buffer_->approximateOpCount());
+                      buffer_->size());
     }
     bool operator!=(const Iterator& other) {
       // Not valid to compare iterators on different buffers.
@@ -889,13 +891,13 @@
       ptr_ += op->skip;
       return *this;
     }
-    operator bool() const { return op_idx_ < buffer_->approximateOpCount(); }
+    operator bool() const { return op_idx_ < buffer_->size(); }
 
-    int op_idx() const { return op_idx_; }
+    size_t op_idx() const { return op_idx_; }
 
     // Return the next op without advancing the iterator, or nullptr if none.
     PaintOp* peek1() const {
-      if (op_idx_ + 1 >= buffer_->approximateOpCount())
+      if (op_idx_ + 1 >= buffer_->size())
         return nullptr;
       if (!op_idx_)
         return reinterpret_cast<PaintOp*>(ptr_);
@@ -905,7 +907,7 @@
     // Return the op two ops ahead without advancing the iterator, or nullptr if
     // none.
     PaintOp* peek2() const {
-      if (op_idx_ + 2 >= buffer_->approximateOpCount())
+      if (op_idx_ + 2 >= buffer_->size())
         return nullptr;
       char* next = ptr_ + reinterpret_cast<PaintOp*>(ptr_)->skip;
       PaintOp* next_op = reinterpret_cast<PaintOp*>(next);
@@ -915,12 +917,12 @@
     }
 
    private:
-    Iterator(const PaintOpBuffer* buffer, char* ptr, int op_idx)
+    Iterator(const PaintOpBuffer* buffer, char* ptr, size_t op_idx)
         : buffer_(buffer), ptr_(ptr), op_idx_(op_idx) {}
 
     const PaintOpBuffer* buffer_ = nullptr;
     char* ptr_ = nullptr;
-    int op_idx_ = 0;
+    size_t op_idx_ = 0;
   };
 
  private:
@@ -961,7 +963,7 @@
   std::unique_ptr<char, base::AlignedFreeDeleter> data_;
   size_t used_ = 0;
   size_t reserved_ = 0;
-  int op_count_ = 0;
+  size_t op_count_ = 0;
 
   // Record paths for veto-to-msaa for gpu raster.
   int num_slow_paths_ = 0;
diff --git a/cc/paint/paint_op_buffer_unittest.cc b/cc/paint/paint_op_buffer_unittest.cc
index 14f308c..a60bc76 100644
--- a/cc/paint/paint_op_buffer_unittest.cc
+++ b/cc/paint/paint_op_buffer_unittest.cc
@@ -25,13 +25,13 @@
 
 TEST(PaintOpBufferTest, Empty) {
   PaintOpBuffer buffer;
-  EXPECT_EQ(buffer.approximateOpCount(), 0);
-  EXPECT_EQ(buffer.approximateBytesUsed(), sizeof(PaintOpBuffer));
+  EXPECT_EQ(buffer.size(), 0u);
+  EXPECT_EQ(buffer.bytes_used(), sizeof(PaintOpBuffer));
   EXPECT_EQ(PaintOpBuffer::Iterator(&buffer), false);
 
   buffer.Reset();
-  EXPECT_EQ(buffer.approximateOpCount(), 0);
-  EXPECT_EQ(buffer.approximateBytesUsed(), sizeof(PaintOpBuffer));
+  EXPECT_EQ(buffer.size(), 0u);
+  EXPECT_EQ(buffer.bytes_used(), sizeof(PaintOpBuffer));
   EXPECT_EQ(PaintOpBuffer::Iterator(&buffer), false);
 }
 
@@ -49,7 +49,7 @@
   buffer.push<DrawColorOp>(draw_color, blend);
   buffer.push<RestoreOp>();
 
-  EXPECT_EQ(buffer.approximateOpCount(), 4);
+  EXPECT_EQ(buffer.size(), 4u);
 
   PaintOpBuffer::Iterator iter(&buffer);
   ASSERT_EQ(iter->GetType(), PaintOpType::SaveLayer);
@@ -94,7 +94,7 @@
   // Verify that when the first op has data, which may not fit in the
   // PaintRecord internal buffer, that it adds a noop as the first op
   // and then appends the "op with data" into the heap buffer.
-  ASSERT_EQ(buffer.approximateOpCount(), 2);
+  ASSERT_EQ(buffer.size(), 2u);
   EXPECT_EQ(buffer.GetFirstOp()->GetType(), PaintOpType::Noop);
 
   // Verify iteration behavior and brief smoke test of op state.
@@ -120,14 +120,14 @@
   buffer.Reset();
   CheckRefCnt(filter, 2);
 
-  ASSERT_EQ(buffer.approximateOpCount(), 0);
+  ASSERT_EQ(buffer.size(), 0u);
   EXPECT_EQ(PaintOpBuffer::Iterator(&buffer), false);
 
   SkRect rect = SkRect::MakeXYWH(1, 2, 3, 4);
   buffer.push<DrawRectOp>(rect, flags);
   CheckRefCnt(filter, 3);
 
-  ASSERT_EQ(buffer.approximateOpCount(), 1);
+  ASSERT_EQ(buffer.size(), 1u);
   EXPECT_EQ(buffer.GetFirstOp()->GetType(), PaintOpType::DrawRect);
 
   PaintOpBuffer::Iterator iter(&buffer);
@@ -139,7 +139,7 @@
   EXPECT_FALSE(iter);
 
   buffer.Reset();
-  ASSERT_EQ(buffer.approximateOpCount(), 0);
+  ASSERT_EQ(buffer.size(), 0u);
   CheckRefCnt(filter, 2);
 }
 
@@ -181,7 +181,7 @@
   char text2[] = "qwerty";
   buffer.push_with_data<DrawTextOp>(text2, arraysize(text2), 0.f, 0.f, flags);
 
-  ASSERT_EQ(buffer.approximateOpCount(), 3);
+  ASSERT_EQ(buffer.size(), 3u);
 
   // Verify iteration behavior and brief smoke test of op state.
   PaintOpBuffer::Iterator iter(&buffer);
@@ -376,7 +376,7 @@
   EXPECT_TRUE(draw_flags.SupportsFoldingAlpha());
   SkRect rect = SkRect::MakeXYWH(1, 2, 3, 4);
   record->push<DrawRectOp>(rect, draw_flags);
-  EXPECT_EQ(record->approximateOpCount(), 1);
+  EXPECT_EQ(record->size(), 1u);
 
   PaintOpBuffer buffer;
 
@@ -403,7 +403,7 @@
 TEST(PaintOpBufferTest, SaveDrawRestore_SingleOpRecordWithSingleNonDrawOp) {
   sk_sp<PaintRecord> record = sk_make_sp<PaintRecord>();
   record->push<NoopOp>();
-  EXPECT_EQ(record->approximateOpCount(), 1);
+  EXPECT_EQ(record->size(), 1u);
   EXPECT_FALSE(record->GetFirstOp()->IsDrawOp());
 
   PaintOpBuffer buffer;
diff --git a/cc/paint/transform_display_item.h b/cc/paint/transform_display_item.h
index a75db2a4..50c2358 100644
--- a/cc/paint/transform_display_item.h
+++ b/cc/paint/transform_display_item.h
@@ -19,7 +19,7 @@
   ~TransformDisplayItem() override;
 
   size_t ExternalMemoryUsage() const { return 0; }
-  int ApproximateOpCount() const { return 1; }
+  int OpCount() const { return 1; }
 
   const gfx::Transform transform;
 };
@@ -29,7 +29,7 @@
   EndTransformDisplayItem();
   ~EndTransformDisplayItem() override;
 
-  int ApproximateOpCount() const { return 0; }
+  int OpCount() const { return 0; }
 };
 
 }  // namespace cc
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DrawingDisplayItem.cpp b/third_party/WebKit/Source/platform/graphics/paint/DrawingDisplayItem.cpp
index 6a76f3be..55b511a 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/DrawingDisplayItem.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/DrawingDisplayItem.cpp
@@ -48,7 +48,7 @@
 
 static bool RecordsEqual(sk_sp<const PaintRecord> record1,
                          sk_sp<const PaintRecord> record2) {
-  if (record1->approximateOpCount() != record2->approximateOpCount())
+  if (record1->size() != record2->size())
     return false;
 
   // TODO(enne): PaintRecord should have an operator==
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DrawingDisplayItem.h b/third_party/WebKit/Source/platform/graphics/paint/DrawingDisplayItem.h
index 3dedbcbd..ccfb009 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/DrawingDisplayItem.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/DrawingDisplayItem.h
@@ -23,8 +23,7 @@
                      sk_sp<const PaintRecord> record,
                      bool known_to_be_opaque = false)
       : DisplayItem(client, type, sizeof(*this)),
-        record_(record && record->approximateOpCount() ? std::move(record)
-                                                       : nullptr),
+        record_(record && record->size() ? std::move(record) : nullptr),
         known_to_be_opaque_(known_to_be_opaque) {
     DCHECK(IsDrawingType(type));
   }
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DrawingRecorder.cpp b/third_party/WebKit/Source/platform/graphics/paint/DrawingRecorder.cpp
index 9e0a200..cfefdac 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/DrawingRecorder.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/DrawingRecorder.cpp
@@ -94,8 +94,7 @@
   if (!RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled() &&
       !context_.GetPaintController().IsForPaintRecordBuilder() &&
       display_item_client_.PaintedOutputOfObjectHasNoEffectRegardlessOfSize()) {
-    DCHECK_EQ(0, picture->approximateOpCount())
-        << display_item_client_.DebugName();
+    DCHECK_EQ(0u, picture->size()) << display_item_client_.DebugName();
   }
 #endif