Commit cbdbf10d authored by Liquan(Max) Gu's avatar Liquan(Max) Gu Committed by Commit Bot

[FCP++] Reduce one duplicate DidChangePerformanceTiming for image paint detector

Currently DidChangePerformanceTiming will be invoked twice if both largest-
and last-image candidate are detected. This Cl removes one invocation by using
a bool.

Bug: 869924
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I8342b268d67b4371522370fc2fc45fc8021a6ed9
Reviewed-on: https://chromium-review.googlesource.com/c/1293762
Commit-Queue: Liquan (Max) Gǔ <maxlg@chromium.org>
Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601656}
parent add0a11a
...@@ -87,9 +87,6 @@ IntRect ImagePaintTimingDetector::CalculateTransformedRect( ...@@ -87,9 +87,6 @@ IntRect ImagePaintTimingDetector::CalculateTransformedRect(
void ImagePaintTimingDetector::OnLargestImagePaintDetected( void ImagePaintTimingDetector::OnLargestImagePaintDetected(
const ImageRecord& largest_image_record) { const ImageRecord& largest_image_record) {
if (largest_image_record.first_paint_time_after_loaded ==
largest_image_paint_)
return;
largest_image_paint_ = largest_image_record.first_paint_time_after_loaded; largest_image_paint_ = largest_image_record.first_paint_time_after_loaded;
std::unique_ptr<TracedValue> value = TracedValue::Create(); std::unique_ptr<TracedValue> value = TracedValue::Create();
PopulateTraceValue(*value, largest_image_record, PopulateTraceValue(*value, largest_image_record,
...@@ -103,8 +100,6 @@ void ImagePaintTimingDetector::OnLargestImagePaintDetected( ...@@ -103,8 +100,6 @@ void ImagePaintTimingDetector::OnLargestImagePaintDetected(
void ImagePaintTimingDetector::OnLastImagePaintDetected( void ImagePaintTimingDetector::OnLastImagePaintDetected(
const ImageRecord& last_image_record) { const ImageRecord& last_image_record) {
if (last_image_record.first_paint_time_after_loaded == last_image_paint_)
return;
last_image_paint_ = last_image_record.first_paint_time_after_loaded; last_image_paint_ = last_image_record.first_paint_time_after_loaded;
std::unique_ptr<TracedValue> value = TracedValue::Create(); std::unique_ptr<TracedValue> value = TracedValue::Create();
PopulateTraceValue(*value, last_image_record, PopulateTraceValue(*value, last_image_record,
...@@ -117,18 +112,30 @@ void ImagePaintTimingDetector::OnLastImagePaintDetected( ...@@ -117,18 +112,30 @@ void ImagePaintTimingDetector::OnLastImagePaintDetected(
} }
void ImagePaintTimingDetector::Analyze() { void ImagePaintTimingDetector::Analyze() {
// These conditions represents the following scenarios:
// 1. candiate being nullptr: no loaded image is found.
// 2. candidate's first paint being null: largest/last image is still pending
// for timing. We discard the candidate and wait for the next analysis.
// 3. new candidate equals to old candidate: we don't need to update the
// result unless it's a new candidate.
ImageRecord* largest_image_record = FindLargestPaintCandidate(); ImageRecord* largest_image_record = FindLargestPaintCandidate();
// In cases where largest/last image is still pending for timing, we discard bool new_candidate_detected = false;
// the result and wait for the next analysis.
if (largest_image_record && if (largest_image_record &&
!largest_image_record->first_paint_time_after_loaded.is_null()) { !largest_image_record->first_paint_time_after_loaded.is_null() &&
largest_image_record->first_paint_time_after_loaded !=
largest_image_paint_) {
new_candidate_detected = true;
OnLargestImagePaintDetected(*largest_image_record); OnLargestImagePaintDetected(*largest_image_record);
} }
ImageRecord* last_image_record = FindLastPaintCandidate(); ImageRecord* last_image_record = FindLastPaintCandidate();
if (last_image_record && if (last_image_record &&
!last_image_record->first_paint_time_after_loaded.is_null()) { !last_image_record->first_paint_time_after_loaded.is_null() &&
last_image_record->first_paint_time_after_loaded != last_image_paint_) {
new_candidate_detected = true;
OnLastImagePaintDetected(*last_image_record); OnLastImagePaintDetected(*last_image_record);
} }
if (new_candidate_detected)
frame_view_->GetPaintTracker().DidChangePerformanceTiming();
} }
void ImagePaintTimingDetector::OnPrePaintFinished() { void ImagePaintTimingDetector::OnPrePaintFinished() {
......
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