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

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

Issue 799563002: Use DrawingRecorder::canUseCachedDrawing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 side-by-side diff with in-line comments
Download patch
Index: Source/core/paint/ImagePainter.cpp
diff --git a/Source/core/paint/ImagePainter.cpp b/Source/core/paint/ImagePainter.cpp
index f4388257d6c5f8bb97f712a37fc636ecb5e4f560..33c8853ba0ba25f560802dbf8eeee306130f1042 100644
--- a/Source/core/paint/ImagePainter.cpp
+++ b/Source/core/paint/ImagePainter.cpp
@@ -64,7 +64,10 @@ void ImagePainter::paintAreaElementFocusRing(const PaintInfo& paintInfo)
// https://crbug.com/251206
GraphicsContextStateSaver savedContext(*paintInfo.context);
IntRect focusRect = m_renderImage.absoluteContentBox();
- RenderDrawingRecorder recorder(paintInfo.context, &m_renderImage, paintInfo.phase, focusRect);
+ RenderDrawingRecorder recorder(paintInfo.context, m_renderImage, paintInfo.phase, focusRect);
+ if (recorder.canUseCachedDrawing())
+ return;
+
paintInfo.context->clip(focusRect);
paintInfo.context->drawFocusRing(path, outlineWidth,
areaElementStyle->outlineOffset(),
@@ -85,18 +88,27 @@ void ImagePainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint&
if (cWidth > 2 && cHeight > 2) {
// Draw an outline rect where the image should be.
IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset.x() + m_renderImage.borderLeft() + m_renderImage.paddingLeft(), paintOffset.y() + m_renderImage.borderTop() + m_renderImage.paddingTop(), cWidth, cHeight));
- RenderDrawingRecorder recorder(context, &m_renderImage, paintInfo.phase, paintRect);
+ RenderDrawingRecorder recorder(context, m_renderImage, paintInfo.phase, paintRect);
+ if (recorder.canUseCachedDrawing())
+ return;
+
context->setStrokeStyle(SolidStroke);
context->setStrokeColor(Color::lightGray);
context->setFillColor(Color::transparent);
context->drawRect(paintRect);
}
- } else if (cWidth > 0 && cHeight > 0) {
chrishtr 2014/12/12 00:18:08 Why the change to get rid of the else clause?
Xianzhu 2014/12/12 00:56:49 Restored.
+ return;
+ }
+
+ if (cWidth > 0 && cHeight > 0) {
LayoutRect contentRect = m_renderImage.contentBoxRect();
contentRect.moveBy(paintOffset);
LayoutRect paintRect = m_renderImage.replacedContentRect();
paintRect.moveBy(paintOffset);
- RenderDrawingRecorder recorder(context, &m_renderImage, paintInfo.phase, contentRect);
+ RenderDrawingRecorder recorder(context, m_renderImage, paintInfo.phase, contentRect);
+ if (recorder.canUseCachedDrawing())
+ return;
+
bool clip = !contentRect.contains(paintRect);
if (clip) {
context->save();

Powered by Google App Engine
This is Rietveld 408576698