Commit 4cbf5c87 authored by vmpstr's avatar vmpstr Committed by Commit bot

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}
parent 5d98fe24
......@@ -146,7 +146,7 @@ void RecordingSource::DetermineIfSolidColor() {
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);
......
......@@ -26,7 +26,7 @@ class CC_PAINT_EXPORT ClipDisplayItem : public DisplayItem {
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 @@ class CC_PAINT_EXPORT EndClipDisplayItem : public DisplayItem {
EndClipDisplayItem();
~EndClipDisplayItem() override;
int ApproximateOpCount() const { return 0; }
int OpCount() const { return 0; }
};
} // namespace cc
......
......@@ -23,7 +23,7 @@ class CC_PAINT_EXPORT ClipPathDisplayItem : public DisplayItem {
// 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 @@ class CC_PAINT_EXPORT EndClipPathDisplayItem : public DisplayItem {
EndClipPathDisplayItem();
~EndClipPathDisplayItem() override;
int ApproximateOpCount() const { return 0; }
int OpCount() const { return 0; }
};
} // namespace cc
......
......@@ -29,7 +29,7 @@ class CC_PAINT_EXPORT CompositingDisplayItem : public DisplayItem {
// 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 @@ class CC_PAINT_EXPORT EndCompositingDisplayItem : public DisplayItem {
EndCompositingDisplayItem();
~EndCompositingDisplayItem() override;
int ApproximateOpCount() const { return 0; }
int OpCount() const { return 0; }
};
} // namespace cc
......
......@@ -179,7 +179,7 @@ static bool MergeAndDrawIfPossible(const CompositingDisplayItem& save_item,
// 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 @@ bool DisplayItemList::IsSuitableForGpuRasterization() const {
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 @@ size_t DisplayItemList::ApproximateMemoryUsage() const {
}
bool DisplayItemList::ShouldBeAnalyzedForSolidColor() const {
return ApproximateOpCount() <= kOpCountThatIsOkToAnalyze;
return OpCount() <= kOpCountThatIsOkToAnalyze;
}
void DisplayItemList::EmitTraceSnapshot() const {
......
......@@ -130,7 +130,7 @@ class CC_PAINT_EXPORT DisplayItemList
}
bool IsSuitableForGpuRasterization() const;
int ApproximateOpCount() const;
size_t OpCount() const;
size_t ApproximateMemoryUsage() const;
bool ShouldBeAnalyzedForSolidColor() const;
......@@ -183,7 +183,7 @@ class CC_PAINT_EXPORT DisplayItemList
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 @@ class CC_PAINT_EXPORT DisplayItemList
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().
......
......@@ -344,7 +344,7 @@ TEST(DisplayItemListTest, ApproximateMemoryUsage) {
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 @@ TEST(DisplayItemListTest, SaveDrawRestoreFail_TooManyOps) {
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);
......
......@@ -19,12 +19,12 @@ DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item)
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
......@@ -22,7 +22,7 @@ class CC_PAINT_EXPORT DrawingDisplayItem : public DisplayItem {
~DrawingDisplayItem() override;
size_t ExternalMemoryUsage() const;
int ApproximateOpCount() const;
size_t OpCount() const;
const sk_sp<const PaintRecord> picture;
};
......
......@@ -25,7 +25,7 @@ class CC_PAINT_EXPORT FilterDisplayItem : public DisplayItem {
// 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 @@ class CC_PAINT_EXPORT EndFilterDisplayItem : public DisplayItem {
EndFilterDisplayItem();
~EndFilterDisplayItem() override;
int ApproximateOpCount() const { return 0; }
int OpCount() const { return 0; }
};
} // namespace cc
......
......@@ -19,7 +19,7 @@ class CC_PAINT_EXPORT FloatClipDisplayItem : public DisplayItem {
~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 @@ class CC_PAINT_EXPORT EndFloatClipDisplayItem : public DisplayItem {
EndFloatClipDisplayItem();
~EndFloatClipDisplayItem() override;
int ApproximateOpCount() const { return 0; }
int OpCount() const { return 0; }
};
} // namespace cc
......
......@@ -112,7 +112,7 @@ struct Rasterizer<DrawRecordOp, false> {
// 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(sk_sp<const PaintRecord> record)
DrawRecordOp::~DrawRecordOp() = default;
size_t DrawRecordOp::AdditionalBytesUsed() const {
return record->approximateBytesUsed();
return record->bytes_used();
}
bool DrawRecordOp::HasDiscardableImages() const {
......
......@@ -780,9 +780,11 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt {
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 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt {
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 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt {
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 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt {
// 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 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt {
}
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 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt {
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;
......
......@@ -25,13 +25,13 @@ namespace cc {
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 @@ TEST(PaintOpBufferTest, SimpleAppend) {
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 @@ TEST(PaintOpBufferTest, FirstOpWithAndWithoutData) {
// 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 @@ TEST(PaintOpBufferTest, FirstOpWithAndWithoutData) {
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 @@ TEST(PaintOpBufferTest, FirstOpWithAndWithoutData) {
EXPECT_FALSE(iter);
buffer.Reset();
ASSERT_EQ(buffer.approximateOpCount(), 0);
ASSERT_EQ(buffer.size(), 0u);
CheckRefCnt(filter, 2);
}
......@@ -181,7 +181,7 @@ TEST(PaintOpBufferTest, PaintOpData) {
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 @@ TEST(PaintOpBufferTest, SaveDrawRestore_SingleOpRecordWithSingleOp) {
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_SingleOpRecordWithSingleOp) {
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;
......
......@@ -19,7 +19,7 @@ class CC_PAINT_EXPORT TransformDisplayItem : public DisplayItem {
~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 @@ class CC_PAINT_EXPORT EndTransformDisplayItem : public DisplayItem {
EndTransformDisplayItem();
~EndTransformDisplayItem() override;
int ApproximateOpCount() const { return 0; }
int OpCount() const { return 0; }
};
} // namespace cc
......
......@@ -48,7 +48,7 @@ void DrawingDisplayItem::DumpPropertiesAsDebugString(
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==
......
......@@ -23,8 +23,7 @@ class PLATFORM_EXPORT DrawingDisplayItem final : public DisplayItem {
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));
}
......
......@@ -94,8 +94,7 @@ DrawingRecorder::~DrawingRecorder() {
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment