Shadow GraphicsContext's ImageInterpolationQuality inside GraphicsContextState
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Oct 2015 04:22:59 +0000 (04:22 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Oct 2015 04:22:59 +0000 (04:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150306

Reviewed by Simon Fraser.

When getting the ImageInterpolationQuality, there is no need to round-trip through
the platform's graphics context. This patch migrates this piece of state to the
existing idiom of having a setter in GraphicsContext.cpp which sets the relevent
state in GraphicsContextState and then calls into a platform-specific setter.

No new tests because there is no behavior change.

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::setImageInterpolationQuality):
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::imageInterpolationQuality):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::setPlatformImageInterpolationQuality):
(WebCore::GraphicsContext::setImageInterpolationQuality): Deleted.
(WebCore::GraphicsContext::imageInterpolationQuality): Deleted.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::convertInterpolationQuality):
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::setPlatformImageInterpolationQuality):
(WebCore::GraphicsContext::setImageInterpolationQuality): Deleted.
(WebCore::GraphicsContext::imageInterpolationQuality): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191330 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

index fadc3df..83e322f 100644 (file)
@@ -1,3 +1,32 @@
+2015-10-19  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Shadow GraphicsContext's ImageInterpolationQuality inside GraphicsContextState
+        https://bugs.webkit.org/show_bug.cgi?id=150306
+
+        Reviewed by Simon Fraser.
+
+        When getting the ImageInterpolationQuality, there is no need to round-trip through
+        the platform's graphics context. This patch migrates this piece of state to the
+        existing idiom of having a setter in GraphicsContext.cpp which sets the relevent
+        state in GraphicsContextState and then calls into a platform-specific setter.
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::setImageInterpolationQuality):
+        * platform/graphics/GraphicsContext.h:
+        (WebCore::GraphicsContext::imageInterpolationQuality):
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::setPlatformImageInterpolationQuality):
+        (WebCore::GraphicsContext::setImageInterpolationQuality): Deleted.
+        (WebCore::GraphicsContext::imageInterpolationQuality): Deleted.
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::convertInterpolationQuality):
+        (WebCore::GraphicsContext::platformInit):
+        (WebCore::GraphicsContext::setPlatformImageInterpolationQuality):
+        (WebCore::GraphicsContext::setImageInterpolationQuality): Deleted.
+        (WebCore::GraphicsContext::imageInterpolationQuality): Deleted.
+
 2015-10-19  Chris Dumez  <cdumez@apple.com>
 
         Drop unnecessary Node::toInputElement() virtual function
index 2b4a2f7..3226ca2 100644 (file)
@@ -262,6 +262,16 @@ void GraphicsContext::setShouldSmoothFonts(bool shouldSmoothFonts)
     setPlatformShouldSmoothFonts(shouldSmoothFonts);
 }
 
+void GraphicsContext::setImageInterpolationQuality(InterpolationQuality imageInterpolationQuality)
+{
+    m_state.imageInterpolationQuality = imageInterpolationQuality;
+
+    if (paintingDisabled())
+        return;
+
+    setPlatformImageInterpolationQuality(imageInterpolationQuality);
+}
+
 void GraphicsContext::setAntialiasedFontDilationEnabled(bool antialiasedFontDilationEnabled)
 {
     m_state.antialiasedFontDilationEnabled = antialiasedFontDilationEnabled;
index 1a9f995..41ef5c8 100644 (file)
@@ -155,6 +155,7 @@ struct GraphicsContextState {
     float alpha { 1 };
     CompositeOperator compositeOperator { CompositeSourceOver };
     BlendMode blendMode { BlendModeNormal };
+    InterpolationQuality imageInterpolationQuality { InterpolationDefault };
 
     bool shouldAntialias : 1;
     bool shouldSmoothFonts : 1;
@@ -322,7 +323,7 @@ public:
     void drawPattern(Image&, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, ColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal);
 
     WEBCORE_EXPORT void setImageInterpolationQuality(InterpolationQuality);
-    InterpolationQuality imageInterpolationQuality() const;
+    InterpolationQuality imageInterpolationQuality() const { return m_state.imageInterpolationQuality; }
 
     WEBCORE_EXPORT void clip(const IntRect&);
     WEBCORE_EXPORT void clip(const FloatRect&);
@@ -538,6 +539,7 @@ private:
 
     void setPlatformShouldAntialias(bool);
     void setPlatformShouldSmoothFonts(bool);
+    void setPlatformImageInterpolationQuality(InterpolationQuality);
 
     void setPlatformShadow(const FloatSize&, float blur, const Color&, ColorSpace);
     void clearPlatformShadow();
index 93fb30c..8d8fb57 100644 (file)
@@ -1098,16 +1098,11 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
     cairo_set_antialias(platformContext()->cr(), enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
 }
 
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality quality)
+void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality quality)
 {
     platformContext()->setImageInterpolationQuality(quality);
 }
 
-InterpolationQuality GraphicsContext::imageInterpolationQuality() const
-{
-    return platformContext()->imageInterpolationQuality();
-}
-
 bool GraphicsContext::isAcceleratedContext() const
 {
     return cairo_surface_get_type(cairo_get_target(platformContext()->cr())) == CAIRO_SURFACE_TYPE_GL;
index 836e96e..fc2a8ae 100644 (file)
@@ -104,6 +104,23 @@ CGColorSpaceRef linearRGBColorSpaceRef()
 }
 #endif
 
+static InterpolationQuality convertInterpolationQuality(CGInterpolationQuality quality)
+{
+    switch (quality) {
+    case kCGInterpolationDefault:
+        return InterpolationDefault;
+    case kCGInterpolationNone:
+        return InterpolationNone;
+    case kCGInterpolationLow:
+        return InterpolationLow;
+    case kCGInterpolationMedium:
+        return InterpolationMedium;
+    case kCGInterpolationHigh:
+        return InterpolationHigh;
+    }
+    return InterpolationDefault;
+}
+
 void GraphicsContext::platformInit(CGContextRef cgContext)
 {
     m_data = new GraphicsContextPlatformPrivate(cgContext);
@@ -113,6 +130,7 @@ void GraphicsContext::platformInit(CGContextRef cgContext)
         setPlatformFillColor(fillColor(), fillColorSpace());
         setPlatformStrokeColor(strokeColor(), strokeColorSpace());
         setPlatformStrokeThickness(strokeThickness());
+        m_state.imageInterpolationQuality = convertInterpolationQuality(CGContextGetInterpolationQuality(platformContext()));
     }
 }
 
@@ -1433,11 +1451,8 @@ void GraphicsContext::setURLForRect(const URL& link, const IntRect& destRect)
 #endif
 }
 
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality mode)
+void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality mode)
 {
-    if (paintingDisabled())
-        return;
-
     CGInterpolationQuality quality = kCGInterpolationDefault;
     switch (mode) {
     case InterpolationDefault:
@@ -1459,27 +1474,6 @@ void GraphicsContext::setImageInterpolationQuality(InterpolationQuality mode)
     CGContextSetInterpolationQuality(platformContext(), quality);
 }
 
-InterpolationQuality GraphicsContext::imageInterpolationQuality() const
-{
-    if (paintingDisabled())
-        return InterpolationDefault;
-
-    CGInterpolationQuality quality = CGContextGetInterpolationQuality(platformContext());
-    switch (quality) {
-    case kCGInterpolationDefault:
-        return InterpolationDefault;
-    case kCGInterpolationNone:
-        return InterpolationNone;
-    case kCGInterpolationLow:
-        return InterpolationLow;
-    case kCGInterpolationMedium:
-        return InterpolationMedium;
-    case kCGInterpolationHigh:
-        return InterpolationHigh;
-    }
-    return InterpolationDefault;
-}
-
 void GraphicsContext::setIsCALayerContext(bool isLayerContext)
 {
     if (isLayerContext)