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

Unified Diff: Source/core/paint/PartPainter.cpp

Issue 865353002: Implement clip and scroll DisplayItems for PartPainter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: de-dupe clipRoundedInnerRect Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/paint/PartPainter.cpp
diff --git a/Source/core/paint/PartPainter.cpp b/Source/core/paint/PartPainter.cpp
index 7885c125eeb875e13689b417ec8e5db70918e048..6ff60017973ea17ae80bbc9bfe936d7e3a813eb5 100644
--- a/Source/core/paint/PartPainter.cpp
+++ b/Source/core/paint/PartPainter.cpp
@@ -6,9 +6,11 @@
#include "core/paint/PartPainter.h"
#include "core/paint/BoxPainter.h"
-
#include "core/paint/GraphicsContextAnnotator.h"
+#include "core/paint/RenderDrawingRecorder.h"
+#include "core/paint/RoundedInnerRectClipper.h"
#include "core/paint/ScrollableAreaPainter.h"
+#include "core/paint/TransformRecorder.h"
#include "core/rendering/PaintInfo.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderPart.h"
@@ -23,6 +25,7 @@ void PartPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs
return;
LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location();
+ LayoutRect borderRect(adjustedPaintOffset, m_renderPart.size());
if (m_renderPart.hasBoxDecorationBackground() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
BoxPainter(m_renderPart).paintBoxDecorationBackground(paintInfo, adjustedPaintOffset);
@@ -33,35 +36,29 @@ void PartPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs
}
if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && m_renderPart.style()->hasOutline())
- ObjectPainter(m_renderPart).paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, m_renderPart.size()));
+ ObjectPainter(m_renderPart).paintOutline(paintInfo, borderRect);
if (paintInfo.phase != PaintPhaseForeground)
return;
+ OwnPtr<RoundedInnerRectClipper> clipper;
if (m_renderPart.style()->hasBorderRadius()) {
- LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_renderPart.size());
-
- if (borderRect.isEmpty())
- return;
-
- // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
- paintInfo.context->save();
FloatRoundedRect roundedInnerRect = m_renderPart.style()->getRoundedInnerBorderFor(borderRect,
m_renderPart.paddingTop() + m_renderPart.borderTop(), m_renderPart.paddingBottom() + m_renderPart.borderBottom(), m_renderPart.paddingLeft() + m_renderPart.borderLeft(), m_renderPart.paddingRight() + m_renderPart.borderRight(), true, true);
- BoxPainter::clipRoundedInnerRect(paintInfo.context, borderRect, roundedInnerRect);
+ clipper = adoptPtr(new RoundedInnerRectClipper(m_renderPart, paintInfo, borderRect, roundedInnerRect, ApplyToDisplayListIfEnabled));
}
if (m_renderPart.widget())
m_renderPart.paintContents(paintInfo, paintOffset);
-
- if (m_renderPart.style()->hasBorderRadius())
- paintInfo.context->restore();
+ clipper.clear();
// Paint a partially transparent wash over selected widgets.
if (m_renderPart.isSelected() && !m_renderPart.document().printing()) {
LayoutRect rect = m_renderPart.localSelectionRect();
rect.moveBy(adjustedPaintOffset);
- paintInfo.context->fillRect(pixelSnappedIntRect(rect), m_renderPart.selectionBackgroundColor());
+ IntRect selectionRect = pixelSnappedIntRect(rect);
+ RenderDrawingRecorder recorder(paintInfo.context, m_renderPart, paintInfo.phase, selectionRect);
+ paintInfo.context->fillRect(selectionRect, m_renderPart.selectionBackgroundColor());
}
if (m_renderPart.canResize())
@@ -85,14 +82,9 @@ void PartPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& p
IntSize widgetPaintOffset = paintLocation - widgetLocation;
// When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
// not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing.
- if (!widgetPaintOffset.isZero()) {
- paintInfo.context->translate(widgetPaintOffset.width(), widgetPaintOffset.height());
- paintRect.move(-widgetPaintOffset);
- }
+ TransformRecorder transform(*paintInfo.context, m_renderPart.displayItemClient(),
+ AffineTransform::translation(widgetPaintOffset.width(), widgetPaintOffset.height()));
widget->paint(paintInfo.context, paintRect);
-
- if (!widgetPaintOffset.isZero())
- paintInfo.context->translate(-widgetPaintOffset.width(), -widgetPaintOffset.height());
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698