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

Side by Side Diff: sky/engine/core/rendering/RenderLayer.cpp

Issue 779183004: Get rid of the PaintLayerFlags bitmask. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « sky/engine/core/rendering/RenderLayer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 m_scrollableArea = adoptPtr(new RenderLayerScrollableArea(*this)); 857 m_scrollableArea = adoptPtr(new RenderLayerScrollableArea(*this));
858 else 858 else
859 m_scrollableArea = nullptr; 859 m_scrollableArea = nullptr;
860 } 860 }
861 861
862 bool RenderLayer::hasOverflowControls() const 862 bool RenderLayer::hasOverflowControls() const
863 { 863 {
864 return m_scrollableArea && m_scrollableArea->hasScrollbar(); 864 return m_scrollableArea && m_scrollableArea->hasScrollbar();
865 } 865 }
866 866
867 void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect, PaintBehavior paintBehavior, RenderObject* paintingRoot, PaintLayerFlags paintFl ags) 867 void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect, PaintBehavior paintBehavior, RenderObject* paintingRoot)
868 { 868 {
869 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBeha vior, LayoutSize(), paintingRoot); 869 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBeha vior, LayoutSize(), paintingRoot);
870 paintLayer(context, paintingInfo, paintFlags); 870 paintLayer(context, paintingInfo, PaintContent);
871 } 871 }
872 872
873 void RenderLayer::paintOverlayScrollbars(GraphicsContext* context, const LayoutR ect& damageRect, PaintBehavior paintBehavior, RenderObject* paintingRoot) 873 void RenderLayer::paintOverlayScrollbars(GraphicsContext* context, const LayoutR ect& damageRect, PaintBehavior paintBehavior, RenderObject* paintingRoot)
874 { 874 {
875 if (!m_containsDirtyOverlayScrollbars) 875 if (!m_containsDirtyOverlayScrollbars)
876 return; 876 return;
877 877
878 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBeha vior, LayoutSize(), paintingRoot); 878 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBeha vior, LayoutSize(), paintingRoot);
879 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 879 paintLayer(context, paintingInfo, PaintOverlayScrollbars);
880 880
881 m_containsDirtyOverlayScrollbars = false; 881 m_containsDirtyOverlayScrollbars = false;
882 } 882 }
883 883
884 static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLaye r) 884 static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLaye r)
885 { 885 {
886 if (startLayer == endLayer) 886 if (startLayer == endLayer)
887 return true; 887 return true;
888 888
889 RenderView* view = startLayer->renderer()->view(); 889 RenderView* view = startLayer->renderer()->view();
890 for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock(); currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo ck()) { 890 for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock(); currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo ck()) {
891 if (currentBlock->layer() == endLayer) 891 if (currentBlock->layer() == endLayer)
892 return true; 892 return true;
893 } 893 }
894 894
895 return false; 895 return false;
896 } 896 }
897 897
898 void RenderLayer::clipToRect(const LayerPaintingInfo& localPaintingInfo, Graphic sContext* context, const ClipRect& clipRect, 898 void RenderLayer::clipToRect(const LayerPaintingInfo& localPaintingInfo, Graphic sContext* context, const ClipRect& clipRect,
899 PaintLayerFlags paintFlags, BorderRadiusClippingRule rule) 899 BorderRadiusClippingRule rule)
900 { 900 {
901 if (clipRect.rect() == localPaintingInfo.paintDirtyRect && !clipRect.hasRadi us()) 901 if (clipRect.rect() == localPaintingInfo.paintDirtyRect && !clipRect.hasRadi us())
902 return; 902 return;
903 context->save(); 903 context->save();
904 context->clip(pixelSnappedIntRect(clipRect.rect())); 904 context->clip(pixelSnappedIntRect(clipRect.rect()));
905 905
906 if (!clipRect.hasRadius()) 906 if (!clipRect.hasRadius())
907 return; 907 return;
908 908
909 // If the clip rect has been tainted by a border radius, then we have to wal k up our layer chain applying the clips from 909 // If the clip rect has been tainted by a border radius, then we have to wal k up our layer chain applying the clips from
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 } 975 }
976 976
977 // Make sure the parent's clip rects have been calculated. 977 // Make sure the parent's clip rects have been calculated.
978 ClipRect clipRect = paintingInfo.paintDirtyRect; 978 ClipRect clipRect = paintingInfo.paintDirtyRect;
979 if (parent()) { 979 if (parent()) {
980 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, PaintingCl ipRects); 980 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, PaintingCl ipRects);
981 clipRect = clipper().backgroundClipRect(clipRectsContext); 981 clipRect = clipper().backgroundClipRect(clipRectsContext);
982 clipRect.intersect(paintingInfo.paintDirtyRect); 982 clipRect.intersect(paintingInfo.paintDirtyRect);
983 983
984 // Push the parent coordinate space's clip. 984 // Push the parent coordinate space's clip.
985 parent()->clipToRect(paintingInfo, context, clipRect, paintFlags); 985 parent()->clipToRect(paintingInfo, context, clipRect);
986 } 986 }
987 987
988 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); 988 paintLayerByApplyingTransform(context, paintingInfo, paintFlags);
989 989
990 // Restore the clip. 990 // Restore the clip.
991 if (parent()) 991 if (parent())
992 parent()->restoreClip(context, paintingInfo.paintDirtyRect, clipRect ); 992 parent()->restoreClip(context, paintingInfo.paintDirtyRect, clipRect );
993 993
994 return; 994 return;
995 } 995 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 LayerPaintingInfo localPaintingInfo(paintingInfo); 1041 LayerPaintingInfo localPaintingInfo(paintingInfo);
1042 bool deferredFiltersEnabled = renderer()->document().settings()->deferredFil tersEnabled(); 1042 bool deferredFiltersEnabled = renderer()->document().settings()->deferredFil tersEnabled();
1043 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte rs()); 1043 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte rs());
1044 1044
1045 LayerFragments layerFragments; 1045 LayerFragments layerFragments;
1046 // Collect the fragments. This will compute the clip rectangles and paint of fsets for each layer fragment, as well as whether or not the content of each 1046 // Collect the fragments. This will compute the clip rectangles and paint of fsets for each layer fragment, as well as whether or not the content of each
1047 // fragment should paint. 1047 // fragment should paint.
1048 collectFragments(layerFragments, localPaintingInfo.rootLayer, localPaintingI nfo.paintDirtyRect, 1048 collectFragments(layerFragments, localPaintingInfo.rootLayer, localPaintingI nfo.paintDirtyRect,
1049 PaintingClipRects, &offsetFromRoot, localPaintingInfo.subPixelAccumulati on); 1049 PaintingClipRects, &offsetFromRoot, localPaintingInfo.subPixelAccumulati on);
1050 1050
1051 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr ollbars; 1051 bool isPaintingOverlayScrollbars = paintFlags == PaintOverlayScrollbars;
ojan 2014/12/06 03:47:41 This is the only real "change" in this patch.
ojan 2014/12/06 03:47:42 This is the only real "change" in this patch.
1052 bool shouldPaintContent = isSelfPaintingLayer() && !isPaintingOverlayScrollb ars; 1052 bool shouldPaintContent = isSelfPaintingLayer() && !isPaintingOverlayScrollb ars;
1053 updatePaintingInfoForFragments(layerFragments, localPaintingInfo, paintFlags , shouldPaintContent, &offsetFromRoot); 1053 updatePaintingInfoForFragments(layerFragments, localPaintingInfo, shouldPain tContent, &offsetFromRoot);
1054 1054
1055 bool haveTransparency = isTransparent(); 1055 bool haveTransparency = isTransparent();
1056 1056
1057 if (filterPainter.haveFilterEffect()) { 1057 if (filterPainter.haveFilterEffect()) {
1058 ASSERT(this->filterInfo()); 1058 ASSERT(this->filterInfo());
1059 1059
1060 if (!rootRelativeBoundsComputed) 1060 if (!rootRelativeBoundsComputed)
1061 rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndStacki ngChildren(paintingInfo.rootLayer, offsetFromRoot); 1061 rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndStacki ngChildren(paintingInfo.rootLayer, offsetFromRoot);
1062 1062
1063 if (filterPainter.prepareFilterEffect(this, rootRelativeBounds, painting Info.paintDirtyRect)) { 1063 if (filterPainter.prepareFilterEffect(this, rootRelativeBounds, painting Info.paintDirtyRect)) {
1064 1064
1065 // Rewire the old context to a memory buffer, so that we can capture the contents of the layer. 1065 // Rewire the old context to a memory buffer, so that we can capture the contents of the layer.
1066 // NOTE: We saved the old context in the "transparencyLayerContext" local variable, to be able to start a transparency layer 1066 // NOTE: We saved the old context in the "transparencyLayerContext" local variable, to be able to start a transparency layer
1067 // on the original context and avoid duplicating "beginFilterEffect" after each transparency layer call. Also, note that 1067 // on the original context and avoid duplicating "beginFilterEffect" after each transparency layer call. Also, note that
1068 // beginTransparencyLayers will only create a single lazy transparen cy layer, even though it is called twice in this method. 1068 // beginTransparencyLayers will only create a single lazy transparen cy layer, even though it is called twice in this method.
1069 // With deferred filters, we don't need a separate context, but we d o need to do transparency and clipping before starting 1069 // With deferred filters, we don't need a separate context, but we d o need to do transparency and clipping before starting
1070 // filter processing. 1070 // filter processing.
1071 // FIXME: when the legacy path is removed, remove the transparencyLa yerContext as well. 1071 // FIXME: when the legacy path is removed, remove the transparencyLa yerContext as well.
1072 if (deferredFiltersEnabled) { 1072 if (deferredFiltersEnabled) {
1073 if (haveTransparency) { 1073 if (haveTransparency) {
1074 // If we have a filter and transparency, we have to eagerly start a transparency layer here, rather than risk a child layer lazily starts on e after filter processing. 1074 // If we have a filter and transparency, we have to eagerly start a transparency layer here, rather than risk a child layer lazily starts on e after filter processing.
1075 beginTransparencyLayers(context, localPaintingInfo.rootLayer , paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, localPaintingI nfo.paintBehavior); 1075 beginTransparencyLayers(context, localPaintingInfo.rootLayer , paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, localPaintingI nfo.paintBehavior);
1076 } 1076 }
1077 // We'll handle clipping to the dirty rect before filter rasteri zation. 1077 // We'll handle clipping to the dirty rect before filter rasteri zation.
1078 // Filter processing will automatically expand the clip rect and the offscreen to accommodate any filter outsets. 1078 // Filter processing will automatically expand the clip rect and the offscreen to accommodate any filter outsets.
1079 // FIXME: It is incorrect to just clip to the damageRect here on ce multiple fragments are involved. 1079 // FIXME: It is incorrect to just clip to the damageRect here on ce multiple fragments are involved.
1080 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect; 1080 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect;
1081 clipToRect(localPaintingInfo, context, backgroundRect, paintFlag s); 1081 clipToRect(localPaintingInfo, context, backgroundRect);
1082 // Subsequent code should not clip to the dirty rect, since we'v e already 1082 // Subsequent code should not clip to the dirty rect, since we'v e already
1083 // done it above, and doing it later will defeat the outsets. 1083 // done it above, and doing it later will defeat the outsets.
1084 localPaintingInfo.clipToDirtyRect = false; 1084 localPaintingInfo.clipToDirtyRect = false;
1085 } 1085 }
1086 context = filterPainter.beginFilterEffect(context); 1086 context = filterPainter.beginFilterEffect(context);
1087 1087
1088 // Check that we didn't fail to allocate the graphics context for th e offscreen buffer. 1088 // Check that we didn't fail to allocate the graphics context for th e offscreen buffer.
1089 if (filterPainter.hasStartedFilterEffect() && !deferredFiltersEnable d) { 1089 if (filterPainter.hasStartedFilterEffect() && !deferredFiltersEnable d) {
1090 localPaintingInfo.paintDirtyRect = filterPainter.paintInvalidati onRect(); 1090 localPaintingInfo.paintDirtyRect = filterPainter.paintInvalidati onRect();
1091 // If the filter needs the full source image, we need to avoid u sing the clip rectangles. 1091 // If the filter needs the full source image, we need to avoid u sing the clip rectangles.
(...skipping 15 matching lines...) Expand all
1107 // so it will be tested against as we descend through the renderers. 1107 // so it will be tested against as we descend through the renderers.
1108 RenderObject* paintingRootForRenderer = 0; 1108 RenderObject* paintingRootForRenderer = 0;
1109 if (localPaintingInfo.paintingRoot && !renderer()->isDescendantOf(localPaint ingInfo.paintingRoot)) 1109 if (localPaintingInfo.paintingRoot && !renderer()->isDescendantOf(localPaint ingInfo.paintingRoot))
1110 paintingRootForRenderer = localPaintingInfo.paintingRoot; 1110 paintingRootForRenderer = localPaintingInfo.paintingRoot;
1111 1111
1112 // FIXME(sky): Get rid of PaintBehavior argument now that it's always Normal . 1112 // FIXME(sky): Get rid of PaintBehavior argument now that it's always Normal .
1113 PaintBehavior paintBehavior = PaintBehaviorNormal; 1113 PaintBehavior paintBehavior = PaintBehaviorNormal;
1114 1114
1115 if (shouldPaintContent) { 1115 if (shouldPaintContent) {
1116 paintBackgroundForFragments(layerFragments, context, transparencyLayerCo ntext, paintingInfo.paintDirtyRect, haveTransparency, 1116 paintBackgroundForFragments(layerFragments, context, transparencyLayerCo ntext, paintingInfo.paintDirtyRect, haveTransparency,
1117 localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlag s); 1117 localPaintingInfo, paintBehavior, paintingRootForRenderer);
1118 } 1118 }
1119 1119
1120 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFlags); 1120 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFlags);
1121 1121
1122 if (shouldPaintContent) { 1122 if (shouldPaintContent) {
1123 paintForegroundForFragments(layerFragments, context, transparencyLayerCo ntext, paintingInfo.paintDirtyRect, haveTransparency, 1123 paintForegroundForFragments(layerFragments, context, transparencyLayerCo ntext, paintingInfo.paintDirtyRect, haveTransparency,
1124 localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlag s); 1124 localPaintingInfo, paintBehavior, paintingRootForRenderer);
1125 } 1125 }
1126 1126
1127 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintBe havior, paintingRootForRenderer, paintFlags); 1127 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintBe havior, paintingRootForRenderer);
1128 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting Info, paintFlags); 1128 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting Info, paintFlags);
1129 1129
1130 if (isPaintingOverlayScrollbars) 1130 if (isPaintingOverlayScrollbars)
1131 paintOverflowControlsForFragments(layerFragments, context, localPainting Info, paintFlags); 1131 paintOverflowControlsForFragments(layerFragments, context, localPainting Info);
1132 1132
1133 if (filterPainter.hasStartedFilterEffect()) { 1133 if (filterPainter.hasStartedFilterEffect()) {
1134 // Apply the correct clipping (ie. overflow: hidden). 1134 // Apply the correct clipping (ie. overflow: hidden).
1135 // FIXME: It is incorrect to just clip to the damageRect here once multi ple fragments are involved. 1135 // FIXME: It is incorrect to just clip to the damageRect here once multi ple fragments are involved.
1136 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerF ragments[0].backgroundRect; 1136 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerF ragments[0].backgroundRect;
1137 if (!deferredFiltersEnabled) 1137 if (!deferredFiltersEnabled)
1138 clipToRect(localPaintingInfo, transparencyLayerContext, backgroundRe ct, paintFlags); 1138 clipToRect(localPaintingInfo, transparencyLayerContext, backgroundRe ct);
1139 1139
1140 context = filterPainter.applyFilterEffect(); 1140 context = filterPainter.applyFilterEffect();
1141 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect, backgroundRect); 1141 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect, backgroundRect);
1142 } 1142 }
1143 1143
1144 // Make sure that we now use the original transparency context. 1144 // Make sure that we now use the original transparency context.
1145 ASSERT(transparencyLayerContext == context); 1145 ASSERT(transparencyLayerContext == context);
1146 1146
1147 if (shouldPaintContent && renderer()->hasMask()) 1147 if (shouldPaintContent && renderer()->hasMask())
1148 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForRenderer, paintFlags); 1148 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForRenderer);
1149 1149
1150 // End our transparency layer 1150 // End our transparency layer
1151 if (haveTransparency && m_usedTransparency) { 1151 if (haveTransparency && m_usedTransparency) {
1152 context->endLayer(); 1152 context->endLayer();
1153 context->restore(); 1153 context->restore();
1154 m_usedTransparency = false; 1154 m_usedTransparency = false;
1155 } 1155 }
1156 } 1156 }
1157 1157
1158 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint& translationOffset) 1158 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint& translationOffset)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 ClipRectsCacheSlot clipRectsCacheSlot, const LayoutPoint* offsetFromRoot, 1199 ClipRectsCacheSlot clipRectsCacheSlot, const LayoutPoint* offsetFromRoot,
1200 const LayoutSize& subPixelAccumulation, const LayoutRect* layerBoundingBox) 1200 const LayoutSize& subPixelAccumulation, const LayoutRect* layerBoundingBox)
1201 { 1201 {
1202 // For unpaginated layers, there is only one fragment. 1202 // For unpaginated layers, there is only one fragment.
1203 LayerFragment fragment; 1203 LayerFragment fragment;
1204 ClipRectsContext clipRectsContext(rootLayer, clipRectsCacheSlot, subPixelAcc umulation); 1204 ClipRectsContext clipRectsContext(rootLayer, clipRectsCacheSlot, subPixelAcc umulation);
1205 clipper().calculateRects(clipRectsContext, dirtyRect, fragment.layerBounds, fragment.backgroundRect, fragment.foregroundRect, fragment.outlineRect, offsetFr omRoot); 1205 clipper().calculateRects(clipRectsContext, dirtyRect, fragment.layerBounds, fragment.backgroundRect, fragment.foregroundRect, fragment.outlineRect, offsetFr omRoot);
1206 fragments.append(fragment); 1206 fragments.append(fragment);
1207 } 1207 }
1208 1208
1209 void RenderLayer::updatePaintingInfoForFragments(LayerFragments& fragments, cons t LayerPaintingInfo& localPaintingInfo, PaintLayerFlags localPaintFlags, 1209 void RenderLayer::updatePaintingInfoForFragments(LayerFragments& fragments, cons t LayerPaintingInfo& localPaintingInfo,
1210 bool shouldPaintContent, const LayoutPoint* offsetFromRoot) 1210 bool shouldPaintContent, const LayoutPoint* offsetFromRoot)
1211 { 1211 {
1212 ASSERT(offsetFromRoot); 1212 ASSERT(offsetFromRoot);
1213 for (size_t i = 0; i < fragments.size(); ++i) { 1213 for (size_t i = 0; i < fragments.size(); ++i) {
1214 LayerFragment& fragment = fragments.at(i); 1214 LayerFragment& fragment = fragments.at(i);
1215 LayoutPoint newOffsetFromRoot = *offsetFromRoot; 1215 LayoutPoint newOffsetFromRoot = *offsetFromRoot;
1216 fragment.shouldPaintContent = shouldPaintContent && intersectsDamageRect (fragment.layerBounds, fragment.backgroundRect.rect(), localPaintingInfo.rootLay er, &newOffsetFromRoot); 1216 fragment.shouldPaintContent = shouldPaintContent && intersectsDamageRect (fragment.layerBounds, fragment.backgroundRect.rect(), localPaintingInfo.rootLay er, &newOffsetFromRoot);
1217 } 1217 }
1218 } 1218 }
1219 1219
1220 void RenderLayer::paintBackgroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext, 1220 void RenderLayer::paintBackgroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext,
1221 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, 1221 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior,
1222 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 1222 RenderObject* paintingRootForRenderer)
1223 { 1223 {
1224 for (size_t i = 0; i < layerFragments.size(); ++i) { 1224 for (size_t i = 0; i < layerFragments.size(); ++i) {
1225 const LayerFragment& fragment = layerFragments.at(i); 1225 const LayerFragment& fragment = layerFragments.at(i);
1226 if (!fragment.shouldPaintContent) 1226 if (!fragment.shouldPaintContent)
1227 continue; 1227 continue;
1228 1228
1229 // Begin transparency layers lazily now that we know we have to paint so mething. 1229 // Begin transparency layers lazily now that we know we have to paint so mething.
1230 if (haveTransparency) 1230 if (haveTransparency)
1231 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo. rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, l ocalPaintingInfo.paintBehavior); 1231 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo. rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, l ocalPaintingInfo.paintBehavior);
1232 1232
1233 if (localPaintingInfo.clipToDirtyRect) { 1233 if (localPaintingInfo.clipToDirtyRect) {
1234 // Paint our background first, before painting any child layers. 1234 // Paint our background first, before painting any child layers.
1235 // Establish the clip used to paint our background. 1235 // Establish the clip used to paint our background.
1236 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Background painting will handle cli pping to self. 1236 clipToRect(localPaintingInfo, context, fragment.backgroundRect, DoNo tIncludeSelfForBorderRadius); // Background painting will handle clipping to sel f.
1237 } 1237 }
1238 1238
1239 // Paint the background. 1239 // Paint the background.
1240 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. 1240 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info.
1241 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseBlockBackground, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer()); 1241 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseBlockBackground, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer());
1242 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); 1242 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation));
1243 1243
1244 if (localPaintingInfo.clipToDirtyRect) 1244 if (localPaintingInfo.clipToDirtyRect)
1245 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect); 1245 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect);
1246 } 1246 }
1247 } 1247 }
1248 1248
1249 void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext, 1249 void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext,
1250 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, 1250 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior,
1251 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 1251 RenderObject* paintingRootForRenderer)
1252 { 1252 {
1253 // Begin transparency if we have something to paint. 1253 // Begin transparency if we have something to paint.
1254 if (haveTransparency) { 1254 if (haveTransparency) {
1255 for (size_t i = 0; i < layerFragments.size(); ++i) { 1255 for (size_t i = 0; i < layerFragments.size(); ++i) {
1256 const LayerFragment& fragment = layerFragments.at(i); 1256 const LayerFragment& fragment = layerFragments.at(i);
1257 if (fragment.shouldPaintContent && !fragment.foregroundRect.isEmpty( )) { 1257 if (fragment.shouldPaintContent && !fragment.foregroundRect.isEmpty( )) {
1258 beginTransparencyLayers(transparencyLayerContext, localPaintingI nfo.rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulatio n, localPaintingInfo.paintBehavior); 1258 beginTransparencyLayers(transparencyLayerContext, localPaintingI nfo.rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulatio n, localPaintingInfo.paintBehavior);
1259 break; 1259 break;
1260 } 1260 }
1261 } 1261 }
1262 } 1262 }
1263 1263
1264 // Optimize clipping for the single fragment case. 1264 // Optimize clipping for the single fragment case.
1265 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && layerFragments[0].shouldPaintContent && !layerFragments[0].foregroundRe ct.isEmpty(); 1265 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && layerFragments[0].shouldPaintContent && !layerFragments[0].foregroundRe ct.isEmpty();
1266 if (shouldClip) 1266 if (shouldClip)
1267 clipToRect(localPaintingInfo, context, layerFragments[0].foregroundRect, paintFlags); 1267 clipToRect(localPaintingInfo, context, layerFragments[0].foregroundRect) ;
1268 1268
1269 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for 1269 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for
1270 // interleaving of the fragments to work properly. 1270 // interleaving of the fragments to work properly.
1271 paintForegroundForFragmentsWithPhase(PaintPhaseChildBlockBackgrounds, layerF ragments, 1271 paintForegroundForFragmentsWithPhase(PaintPhaseChildBlockBackgrounds, layerF ragments,
1272 context, localPaintingInfo, paintBehavior, paintingRootForRenderer, pain tFlags); 1272 context, localPaintingInfo, paintBehavior, paintingRootForRenderer);
1273 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragments, c ontext, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags); 1273 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragments, c ontext, localPaintingInfo, paintBehavior, paintingRootForRenderer);
1274 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragments , context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags ); 1274 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragments , context, localPaintingInfo, paintBehavior, paintingRootForRenderer);
1275 1275
1276 if (shouldClip) 1276 if (shouldClip)
1277 restoreClip(context, localPaintingInfo.paintDirtyRect, layerFragments[0] .foregroundRect); 1277 restoreClip(context, localPaintingInfo.paintDirtyRect, layerFragments[0] .foregroundRect);
1278 } 1278 }
1279 1279
1280 void RenderLayer::paintForegroundForFragmentsWithPhase(PaintPhase phase, const L ayerFragments& layerFragments, GraphicsContext* context, 1280 void RenderLayer::paintForegroundForFragmentsWithPhase(PaintPhase phase, const L ayerFragments& layerFragments, GraphicsContext* context,
1281 const LayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, Ren derObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 1281 const LayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, Ren derObject* paintingRootForRenderer)
1282 { 1282 {
1283 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() > 1; 1283 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() > 1;
1284 1284
1285 for (size_t i = 0; i < layerFragments.size(); ++i) { 1285 for (size_t i = 0; i < layerFragments.size(); ++i) {
1286 const LayerFragment& fragment = layerFragments.at(i); 1286 const LayerFragment& fragment = layerFragments.at(i);
1287 if (!fragment.shouldPaintContent || fragment.foregroundRect.isEmpty()) 1287 if (!fragment.shouldPaintContent || fragment.foregroundRect.isEmpty())
1288 continue; 1288 continue;
1289 1289
1290 if (shouldClip) 1290 if (shouldClip)
1291 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain tFlags); 1291 clipToRect(localPaintingInfo, context, fragment.foregroundRect);
1292 1292
1293 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.foregroundRect .rect()), phase, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.ro otLayer->renderer()); 1293 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.foregroundRect .rect()), phase, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.ro otLayer->renderer());
1294 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); 1294 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation));
1295 1295
1296 if (shouldClip) 1296 if (shouldClip)
1297 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect); 1297 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect);
1298 } 1298 }
1299 } 1299 }
1300 1300
1301 void RenderLayer::paintOutlineForFragments(const LayerFragments& layerFragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, 1301 void RenderLayer::paintOutlineForFragments(const LayerFragments& layerFragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
1302 PaintBehavior paintBehavior, RenderObject* paintingRootForRenderer, PaintLay erFlags paintFlags) 1302 PaintBehavior paintBehavior, RenderObject* paintingRootForRenderer)
1303 { 1303 {
1304 for (size_t i = 0; i < layerFragments.size(); ++i) { 1304 for (size_t i = 0; i < layerFragments.size(); ++i) {
1305 const LayerFragment& fragment = layerFragments.at(i); 1305 const LayerFragment& fragment = layerFragments.at(i);
1306 if (fragment.outlineRect.isEmpty()) 1306 if (fragment.outlineRect.isEmpty())
1307 continue; 1307 continue;
1308 1308
1309 // Paint our own outline 1309 // Paint our own outline
1310 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.outlineRect.re ct()), PaintPhaseSelfOutline, paintBehavior, paintingRootForRenderer, 0, localPa intingInfo.rootLayer->renderer()); 1310 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.outlineRect.re ct()), PaintPhaseSelfOutline, paintBehavior, paintingRootForRenderer, 0, localPa intingInfo.rootLayer->renderer());
1311 clipToRect(localPaintingInfo, context, fragment.outlineRect, paintFlags, DoNotIncludeSelfForBorderRadius); 1311 clipToRect(localPaintingInfo, context, fragment.outlineRect, DoNotInclud eSelfForBorderRadius);
1312 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); 1312 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation));
1313 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.outlineR ect); 1313 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.outlineR ect);
1314 } 1314 }
1315 } 1315 }
1316 1316
1317 void RenderLayer::paintMaskForFragments(const LayerFragments& layerFragments, Gr aphicsContext* context, const LayerPaintingInfo& localPaintingInfo, 1317 void RenderLayer::paintMaskForFragments(const LayerFragments& layerFragments, Gr aphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
1318 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 1318 RenderObject* paintingRootForRenderer)
1319 { 1319 {
1320 for (size_t i = 0; i < layerFragments.size(); ++i) { 1320 for (size_t i = 0; i < layerFragments.size(); ++i) {
1321 const LayerFragment& fragment = layerFragments.at(i); 1321 const LayerFragment& fragment = layerFragments.at(i);
1322 if (!fragment.shouldPaintContent) 1322 if (!fragment.shouldPaintContent)
1323 continue; 1323 continue;
1324 1324
1325 if (localPaintingInfo.clipToDirtyRect) 1325 if (localPaintingInfo.clipToDirtyRect)
1326 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self. 1326 clipToRect(localPaintingInfo, context, fragment.backgroundRect, DoNo tIncludeSelfForBorderRadius); // Mask painting will handle clipping to self.
1327 1327
1328 // Paint the mask. 1328 // Paint the mask.
1329 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. 1329 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info.
1330 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, 0, local PaintingInfo.rootLayer->renderer()); 1330 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, 0, local PaintingInfo.rootLayer->renderer());
1331 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); 1331 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation));
1332 1332
1333 if (localPaintingInfo.clipToDirtyRect) 1333 if (localPaintingInfo.clipToDirtyRect)
1334 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect); 1334 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect);
1335 } 1335 }
1336 } 1336 }
1337 1337
1338 void RenderLayer::paintOverflowControlsForFragments(const LayerFragments& layerF ragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 1338 void RenderLayer::paintOverflowControlsForFragments(const LayerFragments& layerF ragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo)
1339 { 1339 {
1340 for (size_t i = 0; i < layerFragments.size(); ++i) { 1340 for (size_t i = 0; i < layerFragments.size(); ++i) {
1341 const LayerFragment& fragment = layerFragments.at(i); 1341 const LayerFragment& fragment = layerFragments.at(i);
1342 clipToRect(localPaintingInfo, context, fragment.backgroundRect, paintFla gs); 1342 clipToRect(localPaintingInfo, context, fragment.backgroundRect);
1343 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea()) 1343 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea())
1344 scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoi nt(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.sub PixelAccumulation)), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); 1344 scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoi nt(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.sub PixelAccumulation)), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
1345 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou ndRect); 1345 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou ndRect);
1346 } 1346 }
1347 } 1347 }
1348 1348
1349 static inline LayoutRect frameVisibleRect(RenderObject* renderer) 1349 static inline LayoutRect frameVisibleRect(RenderObject* renderer)
1350 { 1350 {
1351 FrameView* frameView = renderer->document().view(); 1351 FrameView* frameView = renderer->document().view();
1352 if (!frameView) 1352 if (!frameView)
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2148 } 2148 }
2149 } 2149 }
2150 2150
2151 void showLayerTree(const blink::RenderObject* renderer) 2151 void showLayerTree(const blink::RenderObject* renderer)
2152 { 2152 {
2153 if (!renderer) 2153 if (!renderer)
2154 return; 2154 return;
2155 showLayerTree(renderer->enclosingLayer()); 2155 showLayerTree(renderer->enclosingLayer());
2156 } 2156 }
2157 #endif 2157 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698