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

Side by Side Diff: Source/core/paint/DeprecatedPaintLayerPainter.cpp

Issue 1218013003: Keep a cache of caret painters to avoid recomputing all the time. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: a shade of deduplication blue Created 5 years, 5 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "core/paint/DeprecatedPaintLayerPainter.h" 6 #include "core/paint/DeprecatedPaintLayerPainter.h"
7 7
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/layout/ClipPathOperation.h" 9 #include "core/layout/ClipPathOperation.h"
10 #include "core/layout/LayoutBlock.h" 10 #include "core/layout/LayoutBlock.h"
11 #include "core/layout/LayoutView.h" 11 #include "core/layout/LayoutView.h"
12 #include "core/layout/svg/LayoutSVGResourceClipper.h" 12 #include "core/layout/svg/LayoutSVGResourceClipper.h"
13 #include "core/page/Page.h" 13 #include "core/page/Page.h"
14 #include "core/paint/CompositingRecorder.h" 14 #include "core/paint/CompositingRecorder.h"
15 #include "core/paint/DeprecatedPaintLayer.h" 15 #include "core/paint/DeprecatedPaintLayer.h"
16 #include "core/paint/FilterPainter.h" 16 #include "core/paint/FilterPainter.h"
17 #include "core/paint/LayerClipRecorder.h" 17 #include "core/paint/LayerClipRecorder.h"
18 #include "core/paint/LayerFixedPositionRecorder.h" 18 #include "core/paint/LayerFixedPositionRecorder.h"
19 #include "core/paint/PaintDataCache.h"
19 #include "core/paint/PaintInfo.h" 20 #include "core/paint/PaintInfo.h"
20 #include "core/paint/SVGClipPainter.h" 21 #include "core/paint/SVGClipPainter.h"
21 #include "core/paint/ScopeRecorder.h" 22 #include "core/paint/ScopeRecorder.h"
22 #include "core/paint/ScrollRecorder.h" 23 #include "core/paint/ScrollRecorder.h"
23 #include "core/paint/ScrollableAreaPainter.h" 24 #include "core/paint/ScrollableAreaPainter.h"
24 #include "core/paint/Transform3DRecorder.h" 25 #include "core/paint/Transform3DRecorder.h"
25 #include "platform/graphics/GraphicsLayer.h" 26 #include "platform/graphics/GraphicsLayer.h"
26 #include "platform/graphics/paint/ClipPathRecorder.h" 27 #include "platform/graphics/paint/ClipPathRecorder.h"
27 #include "platform/graphics/paint/ClipRecorder.h" 28 #include "platform/graphics/paint/ClipRecorder.h"
28 #include "platform/graphics/paint/CompositingDisplayItem.h" 29 #include "platform/graphics/paint/CompositingDisplayItem.h"
29 #include "platform/graphics/paint/Transform3DDisplayItem.h" 30 #include "platform/graphics/paint/Transform3DDisplayItem.h"
30 #include "wtf/Optional.h" 31 #include "wtf/Optional.h"
31 32
32 namespace blink { 33 namespace blink {
33 34
34 static inline bool shouldSuppressPaintingLayer(DeprecatedPaintLayer* layer) 35 static inline bool shouldSuppressPaintingLayer(DeprecatedPaintLayer* layer)
35 { 36 {
36 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC. 37 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC.
37 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document 38 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
38 // will do a full paintInvalidationForWholeLayoutObject(). 39 // will do a full paintInvalidationForWholeLayoutObject().
39 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement()) 40 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement())
40 return true; 41 return true;
41 42
42 return false; 43 return false;
43 } 44 }
44 45
45 void DeprecatedPaintLayerPainter::paint(GraphicsContext* context, const LayoutRe ct& damageRect, PaintBehavior paintBehavior, LayoutObject* paintingRoot, PaintLa yerFlags paintFlags) 46 void DeprecatedPaintLayerPainter::paint(GraphicsContext* context, const LayoutRe ct& damageRect, PaintBehavior paintBehavior, LayoutObject* paintingRoot, PaintLa yerFlags paintFlags)
46 { 47 {
47 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintBehavior, LayoutSize(), paintingRoot); 48 PaintDataCache paintDataCache;
49 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintBehavior, LayoutSize(), paintingRoot, &paintData Cache);
48 if (shouldPaintLayerInSoftwareMode(paintingInfo, paintFlags)) 50 if (shouldPaintLayerInSoftwareMode(paintingInfo, paintFlags))
49 paintLayer(context, paintingInfo, paintFlags); 51 paintLayer(context, paintingInfo, paintFlags);
50 } 52 }
51 53
52 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const LayoutObject* layoutObject) 54 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const LayoutObject* layoutObject)
53 { 55 {
54 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO verflowClip : RespectOverflowClip; 56 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO verflowClip : RespectOverflowClip;
55 } 57 }
56 58
57 void DeprecatedPaintLayerPainter::paintLayer(GraphicsContext* context, const Dep recatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 59 void DeprecatedPaintLayerPainter::paintLayer(GraphicsContext* context, const Dep recatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 delta.moveBy(fragmentTranslation); 402 delta.moveBy(fragmentTranslation);
401 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo .paintBehavior)); 403 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo .paintBehavior));
402 IntPoint roundedDelta = roundedIntPoint(delta); 404 IntPoint roundedDelta = roundedIntPoint(delta);
403 transform.translateRight(roundedDelta.x(), roundedDelta.y()); 405 transform.translateRight(roundedDelta.x(), roundedDelta.y());
404 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta); 406 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta);
405 407
406 Transform3DRecorder transform3DRecorder(*context, *m_paintLayer.layoutObject (), DisplayItem::Transform3DElementTransform, transform); 408 Transform3DRecorder transform3DRecorder(*context, *m_paintLayer.layoutObject (), DisplayItem::Transform3DElementTransform, transform);
407 409
408 // Now do a paint with the root layer shifted to be us. 410 // Now do a paint with the root layer shifted to be us.
409 DeprecatedPaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, Layo utRect(enclosingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect) )), paintingInfo.paintBehavior, 411 DeprecatedPaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, Layo utRect(enclosingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect) )), paintingInfo.paintBehavior,
410 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); 412 adjustedSubPixelAccumulation, paintingInfo.paintingRoot, paintingInfo.pa intDataCache);
411 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags , ForceSingleFragment); 413 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags , ForceSingleFragment);
412 } 414 }
413 415
414 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL ayerFlags paintFlags) 416 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL ayerFlags paintFlags)
415 { 417 {
416 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) 418 if (!m_paintLayer.hasSelfPaintingLayerDescendant())
417 return; 419 return;
418 420
419 #if ENABLE(ASSERT) 421 #if ENABLE(ASSERT)
420 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); 422 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; 494 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius;
493 break; 495 break;
494 default: 496 default:
495 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; 497 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius;
496 break; 498 break;
497 } 499 }
498 500
499 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), clipType, c lipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule); 501 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), clipType, c lipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule);
500 } 502 }
501 503
502 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForLayoutObject, 0, paintingInfo.rootLayer->layoutObjec t()); 504 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForLayoutObject, 0, paintingInfo.rootLayer->layoutObjec t(), paintingInfo.paintDataCache);
503 OwnPtr<ScrollRecorder> scrollRecorder; 505 OwnPtr<ScrollRecorder> scrollRecorder;
504 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_paintL ayer.layoutBoxLocation()); 506 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_paintL ayer.layoutBoxLocation());
505 if (!paintingInfo.scrollOffsetAccumulation.isZero()) { 507 if (!paintingInfo.scrollOffsetAccumulation.isZero()) {
506 // As a descendant of the root layer, m_paintLayer's painting is not con trolled by the ScrollRecorders 508 // As a descendant of the root layer, m_paintLayer's painting is not con trolled by the ScrollRecorders
507 // created by BlockPainter of the ancestor layers up to the root layer, so we need to issue ScrollRecorder 509 // created by BlockPainter of the ancestor layers up to the root layer, so we need to issue ScrollRecorder
508 // for this layer seperately, with the scroll offset accumulated from th e root layer to the parent of this 510 // for this layer seperately, with the scroll offset accumulated from th e root layer to the parent of this
509 // layer, to get the same result as ScrollRecorder in BlockPainter. 511 // layer, to get the same result as ScrollRecorder in BlockPainter.
510 paintOffset += paintingInfo.scrollOffsetAccumulation; 512 paintOffset += paintingInfo.scrollOffsetAccumulation;
511 paintInfo.rect.move(paintingInfo.scrollOffsetAccumulation); 513 paintInfo.rect.move(paintingInfo.scrollOffsetAccumulation);
512 scrollRecorder = adoptPtr(new ScrollRecorder(*paintInfo.context, *m_pain tLayer.layoutObject(), paintInfo.phase, paintingInfo.scrollOffsetAccumulation)); 514 scrollRecorder = adoptPtr(new ScrollRecorder(*paintInfo.context, *m_pain tLayer.layoutObject(), paintInfo.phase, paintingInfo.scrollOffsetAccumulation));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 611 if (!m_paintLayer.containsDirtyOverlayScrollbars())
610 return; 612 return;
611 613
612 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintBehavior, LayoutSize(), paintingRoot); 614 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintBehavior, LayoutSize(), paintingRoot);
613 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 615 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
614 616
615 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 617 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
616 } 618 }
617 619
618 } // namespace blink 620 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/BlockPainter.cpp ('k') | Source/core/paint/DeprecatedPaintLayerPaintingInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698