WebKit Bugzilla
Attachment 339371 Details for
Bug 185230
: Use IOSurfaces for CoreImage operations where possible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185230-20180502174529.patch (text/plain), 4.83 KB, created by
Dean Jackson
on 2018-05-02 17:45:29 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dean Jackson
Created:
2018-05-02 17:45:29 PDT
Size:
4.83 KB
patch
obsolete
>Subversion Revision: 231201 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index fd69da2d37bc37401f4a154407fd3a750d75740c..cfb9c07011008609812629cdc34c1cf8e2be8b50 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2018-05-02 Dean Jackson <dino@apple.com> >+ >+ Use IOSurfaces for CoreImage operations where possible >+ https://bugs.webkit.org/show_bug.cgi?id=185230 >+ <rdar://problem/39926929> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ On iOS hardware, we can use IOSurfaces as a rendering destination >+ for CoreImage, which means we're keeping data on the GPU >+ for rendering. >+ >+ As a drive-by fix, I used a convenience method for Gaussian blurs. >+ >+ * rendering/RenderThemeIOS.mm: >+ (WebCore::RenderThemeIOS::paintSystemPreviewBadge): >+ > 2018-05-02 Dean Jackson <dino@apple.com> > > Draw SystemPreview badge to specification on iOS >diff --git a/Source/WebCore/rendering/RenderThemeIOS.mm b/Source/WebCore/rendering/RenderThemeIOS.mm >index d819b0022c8b45407a86ce02b2ce1cdb0904b2d0..ab657bfb330f20f8e7f2ec1642e6f696fd3e304f 100644 >--- a/Source/WebCore/rendering/RenderThemeIOS.mm >+++ b/Source/WebCore/rendering/RenderThemeIOS.mm >@@ -49,6 +49,7 @@ > #import "HTMLInputElement.h" > #import "HTMLNames.h" > #import "HTMLSelectElement.h" >+#import "IOSurface.h" > #import "Icon.h" > #import "LocalizedDateCache.h" > #import "NodeRenderStyle.h" >@@ -1826,19 +1827,19 @@ String RenderThemeIOS::extraDefaultStyleSheet() > #if USE(SYSTEM_PREVIEW) > void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& paintInfo, const FloatRect& rect) > { >- static const float largeBadgeDimension = 70; >- static const float largeBadgeOffset = 20; >+ static const int largeBadgeDimension = 70; >+ static const int largeBadgeOffset = 20; > >- static const float smallBadgeDimension = 35; >- static const float smallBadgeOffset = 8; >+ static const int smallBadgeDimension = 35; >+ static const int smallBadgeOffset = 8; > >- static const float minimumSizeForLargeBadge = 240; >+ static const int minimumSizeForLargeBadge = 240; > > bool useSmallBadge = rect.width() < minimumSizeForLargeBadge || rect.height() < minimumSizeForLargeBadge; >- float badgeOffset = useSmallBadge ? smallBadgeOffset : largeBadgeOffset; >- float badgeDimension = useSmallBadge ? smallBadgeDimension : largeBadgeDimension; >+ int badgeOffset = useSmallBadge ? smallBadgeOffset : largeBadgeOffset; >+ int badgeDimension = useSmallBadge ? smallBadgeDimension : largeBadgeDimension; > >- float minimumDimension = badgeDimension + 2 * badgeOffset; >+ int minimumDimension = badgeDimension + 2 * badgeOffset; > if (rect.width() < minimumDimension || rect.height() < minimumDimension) > return; > >@@ -1860,14 +1861,11 @@ void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& pain > CIImage *clampedImage = [scaledImage imageByClampingToRect:flippedInsetBadgeRect]; > > // Blur. >- CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"]; >- [blurFilter setDefaults]; >- [blurFilter setValue:@(10) forKey:kCIInputRadiusKey]; >- [blurFilter setValue:clampedImage forKey:kCIInputImageKey]; >+ CIImage *blurredImage = [clampedImage imageByApplyingGaussianBlurWithSigma:10]; > > // Saturate. > CIFilter *saturationFilter = [CIFilter filterWithName:@"CIColorControls"]; >- [saturationFilter setValue:blurFilter.outputImage forKey:kCIInputImageKey]; >+ [saturationFilter setValue:blurredImage forKey:kCIInputImageKey]; > [saturationFilter setValue:@1.8 forKey:kCIInputSaturationKey]; > > // Tint. >@@ -1892,7 +1890,18 @@ void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& pain > > if (!m_ciContext) > m_ciContext = [CIContext context]; >- RetainPtr<CGImageRef> cgImage = adoptCF([m_ciContext.get() createCGImage:sourceOverFilter.outputImage fromRect:flippedInsetBadgeRect]); >+ >+ RetainPtr<CGImageRef> cgImage; >+#if HAVE(IOSURFACE) >+ // Crop the result to the badge location. >+ CIImage *croppedImage = [sourceOverFilter.outputImage imageByCroppingToRect:flippedInsetBadgeRect]; >+ CIImage *translatedImage = [croppedImage imageByApplyingTransform:CGAffineTransformMakeTranslation(-flippedInsetBadgeRect.origin.x, -flippedInsetBadgeRect.origin.y)]; >+ auto surface = IOSurface::create({ badgeDimension, badgeDimension }, sRGBColorSpaceRef()); >+ [m_ciContext.get() render:translatedImage toIOSurface:surface->surface() bounds:CGRectMake(0, 0, badgeDimension, badgeDimension) colorSpace:sRGBColorSpaceRef()]; >+ cgImage = surface->createImage(); >+#else >+ cgImage = adoptCF([m_ciContext.get() createCGImage:sourceOverFilter.outputImage fromRect:flippedInsetBadgeRect]); >+#endif > > CGContextSaveGState(ctx); > CGContextTranslateCTM(ctx, absoluteBadgeRect.origin.x, absoluteBadgeRect.origin.y);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185230
:
339371
|
339613
|
339614