Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include "ColumnInfo.h" | 47 #include "ColumnInfo.h" |
| 48 #include "CSSPropertyNames.h" | 48 #include "CSSPropertyNames.h" |
| 49 #include "Chrome.h" | 49 #include "Chrome.h" |
| 50 #include "Document.h" | 50 #include "Document.h" |
| 51 #include "DocumentEventQueue.h" | 51 #include "DocumentEventQueue.h" |
| 52 #include "EventHandler.h" | 52 #include "EventHandler.h" |
| 53 #if ENABLE(CSS_FILTERS) | 53 #if ENABLE(CSS_FILTERS) |
| 54 #include "FEColorMatrix.h" | 54 #include "FEColorMatrix.h" |
| 55 #include "FEMerge.h" | 55 #include "FEMerge.h" |
| 56 #include "FilterEffectRenderer.h" | 56 #include "FilterEffectRenderer.h" |
| 57 #include "ReferenceFilterRenderer.h" | |
| 57 #endif | 58 #endif |
| 58 #include "FeatureObserver.h" | 59 #include "FeatureObserver.h" |
| 59 #include "FloatConversion.h" | 60 #include "FloatConversion.h" |
| 60 #include "FloatPoint3D.h" | 61 #include "FloatPoint3D.h" |
| 61 #include "FloatRect.h" | 62 #include "FloatRect.h" |
| 62 #include "FocusController.h" | 63 #include "FocusController.h" |
| 63 #include "Frame.h" | 64 #include "Frame.h" |
| 64 #include "FrameLoader.h" | 65 #include "FrameLoader.h" |
| 65 #include "FrameLoaderClient.h" | 66 #include "FrameLoaderClient.h" |
| 66 #include "FrameSelection.h" | 67 #include "FrameSelection.h" |
| (...skipping 5915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5982 if (!hasOrHadFilters(oldStyle, newStyle)) | 5983 if (!hasOrHadFilters(oldStyle, newStyle)) |
| 5983 return; | 5984 return; |
| 5984 | 5985 |
| 5985 updateOrRemoveFilterClients(); | 5986 updateOrRemoveFilterClients(); |
| 5986 // During an accelerated animation, both WebKit and the compositor animate p roperties. | 5987 // During an accelerated animation, both WebKit and the compositor animate p roperties. |
| 5987 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation. | 5988 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation. |
| 5988 bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRun ningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); | 5989 bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRun ningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); |
| 5989 if (shouldUpdateFilters) | 5990 if (shouldUpdateFilters) |
| 5990 backing()->updateFilters(renderer()->style()); | 5991 backing()->updateFilters(renderer()->style()); |
| 5991 updateOrRemoveFilterEffectRenderer(); | 5992 updateOrRemoveFilterEffectRenderer(); |
| 5992 // FIXME: Accelerated SVG reference filters still rely on FilterEffectRender er to build the filter graph. | |
| 5993 // Thus, we have to call updateFilters again, after we have a FilterEffectRe nderer. | |
| 5994 // FilterEffectRenderer is intended to render software filters and shouldn't be needed for accelerated filters. | |
| 5995 // We should extract the SVG graph building functionality out of FilterEffec tRenderer, and it should happen in RenderLayer::computeFilterOperations. | |
| 5996 // https://bugs.webkit.org/show_bug.cgi?id=114051 | |
| 5997 if (shouldUpdateFilters && newStyle->filter().hasReferenceFilter()) | |
| 5998 backing()->updateFilters(renderer()->style()); | |
| 5999 } | 5993 } |
| 6000 #endif | 5994 #endif |
| 6001 | 5995 |
| 6002 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) | 5996 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) |
| 6003 { | 5997 { |
| 6004 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); | 5998 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); |
| 6005 if (isNormalFlowOnly != m_isNormalFlowOnly) { | 5999 if (isNormalFlowOnly != m_isNormalFlowOnly) { |
| 6006 m_isNormalFlowOnly = isNormalFlowOnly; | 6000 m_isNormalFlowOnly = isNormalFlowOnly; |
| 6007 RenderLayer* p = parent(); | 6001 RenderLayer* p = parent(); |
| 6008 if (p) | 6002 if (p) |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6185 { | 6179 { |
| 6186 // We only want to enable shaders if WebGL is also enabled on this platform. | 6180 // We only want to enable shaders if WebGL is also enabled on this platform. |
| 6187 const Settings* settings = renderer()->document()->settings(); | 6181 const Settings* settings = renderer()->document()->settings(); |
| 6188 return settings && settings->isCSSCustomFilterEnabled() && settings->webGLEn abled(); | 6182 return settings && settings->isCSSCustomFilterEnabled() && settings->webGLEn abled(); |
| 6189 } | 6183 } |
| 6190 #endif | 6184 #endif |
| 6191 | 6185 |
| 6192 #if ENABLE(CSS_FILTERS) | 6186 #if ENABLE(CSS_FILTERS) |
| 6193 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style) | 6187 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style) |
| 6194 { | 6188 { |
| 6195 #if !ENABLE(CSS_SHADERS) | |
| 6196 return style->filter(); | |
| 6197 #else | |
| 6198 const FilterOperations& filters = style->filter(); | 6189 const FilterOperations& filters = style->filter(); |
| 6199 if (!filters.hasCustomFilter()) | 6190 if (!filters.hasCustomFilter() && !filters.hasReferenceFilter()) |
| 6200 return filters; | 6191 return filters; |
| 6201 | 6192 |
| 6202 if (!isCSSCustomFilterEnabled()) { | |
| 6203 // CSS Custom filters should not parse at all in this case, but there mi ght be | |
| 6204 // remaining styles that were parsed when the flag was enabled. Reproduc es in DumpRenderTree | |
| 6205 // because it resets the flag while the previous test is still loaded. | |
| 6206 return FilterOperations(); | |
| 6207 } | |
| 6208 | |
| 6209 FilterOperations outputFilters; | 6193 FilterOperations outputFilters; |
| 6210 for (size_t i = 0; i < filters.size(); ++i) { | 6194 for (size_t i = 0; i < filters.size(); ++i) { |
| 6211 RefPtr<FilterOperation> filterOperation = filters.operations().at(i); | 6195 RefPtr<FilterOperation> filterOperation = filters.operations().at(i); |
| 6212 if (filterOperation->getOperationType() == FilterOperation::CUSTOM) { | 6196 switch (filterOperation->getOperationType()) { |
| 6197 case FilterOperation::CUSTOM: { | |
| 6198 if (!isCSSCustomFilterEnabled()) { | |
| 6199 // CSS Custom filters should not parse at all in this case, but there might be | |
| 6200 // remaining styles that were parsed when the flag was enabled. Reproduces in DumpRenderTree | |
| 6201 // because it resets the flag while the previous test is still l oaded. | |
| 6202 continue; | |
| 6203 } | |
| 6213 // We have to wait until the program of CSS Shaders is loaded before setting it on the layer. | 6204 // We have to wait until the program of CSS Shaders is loaded before setting it on the layer. |
| 6214 // Note that we will handle the loading of the shaders and repaintin g of the layer in updateOrRemoveFilterClients. | 6205 // Note that we will handle the loading of the shaders and repaintin g of the layer in updateOrRemoveFilterClients. |
| 6215 const CustomFilterOperation* customOperation = static_cast<const Cus tomFilterOperation*>(filterOperation.get()); | 6206 const CustomFilterOperation* customOperation = static_cast<const Cus tomFilterOperation*>(filterOperation.get()); |
| 6216 RefPtr<CustomFilterProgram> program = customOperation->program(); | 6207 RefPtr<CustomFilterProgram> program = customOperation->program(); |
| 6217 if (!program->isLoaded()) | 6208 if (!program->isLoaded()) |
| 6218 continue; | 6209 continue; |
| 6219 | 6210 |
| 6220 CustomFilterGlobalContext* globalContext = renderer()->view()->custo mFilterGlobalContext(); | 6211 CustomFilterGlobalContext* globalContext = renderer()->view()->custo mFilterGlobalContext(); |
| 6221 RefPtr<CustomFilterValidatedProgram> validatedProgram = globalContex t->getValidatedProgram(program->programInfo()); | 6212 RefPtr<CustomFilterValidatedProgram> validatedProgram = globalContex t->getValidatedProgram(program->programInfo()); |
| 6222 if (!validatedProgram->isInitialized()) | 6213 if (!validatedProgram->isInitialized()) |
| 6223 continue; | 6214 continue; |
| 6224 | 6215 |
| 6225 RefPtr<ValidatedCustomFilterOperation> validatedOperation = Validate dCustomFilterOperation::create(validatedProgram.release(), | 6216 RefPtr<ValidatedCustomFilterOperation> validatedOperation = Validate dCustomFilterOperation::create(validatedProgram.release(), |
| 6226 customOperation->parameters(), customOperation->meshRows(), cust omOperation->meshColumns(), customOperation->meshType()); | 6217 customOperation->parameters(), customOperation->meshRows(), cust omOperation->meshColumns(), customOperation->meshType()); |
| 6227 outputFilters.operations().append(validatedOperation.release()); | 6218 outputFilters.operations().append(validatedOperation.release()); |
| 6228 continue; | 6219 continue; |
| 6229 } | 6220 } |
| 6221 case FilterOperation::REFERENCE: { | |
| 6222 ReferenceFilterOperation* referenceOperation = static_cast<Reference FilterOperation*>(filterOperation.get()); | |
| 6223 ReferenceFilterRenderer::computeFilter(renderer(), referenceOperatio n); | |
|
Stephen White
2013/04/10 22:19:38
OK, bear with me, I'm trying to understand the cal
achicu
2013/04/16 22:11:16
FilterEffectRenderer::build will only be called wh
| |
| 6224 } | |
| 6225 default: | |
| 6226 // All the other filters don't need to be computed. | |
| 6227 break; | |
| 6228 } | |
| 6230 outputFilters.operations().append(filterOperation.release()); | 6229 outputFilters.operations().append(filterOperation.release()); |
| 6231 } | 6230 } |
| 6232 return outputFilters; | 6231 return outputFilters; |
| 6233 #endif | |
| 6234 } | 6232 } |
| 6235 | 6233 |
| 6236 void RenderLayer::updateOrRemoveFilterClients() | 6234 void RenderLayer::updateOrRemoveFilterClients() |
| 6237 { | 6235 { |
| 6238 if (!hasFilter()) { | 6236 if (!hasFilter()) { |
| 6239 removeFilterInfoIfNeeded(); | 6237 removeFilterInfoIfNeeded(); |
| 6240 return; | 6238 return; |
| 6241 } | 6239 } |
| 6242 | 6240 |
| 6243 #if ENABLE(CSS_SHADERS) | 6241 #if ENABLE(CSS_SHADERS) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 6259 { | 6257 { |
| 6260 // FilterEffectRenderer is only used to render the filters in software mode, | 6258 // FilterEffectRenderer is only used to render the filters in software mode, |
| 6261 // so we always need to run updateOrRemoveFilterEffectRenderer after the com posited | 6259 // so we always need to run updateOrRemoveFilterEffectRenderer after the com posited |
| 6262 // mode might have changed for this layer. | 6260 // mode might have changed for this layer. |
| 6263 if (!paintsWithFilters()) { | 6261 if (!paintsWithFilters()) { |
| 6264 // Don't delete the whole filter info here, because we might use it | 6262 // Don't delete the whole filter info here, because we might use it |
| 6265 // for loading CSS shader files. | 6263 // for loading CSS shader files. |
| 6266 if (RenderLayerFilterInfo* filterInfo = this->filterInfo()) | 6264 if (RenderLayerFilterInfo* filterInfo = this->filterInfo()) |
| 6267 filterInfo->setRenderer(0); | 6265 filterInfo->setRenderer(0); |
| 6268 | 6266 |
| 6269 // FIXME: Accelerated SVG reference filters shouldn't rely on FilterEffe ctRenderer to build the filter graph. | 6267 return; |
| 6270 // https://bugs.webkit.org/show_bug.cgi?id=114051 | |
| 6271 | |
| 6272 // Early-return only if we *don't* have reference filters. | |
| 6273 // For reference filters, we still want the FilterEffect graph built | |
| 6274 // for us, even if we're composited. | |
| 6275 if (!renderer()->style()->filter().hasReferenceFilter()) | |
| 6276 return; | |
| 6277 } | 6268 } |
| 6278 | 6269 |
| 6279 RenderLayerFilterInfo* filterInfo = ensureFilterInfo(); | 6270 RenderLayerFilterInfo* filterInfo = ensureFilterInfo(); |
| 6280 if (!filterInfo->renderer()) { | 6271 if (!filterInfo->renderer()) { |
| 6281 RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::crea te(); | 6272 RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::crea te(); |
| 6282 RenderingMode renderingMode = renderer()->frame()->page()->settings()->a cceleratedFiltersEnabled() ? Accelerated : Unaccelerated; | 6273 RenderingMode renderingMode = renderer()->frame()->page()->settings()->a cceleratedFiltersEnabled() ? Accelerated : Unaccelerated; |
| 6283 filterRenderer->setRenderingMode(renderingMode); | 6274 filterRenderer->setRenderingMode(renderingMode); |
| 6284 filterInfo->setRenderer(filterRenderer.release()); | 6275 filterInfo->setRenderer(filterRenderer.release()); |
| 6285 | 6276 |
| 6286 // We can optimize away code paths in other places if we know that there are no software filters. | 6277 // We can optimize away code paths in other places if we know that there are no software filters. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6340 } | 6331 } |
| 6341 } | 6332 } |
| 6342 | 6333 |
| 6343 void showLayerTree(const WebCore::RenderObject* renderer) | 6334 void showLayerTree(const WebCore::RenderObject* renderer) |
| 6344 { | 6335 { |
| 6345 if (!renderer) | 6336 if (!renderer) |
| 6346 return; | 6337 return; |
| 6347 showLayerTree(renderer->enclosingLayer()); | 6338 showLayerTree(renderer->enclosingLayer()); |
| 6348 } | 6339 } |
| 6349 #endif | 6340 #endif |
| OLD | NEW |