Commit 745db6cd authored by chrishtr@chromium.org's avatar chrishtr@chromium.org

Actually paint squashed layers when printing.

BUG=391662

Review URL: https://codereview.chromium.org/408543002

git-svn-id: svn://svn.chromium.org/blink/trunk@178532 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4327af30
crbug.com/391662 compositing/squashing/squashing-print.html [ NeedsRebaseline ]
crbug.com/391662 virtual/softwarecompositing/squashing/squashing-print.html [ NeedsRebaseline ]
# This directly has manual tests that don't have to run with run-webkit-tests # This directly has manual tests that don't have to run with run-webkit-tests
crbug.com/359838 http/tests/ManualTests/ [ Skip ] crbug.com/359838 http/tests/ManualTests/ [ Skip ]
......
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.setPrinting();
</script>
<div style="width: 100px; height: 100px; border: 1px solid black; transform: translateZ(0)"></div>
<div style="position: absolute; top: 50px; left: 50px; width: 100px; height: 100px; border: 1px solid black"></div>
\ No newline at end of file
layer at (0,0) size 1000x152
RenderView at (0,0) size 1000x118
layer at (0,0) size 800x118
RenderBlock {HTML} at (0,0) size 800x118
RenderBody {BODY} at (8,8) size 784x102
layer at (8,8) size 102x102
RenderBlock {DIV} at (0,0) size 102x102 [border: (1px solid #000000)]
layer at (50,50) size 102x102
RenderBlock (positioned) {DIV} at (50,50) size 102x102 [border: (1px solid #000000)]
...@@ -1575,7 +1575,8 @@ void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect, ...@@ -1575,7 +1575,8 @@ void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect,
OverlapTestRequestMap overlapTestRequests; OverlapTestRequestMap overlapTestRequests;
LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBehavior, LayoutSize(), paintingRoot, &overlapTestRequests); LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBehavior, LayoutSize(), paintingRoot, &overlapTestRequests);
paintLayer(context, paintingInfo, paintFlags); if (shouldPaintLayerInSoftwareMode(context, paintingInfo, paintFlags))
paintLayer(context, paintingInfo, paintFlags);
OverlapTestRequestMap::iterator end = overlapTestRequests.end(); OverlapTestRequestMap::iterator end = overlapTestRequests.end();
for (OverlapTestRequestMap::iterator it = overlapTestRequests.begin(); it != end; ++it) for (OverlapTestRequestMap::iterator it = overlapTestRequests.begin(); it != end; ++it)
...@@ -1662,11 +1663,6 @@ static void performOverlapTests(OverlapTestRequestMap& overlapTestRequests, cons ...@@ -1662,11 +1663,6 @@ static void performOverlapTests(OverlapTestRequestMap& overlapTestRequests, cons
overlapTestRequests.removeAll(overlappedRequestClients); overlapTestRequests.removeAll(overlappedRequestClients);
} }
static bool shouldDoSoftwarePaint(const RenderLayer* layer, bool paintingReflection)
{
return paintingReflection && !layer->has3DTransform();
}
static inline bool shouldSuppressPaintingLayer(RenderLayer* layer) static inline bool shouldSuppressPaintingLayer(RenderLayer* layer)
{ {
// Avoid painting descendants of the root layer when stylesheets haven't loaded. This eliminates FOUC. // Avoid painting descendants of the root layer when stylesheets haven't loaded. This eliminates FOUC.
...@@ -1693,17 +1689,13 @@ void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& ...@@ -1693,17 +1689,13 @@ void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
// https://code.google.com/p/chromium/issues/detail?id=343772 // https://code.google.com/p/chromium/issues/detail?id=343772
DisableCompositingQueryAsserts disabler; DisableCompositingQueryAsserts disabler;
if (compositingState() != NotComposited && compositingState() != PaintsIntoGroupedBacking) { if (compositingState() != NotComposited) {
// The updatingControlTints() painting pass goes through compositing layers,
// but we need to ensure that we don't cache clip rects computed with the wrong root in this case.
if (context->updatingControlTints() || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers)) { if (context->updatingControlTints() || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers)) {
// The updatingControlTints() painting pass goes through compositing layers,
// but we need to ensure that we don't cache clip rects computed with the wrong root in this case.
// FIXME: ok, but what about PaintBehaviorFlattenCompositingLayers? That's for printing.
// FIXME: why isn't the code here global, as opposed to being set on each paintLayer() call?
paintFlags |= PaintLayerUncachedClipRects; paintFlags |= PaintLayerUncachedClipRects;
} else if (!compositedLayerMapping()->paintsIntoCompositedAncestor()
&& !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingReflection)
&& !paintForFixedRootBackground(this, paintFlags)) {
// If this RenderLayer should paint into its own backing, that will be done via CompositedLayerMapping::paintContents()
// and CompositedLayerMapping::doPaintTask().
return;
} }
} else if (viewportConstrainedNotCompositedReason() == NotCompositedForBoundsOutOfView) { } else if (viewportConstrainedNotCompositedReason() == NotCompositedForBoundsOutOfView) {
// Don't paint out-of-view viewport constrained layers (when doing prepainting) because they will never be visible // Don't paint out-of-view viewport constrained layers (when doing prepainting) because they will never be visible
...@@ -2033,6 +2025,18 @@ void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const ...@@ -2033,6 +2025,18 @@ void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const
paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags); paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags);
} }
bool RenderLayer::shouldPaintLayerInSoftwareMode(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
{
DisableCompositingQueryAsserts disabler;
return compositingState() == NotComposited
|| compositingState() == HasOwnBackingButPaintsIntoAncestor
|| context->updatingControlTints()
|| (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers)
|| ((paintFlags & PaintLayerPaintingReflection) && !has3DTransform())
|| paintForFixedRootBackground(this, paintFlags);
}
void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
{ {
if (!hasSelfPaintingLayerDescendant()) if (!hasSelfPaintingLayerDescendant())
...@@ -2045,9 +2049,9 @@ void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* conte ...@@ -2045,9 +2049,9 @@ void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* conte
RenderLayerStackingNodeIterator iterator(*m_stackingNode, childrenToVisit); RenderLayerStackingNodeIterator iterator(*m_stackingNode, childrenToVisit);
while (RenderLayerStackingNode* child = iterator.next()) { while (RenderLayerStackingNode* child = iterator.next()) {
RenderLayer* childLayer = child->layer(); RenderLayer* childLayer = child->layer();
// If this RenderLayer should paint into its own backing or a grouped backing, that will be done via CompositedLayerMapping::paintContents()
// Squashed RenderLayers should not paint into their ancestor. // and CompositedLayerMapping::doPaintTask().
if (childLayer->compositingState() == PaintsIntoGroupedBacking) if (!childLayer->shouldPaintLayerInSoftwareMode(context, paintingInfo, paintFlags))
continue; continue;
if (!childLayer->isPaginated()) if (!childLayer->isPaginated())
......
...@@ -579,6 +579,11 @@ private: ...@@ -579,6 +579,11 @@ private:
void paintLayerContentsAndReflection(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags); void paintLayerContentsAndReflection(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags);
void paintLayerByApplyingTransform(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags, const LayoutPoint& translationOffset = LayoutPoint()); void paintLayerByApplyingTransform(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags, const LayoutPoint& translationOffset = LayoutPoint());
// Returns whether this layer should be painted during sofware painting (i.e., not via calls from CompositedLayerMapping to draw into composited
// layers).
bool shouldPaintLayerInSoftwareMode(GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags paintFlags);
void paintChildren(unsigned childrenToVisit, GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags); void paintChildren(unsigned childrenToVisit, GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags);
void paintPaginatedChildLayer(RenderLayer* childLayer, GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags); void paintPaginatedChildLayer(RenderLayer* childLayer, GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags);
void paintChildLayerIntoColumns(RenderLayer* childLayer, GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags, const Vector<RenderLayer*>& columnLayers, size_t columnIndex); void paintChildLayerIntoColumns(RenderLayer* childLayer, GraphicsContext*, const LayerPaintingInfo&, PaintLayerFlags, const Vector<RenderLayer*>& columnLayers, size_t columnIndex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment