Changeset 246391 in webkit
- Timestamp:
- Jun 12, 2019, 9:10:33 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 3 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/svg/clip-path/clip-hidpi-expected.svg (added)
-
LayoutTests/svg/clip-path/clip-hidpi.svg (added)
-
LayoutTests/svg/clip-path/clip-opacity-translate-expected.svg (added)
-
LayoutTests/svg/clip-path/clip-opacity-translate.svg (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r246390 r246391 1 2019-06-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [cairo][SVG] If clipPath has multiple elements, clip-path doesn't work with transform 4 https://bugs.webkit.org/show_bug.cgi?id=198746 5 <rdar://problem/51620347> 6 7 Reviewed by Don Olmstead. 8 9 * svg/clip-path/clip-hidpi-expected.svg: Added. 10 * svg/clip-path/clip-hidpi.svg: Added. 11 * svg/clip-path/clip-opacity-translate-expected.svg: Added. 12 * svg/clip-path/clip-opacity-translate.svg: Added. 13 1 14 2019-06-12 Myles C. Maxfield <mmaxfield@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r246389 r246391 1 2019-06-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [cairo][SVG] If clipPath has multiple elements, clip-path doesn't work with transform 4 https://bugs.webkit.org/show_bug.cgi?id=198746 5 6 Reviewed by Don Olmstead. 7 8 We need to save the current transformation matrix at the moment the image mask is set and set it again on 9 restore right before applying the mask. This patch also creates a pattern for the image mask surface and set its 10 transformation matrix according to the mask position, so that we don't need to save the mask rectangle too. 11 12 Tests: svg/clip-path/clip-hidpi-expected.svg 13 svg/clip-path/clip-hidpi.svg 14 svg/clip-path/clip-opacity-translate-expected.svg 15 svg/clip-path/clip-opacity-translate.svg 16 17 * platform/graphics/cairo/PlatformContextCairo.cpp: 18 (WebCore::PlatformContextCairo::restore): 19 (WebCore::PlatformContextCairo::pushImageMask): 20 1 21 2019-06-12 Simon Fraser <simon.fraser@apple.com> 2 22 -
trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp
r246354 r246391 31 31 #if USE(CAIRO) 32 32 33 #include "CairoUtilities.h"34 #include "Gradient.h"35 #include "GraphicsContext.h"36 #include "Pattern.h"37 33 #include <cairo.h> 38 34 39 35 namespace WebCore { 40 41 // In Cairo image masking is immediate, so to emulate image clipping we must save masking42 // details as part of the context state and apply them during platform restore.43 class ImageMaskInformation {44 public:45 void update(cairo_surface_t* maskSurface, const FloatRect& maskRect)46 {47 m_maskSurface = maskSurface;48 m_maskRect = maskRect;49 }50 51 bool isValid() const { return m_maskSurface; }52 cairo_surface_t* maskSurface() const { return m_maskSurface.get(); }53 const FloatRect& maskRect() const { return m_maskRect; }54 55 private:56 RefPtr<cairo_surface_t> m_maskSurface;57 FloatRect m_maskRect;58 };59 60 36 61 37 // Encapsulates the additional painting state information we store for each … … 65 41 State() = default; 66 42 67 ImageMaskInformation m_imageMaskInformation; 43 struct { 44 RefPtr<cairo_pattern_t> pattern; 45 cairo_matrix_t matrix; 46 } m_mask; 68 47 }; 69 48 … … 77 56 void PlatformContextCairo::restore() 78 57 { 79 const ImageMaskInformation& maskInformation = m_state->m_imageMaskInformation; 80 if (maskInformation.isValid()) { 81 const FloatRect& maskRect = maskInformation.maskRect(); 58 if (m_state->m_mask.pattern) { 82 59 cairo_pop_group_to_source(m_cr.get()); 83 cairo_mask_surface(m_cr.get(), maskInformation.maskSurface(), maskRect.x(), maskRect.y()); 60 61 cairo_matrix_t matrix; 62 cairo_get_matrix(m_cr.get(), &matrix); 63 cairo_set_matrix(m_cr.get(), &m_state->m_mask.matrix); 64 cairo_mask(m_cr.get(), m_state->m_mask.pattern.get()); 65 cairo_set_matrix(m_cr.get(), &matrix); 84 66 } 85 67 … … 106 88 // since we actually apply the mask in restorePlatformState. 107 89 ASSERT(!m_stateStack.isEmpty()); 108 m_state->m_imageMaskInformation.update(surface, rect); 90 m_state->m_mask.pattern = adoptRef(cairo_pattern_create_for_surface(surface)); 91 cairo_get_matrix(m_cr.get(), &m_state->m_mask.matrix); 109 92 110 // Cairo doesn't support the notion of an image clip, so we push a group here 111 // and then paint it to the surface with an image mask (which is an immediate 112 // operation) during restorePlatformState. 93 cairo_matrix_t matrix; 94 cairo_matrix_init_translate(&matrix, -rect.x(), -rect.y()); 95 cairo_pattern_set_matrix(m_state->m_mask.pattern.get(), &matrix); 96 113 97 cairo_push_group(m_cr.get()); 114 98 }
Note:
See TracChangeset
for help on using the changeset viewer.