Skip to content
Permalink
Browse files
2011-05-24 Ryuan Choi <ryuan.choi@samsung.com>
        Reviewed by Andreas Kling.

        [GTK] Implement GraphicsContextCairo::imageInterpolationQuality().
        https://bugs.webkit.org/show_bug.cgi?id=60827

        Implement getter/setter of imageInterpolationQuality and logic to change
        interpolation algorithm when drawing image.
        Mac and Qt already implemented it.

        * platform/graphics/cairo/GraphicsContextCairo.cpp:
        (WebCore::GraphicsContext::setImageInterpolationQuality):
        (WebCore::GraphicsContext::imageInterpolationQuality):
        * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
        * platform/graphics/cairo/PlatformContextCairo.cpp:
        (WebCore::PlatformContextCairo::drawSurfaceToContext):
        * platform/graphics/cairo/PlatformContextCairo.h:
        (WebCore::PlatformContextCairo::setImageInterpolationQuality): Added.
        (WebCore::PlatformContextCairo::imageInterpolationQuality): Added.

Canonical link: https://commits.webkit.org/76731@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
webkit-commit-queue committed May 24, 2011
1 parent 45b2454 commit acf4f3aa697330a2e9d749d3d122564be42b3f83
@@ -1,3 +1,24 @@
2011-05-24 Ryuan Choi <ryuan.choi@samsung.com>

Reviewed by Andreas Kling.

[GTK] Implement GraphicsContextCairo::imageInterpolationQuality().
https://bugs.webkit.org/show_bug.cgi?id=60827

Implement getter/setter of imageInterpolationQuality and logic to change
interpolation algorithm when drawing image.
Mac and Qt already implemented it.

* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::setImageInterpolationQuality):
(WebCore::GraphicsContext::imageInterpolationQuality):
* platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
* platform/graphics/cairo/PlatformContextCairo.cpp:
(WebCore::PlatformContextCairo::drawSurfaceToContext):
* platform/graphics/cairo/PlatformContextCairo.h:
(WebCore::PlatformContextCairo::setImageInterpolationQuality): Added.
(WebCore::PlatformContextCairo::imageInterpolationQuality): Added.

2011-05-24 Leandro Gracia Gil <leandrogracia@chromium.org>

Reviewed by Tony Gentilcore.
@@ -1154,13 +1154,14 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
cairo_set_antialias(platformContext()->cr(), enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
}

void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
void GraphicsContext::setImageInterpolationQuality(InterpolationQuality quality)
{
platformContext()->setImageInterpolationQuality(quality);
}

InterpolationQuality GraphicsContext::imageInterpolationQuality() const
{
return InterpolationDefault;
return platformContext()->imageInterpolationQuality();
}

} // namespace WebCore
@@ -102,6 +102,7 @@ class GraphicsContextPlatformPrivate {
Vector<float> layers;
ContextShadow shadow;
Vector<ContextShadow> shadowStack;
InterpolationQuality imageInterpolationQuality;

#if PLATFORM(GTK)
GdkEventExpose* expose;
@@ -97,6 +97,20 @@ void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const
// a pattern transformation on the image and draw the transformed pattern.
// Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
RefPtr<cairo_pattern_t> pattern = adoptRef(cairo_pattern_create_for_surface(surface));

switch (m_imageInterpolationQuality) {
case InterpolationNone:
case InterpolationLow:
cairo_pattern_set_filter(pattern.get(), CAIRO_FILTER_FAST);
break;
case InterpolationMedium:
case InterpolationHigh:
cairo_pattern_set_filter(pattern.get(), CAIRO_FILTER_BILINEAR);
break;
case InterpolationDefault:
cairo_pattern_set_filter(pattern.get(), CAIRO_FILTER_BILINEAR);
break;
}
cairo_pattern_set_extend(pattern.get(), CAIRO_EXTEND_PAD);

float scaleX = srcRect.width() / destRect.width();
@@ -27,6 +27,7 @@
#define PlatformContextCairo_h

#include "ContextShadow.h"
#include "GraphicsContext.h"
#include "RefPtrCairo.h"

namespace WebCore {
@@ -68,9 +69,13 @@ class PlatformContextCairo {
void pushImageMask(cairo_surface_t*, const FloatRect&);
void drawSurfaceToContext(cairo_surface_t*, const FloatRect& destRect, const FloatRect& srcRect, GraphicsContext*);

void setImageInterpolationQuality(InterpolationQuality quality) { m_imageInterpolationQuality = quality; }
InterpolationQuality imageInterpolationQuality() const { return m_imageInterpolationQuality; }

private:
RefPtr<cairo_t> m_cr;
Vector<ImageMaskInformation> m_maskImageStack;
InterpolationQuality m_imageInterpolationQuality;
};

} // namespace WebCore

0 comments on commit acf4f3a

Please sign in to comment.