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

Side by Side Diff: third_party/WebKit/Source/core/paint/BoxPainter.cpp

Issue 1391753005: (WIP) Invalidation during painting (for synchronized painting) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 "core/paint/BoxPainter.h" 5 #include "core/paint/BoxPainter.h"
6 6
7 #include "core/HTMLNames.h" 7 #include "core/HTMLNames.h"
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/html/HTMLFrameOwnerElement.h" 9 #include "core/html/HTMLFrameOwnerElement.h"
10 #include "core/layout/ImageQualityController.h" 10 #include "core/layout/ImageQualityController.h"
(...skipping 20 matching lines...) Expand all
31 #include "platform/geometry/LayoutRectOutsets.h" 31 #include "platform/geometry/LayoutRectOutsets.h"
32 #include "platform/graphics/GraphicsContextStateSaver.h" 32 #include "platform/graphics/GraphicsContextStateSaver.h"
33 #include "platform/graphics/paint/CompositingDisplayItem.h" 33 #include "platform/graphics/paint/CompositingDisplayItem.h"
34 #include "wtf/Optional.h" 34 #include "wtf/Optional.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 void BoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffse t) 38 void BoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffse t)
39 { 39 {
40 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBox.location(); 40 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBox.location();
41
41 // Default implementation. Just pass paint through to the children. 42 // Default implementation. Just pass paint through to the children.
42 PaintInfo childInfo(paintInfo); 43 PaintInfo childInfo(paintInfo);
43 for (LayoutObject* child = m_layoutBox.slowFirstChild(); child; child = chil d->nextSibling()) 44 for (LayoutObject* child = m_layoutBox.slowFirstChild(); child; child = chil d->nextSibling())
44 child->paint(childInfo, adjustedPaintOffset); 45 child->paint(childInfo, adjustedPaintOffset);
45 } 46 }
46 47
47 void BoxPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 48 void BoxPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
48 { 49 {
49 LayoutRect paintRect = m_layoutBox.borderBoxRect(); 50 LayoutRect paintRect = m_layoutBox.borderBoxRect();
50 paintRect.moveBy(paintOffset); 51 paintRect.moveBy(paintOffset);
(...skipping 20 matching lines...) Expand all
71 void BoxPainter::paintBoxDecorationBackgroundWithRect(const PaintInfo& paintInfo , const LayoutPoint& paintOffset, const LayoutRect& paintRect) 72 void BoxPainter::paintBoxDecorationBackgroundWithRect(const PaintInfo& paintInfo , const LayoutPoint& paintOffset, const LayoutRect& paintRect)
72 { 73 {
73 const ComputedStyle& style = m_layoutBox.styleRef(); 74 const ComputedStyle& style = m_layoutBox.styleRef();
74 75
75 // FIXME: For now we don't have notification on media buffered range change from media player 76 // FIXME: For now we don't have notification on media buffered range change from media player
76 // and miss paint invalidation on buffered range change. crbug.com/484288. 77 // and miss paint invalidation on buffered range change. crbug.com/484288.
77 Optional<DisplayItemCacheSkipper> cacheSkipper; 78 Optional<DisplayItemCacheSkipper> cacheSkipper;
78 if (style.appearance() == MediaSliderPart) 79 if (style.appearance() == MediaSliderPart)
79 cacheSkipper.emplace(paintInfo.context); 80 cacheSkipper.emplace(paintInfo.context);
80 81
81 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutBox, DisplayItem::BoxDecorationBackground, paintOffset)) 82 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutBox, DisplayItem::BoxDecorationBackground))
82 return; 83 return;
83 84
84 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, Display Item::BoxDecorationBackground, boundsForDrawingRecorder(paintOffset), paintOffse t); 85 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, Display Item::BoxDecorationBackground, boundsForDrawingRecorder(paintOffset));
85 86
86 BoxDecorationData boxDecorationData(m_layoutBox); 87 BoxDecorationData boxDecorationData(m_layoutBox);
87 88
88 // FIXME: Should eventually give the theme control over whether the box shad ow should paint, since controls could have 89 // FIXME: Should eventually give the theme control over whether the box shad ow should paint, since controls could have
89 // custom shadows of their own. 90 // custom shadows of their own.
90 if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee dAvoidance)) 91 if (!m_layoutBox.boxShadowShouldBeAppliedToBackground(boxDecorationData.blee dAvoidance))
91 paintBoxShadow(paintInfo, paintRect, style, Normal); 92 paintBoxShadow(paintInfo, paintRect, style, Normal);
92 93
93 GraphicsContextStateSaver stateSaver(paintInfo.context, false); 94 GraphicsContextStateSaver stateSaver(paintInfo.context, false);
94 if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) { 95 if (bleedAvoidanceIsClipping(boxDecorationData.bleedAvoidance)) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 context.endLayer(); 482 context.endLayer();
482 context.endLayer(); 483 context.endLayer();
483 } 484 }
484 } 485 }
485 486
486 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) 487 void BoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
487 { 488 {
488 if (m_layoutBox.style()->visibility() != VISIBLE || paintInfo.phase != Paint PhaseMask) 489 if (m_layoutBox.style()->visibility() != VISIBLE || paintInfo.phase != Paint PhaseMask)
489 return; 490 return;
490 491
491 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutBox, paintInfo.phase, paintOffset)) 492 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutBox, paintInfo.phase))
492 return; 493 return;
493 494
494 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect()); 495 LayoutRect visualOverflowRect(m_layoutBox.visualOverflowRect());
495 visualOverflowRect.moveBy(paintOffset); 496 visualOverflowRect.moveBy(paintOffset);
496 497
497 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, paintIn fo.phase, visualOverflowRect, paintOffset); 498 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBox, paintIn fo.phase, visualOverflowRect);
498 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size()); 499 LayoutRect paintRect = LayoutRect(paintOffset, m_layoutBox.size());
499 paintMaskImages(paintInfo, paintRect); 500 paintMaskImages(paintInfo, paintRect);
500 } 501 }
501 502
502 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p aintRect) 503 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p aintRect)
503 { 504 {
504 // Figure out if we need to push a transparency layer to render our mask. 505 // Figure out if we need to push a transparency layer to render our mask.
505 bool pushTransparencyLayer = false; 506 bool pushTransparencyLayer = false;
506 bool compositedMask = m_layoutBox.hasLayer() && m_layoutBox.layer()->hasComp ositedMask(); 507 bool compositedMask = m_layoutBox.hasLayer() && m_layoutBox.layer()->hasComp ositedMask();
507 bool flattenCompositingLayers = paintInfo.globalPaintFlags() & GlobalPaintFl attenCompositingLayers; 508 bool flattenCompositingLayers = paintInfo.globalPaintFlags() & GlobalPaintFl attenCompositingLayers;
(...skipping 26 matching lines...) Expand all
534 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint & paintOffset) 535 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint & paintOffset)
535 { 536 {
536 ASSERT(paintInfo.phase == PaintPhaseClippingMask); 537 ASSERT(paintInfo.phase == PaintPhaseClippingMask);
537 538
538 if (m_layoutBox.style()->visibility() != VISIBLE) 539 if (m_layoutBox.style()->visibility() != VISIBLE)
539 return; 540 return;
540 541
541 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint sIntoOwnBacking) 542 if (!m_layoutBox.layer() || m_layoutBox.layer()->compositingState() != Paint sIntoOwnBacking)
542 return; 543 return;
543 544
544 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutBox, paintInfo.phase, paintOffset)) 545 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutBox, paintInfo.phase))
545 return; 546 return;
546 547
547 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox. size())); 548 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset, m_layoutBox. size()));
548 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutBox, paintInfo.phase, paintRect, paintOffset); 549 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutBox, paintInfo.phase, paintRect);
549 paintInfo.context.fillRect(paintRect, Color::black); 550 paintInfo.context.fillRect(paintRect, Color::black);
550 } 551 }
551 552
552 InterpolationQuality BoxPainter::chooseInterpolationQuality(const LayoutObject& obj, Image* image, const void* layer, const LayoutSize& size) 553 InterpolationQuality BoxPainter::chooseInterpolationQuality(const LayoutObject& obj, Image* image, const void* layer, const LayoutSize& size)
553 { 554 {
554 return ImageQualityController::imageQualityController()->chooseInterpolation Quality(obj, image, layer, size); 555 return ImageQualityController::imageQualityController()->chooseInterpolation Quality(obj, image, layer, size);
555 } 556 }
556 557
557 bool BoxPainter::paintNinePieceImage(const LayoutBoxModelObject& obj, GraphicsCo ntext& graphicsContext, const LayoutRect& rect, const ComputedStyle& style, cons t NinePieceImage& ninePieceImage, SkXfermode::Mode op) 558 bool BoxPainter::paintNinePieceImage(const LayoutBoxModelObject& obj, GraphicsCo ntext& graphicsContext, const LayoutRect& rect, const ComputedStyle& style, cons t NinePieceImage& ninePieceImage, SkXfermode::Mode op)
558 { 559 {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 691 }
691 } 692 }
692 693
693 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle& style, const Document& document) 694 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle& style, const Document& document)
694 { 695 {
695 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc onomy 696 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc onomy
696 && (!document.settings() || !document.settings()->shouldPrintBackgrounds ()); 697 && (!document.settings() || !document.settings()->shouldPrintBackgrounds ());
697 } 698 }
698 699
699 } // namespace blink 700 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BlockPainter.cpp ('k') | third_party/WebKit/Source/core/paint/DetailsMarkerPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698