WebKit Bugzilla
Attachment 339656 Details for
Bug 185356
: Draw a drop-shadow behind the system preview badge
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185356-20180505150159.patch (text/plain), 6.59 KB, created by
Dean Jackson
on 2018-05-05 15:02:00 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dean Jackson
Created:
2018-05-05 15:02:00 PDT
Size:
6.59 KB
patch
obsolete
>Subversion Revision: 231310 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 6ae84102c8b6f5d89e5d67df0ea5f0fedc37270c..41dbbc2a04800da530b6dc2fc468cb3fc00a7e28 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2018-05-05 Dean Jackson <dino@apple.com> >+ >+ Draw a drop-shadow behind the system preview badge >+ https://bugs.webkit.org/show_bug.cgi?id=185356 >+ <rdar://problem/40004936> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Draw a very subtle drop-shadow under the system >+ preview badge so that it is more visible on a pure >+ white background. >+ >+ I also moved some code around to make it more clear >+ and improved comments. >+ >+ * rendering/RenderThemeIOS.mm: >+ (WebCore::RenderThemeIOS::paintSystemPreviewBadge): >+ > 2018-05-02 Dean Jackson <dino@apple.com> > > Use IOSurfaces for CoreImage operations where possible >diff --git a/Source/WebCore/rendering/RenderThemeIOS.mm b/Source/WebCore/rendering/RenderThemeIOS.mm >index 97a388d3ceeb22daf4bdf646c90a7c9f3eac8bb5..603e1987b7284854f7747afe6ff1751ebfd95a48 100644 >--- a/Source/WebCore/rendering/RenderThemeIOS.mm >+++ b/Source/WebCore/rendering/RenderThemeIOS.mm >@@ -1843,18 +1843,45 @@ void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& pain > if (rect.width() < minimumDimension || rect.height() < minimumDimension) > return; > >+ CGRect absoluteBadgeRect = CGRectMake(rect.x() + rect.width() - badgeDimension - badgeOffset, rect.y() + badgeOffset, badgeDimension, badgeDimension); >+ CGRect insetBadgeRect = CGRectMake(rect.width() - badgeDimension - badgeOffset, badgeOffset, badgeDimension, badgeDimension); >+ CGRect badgeRect = CGRectMake(0, 0, badgeDimension, badgeDimension); >+ > CIImage *inputImage = [CIImage imageWithCGImage:image.nativeImage().get()]; > >- // Scale from intrinsic size to render size. >+ // Create a circle to be used for the clipping path in the badge, as well as the drop shadow. >+ RetainPtr<CGPathRef> circle = adoptCF(CGPathCreateWithRoundedRect(absoluteBadgeRect, badgeDimension / 2, badgeDimension / 2, nullptr)); >+ >+ CGContextRef ctx = paintInfo.context().platformContext(); >+ >+ CGContextSaveGState(ctx); >+ >+ // Draw a drop shadow around the circle. >+ CGFloat shadowColorComponents[4] = { 0, 0, 0, 0.1 }; >+ RetainPtr<CGColorRef> shadowColor = adoptCF(CGColorCreate(sRGBColorSpaceRef(), shadowColorComponents)); >+ // The circle must have an alpha channel value of 1 for the shadow color to appear. >+ CGFloat circleColorComponents[4] = { 0, 0, 0, 1 }; >+ RetainPtr<CGColorRef> circleColor = adoptCF(CGColorCreate(sRGBColorSpaceRef(), circleColorComponents)); >+ CGContextSetFillColorWithColor(ctx, circleColor.get()); >+ CGContextSetShadowWithColor(ctx, CGSizeZero, 16, shadowColor.get()); >+ >+ // Draw a slightly smaller circle with a shadow, otherwise we'll see a fringe of the solid >+ // black circle around the edges of the cliped path below. >+ CGContextBeginPath(ctx); >+ CGRect slightlySmallerAbsoluteBadgeRect = CGRectMake(absoluteBadgeRect.origin.x + 0.5, absoluteBadgeRect.origin.y + 0.5, badgeDimension - 1, badgeDimension - 1); >+ RetainPtr<CGPathRef> slightlySmallerCircle = adoptCF(CGPathCreateWithRoundedRect(slightlySmallerAbsoluteBadgeRect, slightlySmallerAbsoluteBadgeRect.size.width / 2, slightlySmallerAbsoluteBadgeRect.size.height / 2, nullptr)); >+ CGContextAddPath(ctx, slightlySmallerCircle.get()); >+ CGContextClosePath(ctx); >+ CGContextFillPath(ctx); >+ >+ CGContextRestoreGState(ctx); >+ >+ // Draw the blurred backdrop. Scale from intrinsic size to render size. > CGAffineTransform transform = CGAffineTransformIdentity; > transform = CGAffineTransformScale(transform, rect.width() / image.width(), rect.height() / image.height()); > CIImage *scaledImage = [inputImage imageByApplyingTransform:transform]; > >- CGRect absoluteBadgeRect = CGRectMake(rect.x() + rect.width() - badgeDimension - badgeOffset, rect.y() + badgeOffset, badgeDimension, badgeDimension); >- CGRect insetBadgeRect = CGRectMake(rect.width() - badgeDimension - badgeOffset, badgeOffset, badgeDimension, badgeDimension); >- CGRect badgeRect = CGRectMake(0, 0, badgeDimension, badgeDimension); >- >- // CI coordinates are y-up, so we need to flip the badge rectangle within the image frame. >+ // CoreImage coordinates are y-up, so we need to flip the badge rectangle within the image frame. > CGRect flippedInsetBadgeRect = CGRectMake(insetBadgeRect.origin.x, rect.height() - insetBadgeRect.origin.y - insetBadgeRect.size.height, badgeDimension, badgeDimension); > > // Create a cropped region with pixel values extending outwards. >@@ -1878,16 +1905,6 @@ void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& pain > [sourceOverFilter setValue:tintFilter1.outputImage forKey:kCIInputImageKey]; > [sourceOverFilter setValue:saturationFilter.outputImage forKey:kCIInputBackgroundImageKey]; > >- // Before we render the result, we should clip to a circle around the badge rectangle. >- CGContextRef ctx = paintInfo.context().platformContext(); >- CGContextSaveGState(ctx); >- CGContextBeginPath(ctx); >- CGPathRef circle = CGPathCreateWithRoundedRect(absoluteBadgeRect, badgeDimension / 2, badgeDimension / 2, nil); >- CGContextAddPath(ctx, circle); >- CGContextClosePath(ctx); >- CGContextClip(ctx); >- CGPathRelease(circle); >- > if (!m_ciContext) > m_ciContext = [CIContext context]; > >@@ -1912,17 +1929,20 @@ void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& pain > cgImage = adoptCF([m_ciContext.get() createCGImage:sourceOverFilter.outputImage fromRect:flippedInsetBadgeRect]); > #endif > >+ // Before we render the result, we should clip to a circle around the badge rectangle. > CGContextSaveGState(ctx); >+ CGContextBeginPath(ctx); >+ CGContextAddPath(ctx, circle.get()); >+ CGContextClosePath(ctx); >+ CGContextClip(ctx); >+ > CGContextTranslateCTM(ctx, absoluteBadgeRect.origin.x, absoluteBadgeRect.origin.y); > CGContextTranslateCTM(ctx, 0, badgeDimension); > CGContextScaleCTM(ctx, 1, -1); > CGContextDrawImage(ctx, badgeRect, cgImage.get()); >- CGContextRestoreGState(ctx); > > #if USE(APPLE_INTERNAL_SDK) > if (auto logo = systemPreviewLogo()) { >- // FIXME: Do we need to flip here too? >- CGContextTranslateCTM(ctx, absoluteBadgeRect.origin.x, absoluteBadgeRect.origin.y); > CGSize pdfSize = CGPDFPageGetBoxRect(logo, kCGPDFMediaBox).size; > CGFloat scaleX = badgeDimension / pdfSize.width; > CGFloat scaleY = badgeDimension / pdfSize.height;
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
Flags:
wenson_hsieh
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185356
: 339656