| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/paint/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
| 6 | 6 |
| 7 #include "platform/graphics/GraphicsLayer.h" | 7 #include "platform/graphics/GraphicsLayer.h" |
| 8 #include "platform/graphics/paint/DrawingDisplayItem.h" | 8 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 9 #include "platform/instrumentation/tracing/TraceEvent.h" | 9 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 10 #include "platform/wtf/AutoReset.h" | 10 #include "platform/wtf/AutoReset.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 new_display_item_list_[index].AsDebugString().Utf8().data(), index); | 293 new_display_item_list_[index].AsDebugString().Utf8().data(), index); |
| 294 #endif | 294 #endif |
| 295 NOTREACHED(); | 295 NOTREACHED(); |
| 296 } | 296 } |
| 297 AddItemToIndexIfNeeded(display_item, new_display_item_list_.size() - 1, | 297 AddItemToIndexIfNeeded(display_item, new_display_item_list_.size() - 1, |
| 298 new_display_item_indices_by_client_); | 298 new_display_item_indices_by_client_); |
| 299 #endif // DCHECK_IS_ON() | 299 #endif // DCHECK_IS_ON() |
| 300 | 300 |
| 301 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) | 301 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) |
| 302 CheckUnderInvalidation(); | 302 CheckUnderInvalidation(); |
| 303 |
| 304 if (!frame_first_paints_.back().first_painted && display_item.IsDrawing() && |
| 305 // Here we ignore all document-background paintings because we don't |
| 306 // know if the background is default. ViewPainter should have called |
| 307 // setFirstPainted() if this display item is for non-default |
| 308 // background. |
| 309 display_item.GetType() != DisplayItem::kDocumentBackground && |
| 310 display_item.DrawsContent()) { |
| 311 SetFirstPainted(); |
| 312 } |
| 303 } | 313 } |
| 304 | 314 |
| 305 DisplayItem& PaintController::MoveItemFromCurrentListToNewList(size_t index) { | 315 DisplayItem& PaintController::MoveItemFromCurrentListToNewList(size_t index) { |
| 306 items_moved_into_new_list_.resize( | 316 items_moved_into_new_list_.resize( |
| 307 current_paint_artifact_.GetDisplayItemList().size()); | 317 current_paint_artifact_.GetDisplayItemList().size()); |
| 308 items_moved_into_new_list_[index] = new_display_item_list_.size(); | 318 items_moved_into_new_list_[index] = new_display_item_list_.size(); |
| 309 return new_display_item_list_.AppendByMoving( | 319 return new_display_item_list_.AppendByMoving( |
| 310 current_paint_artifact_.GetDisplayItemList()[index]); | 320 current_paint_artifact_.GetDisplayItemList()[index]); |
| 311 } | 321 } |
| 312 | 322 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 if (item.IsCacheable()) { | 595 if (item.IsCacheable()) { |
| 586 item.Client().SetDisplayItemsCached(current_cache_generation_); | 596 item.Client().SetDisplayItemsCached(current_cache_generation_); |
| 587 } else { | 597 } else { |
| 588 if (item.Client().IsJustCreated()) | 598 if (item.Client().IsJustCreated()) |
| 589 item.Client().ClearIsJustCreated(); | 599 item.Client().ClearIsJustCreated(); |
| 590 if (item.SkippedCache()) | 600 if (item.SkippedCache()) |
| 591 skipped_cache_clients.push_back(&item.Client()); | 601 skipped_cache_clients.push_back(&item.Client()); |
| 592 } | 602 } |
| 593 } | 603 } |
| 594 | 604 |
| 595 if (!first_painted_) { | |
| 596 for (const auto& item : new_display_item_list_) { | |
| 597 if (item.IsDrawing() && | |
| 598 // Here we ignore all document-background paintings because we don't | |
| 599 // know if the background is default. ViewPainter should have called | |
| 600 // setFirstPainted() if this display item is for non-default | |
| 601 // background. | |
| 602 item.GetType() != DisplayItem::kDocumentBackground && | |
| 603 item.DrawsContent()) { | |
| 604 first_painted_ = true; | |
| 605 break; | |
| 606 } | |
| 607 } | |
| 608 } | |
| 609 | |
| 610 for (auto* client : skipped_cache_clients) | 605 for (auto* client : skipped_cache_clients) |
| 611 client->SetDisplayItemsUncached(); | 606 client->SetDisplayItemsUncached(); |
| 612 | 607 |
| 613 // The new list will not be appended to again so we can release unused memory. | 608 // The new list will not be appended to again so we can release unused memory. |
| 614 new_display_item_list_.ShrinkToFit(); | 609 new_display_item_list_.ShrinkToFit(); |
| 615 | 610 |
| 616 if (raster_invalidation_tracking_info_) { | 611 if (raster_invalidation_tracking_info_) { |
| 617 for (const auto& chunk : current_paint_artifact_.PaintChunks()) | 612 for (const auto& chunk : current_paint_artifact_.PaintChunks()) |
| 618 raster_invalidation_tracking_info_->map.Remove(&chunk); | 613 raster_invalidation_tracking_info_->map.Remove(&chunk); |
| 619 } | 614 } |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 0, new_display_item_list_.size(), | 972 0, new_display_item_list_.size(), |
| 978 show_paint_records | 973 show_paint_records |
| 979 ? (DisplayItemList::JsonOptions::kShowPaintRecords | | 974 ? (DisplayItemList::JsonOptions::kShowPaintRecords | |
| 980 DisplayItemList::JsonOptions::kShowClientDebugName) | 975 DisplayItemList::JsonOptions::kShowClientDebugName) |
| 981 : DisplayItemList::JsonOptions::kShowClientDebugName) | 976 : DisplayItemList::JsonOptions::kShowClientDebugName) |
| 982 ->ToPrettyJSONString() | 977 ->ToPrettyJSONString() |
| 983 .Utf8() | 978 .Utf8() |
| 984 .data()); | 979 .data()); |
| 985 } | 980 } |
| 986 | 981 |
| 982 void PaintController::SetFirstPainted() { |
| 983 frame_first_paints_.back().first_painted = true; |
| 984 } |
| 985 |
| 986 void PaintController::SetTextPainted() { |
| 987 frame_first_paints_.back().text_painted = true; |
| 988 } |
| 989 |
| 990 void PaintController::SetImagePainted() { |
| 991 frame_first_paints_.back().image_painted = true; |
| 992 } |
| 993 |
| 994 void PaintController::BeginFrame(const void* frame) { |
| 995 frame_first_paints_.push_back(FrameFirstPaint(frame)); |
| 996 } |
| 997 |
| 998 FrameFirstPaint PaintController::EndFrame(const void* frame) { |
| 999 FrameFirstPaint result = frame_first_paints_.back(); |
| 1000 DCHECK(result.frame == frame); |
| 1001 frame_first_paints_.pop_back(); |
| 1002 return result; |
| 1003 } |
| 1004 |
| 987 } // namespace blink | 1005 } // namespace blink |
| OLD | NEW |