Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1013)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp

Issue 2872793002: Notify paint for each frame (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 if (item.IsCacheable()) { 570 if (item.IsCacheable()) {
571 item.Client().SetDisplayItemsCached(current_cache_generation_); 571 item.Client().SetDisplayItemsCached(current_cache_generation_);
572 } else { 572 } else {
573 if (item.Client().IsJustCreated()) 573 if (item.Client().IsJustCreated())
574 item.Client().ClearIsJustCreated(); 574 item.Client().ClearIsJustCreated();
575 if (item.SkippedCache()) 575 if (item.SkippedCache())
576 skipped_cache_clients.push_back(&item.Client()); 576 skipped_cache_clients.push_back(&item.Client());
577 } 577 }
578 } 578 }
579 579
580 if (!first_painted_) { 580 if (!FirstPainted(current_frames_.back())) {
581 for (const auto& item : new_display_item_list_) { 581 for (const auto& item : new_display_item_list_) {
582 if (item.IsDrawing() && 582 if (item.IsDrawing() &&
583 // Here we ignore all document-background paintings because we don't 583 // Here we ignore all document-background paintings because we don't
584 // know if the background is default. ViewPainter should have called 584 // know if the background is default. ViewPainter should have called
585 // setFirstPainted() if this display item is for non-default 585 // setFirstPainted() if this display item is for non-default
586 // background. 586 // background.
587 item.GetType() != DisplayItem::kDocumentBackground && 587 item.GetType() != DisplayItem::kDocumentBackground &&
588 item.DrawsContent()) { 588 item.DrawsContent()) {
589 first_painted_ = true; 589 SetFirstPainted();
590 break; 590 break;
591 } 591 }
592 } 592 }
593 } 593 }
Xianzhu 2017/05/08 22:44:46 The above block should be moved into ProcessNewIte
Zhen Wang 2017/05/09 20:13:43 Done.
594 594
595 for (auto* client : skipped_cache_clients) 595 for (auto* client : skipped_cache_clients)
596 client->SetDisplayItemsUncached(); 596 client->SetDisplayItemsUncached();
597 597
598 // The new list will not be appended to again so we can release unused memory. 598 // The new list will not be appended to again so we can release unused memory.
599 new_display_item_list_.ShrinkToFit(); 599 new_display_item_list_.ShrinkToFit();
600 current_paint_artifact_ = PaintArtifact( 600 current_paint_artifact_ = PaintArtifact(
601 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(), 601 std::move(new_display_item_list_), new_paint_chunks_.ReleasePaintChunks(),
602 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto); 602 num_slow_paths <= kMaxNumberOfSlowPathsBeforeVeto);
603 ResetCurrentListIndices(); 603 ResetCurrentListIndices();
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 0, new_display_item_list_.size(), 937 0, new_display_item_list_.size(),
938 show_paint_records 938 show_paint_records
939 ? (DisplayItemList::JsonOptions::kShowPaintRecords | 939 ? (DisplayItemList::JsonOptions::kShowPaintRecords |
940 DisplayItemList::JsonOptions::kShowClientDebugName) 940 DisplayItemList::JsonOptions::kShowClientDebugName)
941 : DisplayItemList::JsonOptions::kShowClientDebugName) 941 : DisplayItemList::JsonOptions::kShowClientDebugName)
942 ->ToPrettyJSONString() 942 ->ToPrettyJSONString()
943 .Utf8() 943 .Utf8()
944 .data()); 944 .data());
945 } 945 }
946 946
947 bool PaintController::FirstPainted(const void* frame) const {
948 if (first_painted_.Contains(frame))
949 return first_painted_.at(frame);
950
951 return false;
952 }
953
954 void PaintController::SetFirstPainted() {
955 DCHECK(!current_frames_.IsEmpty());
956 first_painted_.Set(current_frames_.back(), true);
957 }
958
959 bool PaintController::TextPainted(const void* frame) const {
960 if (text_painted_.Contains(frame))
961 return text_painted_.at(frame);
962
963 return false;
964 }
965
966 void PaintController::SetTextPainted() {
967 DCHECK(!current_frames_.IsEmpty());
968 text_painted_.Set(current_frames_.back(), true);
969 }
970
971 bool PaintController::ImagePainted(const void* frame) const {
972 if (image_painted_.Contains(frame))
973 return image_painted_.at(frame);
974
975 return false;
976 }
977
978 void PaintController::SetImagePainted() {
979 DCHECK(!current_frames_.IsEmpty());
980 image_painted_.Set(current_frames_.back(), true);
981 }
982
983 void PaintController::BeginFrame(const void* frame) {
984 current_frames_.push_back(frame);
985 }
986
987 void PaintController::EndFrame(const void* frame) {
988 DCHECK(current_frames_.back() == frame);
989 current_frames_.pop_back();
990 }
991
947 } // namespace blink 992 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698