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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 new_display_item_list_[index].AsDebugString().Utf8().data(), index); | 278 new_display_item_list_[index].AsDebugString().Utf8().data(), index); |
279 #endif | 279 #endif |
280 NOTREACHED(); | 280 NOTREACHED(); |
281 } | 281 } |
282 AddItemToIndexIfNeeded(display_item, new_display_item_list_.size() - 1, | 282 AddItemToIndexIfNeeded(display_item, new_display_item_list_.size() - 1, |
283 new_display_item_indices_by_client_); | 283 new_display_item_indices_by_client_); |
284 #endif // DCHECK_IS_ON() | 284 #endif // DCHECK_IS_ON() |
285 | 285 |
286 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) | 286 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) |
287 CheckUnderInvalidation(); | 287 CheckUnderInvalidation(); |
288 | |
289 if (!frame_first_paints_.back().first_painted && display_item.IsDrawing() && | |
Xianzhu
2017/05/09 21:07:56
PaintController might paint something before Begin
Zhen Wang
2017/05/09 22:59:40
Done.
| |
290 // Here we ignore all document-background paintings because we don't | |
291 // know if the background is default. ViewPainter should have called | |
292 // setFirstPainted() if this display item is for non-default | |
293 // background. | |
294 display_item.GetType() != DisplayItem::kDocumentBackground && | |
295 display_item.DrawsContent()) { | |
296 SetFirstPainted(); | |
297 } | |
288 } | 298 } |
289 | 299 |
290 DisplayItem& PaintController::MoveItemFromCurrentListToNewList(size_t index) { | 300 DisplayItem& PaintController::MoveItemFromCurrentListToNewList(size_t index) { |
291 items_moved_into_new_list_.resize( | 301 items_moved_into_new_list_.resize( |
292 current_paint_artifact_.GetDisplayItemList().size()); | 302 current_paint_artifact_.GetDisplayItemList().size()); |
293 items_moved_into_new_list_[index] = new_display_item_list_.size(); | 303 items_moved_into_new_list_[index] = new_display_item_list_.size(); |
294 return new_display_item_list_.AppendByMoving( | 304 return new_display_item_list_.AppendByMoving( |
295 current_paint_artifact_.GetDisplayItemList()[index]); | 305 current_paint_artifact_.GetDisplayItemList()[index]); |
296 } | 306 } |
297 | 307 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 if (item.IsCacheable()) { | 580 if (item.IsCacheable()) { |
571 item.Client().SetDisplayItemsCached(current_cache_generation_); | 581 item.Client().SetDisplayItemsCached(current_cache_generation_); |
572 } else { | 582 } else { |
573 if (item.Client().IsJustCreated()) | 583 if (item.Client().IsJustCreated()) |
574 item.Client().ClearIsJustCreated(); | 584 item.Client().ClearIsJustCreated(); |
575 if (item.SkippedCache()) | 585 if (item.SkippedCache()) |
576 skipped_cache_clients.push_back(&item.Client()); | 586 skipped_cache_clients.push_back(&item.Client()); |
577 } | 587 } |
578 } | 588 } |
579 | 589 |
580 if (!first_painted_) { | |
581 for (const auto& item : new_display_item_list_) { | |
582 if (item.IsDrawing() && | |
583 // Here we ignore all document-background paintings because we don't | |
584 // know if the background is default. ViewPainter should have called | |
585 // setFirstPainted() if this display item is for non-default | |
586 // background. | |
587 item.GetType() != DisplayItem::kDocumentBackground && | |
588 item.DrawsContent()) { | |
589 first_painted_ = true; | |
590 break; | |
591 } | |
592 } | |
593 } | |
594 | |
595 for (auto* client : skipped_cache_clients) | 590 for (auto* client : skipped_cache_clients) |
596 client->SetDisplayItemsUncached(); | 591 client->SetDisplayItemsUncached(); |
597 | 592 |
598 // The new list will not be appended to again so we can release unused memory. | 593 // The new list will not be appended to again so we can release unused memory. |
599 new_display_item_list_.ShrinkToFit(); | 594 new_display_item_list_.ShrinkToFit(); |
600 current_paint_artifact_ = PaintArtifact( | 595 current_paint_artifact_ = PaintArtifact( |
601 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(), | 596 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(), |
602 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto); | 597 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto); |
603 ResetCurrentListIndices(); | 598 ResetCurrentListIndices(); |
604 out_of_order_item_indices_.clear(); | 599 out_of_order_item_indices_.clear(); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
937 0, new_display_item_list_.size(), | 932 0, new_display_item_list_.size(), |
938 show_paint_records | 933 show_paint_records |
939 ? (DisplayItemList::JsonOptions::kShowPaintRecords | | 934 ? (DisplayItemList::JsonOptions::kShowPaintRecords | |
940 DisplayItemList::JsonOptions::kShowClientDebugName) | 935 DisplayItemList::JsonOptions::kShowClientDebugName) |
941 : DisplayItemList::JsonOptions::kShowClientDebugName) | 936 : DisplayItemList::JsonOptions::kShowClientDebugName) |
942 ->ToPrettyJSONString() | 937 ->ToPrettyJSONString() |
943 .Utf8() | 938 .Utf8() |
944 .data()); | 939 .data()); |
945 } | 940 } |
946 | 941 |
942 void PaintController::SetFirstPainted() { | |
943 frame_first_paints_.back().first_painted = true; | |
944 } | |
945 | |
946 void PaintController::SetTextPainted() { | |
947 frame_first_paints_.back().text_painted = true; | |
948 } | |
949 | |
950 void PaintController::SetImagePainted() { | |
951 frame_first_paints_.back().image_painted = true; | |
952 } | |
953 | |
954 void PaintController::BeginFrame(const void* frame) { | |
955 frame_first_paints_.push_back(FrameFirstPaint(frame)); | |
956 } | |
957 | |
958 FrameFirstPaint PaintController::EndFrame(const void* frame) { | |
959 FrameFirstPaint result = frame_first_paints_.back(); | |
960 DCHECK(result.frame == frame); | |
961 frame_first_paints_.pop_back(); | |
962 return result; | |
963 } | |
964 | |
947 } // namespace blink | 965 } // namespace blink |
OLD | NEW |