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

Side by Side Diff: Source/core/paint/ObjectPainter.cpp

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « Source/core/paint/MultiColumnSetPainter.cpp ('k') | Source/core/paint/PartPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/ObjectPainter.h" 6 #include "core/paint/ObjectPainter.h"
7 7
8 #include "core/layout/LayoutObject.h" 8 #include "core/layout/LayoutObject.h"
9 #include "core/layout/LayoutTheme.h" 9 #include "core/layout/LayoutTheme.h"
10 #include "core/paint/BoxBorderPainter.h" 10 #include "core/paint/BoxBorderPainter.h"
(...skipping 21 matching lines...) Expand all
32 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i])); 32 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i]));
33 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor) ); 33 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor) );
34 } 34 }
35 35
36 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& o bjectBounds, const LayoutRect& visualOverflowBounds) 36 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& o bjectBounds, const LayoutRect& visualOverflowBounds)
37 { 37 {
38 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); 38 const ComputedStyle& styleToUse = m_layoutObject.styleRef();
39 if (!styleToUse.hasOutline()) 39 if (!styleToUse.hasOutline())
40 return; 40 return;
41 41
42 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, paintInfo.phase))
43 return;
44
42 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai ntInfo.phase, visualOverflowBounds); 45 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai ntInfo.phase, visualOverflowBounds);
43 if (recorder.canUseCachedDrawing())
44 return;
45 46
46 if (styleToUse.outlineStyleIsAuto()) { 47 if (styleToUse.outlineStyleIsAuto()) {
47 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) { 48 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) {
48 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring. 49 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
49 Vector<LayoutRect> focusRingRects; 50 Vector<LayoutRect> focusRingRects;
50 m_layoutObject.addFocusRingRects(focusRingRects, objectBounds.locati on()); 51 m_layoutObject.addFocusRingRects(focusRingRects, objectBounds.locati on());
51 paintFocusRing(paintInfo, styleToUse, focusRingRects); 52 paintFocusRing(paintInfo, styleToUse, focusRingRects);
52 } 53 }
53 return; 54 return;
54 } 55 }
(...skipping 22 matching lines...) Expand all
77 KURL url = toElement(m_layoutObject.node())->hrefURL(); 78 KURL url = toElement(m_layoutObject.node())->hrefURL();
78 if (!url.isValid()) 79 if (!url.isValid())
79 return; 80 return;
80 81
81 Vector<LayoutRect> focusRingRects; 82 Vector<LayoutRect> focusRingRects;
82 m_layoutObject.addFocusRingRects(focusRingRects, paintOffset); 83 m_layoutObject.addFocusRingRects(focusRingRects, paintOffset);
83 IntRect rect = pixelSnappedIntRect(unionRect(focusRingRects)); 84 IntRect rect = pixelSnappedIntRect(unionRect(focusRingRects));
84 if (rect.isEmpty()) 85 if (rect.isEmpty())
85 return; 86 return;
86 87
87 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, Dis playItem::PrintedContentPDFURLRect, rect); 88 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, DisplayItem::PrintedContentPDFURLRect))
88 if (recorder.canUseCachedDrawing())
89 return; 89 return;
90 90
91 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, Dis playItem::PrintedContentPDFURLRect, rect);
91 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la youtObject.document().baseURL())) { 92 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la youtObject.document().baseURL())) {
92 String fragmentName = url.fragmentIdentifier(); 93 String fragmentName = url.fragmentIdentifier();
93 if (m_layoutObject.document().findAnchor(fragmentName)) 94 if (m_layoutObject.document().findAnchor(fragmentName))
94 paintInfo.context->setURLFragmentForRect(fragmentName, rect); 95 paintInfo.context->setURLFragmentForRect(fragmentName, rect);
95 return; 96 return;
96 } 97 }
97 paintInfo.context->setURLForRect(url, rect); 98 paintInfo.context->setURLForRect(url, rect);
98 } 99 }
99 100
100 void ObjectPainter::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2, 101 void ObjectPainter::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2,
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); 341 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0));
341 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); 342 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0));
342 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); 343 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0));
343 break; 344 break;
344 } 345 }
345 346
346 graphicsContext->fillPolygon(4, quad, color, antialias); 347 graphicsContext->fillPolygon(4, quad, color, antialias);
347 } 348 }
348 349
349 } // namespace blink 350 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/MultiColumnSetPainter.cpp ('k') | Source/core/paint/PartPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698