Title: [265346] trunk/Source/WebCore
- Revision
- 265346
- Author
- commit-qu...@webkit.org
- Date
- 2020-08-06 14:02:12 -0700 (Thu, 06 Aug 2020)
Log Message
[CG] Avoid creating a sub-image when drawing a small scaled sub-rect from a native image
https://bugs.webkit.org/show_bug.cgi?id=215015
<rdar://problem/63845893>
Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2020-08-06
Reviewed by Simon Fraser.
The reason for creating the sub-image in GraphicsContext::drawNativeImage()
is to have a better image interpolation for the scaled sub-rect. For small
destRect, the interpolation on the original image is almost the same as
the interpolation on the sub-image. So we should avoid creating the sub-
image if destRect.area() is less than some minimum value. Creating many
sub-images can affect the rendering performance.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::drawNativeImage):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (265345 => 265346)
--- trunk/Source/WebCore/ChangeLog 2020-08-06 20:21:06 UTC (rev 265345)
+++ trunk/Source/WebCore/ChangeLog 2020-08-06 21:02:12 UTC (rev 265346)
@@ -1,3 +1,21 @@
+2020-08-06 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ [CG] Avoid creating a sub-image when drawing a small scaled sub-rect from a native image
+ https://bugs.webkit.org/show_bug.cgi?id=215015
+ <rdar://problem/63845893>
+
+ Reviewed by Simon Fraser.
+
+ The reason for creating the sub-image in GraphicsContext::drawNativeImage()
+ is to have a better image interpolation for the scaled sub-rect. For small
+ destRect, the interpolation on the original image is almost the same as
+ the interpolation on the sub-image. So we should avoid creating the sub-
+ image if destRect.area() is less than some minimum value. Creating many
+ sub-images can affect the rendering performance.
+
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::drawNativeImage):
+
2020-08-06 David Kilzer <ddkil...@apple.com>
WTF::makeString() should handle enum values
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (265345 => 265346)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2020-08-06 20:21:06 UTC (rev 265345)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2020-08-06 21:02:12 UTC (rev 265346)
@@ -315,9 +315,10 @@
// containing only the portion we want to display. We need to do this because high-quality
// interpolation smoothes sharp edges, causing pixels from outside the source rect to bleed
// into the destination rect. See <rdar://problem/6112909>.
- shouldUseSubimage = (interpolationQuality != kCGInterpolationNone) && (srcRect.size() != destRect.size() || !getCTM().isIdentityOrTranslationOrFlipped());
+ const float minimumAreaForInterpolation = 40 * 40;
float xScale = srcRect.width() / destRect.width();
float yScale = srcRect.height() / destRect.height();
+ shouldUseSubimage = (interpolationQuality != kCGInterpolationNone) && (xScale < 0 || yScale < 0 || destRect.area() >= minimumAreaForInterpolation) && (srcRect.size() != destRect.size() || !getCTM().isIdentityOrTranslationOrFlipped());
if (shouldUseSubimage) {
FloatRect subimageRect = srcRect;
float leftPadding = srcRect.x() - floorf(srcRect.x());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes