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

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

Issue 14793008: Extract the SVG Filter Reference implementation out of the FilterEffectRenderer into its own type (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix copyrights Created 7 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 | Annotate | Revision Log
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "core/platform/HistogramSupport.h" 69 #include "core/platform/HistogramSupport.h"
70 #include "core/platform/PlatformGestureEvent.h" 70 #include "core/platform/PlatformGestureEvent.h"
71 #include "core/platform/PlatformMouseEvent.h" 71 #include "core/platform/PlatformMouseEvent.h"
72 #include "core/platform/ScrollAnimator.h" 72 #include "core/platform/ScrollAnimator.h"
73 #include "core/platform/Scrollbar.h" 73 #include "core/platform/Scrollbar.h"
74 #include "core/platform/ScrollbarTheme.h" 74 #include "core/platform/ScrollbarTheme.h"
75 #include "core/platform/chromium/TraceEvent.h" 75 #include "core/platform/chromium/TraceEvent.h"
76 #include "core/platform/graphics/FloatPoint3D.h" 76 #include "core/platform/graphics/FloatPoint3D.h"
77 #include "core/platform/graphics/FloatRect.h" 77 #include "core/platform/graphics/FloatRect.h"
78 #include "core/platform/graphics/GraphicsContextStateSaver.h" 78 #include "core/platform/graphics/GraphicsContextStateSaver.h"
79 #include "core/platform/graphics/filters/ReferenceFilter.h"
80 #include "core/platform/graphics/filters/SourceGraphic.h"
79 #include "core/platform/graphics/filters/custom/CustomFilterGlobalContext.h" 81 #include "core/platform/graphics/filters/custom/CustomFilterGlobalContext.h"
80 #include "core/platform/graphics/filters/custom/CustomFilterOperation.h" 82 #include "core/platform/graphics/filters/custom/CustomFilterOperation.h"
81 #include "core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h" 83 #include "core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h"
82 #include "core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h " 84 #include "core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h "
83 #include "core/platform/graphics/transforms/ScaleTransformOperation.h" 85 #include "core/platform/graphics/transforms/ScaleTransformOperation.h"
84 #include "core/platform/graphics/transforms/TransformationMatrix.h" 86 #include "core/platform/graphics/transforms/TransformationMatrix.h"
85 #include "core/platform/graphics/transforms/TranslateTransformOperation.h" 87 #include "core/platform/graphics/transforms/TranslateTransformOperation.h"
86 #include "core/rendering/ColumnInfo.h" 88 #include "core/rendering/ColumnInfo.h"
87 #include "core/rendering/FilterEffectRenderer.h" 89 #include "core/rendering/FilterEffectRenderer.h"
88 #include "core/rendering/HitTestRequest.h" 90 #include "core/rendering/HitTestRequest.h"
89 #include "core/rendering/HitTestResult.h" 91 #include "core/rendering/HitTestResult.h"
90 #include "core/rendering/HitTestingTransformState.h" 92 #include "core/rendering/HitTestingTransformState.h"
91 #include "core/rendering/OverlapTestRequestClient.h" 93 #include "core/rendering/OverlapTestRequestClient.h"
92 #include "core/rendering/RenderArena.h" 94 #include "core/rendering/RenderArena.h"
93 #include "core/rendering/RenderFlowThread.h" 95 #include "core/rendering/RenderFlowThread.h"
94 #include "core/rendering/RenderGeometryMap.h" 96 #include "core/rendering/RenderGeometryMap.h"
95 #include "core/rendering/RenderInline.h" 97 #include "core/rendering/RenderInline.h"
96 #include "core/rendering/RenderLayerBacking.h" 98 #include "core/rendering/RenderLayerBacking.h"
97 #include "core/rendering/RenderLayerCompositor.h" 99 #include "core/rendering/RenderLayerCompositor.h"
98 #include "core/rendering/RenderReplica.h" 100 #include "core/rendering/RenderReplica.h"
99 #include "core/rendering/RenderScrollbar.h" 101 #include "core/rendering/RenderScrollbar.h"
100 #include "core/rendering/RenderScrollbarPart.h" 102 #include "core/rendering/RenderScrollbarPart.h"
101 #include "core/rendering/RenderTreeAsText.h" 103 #include "core/rendering/RenderTreeAsText.h"
102 #include "core/rendering/RenderView.h" 104 #include "core/rendering/RenderView.h"
105 #include "core/rendering/svg/ReferenceFilterBuilder.h"
103 #include "core/rendering/svg/RenderSVGResourceClipper.h" 106 #include "core/rendering/svg/RenderSVGResourceClipper.h"
104 #include <wtf/MemoryInstrumentationVector.h> 107 #include <wtf/MemoryInstrumentationVector.h>
105 #include <wtf/StdLibExtras.h> 108 #include <wtf/StdLibExtras.h>
106 #include <wtf/text/CString.h> 109 #include <wtf/text/CString.h>
107 #include <wtf/UnusedParam.h> 110 #include <wtf/UnusedParam.h>
108 111
109 #define MIN_INTERSECT_FOR_REVEAL 32 112 #define MIN_INTERSECT_FOR_REVEAL 32
110 113
111 using namespace std; 114 using namespace std;
112 115
(...skipping 5926 matching lines...) Expand 10 before | Expand all | Expand 10 after
6039 if (!hasOrHadFilters(oldStyle, newStyle)) 6042 if (!hasOrHadFilters(oldStyle, newStyle))
6040 return; 6043 return;
6041 6044
6042 updateOrRemoveFilterClients(); 6045 updateOrRemoveFilterClients();
6043 // During an accelerated animation, both WebKit and the compositor animate p roperties. 6046 // During an accelerated animation, both WebKit and the compositor animate p roperties.
6044 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation. 6047 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation.
6045 bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRun ningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); 6048 bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRun ningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter);
6046 if (shouldUpdateFilters) 6049 if (shouldUpdateFilters)
6047 backing()->updateFilters(renderer()->style()); 6050 backing()->updateFilters(renderer()->style());
6048 updateOrRemoveFilterEffectRenderer(); 6051 updateOrRemoveFilterEffectRenderer();
6049 // FIXME: Accelerated SVG reference filters still rely on FilterEffectRender er to build the filter graph.
6050 // Thus, we have to call updateFilters again, after we have a FilterEffectRe nderer.
6051 // FilterEffectRenderer is intended to render software filters and shouldn't be needed for accelerated filters.
6052 // We should extract the SVG graph building functionality out of FilterEffec tRenderer, and it should happen in RenderLayer::computeFilterOperations.
6053 // https://bugs.webkit.org/show_bug.cgi?id=114051
6054 if (shouldUpdateFilters && newStyle->filter().hasReferenceFilter())
6055 backing()->updateFilters(renderer()->style());
6056 } 6052 }
6057 6053
6058 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) 6054 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle)
6059 { 6055 {
6060 updateIsNormalFlowOnly(); 6056 updateIsNormalFlowOnly();
6061 6057
6062 updateResizerAreaSet(); 6058 updateResizerAreaSet();
6063 updateScrollbarsAfterStyleChange(oldStyle); 6059 updateScrollbarsAfterStyleChange(oldStyle);
6064 updateStackingContextsAfterStyleChange(oldStyle); 6060 updateStackingContextsAfterStyleChange(oldStyle);
6065 updateVisibilityAfterStyleChange(oldStyle); 6061 updateVisibilityAfterStyleChange(oldStyle);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
6238 bool RenderLayer::isCSSCustomFilterEnabled() const 6234 bool RenderLayer::isCSSCustomFilterEnabled() const
6239 { 6235 {
6240 // We only want to enable shaders if WebGL is also enabled on this platform. 6236 // We only want to enable shaders if WebGL is also enabled on this platform.
6241 const Settings* settings = renderer()->document()->settings(); 6237 const Settings* settings = renderer()->document()->settings();
6242 return settings && settings->isCSSCustomFilterEnabled() && settings->webGLEn abled(); 6238 return settings && settings->isCSSCustomFilterEnabled() && settings->webGLEn abled();
6243 } 6239 }
6244 6240
6245 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style) 6241 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style)
6246 { 6242 {
6247 const FilterOperations& filters = style->filter(); 6243 const FilterOperations& filters = style->filter();
6244 if (filters.hasReferenceFilter()) {
6245 for (size_t i = 0; i < filters.size(); ++i) {
6246 FilterOperation* filterOperation = filters.operations().at(i).get();
6247 if (filterOperation->getOperationType() != FilterOperation::REFERENC E)
6248 continue;
6249 ReferenceFilterOperation* referenceOperation = static_cast<Reference FilterOperation*>(filterOperation);
6250 // FIXME: Cache the ReferenceFilter if it didn't change.
6251 RefPtr<ReferenceFilter> referenceFilter = ReferenceFilter::create();
6252 float zoom = style->effectiveZoom();
6253 referenceFilter->setFilterResolution(FloatSize(zoom, zoom));
6254 referenceFilter->setLastEffect(ReferenceFilterBuilder::build(referen ceFilter.get(), renderer(), referenceFilter->sourceGraphic(),
6255 referenceOperation));
6256 referenceOperation->setFilter(referenceFilter.release());
6257 }
6258 }
6259
6248 if (!filters.hasCustomFilter()) 6260 if (!filters.hasCustomFilter())
6249 return filters; 6261 return filters;
6250 6262
6251 if (!isCSSCustomFilterEnabled()) { 6263 if (!isCSSCustomFilterEnabled()) {
6252 // CSS Custom filters should not parse at all in this case, but there mi ght be 6264 // CSS Custom filters should not parse at all in this case, but there mi ght be
6253 // remaining styles that were parsed when the flag was enabled. Reproduc es in DumpRenderTree 6265 // remaining styles that were parsed when the flag was enabled. Reproduc es in DumpRenderTree
6254 // because it resets the flag while the previous test is still loaded. 6266 // because it resets the flag while the previous test is still loaded.
6255 return FilterOperations(); 6267 return FilterOperations();
6256 } 6268 }
6257 6269
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
6303 { 6315 {
6304 // FilterEffectRenderer is only used to render the filters in software mode, 6316 // FilterEffectRenderer is only used to render the filters in software mode,
6305 // so we always need to run updateOrRemoveFilterEffectRenderer after the com posited 6317 // so we always need to run updateOrRemoveFilterEffectRenderer after the com posited
6306 // mode might have changed for this layer. 6318 // mode might have changed for this layer.
6307 if (!paintsWithFilters()) { 6319 if (!paintsWithFilters()) {
6308 // Don't delete the whole filter info here, because we might use it 6320 // Don't delete the whole filter info here, because we might use it
6309 // for loading CSS shader files. 6321 // for loading CSS shader files.
6310 if (RenderLayerFilterInfo* filterInfo = this->filterInfo()) 6322 if (RenderLayerFilterInfo* filterInfo = this->filterInfo())
6311 filterInfo->setRenderer(0); 6323 filterInfo->setRenderer(0);
6312 6324
6313 // FIXME: Accelerated SVG reference filters shouldn't rely on FilterEffe ctRenderer to build the filter graph. 6325 return;
6314 // https://bugs.webkit.org/show_bug.cgi?id=114051
6315
6316 // Early-return only if we *don't* have reference filters.
6317 // For reference filters, we still want the FilterEffect graph built
6318 // for us, even if we're composited.
6319 if (!renderer()->style()->filter().hasReferenceFilter())
6320 return;
6321 } 6326 }
6322 6327
6323 RenderLayerFilterInfo* filterInfo = ensureFilterInfo(); 6328 RenderLayerFilterInfo* filterInfo = ensureFilterInfo();
6324 if (!filterInfo->renderer()) { 6329 if (!filterInfo->renderer()) {
6325 RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::crea te(); 6330 RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::crea te();
6326 RenderingMode renderingMode = renderer()->frame()->page()->settings()->a cceleratedFiltersEnabled() ? Accelerated : Unaccelerated; 6331 RenderingMode renderingMode = renderer()->frame()->page()->settings()->a cceleratedFiltersEnabled() ? Accelerated : Unaccelerated;
6327 filterRenderer->setRenderingMode(renderingMode); 6332 filterRenderer->setRenderingMode(renderingMode);
6328 filterInfo->setRenderer(filterRenderer.release()); 6333 filterInfo->setRenderer(filterRenderer.release());
6329 6334
6330 // We can optimize away code paths in other places if we know that there are no software filters. 6335 // We can optimize away code paths in other places if we know that there are no software filters.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
6382 } 6387 }
6383 } 6388 }
6384 6389
6385 void showLayerTree(const WebCore::RenderObject* renderer) 6390 void showLayerTree(const WebCore::RenderObject* renderer)
6386 { 6391 {
6387 if (!renderer) 6392 if (!renderer)
6388 return; 6393 return;
6389 showLayerTree(renderer->enclosingLayer()); 6394 showLayerTree(renderer->enclosingLayer());
6390 } 6395 }
6391 #endif 6396 #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