Changeset 282335 in webkit
- Timestamp:
- Sep 13, 2021 10:20:57 AM (10 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/mac/webgl/webgl-image-rendering-expected.png (added)
-
LayoutTests/webgl/webgl-image-rendering-expected.txt (added)
-
LayoutTests/webgl/webgl-image-rendering.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/graphics/GraphicsLayer.h (modified) (2 diffs)
-
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (modified) (6 diffs)
-
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (modified) (3 diffs)
-
Source/WebCore/rendering/RenderLayerBacking.cpp (modified) (4 diffs)
-
Source/WebCore/rendering/RenderLayerBacking.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r282331 r282335 1 2021-09-13 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 image-rendering: pixelated does not work with WebGL (but does with Canvas2D) 4 https://bugs.webkit.org/show_bug.cgi?id=193895 5 <rdar://problem/47656086> 6 7 Reviewed by Simon Fraser. 8 9 Add a test comparing upscaling of WebGL canvas element and an image element 10 with the same contents when using image-rendering: properties. 11 12 * platform/mac/webgl/webgl-image-rendering-expected.png: Added. 13 * webgl/webgl-image-rendering-expected.txt: Added. 14 * webgl/webgl-image-rendering.html: Added. 15 1 16 2021-09-13 Eric Hutchison <ehutchison@apple.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r282326 r282335 1 2021-09-13 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 image-rendering: pixelated does not work with WebGL (but does with Canvas2D) 4 https://bugs.webkit.org/show_bug.cgi?id=193895 5 <rdar://problem/47656086> 6 7 Reviewed by Simon Fraser. 8 9 Implement image-rendering: crisp-edges for WebGL canvas elements 10 normal on-screen compositing code path on Cocoa by using CA layer filtering 11 properties. 12 13 Similar to non-compositing code path, approximate image-rendering: pixelated 14 by making it an alias of crisp-edges. 15 16 Test: webgl/webgl-image-rendering.html 17 18 * platform/graphics/GraphicsLayer.h: 19 (WebCore::GraphicsLayer::setContentsMinificationFilter): 20 (WebCore::GraphicsLayer::contentsMinificationFilter const): 21 (WebCore::GraphicsLayer::setContentsMagnificationFilter): 22 (WebCore::GraphicsLayer::contentsMagnificationFilter const): 23 * platform/graphics/ca/GraphicsLayerCA.cpp: 24 (WebCore::toPlatformCALayerFilterType): 25 (WebCore::GraphicsLayerCA::setContentsMinificationFilter): 26 (WebCore::GraphicsLayerCA::setContentsMagnificationFilter): 27 (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): 28 (WebCore::GraphicsLayerCA::updateContentsScalingFilters): 29 (WebCore::GraphicsLayerCA::updateContentsPlatformLayer): 30 (WebCore::GraphicsLayerCA::layerChangeAsString): 31 * platform/graphics/ca/GraphicsLayerCA.h: 32 * rendering/RenderHTMLCanvas.h: 33 * rendering/RenderLayerBacking.cpp: 34 (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): 35 (WebCore::RenderLayerBacking::updateContentsScalingFilters): 36 (WebCore::RenderLayerBacking::updateConfigurationAfterStyleChange): 37 (WebCore::RenderLayerBacking::updateGeometry): 38 (WebCore::RenderLayerBacking::paintIntoLayer): 39 * rendering/RenderLayerBacking.h: 40 1 41 2021-09-13 Alan Bujtas <zalan@apple.com> 2 42 -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.h
r281238 r282335 541 541 CompositingCoordinatesOrientation contentsOrientation() const { return m_contentsOrientation; } 542 542 543 enum class ScalingFilter { Linear, Nearest, Trilinear }; 544 virtual void setContentsMinificationFilter(ScalingFilter filter) { m_contentsMinificationFilter = filter; } 545 ScalingFilter contentsMinificationFilter() const { return m_contentsMinificationFilter; } 546 virtual void setContentsMagnificationFilter(ScalingFilter filter) { m_contentsMagnificationFilter = filter; } 547 ScalingFilter contentsMagnificationFilter() const { return m_contentsMagnificationFilter; } 548 543 549 void dumpLayer(WTF::TextStream&, OptionSet<LayerTreeAsTextOptions> = { }) const; 544 550 … … 770 776 FloatSize m_contentsTilePhase; 771 777 FloatSize m_contentsTileSize; 778 ScalingFilter m_contentsMinificationFilter = ScalingFilter::Linear; 779 ScalingFilter m_contentsMagnificationFilter = ScalingFilter::Linear; 772 780 FloatRoundedRect m_backdropFiltersRect; 773 781 std::optional<FloatRect> m_animationExtent; -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r281238 r282335 303 303 } 304 304 305 static PlatformCALayer::FilterType toPlatformCALayerFilterType(GraphicsLayer::ScalingFilter filter) 306 { 307 switch (filter) { 308 case GraphicsLayer::ScalingFilter::Linear: 309 return PlatformCALayer::Linear; 310 case GraphicsLayer::ScalingFilter::Nearest: 311 return PlatformCALayer::Nearest; 312 case GraphicsLayer::ScalingFilter::Trilinear: 313 return PlatformCALayer::Trilinear; 314 } 315 ASSERT_NOT_REACHED(); 316 return PlatformCALayer::Linear; 317 } 318 305 319 bool GraphicsLayer::supportsLayerType(Type type) 306 320 { … … 1342 1356 #endif 1343 1357 1358 void GraphicsLayerCA::setContentsMinificationFilter(ScalingFilter filter) 1359 { 1360 if (filter == m_contentsMinificationFilter) 1361 return; 1362 GraphicsLayer::setContentsMinificationFilter(filter); 1363 noteLayerPropertyChanged(ContentsScalingFiltersChanged); 1364 } 1365 1366 void GraphicsLayerCA::setContentsMagnificationFilter(ScalingFilter filter) 1367 { 1368 if (filter == m_contentsMagnificationFilter) 1369 return; 1370 GraphicsLayer::setContentsMagnificationFilter(filter); 1371 noteLayerPropertyChanged(ContentsScalingFiltersChanged); 1372 } 1373 1344 1374 void GraphicsLayerCA::layerDidDisplay(PlatformCALayer* layer) 1345 1375 { … … 2026 2056 #endif 2027 2057 #endif 2058 if (m_uncommittedChanges & ContentsScalingFiltersChanged) 2059 updateContentsScalingFilters(); 2028 2060 2029 2061 if (m_uncommittedChanges & ChildrenChanged) { … … 2486 2518 #endif 2487 2519 2520 void GraphicsLayerCA::updateContentsScalingFilters() 2521 { 2522 if (!m_contentsLayer) 2523 return; 2524 m_contentsLayer->setMinificationFilter(toPlatformCALayerFilterType(m_contentsMinificationFilter)); 2525 m_contentsLayer->setMagnificationFilter(toPlatformCALayerFilterType(m_contentsMagnificationFilter)); 2526 } 2527 2488 2528 bool GraphicsLayerCA::updateStructuralLayer() 2489 2529 { … … 2759 2799 2760 2800 updateContentsRects(); 2801 updateContentsScalingFilters(); 2761 2802 } 2762 2803 … … 4187 4228 #endif 4188 4229 #endif 4230 case LayerChange::ContentsScalingFiltersChanged: return "ContentsScalingFiltersChanged"; 4189 4231 } 4190 4232 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
r281238 r282335 156 156 WEBCORE_EXPORT PlatformLayerID contentsLayerIDForModel() const override; 157 157 #endif 158 WEBCORE_EXPORT void setContentsMinificationFilter(ScalingFilter) override; 159 WEBCORE_EXPORT void setContentsMagnificationFilter(ScalingFilter) override; 158 160 159 161 bool usesContentsLayer() const override { return m_contentsLayerPurpose != ContentsLayerPurpose::None; } … … 464 466 #endif 465 467 #endif 468 void updateContentsScalingFilters(); 466 469 467 470 enum StructuralLayerPurpose { … … 579 582 #endif 580 583 #endif 584 ContentsScalingFiltersChanged = 1LLU << 44, 581 585 }; 582 586 typedef uint64_t LayerChangeFlags; -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r281364 r282335 541 541 } 542 542 #endif 543 544 updateOpacity( renderer().style());545 updateTransform( renderer().style());546 updateFilters( renderer().style());543 auto& style = renderer().style(); 544 updateOpacity(style); 545 updateTransform(style); 546 updateFilters(style); 547 547 #if ENABLE(FILTERS_LEVEL_2) 548 updateBackdropFilters( renderer().style());548 updateBackdropFilters(style); 549 549 #endif 550 550 #if ENABLE(CSS_COMPOSITING) 551 updateBlendMode(renderer().style()); 552 #endif 553 updateCustomAppearance(renderer().style()); 551 updateBlendMode(style); 552 #endif 553 updateCustomAppearance(style); 554 updateContentsScalingFilters(style); 554 555 } 555 556 … … 780 781 } 781 782 783 void RenderLayerBacking::updateContentsScalingFilters(const RenderStyle& style) 784 { 785 if (!renderer().isCanvas() || canvasCompositingStrategy(renderer()) != CanvasAsLayerContents) 786 return; 787 auto minificationFilter = GraphicsLayer::ScalingFilter::Linear; 788 auto magnificationFilter = GraphicsLayer::ScalingFilter::Linear; 789 switch (style.imageRendering()) { 790 case ImageRendering::CrispEdges: 791 case ImageRendering::Pixelated: 792 // FIXME: In order to match other code-paths, we treat these the same. 793 minificationFilter = GraphicsLayer::ScalingFilter::Nearest; 794 magnificationFilter = GraphicsLayer::ScalingFilter::Nearest; 795 break; 796 default: 797 break; 798 } 799 m_graphicsLayer->setContentsMinificationFilter(minificationFilter); 800 m_graphicsLayer->setContentsMagnificationFilter(magnificationFilter); 801 } 802 782 803 static bool layerOrAncestorIsTransformedOrUsingCompositedScrolling(RenderLayer& layer) 783 804 { … … 960 981 #endif 961 982 updateCustomAppearance(style); 983 updateContentsScalingFilters(style); 962 984 } 963 985 … … 1285 1307 updateBlendMode(style); 1286 1308 #endif 1309 updateContentsScalingFilters(style); 1287 1310 1288 1311 ASSERT(compositedAncestor == m_owningLayer.ancestorCompositingLayer()); -
trunk/Source/WebCore/rendering/RenderLayerBacking.h
r281238 r282335 356 356 #endif 357 357 void updateCustomAppearance(const RenderStyle&); 358 void updateContentsScalingFilters(const RenderStyle&); 358 359 359 360 // Return the opacity value that this layer should use for compositing.
Note: See TracChangeset
for help on using the changeset viewer.