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

Side by Side Diff: Source/core/rendering/RenderLayer.cpp

Issue 13984002: Extracting the SVG Filter Reference implementation out of the FilterEffectRenderer into its own typ… Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Updated to ToT, fixed style, warnings Created 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 #include "core/platform/graphics/FloatPoint3D.h" 79 #include "core/platform/graphics/FloatPoint3D.h"
80 #include "core/platform/graphics/FloatRect.h" 80 #include "core/platform/graphics/FloatRect.h"
81 #include "core/platform/graphics/Gradient.h" 81 #include "core/platform/graphics/Gradient.h"
82 #include "core/platform/graphics/GraphicsContextStateSaver.h" 82 #include "core/platform/graphics/GraphicsContextStateSaver.h"
83 #include "core/platform/graphics/filters/custom/CustomFilterGlobalContext.h" 83 #include "core/platform/graphics/filters/custom/CustomFilterGlobalContext.h"
84 #include "core/platform/graphics/filters/custom/CustomFilterOperation.h" 84 #include "core/platform/graphics/filters/custom/CustomFilterOperation.h"
85 #include "core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h" 85 #include "core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h"
86 #include "core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h " 86 #include "core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h "
87 #include "core/platform/graphics/filters/FEColorMatrix.h" 87 #include "core/platform/graphics/filters/FEColorMatrix.h"
88 #include "core/platform/graphics/filters/FEMerge.h" 88 #include "core/platform/graphics/filters/FEMerge.h"
89 #include "core/platform/graphics/filters/ReferenceFilter.h"
89 #include "core/platform/graphics/filters/SourceGraphic.h" 90 #include "core/platform/graphics/filters/SourceGraphic.h"
90 #include "core/platform/graphics/transforms/ScaleTransformOperation.h" 91 #include "core/platform/graphics/transforms/ScaleTransformOperation.h"
91 #include "core/platform/graphics/transforms/TransformationMatrix.h" 92 #include "core/platform/graphics/transforms/TransformationMatrix.h"
92 #include "core/platform/graphics/transforms/TranslateTransformOperation.h" 93 #include "core/platform/graphics/transforms/TranslateTransformOperation.h"
93 #include "core/platform/text/TextStream.h" 94 #include "core/platform/text/TextStream.h"
94 #include "core/rendering/ColumnInfo.h" 95 #include "core/rendering/ColumnInfo.h"
95 #include "core/rendering/FilterEffectRenderer.h" 96 #include "core/rendering/FilterEffectRenderer.h"
96 #include "core/rendering/HitTestRequest.h" 97 #include "core/rendering/HitTestRequest.h"
97 #include "core/rendering/HitTestResult.h" 98 #include "core/rendering/HitTestResult.h"
98 #include "core/rendering/HitTestingTransformState.h" 99 #include "core/rendering/HitTestingTransformState.h"
99 #include "core/rendering/OverlapTestRequestClient.h" 100 #include "core/rendering/OverlapTestRequestClient.h"
100 #include "core/rendering/RenderArena.h" 101 #include "core/rendering/RenderArena.h"
101 #include "core/rendering/RenderFlowThread.h" 102 #include "core/rendering/RenderFlowThread.h"
102 #include "core/rendering/RenderGeometryMap.h" 103 #include "core/rendering/RenderGeometryMap.h"
103 #include "core/rendering/RenderInline.h" 104 #include "core/rendering/RenderInline.h"
104 #include "core/rendering/RenderLayerBacking.h" 105 #include "core/rendering/RenderLayerBacking.h"
105 #include "core/rendering/RenderLayerCompositor.h" 106 #include "core/rendering/RenderLayerCompositor.h"
106 #include "core/rendering/RenderLazyBlock.h" 107 #include "core/rendering/RenderLazyBlock.h"
107 #include "core/rendering/RenderMarquee.h" 108 #include "core/rendering/RenderMarquee.h"
108 #include "core/rendering/RenderReplica.h" 109 #include "core/rendering/RenderReplica.h"
109 #include "core/rendering/RenderScrollbar.h" 110 #include "core/rendering/RenderScrollbar.h"
110 #include "core/rendering/RenderScrollbarPart.h" 111 #include "core/rendering/RenderScrollbarPart.h"
111 #include "core/rendering/RenderTheme.h" 112 #include "core/rendering/RenderTheme.h"
112 #include "core/rendering/RenderTreeAsText.h" 113 #include "core/rendering/RenderTreeAsText.h"
113 #include "core/rendering/RenderView.h" 114 #include "core/rendering/RenderView.h"
115 #include "core/rendering/svg/ReferenceFilterBuilder.h"
114 #include "core/rendering/svg/RenderSVGResourceClipper.h" 116 #include "core/rendering/svg/RenderSVGResourceClipper.h"
115 #include <wtf/MemoryInstrumentationVector.h> 117 #include <wtf/MemoryInstrumentationVector.h>
116 #include <wtf/StdLibExtras.h> 118 #include <wtf/StdLibExtras.h>
117 #include <wtf/text/CString.h> 119 #include <wtf/text/CString.h>
118 #include <wtf/UnusedParam.h> 120 #include <wtf/UnusedParam.h>
119 121
120 #if ENABLE(SVG) 122 #if ENABLE(SVG)
121 #include "SVGNames.h" 123 #include "SVGNames.h"
122 #endif 124 #endif
123 125
(...skipping 6005 matching lines...) Expand 10 before | Expand all | Expand 10 after
6129 if (!hasOrHadFilters(oldStyle, newStyle)) 6131 if (!hasOrHadFilters(oldStyle, newStyle))
6130 return; 6132 return;
6131 6133
6132 updateOrRemoveFilterClients(); 6134 updateOrRemoveFilterClients();
6133 // During an accelerated animation, both WebKit and the compositor animate p roperties. 6135 // During an accelerated animation, both WebKit and the compositor animate p roperties.
6134 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation. 6136 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation.
6135 bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRun ningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); 6137 bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRun ningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter);
6136 if (shouldUpdateFilters) 6138 if (shouldUpdateFilters)
6137 backing()->updateFilters(renderer()->style()); 6139 backing()->updateFilters(renderer()->style());
6138 updateOrRemoveFilterEffectRenderer(); 6140 updateOrRemoveFilterEffectRenderer();
6139 // FIXME: Accelerated SVG reference filters still rely on FilterEffectRender er to build the filter graph.
6140 // Thus, we have to call updateFilters again, after we have a FilterEffectRe nderer.
6141 // FilterEffectRenderer is intended to render software filters and shouldn't be needed for accelerated filters.
6142 // We should extract the SVG graph building functionality out of FilterEffec tRenderer, and it should happen in RenderLayer::computeFilterOperations.
6143 // https://bugs.webkit.org/show_bug.cgi?id=114051
6144 if (shouldUpdateFilters && newStyle->filter().hasReferenceFilter())
6145 backing()->updateFilters(renderer()->style());
6146 } 6141 }
6147 6142
6148 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) 6143 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle)
6149 { 6144 {
6150 updateIsNormalFlowOnly(); 6145 updateIsNormalFlowOnly();
6151 6146
6152 if (renderer()->style()->overflowX() == OMARQUEE && renderer()->style()->mar queeBehavior() != MNONE && renderer()->isBox()) { 6147 if (renderer()->style()->overflowX() == OMARQUEE && renderer()->style()->mar queeBehavior() != MNONE && renderer()->isBox()) {
6153 if (!m_marquee) 6148 if (!m_marquee)
6154 m_marquee = adoptPtr(new RenderMarquee(this)); 6149 m_marquee = adoptPtr(new RenderMarquee(this));
6155 UseCounter::count(renderer()->document(), renderer()->isHTMLMarquee() ? UseCounter::HTMLMarqueeElement : UseCounter::CSSOverflowMarquee); 6150 UseCounter::count(renderer()->document(), renderer()->isHTMLMarquee() ? UseCounter::HTMLMarqueeElement : UseCounter::CSSOverflowMarquee);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
6339 bool RenderLayer::isCSSCustomFilterEnabled() const 6334 bool RenderLayer::isCSSCustomFilterEnabled() const
6340 { 6335 {
6341 // We only want to enable shaders if WebGL is also enabled on this platform. 6336 // We only want to enable shaders if WebGL is also enabled on this platform.
6342 const Settings* settings = renderer()->document()->settings(); 6337 const Settings* settings = renderer()->document()->settings();
6343 return settings && settings->isCSSCustomFilterEnabled() && settings->webGLEn abled(); 6338 return settings && settings->isCSSCustomFilterEnabled() && settings->webGLEn abled();
6344 } 6339 }
6345 6340
6346 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style) 6341 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style)
6347 { 6342 {
6348 const FilterOperations& filters = style->filter(); 6343 const FilterOperations& filters = style->filter();
6344 if (filters.hasReferenceFilter()) {
6345 for (size_t i = 0; i < filters.size(); ++i) {
6346 FilterOperation* filterOperation = filters.operations().at(i).get();
6347 if (filterOperation->getOperationType() != FilterOperation::REFERENC E)
6348 continue;
6349 ReferenceFilterOperation* referenceOperation = static_cast<Reference FilterOperation*>(filterOperation);
6350 // FIXME: Cache the ReferenceFilter if it didn't change.
6351 RefPtr<ReferenceFilter> referenceFilter = ReferenceFilter::create();
6352 referenceFilter->setLastEffect(ReferenceFilterBuilder::build(referen ceFilter.get(), renderer(), referenceFilter->sourceGraphic(),
6353 referenceOperation));
6354 referenceOperation->setFilter(referenceFilter.release());
6355 }
6356 }
6357
6349 if (!filters.hasCustomFilter()) 6358 if (!filters.hasCustomFilter())
6350 return filters; 6359 return filters;
6351 6360
6352 if (!isCSSCustomFilterEnabled()) { 6361 if (!isCSSCustomFilterEnabled()) {
6353 // CSS Custom filters should not parse at all in this case, but there mi ght be 6362 // CSS Custom filters should not parse at all in this case, but there mi ght be
6354 // remaining styles that were parsed when the flag was enabled. Reproduc es in DumpRenderTree 6363 // remaining styles that were parsed when the flag was enabled. Reproduc es in DumpRenderTree
6355 // because it resets the flag while the previous test is still loaded. 6364 // because it resets the flag while the previous test is still loaded.
6356 return FilterOperations(); 6365 return FilterOperations();
6357 } 6366 }
6358 6367
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
6406 { 6415 {
6407 // FilterEffectRenderer is only used to render the filters in software mode, 6416 // FilterEffectRenderer is only used to render the filters in software mode,
6408 // so we always need to run updateOrRemoveFilterEffectRenderer after the com posited 6417 // so we always need to run updateOrRemoveFilterEffectRenderer after the com posited
6409 // mode might have changed for this layer. 6418 // mode might have changed for this layer.
6410 if (!paintsWithFilters()) { 6419 if (!paintsWithFilters()) {
6411 // Don't delete the whole filter info here, because we might use it 6420 // Don't delete the whole filter info here, because we might use it
6412 // for loading CSS shader files. 6421 // for loading CSS shader files.
6413 if (RenderLayerFilterInfo* filterInfo = this->filterInfo()) 6422 if (RenderLayerFilterInfo* filterInfo = this->filterInfo())
6414 filterInfo->setRenderer(0); 6423 filterInfo->setRenderer(0);
6415 6424
6416 // FIXME: Accelerated SVG reference filters shouldn't rely on FilterEffe ctRenderer to build the filter graph. 6425 return;
6417 // https://bugs.webkit.org/show_bug.cgi?id=114051
6418
6419 // Early-return only if we *don't* have reference filters.
6420 // For reference filters, we still want the FilterEffect graph built
6421 // for us, even if we're composited.
6422 if (!renderer()->style()->filter().hasReferenceFilter())
6423 return;
6424 } 6426 }
6425 6427
6426 RenderLayerFilterInfo* filterInfo = ensureFilterInfo(); 6428 RenderLayerFilterInfo* filterInfo = ensureFilterInfo();
6427 if (!filterInfo->renderer()) { 6429 if (!filterInfo->renderer()) {
6428 RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::crea te(); 6430 RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::crea te();
6429 RenderingMode renderingMode = renderer()->frame()->page()->settings()->a cceleratedFiltersEnabled() ? Accelerated : Unaccelerated; 6431 RenderingMode renderingMode = renderer()->frame()->page()->settings()->a cceleratedFiltersEnabled() ? Accelerated : Unaccelerated;
6430 filterRenderer->setRenderingMode(renderingMode); 6432 filterRenderer->setRenderingMode(renderingMode);
6431 filterInfo->setRenderer(filterRenderer.release()); 6433 filterInfo->setRenderer(filterRenderer.release());
6432 6434
6433 // We can optimize away code paths in other places if we know that there are no software filters. 6435 // We can optimize away code paths in other places if we know that there are no software filters.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6486 } 6488 }
6487 } 6489 }
6488 6490
6489 void showLayerTree(const WebCore::RenderObject* renderer) 6491 void showLayerTree(const WebCore::RenderObject* renderer)
6490 { 6492 {
6491 if (!renderer) 6493 if (!renderer)
6492 return; 6494 return;
6493 showLayerTree(renderer->enclosingLayer()); 6495 showLayerTree(renderer->enclosingLayer());
6494 } 6496 }
6495 #endif 6497 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/FilterEffectRenderer.cpp ('k') | Source/core/rendering/svg/ReferenceFilterBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698