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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp

Issue 2745563004: Reduce copying of local data structures in GeometryMapper and PaintLayerClipper. (Closed)
Patch Set: none Created 3 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/compositing/PaintArtifactCompositor.h" 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include "cc/layers/content_layer_client.h" 10 #include "cc/layers/content_layer_client.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if (transformNode != ancestorState.transform()) { 282 if (transformNode != ancestorState.transform()) {
283 const TransformationMatrix& localToAncestorMatrix = 283 const TransformationMatrix& localToAncestorMatrix =
284 geometryMapper.localToAncestorMatrix(transformNode, 284 geometryMapper.localToAncestorMatrix(transformNode,
285 ancestorState.transform()); 285 ancestorState.transform());
286 // Clips are only in descendant spaces that are transformed by one 286 // Clips are only in descendant spaces that are transformed by one
287 // or more scrolls. 287 // or more scrolls.
288 DCHECK(localToAncestorMatrix.isIdentityOrTranslation()); 288 DCHECK(localToAncestorMatrix.isIdentityOrTranslation());
289 } 289 }
290 #endif 290 #endif
291 291
292 FloatRect combinedClip = 292 const FloatClipRect& combinedClip =
293 geometryMapper.localToAncestorClipRect(localState, ancestorState).rect(); 293 geometryMapper.localToAncestorClipRect(localState, ancestorState).rect();
294 294
295 ccList.CreateAndAppendPairedBeginItem<cc::FloatClipDisplayItem>( 295 ccList.CreateAndAppendPairedBeginItem<cc::FloatClipDisplayItem>(
296 gfx::RectF(combinedClip)); 296 gfx::RectF(combinedClip.rect()));
297 endDisplayItems.push_back(EndClip); 297 endDisplayItems.push_back(EndClip);
298 } 298 }
299 299
300 static void recordPairedBeginDisplayItems( 300 static void recordPairedBeginDisplayItems(
301 const Vector<PropertyTreeState>& pairedStates, 301 const Vector<PropertyTreeState>& pairedStates,
302 const PropertyTreeState& pendingLayerState, 302 const PropertyTreeState& pendingLayerState,
303 cc::DisplayItemList& ccList, 303 cc::DisplayItemList& ccList,
304 Vector<EndDisplayItemType>& endDisplayItems, 304 Vector<EndDisplayItemType>& endDisplayItems,
305 GeometryMapper& geometryMapper) { 305 GeometryMapper& geometryMapper) {
306 PropertyTreeState mappedClipDestinationSpace = pendingLayerState; 306 PropertyTreeState mappedClipDestinationSpace = pendingLayerState;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 597 }
598 598
599 bool PaintArtifactCompositor::mightOverlap( 599 bool PaintArtifactCompositor::mightOverlap(
600 const PaintChunk& paintChunk, 600 const PaintChunk& paintChunk,
601 const PendingLayer& candidatePendingLayer, 601 const PendingLayer& candidatePendingLayer,
602 GeometryMapper& geometryMapper) { 602 GeometryMapper& geometryMapper) {
603 PropertyTreeState rootPropertyTreeState(TransformPaintPropertyNode::root(), 603 PropertyTreeState rootPropertyTreeState(TransformPaintPropertyNode::root(),
604 ClipPaintPropertyNode::root(), 604 ClipPaintPropertyNode::root(),
605 EffectPaintPropertyNode::root()); 605 EffectPaintPropertyNode::root());
606 606
607 FloatRect paintChunkScreenVisualRect = 607 // Intentionally store this as a local copy, because the next call
608 geometryMapper 608 // to |localToAncestorVisualRect| might invalidate it.
609 .localToAncestorVisualRect(paintChunk.bounds, 609 FloatClipRect paintChunkScreenVisualRect =
610 paintChunk.properties.propertyTreeState, 610 geometryMapper.localToAncestorVisualRect(
611 rootPropertyTreeState) 611 paintChunk.bounds, paintChunk.properties.propertyTreeState,
612 .rect(); 612 rootPropertyTreeState);
613 613
614 FloatRect pendingLayerScreenVisualRect = 614 const FloatClipRect& pendingLayerScreenVisualRect =
615 geometryMapper 615 geometryMapper.localToAncestorVisualRect(
616 .localToAncestorVisualRect(candidatePendingLayer.bounds, 616 candidatePendingLayer.bounds, candidatePendingLayer.propertyTreeState,
617 candidatePendingLayer.propertyTreeState, 617 rootPropertyTreeState);
618 rootPropertyTreeState)
619 .rect();
620 618
621 return paintChunkScreenVisualRect.intersects(pendingLayerScreenVisualRect); 619 return paintChunkScreenVisualRect.rect().intersects(
620 pendingLayerScreenVisualRect.rect());
622 } 621 }
623 622
624 PaintArtifactCompositor::PendingLayer::PendingLayer( 623 PaintArtifactCompositor::PendingLayer::PendingLayer(
625 const PaintChunk& firstPaintChunk) 624 const PaintChunk& firstPaintChunk)
626 : bounds(firstPaintChunk.bounds), 625 : bounds(firstPaintChunk.bounds),
627 knownToBeOpaque(firstPaintChunk.knownToBeOpaque), 626 knownToBeOpaque(firstPaintChunk.knownToBeOpaque),
628 backfaceHidden(firstPaintChunk.properties.backfaceHidden), 627 backfaceHidden(firstPaintChunk.properties.backfaceHidden),
629 propertyTreeState(firstPaintChunk.properties.propertyTreeState) { 628 propertyTreeState(firstPaintChunk.properties.propertyTreeState) {
630 paintChunks.push_back(&firstPaintChunk); 629 paintChunks.push_back(&firstPaintChunk);
631 } 630 }
632 631
633 void PaintArtifactCompositor::PendingLayer::add( 632 void PaintArtifactCompositor::PendingLayer::add(
634 const PaintChunk& paintChunk, 633 const PaintChunk& paintChunk,
635 GeometryMapper* geometryMapper) { 634 GeometryMapper* geometryMapper) {
636 DCHECK(paintChunk.properties.backfaceHidden == backfaceHidden); 635 DCHECK(paintChunk.properties.backfaceHidden == backfaceHidden);
637 paintChunks.push_back(&paintChunk); 636 paintChunks.push_back(&paintChunk);
638 FloatRect mappedBounds = paintChunk.bounds; 637 FloatRect mappedBounds = paintChunk.bounds;
639 if (geometryMapper) { 638 if (geometryMapper) {
640 mappedBounds = geometryMapper->localToAncestorRect( 639 geometryMapper->localToAncestorRect(
641 mappedBounds, paintChunk.properties.propertyTreeState.transform(), 640 paintChunk.properties.propertyTreeState.transform(),
642 propertyTreeState.transform()); 641 propertyTreeState.transform(), mappedBounds);
643 } 642 }
644 bounds.unite(mappedBounds); 643 bounds.unite(mappedBounds);
645 if (bounds.size() != paintChunks[0]->bounds.size()) { 644 if (bounds.size() != paintChunks[0]->bounds.size()) {
646 if (bounds.size() != paintChunk.bounds.size()) 645 if (bounds.size() != paintChunk.bounds.size())
647 knownToBeOpaque = false; 646 knownToBeOpaque = false;
648 else 647 else
649 knownToBeOpaque = paintChunk.knownToBeOpaque; 648 knownToBeOpaque = paintChunk.knownToBeOpaque;
650 } 649 }
651 } 650 }
652 651
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 #ifndef NDEBUG 753 #ifndef NDEBUG
755 void PaintArtifactCompositor::showDebugData() { 754 void PaintArtifactCompositor::showDebugData() {
756 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) 755 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo)
757 ->toPrettyJSONString() 756 ->toPrettyJSONString()
758 .utf8() 757 .utf8()
759 .data(); 758 .data();
760 } 759 }
761 #endif 760 #endif
762 761
763 } // namespace blink 762 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698