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

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

Issue 1977793003: Minor SVGFilterPainter cleanups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/SVGFilterPainter.h" 5 #include "core/paint/SVGFilterPainter.h"
6 6
7 #include "core/layout/svg/LayoutSVGResourceFilter.h" 7 #include "core/layout/svg/LayoutSVGResourceFilter.h"
8 #include "core/layout/svg/SVGLayoutSupport.h" 8 #include "core/layout/svg/SVGLayoutSupport.h"
9 #include "core/paint/LayoutObjectDrawingRecorder.h" 9 #include "core/paint/LayoutObjectDrawingRecorder.h"
10 #include "core/paint/TransformRecorder.h" 10 #include "core/paint/TransformRecorder.h"
11 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" 11 #include "platform/graphics/filters/SkiaImageFilterBuilder.h"
12 #include "platform/graphics/filters/SourceGraphic.h" 12 #include "platform/graphics/filters/SourceGraphic.h"
13 #include "platform/graphics/paint/CompositingRecorder.h" 13 #include "platform/graphics/paint/CompositingRecorder.h"
14 #include "platform/graphics/paint/DrawingDisplayItem.h" 14 #include "platform/graphics/paint/DrawingDisplayItem.h"
15 #include "platform/graphics/paint/PaintController.h" 15 #include "platform/graphics/paint/PaintController.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 GraphicsContext* SVGFilterRecordingContext::beginContent(FilterData* filterData) 19 GraphicsContext* SVGFilterRecordingContext::beginContent(FilterData* filterData)
20 { 20 {
21 ASSERT(filterData->m_state == FilterData::Initial); 21 ASSERT(filterData->m_state == FilterData::Initial);
22 22
23 GraphicsContext* context = &paintingContext();
24
25 // Create a new context so the contents of the filter can be drawn and cache d. 23 // Create a new context so the contents of the filter can be drawn and cache d.
26 m_paintController = PaintController::create(); 24 m_paintController = PaintController::create();
27 m_context = adoptPtr(new GraphicsContext(*m_paintController)); 25 m_context = adoptPtr(new GraphicsContext(*m_paintController));
28 context = m_context.get();
29 26
30 filterData->m_state = FilterData::RecordingContent; 27 filterData->m_state = FilterData::RecordingContent;
31 return context; 28 return m_context.get();
32 } 29 }
33 30
34 void SVGFilterRecordingContext::endContent(FilterData* filterData) 31 void SVGFilterRecordingContext::endContent(FilterData* filterData)
35 { 32 {
36 ASSERT(filterData->m_state == FilterData::RecordingContent); 33 ASSERT(filterData->m_state == FilterData::RecordingContent);
37 34
38 SourceGraphic* sourceGraphic = filterData->filter->getSourceGraphic(); 35 SourceGraphic* sourceGraphic = filterData->filter->getSourceGraphic();
39 ASSERT(sourceGraphic); 36 ASSERT(sourceGraphic);
40 37
41 GraphicsContext* context = &paintingContext();
42
43 // Use the context that contains the filtered content. 38 // Use the context that contains the filtered content.
44 ASSERT(m_paintController); 39 ASSERT(m_paintController);
45 ASSERT(m_context); 40 ASSERT(m_context);
46 context = m_context.get(); 41 m_context->beginRecording(filterData->filter->filterRegion());
47 context->beginRecording(filterData->filter->filterRegion());
48 m_paintController->commitNewDisplayItems(); 42 m_paintController->commitNewDisplayItems();
49 m_paintController->paintArtifact().replay(*context); 43 m_paintController->paintArtifact().replay(*m_context);
50 44
51 SkiaImageFilterBuilder::buildSourceGraphic(sourceGraphic, toSkSp(context->en dRecording())); 45 SkiaImageFilterBuilder::buildSourceGraphic(sourceGraphic, toSkSp(m_context-> endRecording()));
52 46
53 // Content is cached by the source graphic so temporaries can be freed. 47 // Content is cached by the source graphic so temporaries can be freed.
54 m_paintController = nullptr; 48 m_paintController = nullptr;
55 m_context = nullptr; 49 m_context = nullptr;
56 50
57 filterData->m_state = FilterData::ReadyToPaint; 51 filterData->m_state = FilterData::ReadyToPaint;
58 } 52 }
59 53
60 static void paintFilteredContent(const LayoutObject& object, GraphicsContext& co ntext, FilterData* filterData) 54 static void paintFilteredContent(GraphicsContext& context, FilterData* filterDat a)
61 { 55 {
62 ASSERT(filterData->m_state == FilterData::ReadyToPaint); 56 ASSERT(filterData->m_state == FilterData::ReadyToPaint);
63 ASSERT(filterData->filter->getSourceGraphic()); 57 ASSERT(filterData->filter->getSourceGraphic());
64 58
65 filterData->m_state = FilterData::PaintingFilter; 59 filterData->m_state = FilterData::PaintingFilter;
66 60
67 sk_sp<SkImageFilter> imageFilter = SkiaImageFilterBuilder::build(filterData- >filter->lastEffect(), ColorSpaceDeviceRGB); 61 sk_sp<SkImageFilter> imageFilter = SkiaImageFilterBuilder::build(filterData- >filter->lastEffect(), ColorSpaceDeviceRGB);
68 FloatRect boundaries = filterData->filter->filterRegion(); 62 FloatRect boundaries = filterData->filter->filterRegion();
69 context.save(); 63 context.save();
70 64
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 filterData->m_state = FilterData::RecordingContent; 142 filterData->m_state = FilterData::RecordingContent;
149 } 143 }
150 144
151 GraphicsContext& context = recordingContext.paintingContext(); 145 GraphicsContext& context = recordingContext.paintingContext();
152 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, object, DisplayItem::SVGFilter)) 146 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, object, DisplayItem::SVGFilter))
153 return; 147 return;
154 148
155 // TODO(chrishtr): stop using an infinite rect, and instead bound the filter . 149 // TODO(chrishtr): stop using an infinite rect, and instead bound the filter .
156 LayoutObjectDrawingRecorder recorder(context, object, DisplayItem::SVGFilter , LayoutRect::infiniteIntRect()); 150 LayoutObjectDrawingRecorder recorder(context, object, DisplayItem::SVGFilter , LayoutRect::infiniteIntRect());
157 if (filterData && filterData->m_state == FilterData::ReadyToPaint) 151 if (filterData && filterData->m_state == FilterData::ReadyToPaint)
158 paintFilteredContent(object, context, filterData); 152 paintFilteredContent(context, filterData);
159 } 153 }
160 154
161 } // namespace blink 155 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698