[Cairo] Avoid extra copy when drawing images

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

Patch by Aloisio Almeida Jr <aloisio.almeida@openbossa.org> on 2013-12-05
Reviewed by Carlos Garcia Campos.

This commit applies some changes proposed after the original patch has
been landed. It fixes the logic to create the subsurface (as it was
inverted). It also remove an unnecessary RefPtr variable to hold the
subsurface.

No new tests. It's an enhancement. Already covered by existing tests.

* platform/graphics/cairo/PlatformContextCairo.cpp:
(WebCore::PlatformContextCairo::drawSurfaceToContext):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160177 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3a470a7f
2013-12-05 Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
[Cairo] Avoid extra copy when drawing images
https://bugs.webkit.org/show_bug.cgi?id=124209
Reviewed by Carlos Garcia Campos.
This commit applies some changes proposed after the original patch has
been landed. It fixes the logic to create the subsurface (as it was
inverted). It also remove an unnecessary RefPtr variable to hold the
subsurface.
No new tests. It's an enhancement. Already covered by existing tests.
* platform/graphics/cairo/PlatformContextCairo.cpp:
(WebCore::PlatformContextCairo::drawSurfaceToContext):
2013-12-05 Zoltan Horvath <zoltan@webkit.org>
[CSS Shapes] Fix inset when only a subset of the arguments are defined
......@@ -172,25 +172,23 @@ void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const
srcRect.setHeight(std::fabs(originalSrcRect.height()));
}
cairo_surface_t* patternSurface = surface;
RefPtr<cairo_surface_t> subsurface;
RefPtr<cairo_surface_t> patternSurface = surface;
float leftPadding = 0;
float topPadding = 0;
if (srcRect.x() || srcRect.y() || srcRect.size() == cairoSurfaceSize(surface)) {
if (srcRect.x() || srcRect.y() || srcRect.size() != cairoSurfaceSize(surface)) {
// 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
subsurface = adoptRef(cairo_surface_create_for_rectangle(surface, expandedSrcRect.x(),
patternSurface = adoptRef(cairo_surface_create_for_rectangle(surface, expandedSrcRect.x(),
expandedSrcRect.y(), expandedSrcRect.width(), expandedSrcRect.height()));
patternSurface = subsurface.get();
leftPadding = static_cast<float>(expandedSrcRect.x()) - floorf(srcRect.x());
topPadding = static_cast<float>(expandedSrcRect.y()) - floorf(srcRect.y());
}
RefPtr<cairo_pattern_t> pattern = adoptRef(cairo_pattern_create_for_surface(patternSurface));
RefPtr<cairo_pattern_t> pattern = adoptRef(cairo_pattern_create_for_surface(patternSurface.get()));
ASSERT(m_state);
switch (m_state->m_imageInterpolationQuality) {
......
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