Changeset 142823 in webkit
- Timestamp:
- Feb 13, 2013 4:59:28 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142822 r142823 1 2013-02-13 Max Vujovic <mvujovic@adobe.com> 2 3 [CSS Filters] Refactor filter outsets into a class 4 https://bugs.webkit.org/show_bug.cgi?id=109330 5 6 Reviewed by Dean Jackson. 7 8 In filters related code, we're often operating on 4 ints representing the top, right, 9 bottom, and left filter outsets. These outsets come from a filter like blur or drop-shadow. 10 This patch packages those ints and their related operations into a class called 11 IntRectExtent. 12 13 Here are some signs that we should make a class to hold those 4 ints: 14 1) In RenderLayer.cpp, we have a expandRectForFilterOutsets function, which looks like 15 feature envy. 16 2) RenderStyle and other classes have methods like getFilterOutsets which set the 4 ints by 17 reference. The calling code has to define 4 ints, which looks bloated. 18 3) To fix bug 109098, we will need to check if filter outsets changed, which sounds like a 19 nice job for an inequality operator. (https://bugs.webkit.org/show_bug.cgi?id=109098) 20 21 No new tests. No change in behavior. Just refactoring. 22 23 * GNUmakefile.list.am: 24 * Target.pri: 25 * WebCore.gypi: 26 * WebCore.xcodeproj/project.pbxproj: 27 * platform/graphics/IntRectExtent.h: Added. 28 (WebCore): 29 (IntRectExtent): 30 (WebCore::IntRectExtent::IntRectExtent): 31 (WebCore::IntRectExtent::top): 32 (WebCore::IntRectExtent::setTop): 33 (WebCore::IntRectExtent::right): 34 (WebCore::IntRectExtent::setRight): 35 (WebCore::IntRectExtent::bottom): 36 (WebCore::IntRectExtent::setBottom): 37 (WebCore::IntRectExtent::left): 38 (WebCore::IntRectExtent::setLeft): 39 (WebCore::IntRectExtent::expandRect): 40 (WebCore::IntRectExtent::isZero): 41 (WebCore::operator==): 42 (WebCore::operator!=): 43 (WebCore::operator+=): 44 * platform/graphics/filters/FilterOperations.cpp: 45 (WebCore::FilterOperations::outsets): 46 * platform/graphics/filters/FilterOperations.h: 47 (FilterOperations): 48 * platform/graphics/texmap/TextureMapperLayer.cpp: 49 (WebCore::TextureMapperLayer::intermediateSurfaceRect): 50 * rendering/FilterEffectRenderer.cpp: 51 (WebCore::FilterEffectRenderer::FilterEffectRenderer): 52 (WebCore::FilterEffectRenderer::build): 53 (WebCore::FilterEffectRenderer::computeSourceImageRectForDirtyRect): 54 * rendering/FilterEffectRenderer.h: 55 (FilterEffectRenderer): 56 * rendering/RenderLayer.cpp: 57 (WebCore::RenderLayer::setFilterBackendNeedsRepaintingInRect): 58 (WebCore::transparencyClipBox): 59 (WebCore::RenderLayer::calculateLayerBounds): 60 * rendering/style/RenderStyle.h: 61 1 62 2013-02-13 Adam Barth <abarth@webkit.org> 2 63 -
trunk/Source/WebCore/GNUmakefile.list.am
r142809 r142823 5646 5646 Source/WebCore/platform/graphics/IntRect.cpp \ 5647 5647 Source/WebCore/platform/graphics/IntRect.h \ 5648 Source/WebCore/platform/graphics/IntRectExtent.h \ 5648 5649 Source/WebCore/platform/graphics/IntSize.h \ 5649 5650 Source/WebCore/platform/graphics/IntSizeHash.h \ -
trunk/Source/WebCore/Target.pri
r142809 r142823 2251 2251 platform/graphics/IntPointHash.h \ 2252 2252 platform/graphics/IntRect.h \ 2253 platform/graphics/IntRectExtent.h \ 2253 2254 platform/graphics/Latin1TextIterator.h \ 2254 2255 platform/graphics/MediaPlayer.h \ -
trunk/Source/WebCore/WebCore.gypi
r142809 r142823 4686 4686 'platform/graphics/FloatSize.cpp', 4687 4687 'platform/graphics/IntRect.cpp', 4688 'platform/graphics/IntRectExtent.h', 4688 4689 'platform/graphics/LayoutRect.cpp', 4689 4690 'platform/graphics/Region.cpp', -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r142809 r142823 3869 3869 A29532D015DD5E1700469EBC /* CustomFilterValidatedProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = A29532CE15DD5E1700469EBC /* CustomFilterValidatedProgram.h */; }; 3870 3870 A2B2AE7C16375EE500CFA50B /* CustomFilterConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = A2B2AE7B16375EE500CFA50B /* CustomFilterConstants.h */; }; 3871 A2B9217316C5CC420041DCD9 /* IntRectExtent.h in Headers */ = {isa = PBXBuildFile; fileRef = A2B9217216C5CC420041DCD9 /* IntRectExtent.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3871 3872 A2E8AE3016A48E1C006BB3AA /* WebKitCSSFilterRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A2E8AE2E16A48E1C006BB3AA /* WebKitCSSFilterRule.cpp */; }; 3872 3873 A2E8AE3116A48E1C006BB3AA /* WebKitCSSFilterRule.h in Headers */ = {isa = PBXBuildFile; fileRef = A2E8AE2F16A48E1C006BB3AA /* WebKitCSSFilterRule.h */; }; … … 11349 11350 A29532CE15DD5E1700469EBC /* CustomFilterValidatedProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterValidatedProgram.h; path = filters/CustomFilterValidatedProgram.h; sourceTree = "<group>"; }; 11350 11351 A2B2AE7B16375EE500CFA50B /* CustomFilterConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterConstants.h; path = filters/CustomFilterConstants.h; sourceTree = "<group>"; }; 11352 A2B9217216C5CC420041DCD9 /* IntRectExtent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntRectExtent.h; sourceTree = "<group>"; }; 11351 11353 A2E8AE2E16A48E1C006BB3AA /* WebKitCSSFilterRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitCSSFilterRule.cpp; sourceTree = "<group>"; }; 11352 11354 A2E8AE2F16A48E1C006BB3AA /* WebKitCSSFilterRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitCSSFilterRule.h; sourceTree = "<group>"; }; … … 20633 20635 B27535450B053814002CE64F /* IntRect.cpp */, 20634 20636 B27535460B053814002CE64F /* IntRect.h */, 20637 A2B9217216C5CC420041DCD9 /* IntRectExtent.h */, 20635 20638 E134F5AA12EE343F004EC58D /* IntRectHash.h */, 20636 20639 B27535470B053814002CE64F /* IntSize.h */, … … 24714 24717 B27535740B053814002CE64F /* IntRect.h in Headers */, 24715 24718 E134F5AB12EE343F004EC58D /* IntRectHash.h in Headers */, 24719 A2B9217316C5CC420041DCD9 /* IntRectExtent.h in Headers */, 24716 24720 B27535750B053814002CE64F /* IntSize.h in Headers */, 24717 24721 B27535760B053814002CE64F /* IntSizeHash.h in Headers */, -
trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp
r132960 r142823 119 119 } 120 120 121 void FilterOperations::getOutsets(int& top, int& right, int& bottom, int& left) const121 FilterOutsets FilterOperations::outsets() const 122 122 { 123 top = 0; 124 right = 0; 125 bottom = 0; 126 left = 0; 123 FilterOutsets totalOutsets; 127 124 for (size_t i = 0; i < m_operations.size(); ++i) { 128 125 FilterOperation* filterOperation = m_operations.at(i).get(); … … 131 128 BlurFilterOperation* blurOperation = static_cast<BlurFilterOperation*>(filterOperation); 132 129 float stdDeviation = floatValueForLength(blurOperation->stdDeviation(), 0); 133 IntSize outset = outsetSizeForBlur(stdDeviation); 134 top += outset.height(); 135 right += outset.width(); 136 bottom += outset.height(); 137 left += outset.width(); 130 IntSize outsetSize = outsetSizeForBlur(stdDeviation); 131 FilterOutsets outsets(outsetSize.height(), outsetSize.width(), outsetSize.height(), outsetSize.width()); 132 totalOutsets += outsets; 138 133 break; 139 134 } 140 135 case FilterOperation::DROP_SHADOW: { 141 136 DropShadowFilterOperation* dropShadowOperation = static_cast<DropShadowFilterOperation*>(filterOperation); 142 IntSize outset = outsetSizeForBlur(dropShadowOperation->stdDeviation()); 143 top += std::max(0, outset.height() - dropShadowOperation->y()); 144 right += std::max(0, outset.width() + dropShadowOperation->x()); 145 bottom += std::max(0, outset.height() + dropShadowOperation->y()); 146 left += std::max(0, outset.width() - dropShadowOperation->x()); 137 IntSize outsetSize = outsetSizeForBlur(dropShadowOperation->stdDeviation()); 138 FilterOutsets outsets( 139 std::max(0, outsetSize.height() - dropShadowOperation->y()), 140 std::max(0, outsetSize.width() + dropShadowOperation->x()), 141 std::max(0, outsetSize.height() + dropShadowOperation->y()), 142 std::max(0, outsetSize.width() - dropShadowOperation->x()) 143 ); 144 totalOutsets += outsets; 147 145 break; 148 146 } … … 159 157 } 160 158 } 159 return totalOutsets; 161 160 } 162 161 -
trunk/Source/WebCore/platform/graphics/filters/FilterOperations.h
r133779 r142823 30 30 31 31 #include "FilterOperation.h" 32 #include "IntRectExtent.h" 32 33 #include <wtf/RefPtr.h> 33 34 #include <wtf/Vector.h> 34 35 35 36 namespace WebCore { 37 38 typedef IntRectExtent FilterOutsets; 36 39 37 40 class FilterOperations { … … 64 67 65 68 bool hasOutsets() const; 66 void getOutsets(int& top, int& right, int& bottom, int& left) const;69 FilterOutsets outsets() const; 67 70 68 71 bool hasFilterThatAffectsOpacity() const; -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
r142579 r142823 185 185 #if ENABLE(CSS_FILTERS) 186 186 if (m_currentFilters.hasOutsets()) { 187 int leftOutset; 188 int topOutset; 189 int bottomOutset; 190 int rightOutset; 191 m_currentFilters.getOutsets(topOutset, rightOutset, bottomOutset, leftOutset); 187 FilterOutsets outsets = m_currentFilters.outsets(); 192 188 IntRect unfilteredTargetRect(rect); 193 rect.move(std::max(0, - leftOutset), std::max(0, -topOutset));194 rect.expand( leftOutset + rightOutset, topOutset + bottomOutset);189 rect.move(std::max(0, -outsets.left()), std::max(0, -outsets.top())); 190 rect.expand(outsets.left() + outsets.right(), outsets.top() + outsets.bottom()); 195 191 rect.unite(unfilteredTargetRect); 196 192 } -
trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp
r140845 r142823 103 103 104 104 FilterEffectRenderer::FilterEffectRenderer() 105 : m_topOutset(0) 106 , m_rightOutset(0) 107 , m_bottomOutset(0) 108 , m_leftOutset(0) 109 , m_graphicsBufferAttached(false) 105 : m_graphicsBufferAttached(false) 110 106 , m_hasFilterThatMovesPixels(false) 111 107 #if ENABLE(CSS_SHADERS) … … 197 193 m_hasFilterThatMovesPixels = operations.hasFilterThatMovesPixels(); 198 194 if (m_hasFilterThatMovesPixels) 199 operations.getOutsets(m_topOutset, m_rightOutset, m_bottomOutset, m_leftOutset);195 m_outsets = operations.outsets(); 200 196 201 197 // Keep the old effects on the stack until we've created the new effects. … … 440 436 // Note that the outsets are reversed here because we are going backwards -> we have the dirty rect and 441 437 // need to find out what is the rectangle that might influence the result inside that dirty rect. 442 rectForRepaint.move(-m_ rightOutset, -m_bottomOutset);443 rectForRepaint.expand(m_ leftOutset + m_rightOutset, m_topOutset + m_bottomOutset);438 rectForRepaint.move(-m_outsets.right(), -m_outsets.bottom()); 439 rectForRepaint.expand(m_outsets.left() + m_outsets.right(), m_outsets.top() + m_outsets.bottom()); 444 440 } 445 441 rectForRepaint.intersect(filterBoxRect); -
trunk/Source/WebCore/rendering/FilterEffectRenderer.h
r138823 r142823 35 35 #include "GraphicsContext.h" 36 36 #include "ImageBuffer.h" 37 #include "IntRectExtent.h" 37 38 #include "LayoutRect.h" 38 39 #include "SVGFilterBuilder.h" … … 141 142 RefPtr<SourceGraphic> m_sourceGraphic; 142 143 143 int m_topOutset; 144 int m_rightOutset; 145 int m_bottomOutset; 146 int m_leftOutset; 147 144 IntRectExtent m_outsets; 145 148 146 bool m_graphicsBufferAttached; 149 147 bool m_hasFilterThatMovesPixels; -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r142527 r142823 1368 1368 } 1369 1369 1370 static inline void expandRectForFilterOutsets(LayoutRect& rect, const RenderLayerModelObject* renderer)1371 {1372 ASSERT(renderer);1373 if (!renderer->style()->hasFilterOutsets())1374 return;1375 1376 int topOutset;1377 int rightOutset;1378 int bottomOutset;1379 int leftOutset;1380 renderer->style()->getFilterOutsets(topOutset, rightOutset, bottomOutset, leftOutset);1381 rect.move(-leftOutset, -topOutset);1382 rect.expand(leftOutset + rightOutset, topOutset + bottomOutset);1383 }1384 1385 1370 void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect, bool immediate) 1386 1371 { … … 1389 1374 1390 1375 LayoutRect rectForRepaint = rect; 1391 expandRectForFilterOutsets(rectForRepaint, renderer());1376 renderer()->style()->filterOutsets().expandRect(rectForRepaint); 1392 1377 1393 1378 RenderLayerFilterInfo* filterInfo = this->filterInfo(); … … 1558 1543 expandClipRectForDescendantsAndReflection(clipRect, layer, layer, paintBehavior); 1559 1544 #if ENABLE(CSS_FILTERS) 1560 expandRectForFilterOutsets(clipRect, layer->renderer());1545 layer->renderer()->style()->filterOutsets().expandRect(clipRect); 1561 1546 #endif 1562 1547 return transform.mapRect(clipRect); … … 1566 1551 expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, paintBehavior); 1567 1552 #if ENABLE(CSS_FILTERS) 1568 expandRectForFilterOutsets(clipRect, layer->renderer());1553 layer->renderer()->style()->filterOutsets().expandRect(clipRect); 1569 1554 #endif 1570 1555 return clipRect; … … 5013 4998 // https://bugs.webkit.org/show_bug.cgi?id=81239 5014 4999 if (flags & IncludeLayerFilterOutsets) 5015 expandRectForFilterOutsets(unionBounds, renderer);5000 renderer->style()->filterOutsets().expandRect(unionBounds); 5016 5001 #endif 5017 5002 -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r142527 r142823 410 410 411 411 #if ENABLE(CSS_FILTERS) 412 void getFilterOutsets(int& top, int& right, int& bottom, int& left) const413 {414 if (hasFilter())415 filter().getOutsets(top, right, bottom, left);416 else {417 top = 0;418 right = 0;419 bottom = 0;420 left = 0;421 }422 }423 412 bool hasFilterOutsets() const { return hasFilter() && filter().hasOutsets(); } 424 #else 425 bool hasFilterOutsets() const { return false; } 413 FilterOutsets filterOutsets() const { return hasFilter() ? filter().outsets() : FilterOutsets(); } 426 414 #endif 427 415 -
trunk/Source/WebKit/chromium/ChangeLog
r142810 r142823 1 2013-02-13 Max Vujovic <mvujovic@adobe.com> 2 3 [CSS Filters] Refactor filter outsets into a class 4 https://bugs.webkit.org/show_bug.cgi?id=109330 5 6 Update FilterOperations unit tests to use new interface for getting filter outsets. 7 8 Reviewed by Dean Jackson. 9 10 * tests/FilterOperationsTest.cpp: 11 (WebKit::TEST): 12 1 13 2013-02-13 Zan Dobersek <zdobersek@igalia.com> 2 14 -
trunk/Source/WebKit/chromium/tests/FilterOperationsTest.cpp
r129373 r142823 41 41 ops.operations().append(BlurFilterOperation::create(Length(20.0, WebCore::Fixed), FilterOperation::BLUR)); 42 42 EXPECT_TRUE(ops.hasOutsets()); 43 int top, right, bottom, left; 44 top = right = bottom = left = 0; 45 ops.getOutsets(top, right, bottom, left); 46 EXPECT_EQ(57, top); 47 EXPECT_EQ(57, right); 48 EXPECT_EQ(57, bottom); 49 EXPECT_EQ(57, left); 43 FilterOutsets outsets = ops.outsets(); 44 EXPECT_EQ(57, outsets.top()); 45 EXPECT_EQ(57, outsets.right()); 46 EXPECT_EQ(57, outsets.bottom()); 47 EXPECT_EQ(57, outsets.left()); 50 48 } 51 49 … … 55 53 ops.operations().append(DropShadowFilterOperation::create(IntPoint(3, 8), 20, Color(1, 2, 3), FilterOperation::DROP_SHADOW)); 56 54 EXPECT_TRUE(ops.hasOutsets()); 57 int top, right, bottom, left; 58 top = right = bottom = left = 0; 59 ops.getOutsets(top, right, bottom, left); 60 EXPECT_EQ(49, top); 61 EXPECT_EQ(60, right); 62 EXPECT_EQ(65, bottom); 63 EXPECT_EQ(54, left); 55 FilterOutsets outsets = ops.outsets(); 56 EXPECT_EQ(49, outsets.top()); 57 EXPECT_EQ(60, outsets.right()); 58 EXPECT_EQ(65, outsets.bottom()); 59 EXPECT_EQ(54, outsets.left()); 64 60 } 65 61
Note: See TracChangeset
for help on using the changeset viewer.