Changeset 286753 in webkit
- Timestamp:
- Dec 8, 2021, 4:36:26 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Headers.cmake (modified) (1 diff)
-
WebCore/WebCore.xcodeproj/project.pbxproj (modified) (1 diff)
-
WebCore/platform/graphics/filters/FilterEffectGeometry.h (modified) (2 diffs)
-
WebCore/platform/graphics/filters/SourceAlpha.cpp (modified) (2 diffs)
-
WebCore/platform/graphics/filters/SourceAlpha.h (modified) (2 diffs)
-
WebCore/svg/SVGUnitTypes.h (modified) (1 diff)
-
WebCore/svg/graphics/filters/SVGFilter.cpp (modified) (1 diff)
-
WebCore/svg/graphics/filters/SVGFilter.h (modified) (2 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Platform/IPC/FilterReference.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286752 r286753 1 2021-12-08 Said Abou-Hallawa <said@apple.com> 2 3 [GPU Process] [Filters] Add the encoding and decoding for SVGFilter 4 https://bugs.webkit.org/show_bug.cgi?id=234024 5 6 Reviewed by Wenson Hsieh. 7 8 Add new methods to help encoding and decoding SVGFilter members. Also 9 add a new constructor for SVGFilter which is going to be called from 10 FilterReference. 11 12 * Headers.cmake: 13 * WebCore.xcodeproj/project.pbxproj: 14 * platform/graphics/filters/FilterEffectGeometry.h: 15 (WebCore::FilterEffectGeometry::encode const): 16 (WebCore::FilterEffectGeometry::decode): 17 18 * platform/graphics/filters/SourceAlpha.cpp: 19 (WebCore::SourceAlpha::create): 20 (WebCore::SourceAlpha::SourceAlpha): 21 * platform/graphics/filters/SourceAlpha.h: 22 The plan is to remove the input effects from FilterEffect. Currently it 23 is still used but not through FilterEffect::apply(). So it is okay for 24 now for GPUProcess to create SourceAlpha without input since the input 25 will not used inside GPUProcess. 26 27 * svg/SVGUnitTypes.h: 28 * svg/graphics/filters/SVGFilter.cpp: 29 (WebCore::SVGFilter::create): 30 (WebCore::SVGFilter::SVGFilter): 31 * svg/graphics/filters/SVGFilter.h: 32 1 33 2021-12-08 Don Olmstead <don.olmstead@sony.com> 2 34 -
trunk/Source/WebCore/Headers.cmake
r286709 r286753 1598 1598 platform/graphics/filters/FilterOperations.h 1599 1599 platform/graphics/filters/LightSource.h 1600 platform/graphics/filters/SourceAlpha.h 1600 1601 platform/graphics/filters/SourceGraphic.h 1601 1602 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r286709 r286753 2757 2757 8485227E1190162C006EDC7F /* JSSVGVKernElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 8485227A1190162C006EDC7F /* JSSVGVKernElement.h */; }; 2758 2758 8485228B1190173C006EDC7F /* SVGVKernElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 848522881190173C006EDC7F /* SVGVKernElement.h */; }; 2759 84A81F3E0FC7DFF000955300 /* SourceAlpha.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A81F3C0FC7DFF000955300 /* SourceAlpha.h */; };2759 84A81F3E0FC7DFF000955300 /* SourceAlpha.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A81F3C0FC7DFF000955300 /* SourceAlpha.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2760 2760 84A81F420FC7E02700955300 /* SourceGraphic.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A81F400FC7E02700955300 /* SourceGraphic.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2761 2761 84B349A222F86E7500D47BCF /* EventTargetConcrete.h in Headers */ = {isa = PBXBuildFile; fileRef = 84B349A022F86E7400D47BCF /* EventTargetConcrete.h */; }; -
trunk/Source/WebCore/platform/graphics/filters/FilterEffectGeometry.h
r286466 r286753 79 79 } 80 80 81 template<class Encoder> void encode(Encoder&) const; 82 template<class Decoder> static std::optional<FilterEffectGeometry> decode(Decoder&); 83 81 84 private: 82 85 FloatRect m_boundaries; … … 86 89 using FilterEffectGeometryMap = HashMap<Ref<FilterEffect>, FilterEffectGeometry>; 87 90 91 template<class Encoder> 92 void FilterEffectGeometry::encode(Encoder& encoder) const 93 { 94 encoder << m_boundaries; 95 encoder << m_flags; 96 } 97 98 template<class Decoder> 99 std::optional<FilterEffectGeometry> FilterEffectGeometry::decode(Decoder& decoder) 100 { 101 std::optional<FloatRect> boundaries; 102 decoder >> boundaries; 103 if (!boundaries) 104 return std::nullopt; 105 106 std::optional<OptionSet<Flags>> flags; 107 decoder >> flags; 108 if (!flags) 109 return std::nullopt; 110 111 return FilterEffectGeometry(*boundaries, *flags); 112 } 113 88 114 } // namespace WebCore 115 116 namespace WTF { 117 118 template<> struct EnumTraits<WebCore::FilterEffectGeometry::Flags> { 119 using values = EnumValues< 120 WebCore::FilterEffectGeometry::Flags, 121 122 WebCore::FilterEffectGeometry::Flags::HasX, 123 WebCore::FilterEffectGeometry::Flags::HasY, 124 WebCore::FilterEffectGeometry::Flags::HasWidth, 125 WebCore::FilterEffectGeometry::Flags::HasHeight 126 >; 127 }; 128 129 } // namespace WTF -
trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.cpp
r286589 r286753 22 22 #include "SourceAlpha.h" 23 23 24 #include "Filter.h"25 24 #include "SourceAlphaSoftwareApplier.h" 26 25 #include <wtf/text/TextStream.h> … … 28 27 namespace WebCore { 29 28 29 Ref<SourceAlpha> SourceAlpha::create() 30 { 31 return adoptRef(*new SourceAlpha()); 32 } 33 30 34 Ref<SourceAlpha> SourceAlpha::create(FilterEffect& sourceEffect) 31 35 { 32 36 return adoptRef(*new SourceAlpha(sourceEffect)); 37 } 38 39 SourceAlpha::SourceAlpha() 40 : FilterEffect(FilterEffect::Type::SourceAlpha) 41 { 33 42 } 34 43 -
trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.h
r286589 r286753 26 26 27 27 class SourceAlpha : public FilterEffect { 28 public: 28 public: 29 WEBCORE_EXPORT static Ref<SourceAlpha> create(); 29 30 static Ref<SourceAlpha> create(FilterEffect&); 30 31 … … 32 33 33 34 private: 35 SourceAlpha(); 34 36 explicit SourceAlpha(FilterEffect&); 35 37 -
trunk/Source/WebCore/svg/SVGUnitTypes.h
r233122 r286753 67 67 68 68 } // namespace WebCore 69 70 namespace WTF { 71 72 template<> struct EnumTraits<WebCore::SVGUnitTypes::SVGUnitType> { 73 using values = EnumValues< 74 WebCore::SVGUnitTypes::SVGUnitType, 75 76 WebCore::SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN, 77 WebCore::SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE, 78 WebCore::SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX 79 >; 80 }; 81 82 } // namespace WTF -
trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp
r286589 r286753 70 70 } 71 71 72 RefPtr<SVGFilter> SVGFilter::create(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits, SVGFilterExpression&& expression) 73 { 74 return adoptRef(*new SVGFilter(targetBoundingBox, primitiveUnits, WTFMove(expression))); 75 } 76 72 77 SVGFilter::SVGFilter(RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits) 73 78 : Filter(Filter::Type::SVGFilter, renderingMode, filterScale, clipOperation, filterRegion) 74 79 , m_targetBoundingBox(targetBoundingBox) 75 80 , m_primitiveUnits(primitiveUnits) 81 { 82 } 83 84 SVGFilter::SVGFilter(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits, SVGFilterExpression&& expression) 85 : Filter(Filter::Type::SVGFilter) 86 , m_targetBoundingBox(targetBoundingBox) 87 , m_primitiveUnits(primitiveUnits) 88 , m_expression(WTFMove(expression)) 76 89 { 77 90 } -
trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h
r286589 r286753 40 40 static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, const FloatRect& filterRegion, const FloatRect& targetBoundingBox); 41 41 static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, FilterEffect* previousEffect); 42 WEBCORE_EXPORT static RefPtr<SVGFilter> create(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits, SVGFilterExpression&&); 42 43 43 44 FloatRect targetBoundingBox() const { return m_targetBoundingBox; } 45 SVGUnitTypes::SVGUnitType primitiveUnits() const { return m_primitiveUnits; } 44 46 47 const SVGFilterExpression& expression() const { return m_expression; } 48 45 49 RefPtr<FilterEffect> lastEffect() const final; 46 50 … … 51 55 private: 52 56 SVGFilter(RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits); 57 SVGFilter(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits, SVGFilterExpression&&); 53 58 54 59 void setExpression(SVGFilterExpression&& expression) { m_expression = WTFMove(expression); } -
trunk/Source/WebKit/ChangeLog
r286751 r286753 1 2021-12-08 Said Abou-Hallawa <said@apple.com> 2 3 [GPU Process] [Filters] Add the encoding and decoding for SVGFilter 4 https://bugs.webkit.org/show_bug.cgi?id=234024 5 6 Reviewed by Wenson Hsieh. 7 8 When encoding the SVGFilter we need to encode the individual FilterEffects 9 in filter.expression(). And for every SVGFilterExpressionTerm we need to 10 encode the index of its Ref<FilterEffect> in the individual FilterEffects. 11 12 When decoding the SVGFilter we do the opposite. We get the Ref<FilterEffect> 13 which corresponds to index of ExpressionReferenceTerm. We send the decoded 14 expression to the constructor of SVGFilter. 15 16 * Platform/IPC/FilterReference.h: 17 (IPC::FilterReference::decodeFilterEffect): 18 (IPC::FilterReference::ExpressionReferenceTerm::encode const): 19 (IPC::FilterReference::ExpressionReferenceTerm::decode): 20 (IPC::FilterReference::encodeSVGFilter): 21 (IPC::FilterReference::decodeSVGFilter): 22 1 23 2021-12-08 Alex Christensen <achristensen@webkit.org> 2 24 -
trunk/Source/WebKit/Platform/IPC/FilterReference.h
r286538 r286753 46 46 #include <WebCore/FilterEffectVector.h> 47 47 #include <WebCore/SVGFilter.h> 48 #include <WebCore/SourceAlpha.h> 48 49 #include <WebCore/SourceGraphic.h> 49 50 … … 63 64 64 65 private: 66 struct ExpressionReferenceTerm { 67 unsigned index; 68 std::optional<WebCore::FilterEffectGeometry> geometry; 69 unsigned level; 70 71 template<class Encoder> void encode(Encoder&) const; 72 template<class Decoder> static std::optional<ExpressionReferenceTerm> decode(Decoder&); 73 }; 74 75 using ExpressionReference = Vector<ExpressionReferenceTerm>; 76 65 77 template<class Encoder> static void encodeFilterEffect(const WebCore::FilterEffect&, Encoder&); 66 78 template<class Decoder> static RefPtr<WebCore::FilterEffect> decodeFilterEffect(Decoder&, WebCore::FilterFunction::Type); 79 template<class Decoder> static RefPtr<WebCore::FilterEffect> decodeFilterEffect(Decoder&); 67 80 68 81 template<class Encoder> static void encodeSVGFilter(const WebCore::SVGFilter&, Encoder&); … … 244 257 break; 245 258 259 case WebCore::FilterEffect::Type::SourceAlpha: 260 effect = WebCore::SourceAlpha::create(); 261 break; 262 246 263 case WebCore::FilterEffect::Type::SourceGraphic: 247 264 effect = WebCore::SourceGraphic::create(); 248 265 break; 249 266 250 case WebCore::FilterEffect::Type::SourceAlpha:251 267 default: 252 268 ASSERT_NOT_REACHED(); … … 261 277 } 262 278 279 template<class Decoder> 280 RefPtr<WebCore::FilterEffect> FilterReference::decodeFilterEffect(Decoder& decoder) 281 { 282 std::optional<WebCore::FilterFunction::Type> filterType; 283 decoder >> filterType; 284 if (!filterType) 285 return nullptr; 286 287 return decodeFilterEffect(decoder, *filterType); 288 } 289 290 template<class Encoder> 291 void FilterReference::ExpressionReferenceTerm::encode(Encoder& encoder) const 292 { 293 encoder << index; 294 encoder << geometry; 295 encoder << level; 296 } 297 298 template<class Decoder> 299 std::optional<FilterReference::ExpressionReferenceTerm> FilterReference::ExpressionReferenceTerm::decode(Decoder& decoder) 300 { 301 std::optional<unsigned> index; 302 decoder >> index; 303 if (!index) 304 return std::nullopt; 305 306 std::optional<std::optional<WebCore::FilterEffectGeometry>> geometry; 307 decoder >> geometry; 308 if (!geometry) 309 return std::nullopt; 310 311 std::optional<unsigned> level; 312 decoder >> level; 313 if (!level) 314 return std::nullopt; 315 316 return { { *index, *geometry, *level } }; 317 } 318 263 319 template<class Encoder> 264 320 void FilterReference::encodeSVGFilter(const WebCore::SVGFilter& filter, Encoder& encoder) 265 321 { 266 // FIXME: Encode the SVGFilter. 322 HashMap<Ref<WebCore::FilterEffect>, unsigned> indicies; 323 Vector<Ref<WebCore::FilterEffect>> effects; 324 325 // Get the individual FilterEffects in filter.expression(). 326 for (auto& term : filter.expression()) { 327 if (indicies.contains(term.effect)) 328 continue; 329 indicies.add(term.effect, effects.size()); 330 effects.append(term.effect); 331 } 332 333 // Replace the Ref<FilterEffect> in SVGExpressionTerm with its index in indicies. 334 auto expressionReference = WTF::map(filter.expression(), [&indicies] (auto&& term) -> ExpressionReferenceTerm { 335 ASSERT(indicies.contains(term.effect)); 336 unsigned index = indicies.get(term.effect); 337 return { index, term.geometry, term.level }; 338 }); 339 340 encoder << filter.targetBoundingBox(); 341 encoder << filter.primitiveUnits(); 342 343 encoder << effects.size(); 344 for (auto& effect : effects) 345 encodeFilterEffect(effect, encoder); 346 347 encoder << expressionReference; 267 348 } 268 349 … … 270 351 RefPtr<WebCore::SVGFilter> FilterReference::decodeSVGFilter(Decoder& decoder) 271 352 { 272 // FIXME: Decode the SVGFilter. 273 return nullptr; 353 std::optional<WebCore::FloatRect> targetBoundingBox; 354 decoder >> targetBoundingBox; 355 if (!targetBoundingBox) 356 return nullptr; 357 358 std::optional<WebCore::SVGUnitTypes::SVGUnitType> primitiveUnits; 359 decoder >> primitiveUnits; 360 if (!primitiveUnits) 361 return nullptr; 362 363 std::optional<size_t> effectsSize; 364 decoder >> effectsSize; 365 if (!effectsSize || !*effectsSize) 366 return nullptr; 367 368 Vector<Ref<WebCore::FilterEffect>> effects; 369 370 for (size_t i = 0; i < *effectsSize; ++i) { 371 auto effect = decodeFilterEffect(decoder); 372 if (!effect) 373 return nullptr; 374 375 effects.append(effect.releaseNonNull()); 376 } 377 378 std::optional<ExpressionReference> expressionReference; 379 decoder >> expressionReference; 380 if (!expressionReference || expressionReference->isEmpty()) 381 return nullptr; 382 383 WebCore::SVGFilterExpression expression; 384 expression.reserveInitialCapacity(expressionReference->size()); 385 386 // Replace the index in ExpressionReferenceTerm with its Ref<FilterEffect> in effects. 387 for (auto& term : *expressionReference) { 388 if (term.index >= effects.size()) 389 return nullptr; 390 expression.uncheckedAppend({ effects[term.index], term.geometry, term.level }); 391 } 392 393 return WebCore::SVGFilter::create(*targetBoundingBox, *primitiveUnits, WTFMove(expression)); 274 394 } 275 395
Note:
See TracChangeset
for help on using the changeset viewer.