Commit b312a845 authored by mrobinson@webkit.org's avatar mrobinson@webkit.org

[GTK] fast/canvas/DrawImageSinglePixelStretch.html fails

https://bugs.webkit.org/show_bug.cgi?id=58309

Reviewed by Alejandro G. Castro.

Source/WebCore:

No new tests. This patch unskips a test.

Prevent sampling outside source boundaries, by creating subsurfaces from source surfaces.
This also requires careful handling of negative and floating source rectangles.

* platform/graphics/cairo/PlatformContextCairo.cpp:
(WebCore::PlatformContextCairo::drawSurfaceToContext): Use a subsurface to prevent sampling
outside rectangle boundaries.

LayoutTests:

* platform/gtk/TestExpectations: Unskip a test which is now passing.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148681 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 34165f2b
2013-04-18 Martin Robinson <mrobinson@igalia.com>
[GTK] fast/canvas/DrawImageSinglePixelStretch.html fails
https://bugs.webkit.org/show_bug.cgi?id=58309
Reviewed by Alejandro G. Castro.
* platform/gtk/TestExpectations: Unskip a test which is now passing.
2013-04-18 Eric Carlson <eric.carlson@apple.com>
Flaky Test: media/track/track-mode.html
......@@ -1065,8 +1065,6 @@ Bug(GTK) editing/spelling/markers.html [ Skip ]
# testRunner.overridePreference("WebKitDefaultFontSize"...) does not take into account screen DPI
webkit.org/b/57160 fast/harness/override-preferences-2.html [ Failure ]
webkit.org/b/58309 fast/canvas/DrawImageSinglePixelStretch.html [ Failure ]
# Expose title direction in WebKit API
webkit.org/b/58845 fast/dom/title-directionality.html [ Failure ]
webkit.org/b/58845 fast/dom/title-directionality-removeChild.html [ Failure ]
......
2013-04-18 Martin Robinson <mrobinson@igalia.com>
[GTK] fast/canvas/DrawImageSinglePixelStretch.html fails
https://bugs.webkit.org/show_bug.cgi?id=58309
Reviewed by Alejandro G. Castro.
No new tests. This patch unskips a test.
Prevent sampling outside source boundaries, by creating subsurfaces from source surfaces.
This also requires careful handling of negative and floating source rectangles.
* platform/graphics/cairo/PlatformContextCairo.cpp:
(WebCore::PlatformContextCairo::drawSurfaceToContext): Use a subsurface to prevent sampling
outside rectangle boundaries.
2013-04-18 Jonathan Feldstein <jfeldstein@blackberry.com>
[BlackBerry] Improper initialization of ANGLEResources (resubmission)
......@@ -154,12 +154,28 @@ static void drawPatternToCairoContext(cairo_t* cr, cairo_pattern_t* pattern, con
cairo_fill(cr);
}
void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& srcRect, GraphicsContext* context)
void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& originalSrcRect, GraphicsContext* context)
{
// If we're drawing a sub portion of the image or scaling then create
// 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));
FloatRect srcRect = originalSrcRect;
// We need to account for negative source dimensions by flipping the rectangle.
if (originalSrcRect.width() < 0) {
srcRect.setX(originalSrcRect.x() + originalSrcRect.width());
srcRect.setWidth(std::fabs(originalSrcRect.width()));
}
if (originalSrcRect.height() < 0) {
srcRect.setY(originalSrcRect.y() + originalSrcRect.height());
srcRect.setHeight(std::fabs(originalSrcRect.height()));
}
// Cairo subsurfaces don't support floating point boundaries well, so we expand the rectangle.
IntRect expandedSrcRect(enclosingIntRect(srcRect));
// We use a subsurface here so that we don't end up sampling outside the originalSrcRect rectangle.
// See https://bugs.webkit.org/show_bug.cgi?id=58309
RefPtr<cairo_surface_t> subsurface = adoptRef(cairo_surface_create_for_rectangle(
surface, expandedSrcRect.x(), expandedSrcRect.y(), expandedSrcRect.width(), expandedSrcRect.height()));
RefPtr<cairo_pattern_t> pattern = adoptRef(cairo_pattern_create_for_surface(subsurface.get()));
ASSERT(m_state);
switch (m_state->m_imageInterpolationQuality) {
......@@ -177,9 +193,15 @@ void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const
}
cairo_pattern_set_extend(pattern.get(), CAIRO_EXTEND_PAD);
float scaleX = srcRect.width() / destRect.width();
float scaleY = srcRect.height() / destRect.height();
cairo_matrix_t matrix = { scaleX, 0, 0, scaleY, srcRect.x(), srcRect.y() };
// The pattern transformation properly scales the pattern for when the source rectangle is a
// different size than the destination rectangle. We also account for any offset we introduced
// by expanding floating point source rectangle sizes. It's important to take the absolute value
// of the scale since the original width and height might be negative.
float scaleX = std::fabs(srcRect.width() / destRect.width());
float scaleY = std::fabs(srcRect.height() / destRect.height());
float leftPadding = static_cast<float>(expandedSrcRect.x()) - floorf(srcRect.x());
float topPadding = static_cast<float>(expandedSrcRect.y()) - floorf(srcRect.y());
cairo_matrix_t matrix = { scaleX, 0, 0, scaleY, leftPadding, topPadding };
cairo_pattern_set_matrix(pattern.get(), &matrix);
ShadowBlur& shadow = context->platformContext()->shadowBlur();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment