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

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

Issue 2615813003: Migrate WTF::Vector::append() to ::push_back() [part 14 of N] (Closed)
Patch Set: rebase, small fix in FontSettings.h Created 3 years, 11 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 "third_party/skia/include/core/SkPictureAnalyzer.h" 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (!m_currentSubsequenceClients.isEmpty()) { 183 if (!m_currentSubsequenceClients.isEmpty()) {
184 // Mark the client shouldKeepAlive under the current subsequence. 184 // Mark the client shouldKeepAlive under the current subsequence.
185 // The status will end when the subsequence owner is invalidated or 185 // The status will end when the subsequence owner is invalidated or
186 // deleted. 186 // deleted.
187 displayItem.client().beginShouldKeepAlive( 187 displayItem.client().beginShouldKeepAlive(
188 m_currentSubsequenceClients.back()); 188 m_currentSubsequenceClients.back());
189 } 189 }
190 } 190 }
191 191
192 if (displayItem.getType() == DisplayItem::kSubsequence) { 192 if (displayItem.getType() == DisplayItem::kSubsequence) {
193 m_currentSubsequenceClients.append(&displayItem.client()); 193 m_currentSubsequenceClients.push_back(&displayItem.client());
194 } else if (displayItem.getType() == DisplayItem::kEndSubsequence) { 194 } else if (displayItem.getType() == DisplayItem::kEndSubsequence) {
195 CHECK(m_currentSubsequenceClients.back() == &displayItem.client()); 195 CHECK(m_currentSubsequenceClients.back() == &displayItem.client());
196 m_currentSubsequenceClients.pop_back(); 196 m_currentSubsequenceClients.pop_back();
197 } 197 }
198 } 198 }
199 #endif 199 #endif
200 200
201 if (isSkippingCache()) 201 if (isSkippingCache())
202 displayItem.setSkippedCache(); 202 displayItem.setSkippedCache();
203 203
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return; 309 return;
310 310
311 IndicesByClientMap::iterator it = 311 IndicesByClientMap::iterator it =
312 displayItemIndicesByClient.find(&displayItem.client()); 312 displayItemIndicesByClient.find(&displayItem.client());
313 Vector<size_t>& indices = 313 Vector<size_t>& indices =
314 it == displayItemIndicesByClient.end() 314 it == displayItemIndicesByClient.end()
315 ? displayItemIndicesByClient 315 ? displayItemIndicesByClient
316 .add(&displayItem.client(), Vector<size_t>()) 316 .add(&displayItem.client(), Vector<size_t>())
317 .storedValue->value 317 .storedValue->value
318 : it->value; 318 : it->value;
319 indices.append(index); 319 indices.push_back(index);
320 } 320 }
321 321
322 size_t PaintController::findCachedItem(const DisplayItem::Id& id) { 322 size_t PaintController::findCachedItem(const DisplayItem::Id& id) {
323 DCHECK(clientCacheIsValid(id.client)); 323 DCHECK(clientCacheIsValid(id.client));
324 324
325 // Try to find the item sequentially first. This is fast if the current list 325 // Try to find the item sequentially first. This is fast if the current list
326 // and the new list are in the same order around the new item. If found, we 326 // and the new list are in the same order around the new item. If found, we
327 // don't need to update and lookup the index. 327 // don't need to update and lookup the index.
328 for (size_t i = m_nextItemToMatch; 328 for (size_t i = m_nextItemToMatch;
329 i < m_currentPaintArtifact.getDisplayItemList().size(); ++i) { 329 i < m_currentPaintArtifact.getDisplayItemList().size(); ++i) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // TODO(wkorman): Only compute and append visual rect for drawings. 516 // TODO(wkorman): Only compute and append visual rect for drawings.
517 m_newDisplayItemList.appendVisualRect( 517 m_newDisplayItemList.appendVisualRect(
518 visualRectForDisplayItem(item, offsetFromLayoutObject)); 518 visualRectForDisplayItem(item, offsetFromLayoutObject));
519 519
520 if (item.isCacheable()) { 520 if (item.isCacheable()) {
521 item.client().setDisplayItemsCached(m_currentCacheGeneration); 521 item.client().setDisplayItemsCached(m_currentCacheGeneration);
522 } else { 522 } else {
523 if (item.client().isJustCreated()) 523 if (item.client().isJustCreated())
524 item.client().clearIsJustCreated(); 524 item.client().clearIsJustCreated();
525 if (item.skippedCache()) 525 if (item.skippedCache())
526 skippedCacheClients.append(&item.client()); 526 skippedCacheClients.push_back(&item.client());
527 } 527 }
528 } 528 }
529 529
530 for (auto* client : skippedCacheClients) 530 for (auto* client : skippedCacheClients)
531 client->setDisplayItemsUncached(); 531 client->setDisplayItemsUncached();
532 532
533 // The new list will not be appended to again so we can release unused memory. 533 // The new list will not be appended to again so we can release unused memory.
534 m_newDisplayItemList.shrinkToFit(); 534 m_newDisplayItemList.shrinkToFit();
535 m_currentPaintArtifact = PaintArtifact( 535 m_currentPaintArtifact = PaintArtifact(
536 std::move(m_newDisplayItemList), m_newPaintChunks.releasePaintChunks(), 536 std::move(m_newDisplayItemList), m_newPaintChunks.releasePaintChunks(),
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 627
628 // Add skipped old chunks into the index. 628 // Add skipped old chunks into the index.
629 if (oldChunk.id) { 629 if (oldChunk.id) {
630 auto it = m_outOfOrderChunkIndices.find(&oldChunk.id->client); 630 auto it = m_outOfOrderChunkIndices.find(&oldChunk.id->client);
631 Vector<size_t>& indices = 631 Vector<size_t>& indices =
632 it == m_outOfOrderChunkIndices.end() 632 it == m_outOfOrderChunkIndices.end()
633 ? m_outOfOrderChunkIndices 633 ? m_outOfOrderChunkIndices
634 .add(&oldChunk.id->client, Vector<size_t>()) 634 .add(&oldChunk.id->client, Vector<size_t>())
635 .storedValue->value 635 .storedValue->value
636 : it->value; 636 : it->value;
637 indices.append(m_nextChunkToMatch); 637 indices.push_back(m_nextChunkToMatch);
638 } 638 }
639 ++m_nextChunkToMatch; 639 ++m_nextChunkToMatch;
640 } 640 }
641 641
642 // Sequential matching reaches the end. Find from the out-of-order index. 642 // Sequential matching reaches the end. Find from the out-of-order index.
643 auto it = m_outOfOrderChunkIndices.find(&newChunk.id->client); 643 auto it = m_outOfOrderChunkIndices.find(&newChunk.id->client);
644 if (it != m_outOfOrderChunkIndices.end()) { 644 if (it != m_outOfOrderChunkIndices.end()) {
645 for (size_t i : it->value) { 645 for (size_t i : it->value) {
646 if (newChunk.matches(oldChunks[i])) { 646 if (newChunk.matches(oldChunks[i])) {
647 generateChunkRasterInvalidationRectsComparingOldChunk(newChunk, 647 generateChunkRasterInvalidationRectsComparingOldChunk(newChunk,
648 oldChunks[i]); 648 oldChunks[i]);
649 return; 649 return;
650 } 650 }
651 } 651 }
652 } 652 }
653 653
654 // We reach here because the chunk is new. 654 // We reach here because the chunk is new.
655 addRasterInvalidationInfo(nullptr, newChunk, infiniteFloatRect); 655 addRasterInvalidationInfo(nullptr, newChunk, infiniteFloatRect);
656 } 656 }
657 657
658 void PaintController::addRasterInvalidationInfo(const DisplayItemClient* client, 658 void PaintController::addRasterInvalidationInfo(const DisplayItemClient* client,
659 PaintChunk& chunk, 659 PaintChunk& chunk,
660 const FloatRect& rect) { 660 const FloatRect& rect) {
661 chunk.rasterInvalidationRects.append(rect); 661 chunk.rasterInvalidationRects.push_back(rect);
662 if (!m_paintChunksRasterInvalidationTrackingMap) 662 if (!m_paintChunksRasterInvalidationTrackingMap)
663 return; 663 return;
664 RasterInvalidationInfo info; 664 RasterInvalidationInfo info;
665 info.rect = enclosingIntRect(rect); 665 info.rect = enclosingIntRect(rect);
666 info.client = client; 666 info.client = client;
667 if (client) { 667 if (client) {
668 info.clientDebugName = client->debugName(); 668 info.clientDebugName = client->debugName();
669 info.reason = client->getPaintInvalidationReason(); 669 info.reason = client->getPaintInvalidationReason();
670 } 670 }
671 RasterInvalidationTracking& tracking = 671 RasterInvalidationTracking& tracking =
672 m_paintChunksRasterInvalidationTrackingMap->add(&chunk); 672 m_paintChunksRasterInvalidationTrackingMap->add(&chunk);
673 tracking.trackedRasterInvalidations.append(info); 673 tracking.trackedRasterInvalidations.push_back(info);
674 } 674 }
675 675
676 void PaintController::generateChunkRasterInvalidationRectsComparingOldChunk( 676 void PaintController::generateChunkRasterInvalidationRectsComparingOldChunk(
677 PaintChunk& newChunk, 677 PaintChunk& newChunk,
678 const PaintChunk& oldChunk) { 678 const PaintChunk& oldChunk) {
679 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 679 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
680 680
681 // TODO(wangxianzhu): Handle PaintInvalidationIncremental. 681 // TODO(wangxianzhu): Handle PaintInvalidationIncremental.
682 // TODO(wangxianzhu): Optimize paint offset change. 682 // TODO(wangxianzhu): Optimize paint offset change.
683 683
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 0, m_newDisplayItemList.size(), 846 0, m_newDisplayItemList.size(),
847 showPictures ? (DisplayItemList::JsonOptions::ShowPictures | 847 showPictures ? (DisplayItemList::JsonOptions::ShowPictures |
848 DisplayItemList::JsonOptions::ShowClientDebugName) 848 DisplayItemList::JsonOptions::ShowClientDebugName)
849 : DisplayItemList::JsonOptions::ShowClientDebugName) 849 : DisplayItemList::JsonOptions::ShowClientDebugName)
850 ->toPrettyJSONString() 850 ->toPrettyJSONString()
851 .utf8() 851 .utf8()
852 .data()); 852 .data());
853 } 853 }
854 854
855 } // namespace blink 855 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698