| OLD | NEW |
| 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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 rootRelativeBounds = physicalBoundingBoxIncludingReflectionA
ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 980 rootRelativeBounds = physicalBoundingBoxIncludingReflectionA
ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 981 rootRelativeBoundsComputed = true; | 981 rootRelativeBoundsComputed = true; |
| 982 } | 982 } |
| 983 | 983 |
| 984 context->clipPath(clipPath->path(rootRelativeBounds), clipPath->
windRule()); | 984 context->clipPath(clipPath->path(rootRelativeBounds), clipPath->
windRule()); |
| 985 } | 985 } |
| 986 } | 986 } |
| 987 } | 987 } |
| 988 | 988 |
| 989 LayerPaintingInfo localPaintingInfo(paintingInfo); | 989 LayerPaintingInfo localPaintingInfo(paintingInfo); |
| 990 bool deferredFiltersEnabled = renderer()->document().settings()->deferredFil
tersEnabled(); | |
| 991 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte
rs()); | 990 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte
rs()); |
| 992 | 991 |
| 993 LayoutRect layerBounds; | 992 LayoutRect layerBounds; |
| 994 ClipRect backgroundRect, foregroundRect, outlineRect; | 993 ClipRect backgroundRect, foregroundRect, outlineRect; |
| 995 ClipRectsContext clipRectsContext(localPaintingInfo.rootLayer, PaintingClipR
ects, localPaintingInfo.subPixelAccumulation); | 994 ClipRectsContext clipRectsContext(localPaintingInfo.rootLayer, PaintingClipR
ects, localPaintingInfo.subPixelAccumulation); |
| 996 clipper().calculateRects(clipRectsContext, localPaintingInfo.paintDirtyRect, | 995 clipper().calculateRects(clipRectsContext, localPaintingInfo.paintDirtyRect, |
| 997 layerBounds, backgroundRect, foregroundRect, outlineRect, | 996 layerBounds, backgroundRect, foregroundRect, outlineRect, |
| 998 &offsetFromRoot); | 997 &offsetFromRoot); |
| 999 | 998 |
| 1000 bool isPaintingOverlayScrollbars = paintFlags == PaintOverlayScrollbars; | 999 bool isPaintingOverlayScrollbars = paintFlags == PaintOverlayScrollbars; |
| 1001 bool shouldPaintContent = isSelfPaintingLayer() && !isPaintingOverlayScrollb
ars | 1000 bool shouldPaintContent = isSelfPaintingLayer() && !isPaintingOverlayScrollb
ars |
| 1002 && intersectsDamageRect(layerBounds, backgroundRect.rect(), localPaintin
gInfo.rootLayer, &offsetFromRoot); | 1001 && intersectsDamageRect(layerBounds, backgroundRect.rect(), localPaintin
gInfo.rootLayer, &offsetFromRoot); |
| 1003 | 1002 |
| 1004 bool haveTransparency = isTransparent(); | 1003 bool haveTransparency = isTransparent(); |
| 1005 | 1004 |
| 1006 if (filterPainter.haveFilterEffect()) { | 1005 if (filterPainter.haveFilterEffect()) { |
| 1007 ASSERT(this->filterInfo()); | 1006 ASSERT(this->filterInfo()); |
| 1008 | 1007 |
| 1009 if (!rootRelativeBoundsComputed) | 1008 if (!rootRelativeBoundsComputed) |
| 1010 rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndStacki
ngChildren(paintingInfo.rootLayer, offsetFromRoot); | 1009 rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndStacki
ngChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 1011 | 1010 |
| 1012 if (filterPainter.prepareFilterEffect(this, rootRelativeBounds, painting
Info.paintDirtyRect)) { | 1011 if (filterPainter.prepareFilterEffect(this, rootRelativeBounds, painting
Info.paintDirtyRect)) { |
| 1013 | |
| 1014 // Rewire the old context to a memory buffer, so that we can capture
the contents of the layer. | 1012 // Rewire the old context to a memory buffer, so that we can capture
the contents of the layer. |
| 1015 // NOTE: We saved the old context in the "transparencyLayerContext"
local variable, to be able to start a transparency layer | 1013 // NOTE: We saved the old context in the "transparencyLayerContext"
local variable, to be able to start a transparency layer |
| 1016 // on the original context and avoid duplicating "beginFilterEffect"
after each transparency layer call. Also, note that | 1014 // on the original context and avoid duplicating "beginFilterEffect"
after each transparency layer call. Also, note that |
| 1017 // beginTransparencyLayers will only create a single lazy transparen
cy layer, even though it is called twice in this method. | 1015 // beginTransparencyLayers will only create a single lazy transparen
cy layer, even though it is called twice in this method. |
| 1018 // With deferred filters, we don't need a separate context, but we d
o need to do transparency and clipping before starting | 1016 // With deferred filters, we don't need a separate context, but we d
o need to do transparency and clipping before starting |
| 1019 // filter processing. | 1017 // filter processing. |
| 1020 // FIXME: when the legacy path is removed, remove the transparencyLa
yerContext as well. | 1018 // FIXME: when the legacy path is removed, remove the transparencyLa
yerContext as well. |
| 1021 if (deferredFiltersEnabled) { | 1019 if (haveTransparency) { |
| 1022 if (haveTransparency) { | 1020 // If we have a filter and transparency, we have to eagerly star
t a transparency layer here, rather than risk a child layer lazily starts one af
ter filter processing. |
| 1023 // 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. | 1021 beginTransparencyLayers(context, localPaintingInfo.rootLayer, pa
intingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation); |
| 1024 beginTransparencyLayers(context, localPaintingInfo.rootLayer
, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation); | |
| 1025 } | |
| 1026 // We'll handle clipping to the dirty rect before filter rasteri
zation. | |
| 1027 // Filter processing will automatically expand the clip rect and
the offscreen to accommodate any filter outsets. | |
| 1028 // FIXME: It is incorrect to just clip to the damageRect here on
ce multiple fragments are involved. | |
| 1029 clipToRect(localPaintingInfo, context, backgroundRect); | |
| 1030 // Subsequent code should not clip to the dirty rect, since we'v
e already | |
| 1031 // done it above, and doing it later will defeat the outsets. | |
| 1032 localPaintingInfo.clipToDirtyRect = false; | |
| 1033 } | 1022 } |
| 1023 // We'll handle clipping to the dirty rect before filter rasterizati
on. |
| 1024 // Filter processing will automatically expand the clip rect and the
offscreen to accommodate any filter outsets. |
| 1025 // FIXME: It is incorrect to just clip to the damageRect here once m
ultiple fragments are involved. |
| 1026 clipToRect(localPaintingInfo, context, backgroundRect); |
| 1027 // Subsequent code should not clip to the dirty rect, since we've al
ready |
| 1028 // done it above, and doing it later will defeat the outsets. |
| 1029 localPaintingInfo.clipToDirtyRect = false; |
| 1030 |
| 1034 context = filterPainter.beginFilterEffect(context); | 1031 context = filterPainter.beginFilterEffect(context); |
| 1035 | |
| 1036 // Check that we didn't fail to allocate the graphics context for th
e offscreen buffer. | |
| 1037 if (filterPainter.hasStartedFilterEffect() && !deferredFiltersEnable
d) { | |
| 1038 localPaintingInfo.paintDirtyRect = filterPainter.paintInvalidati
onRect(); | |
| 1039 // If the filter needs the full source image, we need to avoid u
sing the clip rectangles. | |
| 1040 // Otherwise, if for example this layer has overflow:hidden, a d
rop shadow will not compute correctly. | |
| 1041 // Note that we will still apply the clipping on the final rende
ring of the filter. | |
| 1042 localPaintingInfo.clipToDirtyRect = !filterRenderer()->hasFilter
ThatMovesPixels(); | |
| 1043 } | |
| 1044 } | 1032 } |
| 1045 } | 1033 } |
| 1046 | 1034 |
| 1047 if (filterPainter.hasStartedFilterEffect() && haveTransparency && !deferredF
iltersEnabled) { | |
| 1048 // If we have a filter and transparency, we have to eagerly start a tran
sparency layer here, rather than risk a child layer lazily starts one with the w
rong context. | |
| 1049 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo.root
Layer, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation); | |
| 1050 } | |
| 1051 | |
| 1052 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which | 1035 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which |
| 1053 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). | 1036 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). |
| 1054 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along | 1037 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along |
| 1055 // so it will be tested against as we descend through the renderers. | 1038 // so it will be tested against as we descend through the renderers. |
| 1056 RenderObject* paintingRootForRenderer = 0; | 1039 RenderObject* paintingRootForRenderer = 0; |
| 1057 if (localPaintingInfo.paintingRoot && !renderer()->isDescendantOf(localPaint
ingInfo.paintingRoot)) | 1040 if (localPaintingInfo.paintingRoot && !renderer()->isDescendantOf(localPaint
ingInfo.paintingRoot)) |
| 1058 paintingRootForRenderer = localPaintingInfo.paintingRoot; | 1041 paintingRootForRenderer = localPaintingInfo.paintingRoot; |
| 1059 | 1042 |
| 1060 LayoutPoint layerLocation = toPoint(layerBounds.location() - renderBoxLocati
on() + localPaintingInfo.subPixelAccumulation); | 1043 LayoutPoint layerLocation = toPoint(layerBounds.location() - renderBoxLocati
on() + localPaintingInfo.subPixelAccumulation); |
| 1061 | 1044 |
| 1062 if (shouldPaintContent) { | 1045 if (shouldPaintContent) { |
| 1063 paintBackground(context, transparencyLayerContext, paintingInfo.paintDir
tyRect, haveTransparency, | 1046 paintBackground(context, transparencyLayerContext, paintingInfo.paintDir
tyRect, haveTransparency, |
| 1064 localPaintingInfo, paintingRootForRenderer, layerLocation, backgroun
dRect); | 1047 localPaintingInfo, paintingRootForRenderer, layerLocation, backgroun
dRect); |
| 1065 } | 1048 } |
| 1066 | 1049 |
| 1067 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFlags); | 1050 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFlags); |
| 1068 | 1051 |
| 1069 if (shouldPaintContent) { | 1052 if (shouldPaintContent) { |
| 1070 paintForeground(context, transparencyLayerContext, paintingInfo.paintDir
tyRect, haveTransparency, | 1053 paintForeground(context, transparencyLayerContext, paintingInfo.paintDir
tyRect, haveTransparency, |
| 1071 localPaintingInfo, paintingRootForRenderer, layerLocation, foregroun
dRect); | 1054 localPaintingInfo, paintingRootForRenderer, layerLocation, foregroun
dRect); |
| 1072 } | 1055 } |
| 1073 | 1056 |
| 1074 paintOutline(context, localPaintingInfo, paintingRootForRenderer, layerLocat
ion, outlineRect); | 1057 paintOutline(context, localPaintingInfo, paintingRootForRenderer, layerLocat
ion, outlineRect); |
| 1075 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting
Info, paintFlags); | 1058 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting
Info, paintFlags); |
| 1076 | 1059 |
| 1077 if (isPaintingOverlayScrollbars) | 1060 if (isPaintingOverlayScrollbars) |
| 1078 paintOverflowControls(context, localPaintingInfo, layerLocation, backgro
undRect); | 1061 paintOverflowControls(context, localPaintingInfo, layerLocation, backgro
undRect); |
| 1079 | 1062 |
| 1080 if (filterPainter.hasStartedFilterEffect()) { | 1063 if (filterPainter.hasStartedFilterEffect()) { |
| 1081 // Apply the correct clipping (ie. overflow: hidden). | |
| 1082 // FIXME: It is incorrect to just clip to the damageRect here once multi
ple fragments are involved. | |
| 1083 if (!deferredFiltersEnabled) | |
| 1084 clipToRect(localPaintingInfo, transparencyLayerContext, backgroundRe
ct); | |
| 1085 | |
| 1086 context = filterPainter.applyFilterEffect(); | 1064 context = filterPainter.applyFilterEffect(); |
| 1087 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect,
backgroundRect); | 1065 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect,
backgroundRect); |
| 1088 } | 1066 } |
| 1089 | 1067 |
| 1090 // Make sure that we now use the original transparency context. | 1068 // Make sure that we now use the original transparency context. |
| 1091 ASSERT(transparencyLayerContext == context); | 1069 ASSERT(transparencyLayerContext == context); |
| 1092 | 1070 |
| 1093 if (shouldPaintContent && renderer()->hasMask()) | 1071 if (shouldPaintContent && renderer()->hasMask()) |
| 1094 paintMask(context, localPaintingInfo, paintingRootForRenderer, layerLoca
tion, backgroundRect); | 1072 paintMask(context, localPaintingInfo, paintingRootForRenderer, layerLoca
tion, backgroundRect); |
| 1095 | 1073 |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 } | 1941 } |
| 1964 } | 1942 } |
| 1965 | 1943 |
| 1966 void showLayerTree(const blink::RenderObject* renderer) | 1944 void showLayerTree(const blink::RenderObject* renderer) |
| 1967 { | 1945 { |
| 1968 if (!renderer) | 1946 if (!renderer) |
| 1969 return; | 1947 return; |
| 1970 showLayerTree(renderer->enclosingLayer()); | 1948 showLayerTree(renderer->enclosingLayer()); |
| 1971 } | 1949 } |
| 1972 #endif | 1950 #endif |
| OLD | NEW |