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

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

Issue 900463002: Make SVG painting independent of GraphicsContext's alpha state (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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 "config.h" 5 #include "config.h"
6 #include "core/paint/SVGRootInlineBoxPainter.h" 6 #include "core/paint/SVGRootInlineBoxPainter.h"
7 7
8 #include "core/paint/RenderDrawingRecorder.h" 8 #include "core/paint/RenderDrawingRecorder.h"
9 #include "core/paint/SVGInlineFlowBoxPainter.h" 9 #include "core/paint/SVGInlineFlowBoxPainter.h"
10 #include "core/paint/SVGInlineTextBoxPainter.h" 10 #include "core/paint/SVGInlineTextBoxPainter.h"
11 #include "core/rendering/PaintInfo.h" 11 #include "core/rendering/PaintInfo.h"
12 #include "core/rendering/svg/SVGInlineFlowBox.h" 12 #include "core/rendering/svg/SVGInlineFlowBox.h"
13 #include "core/rendering/svg/SVGInlineTextBox.h" 13 #include "core/rendering/svg/SVGInlineTextBox.h"
14 #include "core/rendering/svg/SVGRenderingContext.h" 14 #include "core/rendering/svg/SVGRenderingContext.h"
15 #include "core/rendering/svg/SVGRootInlineBox.h" 15 #include "core/rendering/svg/SVGRootInlineBox.h"
16 #include "platform/graphics/GraphicsContextStateSaver.h"
17 16
18 namespace blink { 17 namespace blink {
19 18
20 void SVGRootInlineBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin t& paintOffset) 19 void SVGRootInlineBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin t& paintOffset)
21 { 20 {
22 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh aseSelection); 21 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh aseSelection);
23 22
24 bool isPrinting = m_svgRootInlineBox.renderer().document().printing(); 23 bool isPrinting = m_svgRootInlineBox.renderer().document().printing();
25 bool hasSelection = !isPrinting && m_svgRootInlineBox.selectionState() != Re nderObject::SelectionNone; 24 bool hasSelection = !isPrinting && m_svgRootInlineBox.selectionState() != Re nderObject::SelectionNone;
26 25
27 PaintInfo paintInfoBeforeFiltering(paintInfo); 26 PaintInfo paintInfoBeforeFiltering(paintInfo);
28 if (hasSelection) { 27 if (hasSelection) {
29 RenderDrawingRecorder recorder(paintInfoBeforeFiltering.context, m_svgRo otInlineBox.renderer(), paintInfoBeforeFiltering.phase, paintInfoBeforeFiltering .rect); 28 RenderDrawingRecorder recorder(paintInfoBeforeFiltering.context, m_svgRo otInlineBox.renderer(), paintInfoBeforeFiltering.phase, paintInfoBeforeFiltering .rect);
30 if (!recorder.canUseCachedDrawing()) { 29 if (!recorder.canUseCachedDrawing()) {
31 for (InlineBox* child = m_svgRootInlineBox.firstChild(); child; chil d = child->nextOnLine()) { 30 for (InlineBox* child = m_svgRootInlineBox.firstChild(); child; chil d = child->nextOnLine()) {
32 if (child->isSVGInlineTextBox()) 31 if (child->isSVGInlineTextBox())
33 SVGInlineTextBoxPainter(*toSVGInlineTextBox(child)).paintSel ectionBackground(paintInfoBeforeFiltering); 32 SVGInlineTextBoxPainter(*toSVGInlineTextBox(child)).paintSel ectionBackground(paintInfoBeforeFiltering);
34 else if (child->isSVGInlineFlowBox()) 33 else if (child->isSVGInlineFlowBox())
35 SVGInlineFlowBoxPainter(*toSVGInlineFlowBox(child)).paintSel ectionBackground(paintInfoBeforeFiltering); 34 SVGInlineFlowBoxPainter(*toSVGInlineFlowBox(child)).paintSel ectionBackground(paintInfoBeforeFiltering);
36 } 35 }
37 } 36 }
38 } 37 }
39 38
40 // FIXME: Remove this state saver when SVGRenderSupport::updateGraphicsConte xt
41 // no longer affects the global alpha state. See crbug.com/453225
42 GraphicsContextStateSaver stateSaver(*paintInfoBeforeFiltering.context);
43
44 SVGRenderingContext renderingContext(m_svgRootInlineBox.renderer(), paintInf oBeforeFiltering); 39 SVGRenderingContext renderingContext(m_svgRootInlineBox.renderer(), paintInf oBeforeFiltering);
45 if (renderingContext.applyClipMaskAndFilterIfNecessary()) { 40 if (renderingContext.applyClipMaskAndFilterIfNecessary()) {
46 for (InlineBox* child = m_svgRootInlineBox.firstChild(); child; child = child->nextOnLine()) 41 for (InlineBox* child = m_svgRootInlineBox.firstChild(); child; child = child->nextOnLine())
47 child->paint(renderingContext.paintInfo(), paintOffset, 0, 0); 42 child->paint(renderingContext.paintInfo(), paintOffset, 0, 0);
48 } 43 }
49 } 44 }
50 45
51 } // namespace blink 46 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698