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

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

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 3 years, 12 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/tracing/TraceEvent.h" 9 #include "platform/tracing/TraceEvent.h"
10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h"
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 size_t PaintController::approximateUnsharedMemoryUsage() const { 565 size_t PaintController::approximateUnsharedMemoryUsage() const {
566 size_t memoryUsage = sizeof(*this); 566 size_t memoryUsage = sizeof(*this);
567 567
568 // Memory outside this class due to m_currentPaintArtifact. 568 // Memory outside this class due to m_currentPaintArtifact.
569 memoryUsage += m_currentPaintArtifact.approximateUnsharedMemoryUsage() - 569 memoryUsage += m_currentPaintArtifact.approximateUnsharedMemoryUsage() -
570 sizeof(m_currentPaintArtifact); 570 sizeof(m_currentPaintArtifact);
571 571
572 // TODO(jbroman): If display items begin to have significant external memory 572 // TODO(jbroman): If display items begin to have significant external memory
573 // usage that's not shared with the embedder, we should account for it here. 573 // usage that's not shared with the embedder, we should account for it here.
574 // 574 //
575 // External objects, shared with the embedder, such as SkPicture, should be 575 // External objects, shared with the embedder, such as CdlPicture, should be
576 // excluded to avoid double counting. It is the embedder's responsibility to 576 // excluded to avoid double counting. It is the embedder's responsibility to
577 // count such objects. 577 // count such objects.
578 // 578 //
579 // At time of writing, the only known case of unshared external memory was 579 // At time of writing, the only known case of unshared external memory was
580 // the rounded clips vector in ClipDisplayItem, which is not expected to 580 // the rounded clips vector in ClipDisplayItem, which is not expected to
581 // contribute significantly to memory usage. 581 // contribute significantly to memory usage.
582 582
583 // Memory outside this class due to m_newDisplayItemList. 583 // Memory outside this class due to m_newDisplayItemList.
584 DCHECK(m_newDisplayItemList.isEmpty()); 584 DCHECK(m_newDisplayItemList.isEmpty());
585 memoryUsage += m_newDisplayItemList.memoryUsageInBytes(); 585 memoryUsage += m_newDisplayItemList.memoryUsageInBytes();
586 586
587 return memoryUsage; 587 return memoryUsage;
588 } 588 }
589 589
590 void PaintController::appendDebugDrawingAfterCommit( 590 void PaintController::appendDebugDrawingAfterCommit(
591 const DisplayItemClient& displayItemClient, 591 const DisplayItemClient& displayItemClient,
592 sk_sp<SkPicture> picture, 592 sk_sp<CdlPicture> picture,
593 const LayoutSize& offsetFromLayoutObject) { 593 const LayoutSize& offsetFromLayoutObject) {
594 DCHECK(m_newDisplayItemList.isEmpty()); 594 DCHECK(m_newDisplayItemList.isEmpty());
595 DrawingDisplayItem& displayItem = 595 DrawingDisplayItem& displayItem =
596 m_currentPaintArtifact.getDisplayItemList() 596 m_currentPaintArtifact.getDisplayItemList()
597 .allocateAndConstruct<DrawingDisplayItem>(displayItemClient, 597 .allocateAndConstruct<DrawingDisplayItem>(displayItemClient,
598 DisplayItem::kDebugDrawing, 598 DisplayItem::kDebugDrawing,
599 std::move(picture)); 599 std::move(picture));
600 displayItem.setSkippedCache(); 600 displayItem.setSkippedCache();
601 // TODO(wkorman): Only compute and append visual rect for drawings. 601 // TODO(wkorman): Only compute and append visual rect for drawings.
602 m_currentPaintArtifact.getDisplayItemList().appendVisualRect( 602 m_currentPaintArtifact.getDisplayItemList().appendVisualRect(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 #ifndef NDEBUG 745 #ifndef NDEBUG
746 LOG(ERROR) << "New display item: " << newItem.asDebugString(); 746 LOG(ERROR) << "New display item: " << newItem.asDebugString();
747 LOG(ERROR) << "Old display item: " 747 LOG(ERROR) << "Old display item: "
748 << (oldItem ? oldItem->asDebugString() : "None"); 748 << (oldItem ? oldItem->asDebugString() : "None");
749 #else 749 #else
750 LOG(ERROR) << "Run debug build to get more details."; 750 LOG(ERROR) << "Run debug build to get more details.";
751 #endif 751 #endif
752 LOG(ERROR) << "See http://crbug.com/619103."; 752 LOG(ERROR) << "See http://crbug.com/619103.";
753 753
754 #ifndef NDEBUG 754 #ifndef NDEBUG
755 const SkPicture* newPicture = 755 const CdlPicture* newPicture =
756 newItem.isDrawing() 756 newItem.isDrawing()
757 ? static_cast<const DrawingDisplayItem&>(newItem).picture() 757 ? static_cast<const DrawingDisplayItem&>(newItem).picture()
758 : nullptr; 758 : nullptr;
759 const SkPicture* oldPicture = 759 const CdlPicture* oldPicture =
760 oldItem && oldItem->isDrawing() 760 oldItem && oldItem->isDrawing()
761 ? static_cast<const DrawingDisplayItem*>(oldItem)->picture() 761 ? static_cast<const DrawingDisplayItem*>(oldItem)->picture()
762 : nullptr; 762 : nullptr;
763 LOG(INFO) << "new picture:\n" 763 LOG(INFO) << "new picture:\n"
764 << (newPicture ? pictureAsDebugString(newPicture) : "None"); 764 << (newPicture ? pictureAsDebugString(newPicture) : "None");
765 LOG(INFO) << "old picture:\n" 765 LOG(INFO) << "old picture:\n"
766 << (oldPicture ? pictureAsDebugString(oldPicture) : "None"); 766 << (oldPicture ? pictureAsDebugString(oldPicture) : "None");
767 767
768 showDebugData(); 768 showDebugData();
769 #endif // NDEBUG 769 #endif // NDEBUG
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 stringBuilder.append( 855 stringBuilder.append(
856 String::format("clientDebugName: \"%s\"", 856 String::format("clientDebugName: \"%s\"",
857 displayItem.client().debugName().ascii().data())); 857 displayItem.client().debugName().ascii().data()));
858 #endif 858 #endif
859 stringBuilder.append(", cacheIsValid: "); 859 stringBuilder.append(", cacheIsValid: ");
860 stringBuilder.append( 860 stringBuilder.append(
861 clientCacheIsValid(displayItem.client()) ? "true" : "false"); 861 clientCacheIsValid(displayItem.client()) ? "true" : "false");
862 } 862 }
863 #ifndef NDEBUG 863 #ifndef NDEBUG
864 if (showPictures && displayItem.isDrawing()) { 864 if (showPictures && displayItem.isDrawing()) {
865 if (const SkPicture* picture = 865 if (const CdlPicture* picture =
866 static_cast<const DrawingDisplayItem&>(displayItem).picture()) { 866 static_cast<const DrawingDisplayItem&>(displayItem).picture()) {
867 stringBuilder.append(", picture: "); 867 stringBuilder.append(", picture: ");
868 stringBuilder.append(pictureAsDebugString(picture)); 868 stringBuilder.append(pictureAsDebugString(picture));
869 } 869 }
870 } 870 }
871 #endif 871 #endif
872 } 872 }
873 if (list.hasVisualRect(i)) { 873 if (list.hasVisualRect(i)) {
874 IntRect visualRect = list.visualRect(i); 874 IntRect visualRect = list.visualRect(i);
875 stringBuilder.append(String::format( 875 stringBuilder.append(String::format(
(...skipping 11 matching lines...) Expand all
887 m_currentPaintArtifact.getDisplayItemList(), showPictures) 887 m_currentPaintArtifact.getDisplayItemList(), showPictures)
888 .utf8() 888 .utf8()
889 .data()); 889 .data());
890 WTFLogAlways("new display item list: [%s]\n", 890 WTFLogAlways("new display item list: [%s]\n",
891 displayItemListAsDebugString(m_newDisplayItemList, showPictures) 891 displayItemListAsDebugString(m_newDisplayItemList, showPictures)
892 .utf8() 892 .utf8()
893 .data()); 893 .data());
894 } 894 }
895 895
896 } // namespace blink 896 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698