[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
alex at webkit.org
alex at webkit.org
Wed Dec 22 14:06:13 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 3f60aaa801cf0b13b74ed70a4b5cec141c62b656
Author: alex at webkit.org <alex at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Oct 4 15:23:32 2010 +0000
2010-10-04 Alejandro G. Castro <alex at igalia.com>
Reviewed by Martin Robinson.
[cairo] Move some cairo functions to the CairoUtilities
https://bugs.webkit.org/show_bug.cgi?id=47076
Moved some cairo functions to the CairoUtilities so we can use
them outside GraphicsContextCairo.
* platform/graphics/cairo/CairoUtilities.cpp:
(WebCore::appendPathToCairoContext):
(WebCore::setPathOnCairoContext):
(WebCore::appendWebCorePathToCairoContext):
(WebCore::toCairoOperator):
(WebCore::drawPatternToCairoContext):
* platform/graphics/cairo/CairoUtilities.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
* platform/graphics/cairo/ImageCairo.cpp:
(WebCore::Image::drawPattern):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ca18194..c664eb6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-10-04 Alejandro G. Castro <alex at igalia.com>
+
+ Reviewed by Martin Robinson.
+
+ [cairo] Move some cairo functions to the CairoUtilities
+ https://bugs.webkit.org/show_bug.cgi?id=47076
+
+ Moved some cairo functions to the CairoUtilities so we can use
+ them outside GraphicsContextCairo.
+
+ * platform/graphics/cairo/CairoUtilities.cpp:
+ (WebCore::appendPathToCairoContext):
+ (WebCore::setPathOnCairoContext):
+ (WebCore::appendWebCorePathToCairoContext):
+ (WebCore::toCairoOperator):
+ (WebCore::drawPatternToCairoContext):
+ * platform/graphics/cairo/CairoUtilities.h:
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ * platform/graphics/cairo/ImageCairo.cpp:
+ (WebCore::Image::drawPattern):
+
2010-10-04 podivilov at chromium.org <podivilov at chromium.org>
Reviewed by Yury Semikhatsky.
diff --git a/WebCore/platform/graphics/cairo/CairoUtilities.cpp b/WebCore/platform/graphics/cairo/CairoUtilities.cpp
index 8c2049f..ca4dceb 100644
--- a/WebCore/platform/graphics/cairo/CairoUtilities.cpp
+++ b/WebCore/platform/graphics/cairo/CairoUtilities.cpp
@@ -26,8 +26,14 @@
#include "config.h"
#include "CairoUtilities.h"
+#include "AffineTransform.h"
+#include "CairoPath.h"
#include "Color.h"
-#include <cairo.h>
+#include "FloatPoint.h"
+#include "FloatRect.h"
+#include "IntRect.h"
+#include "Path.h"
+#include "PlatformRefPtrCairo.h"
#include <wtf/Vector.h>
namespace WebCore {
@@ -56,4 +62,96 @@ void setSourceRGBAFromColor(cairo_t* context, const Color& color)
cairo_set_source_rgba(context, red, green, blue, alpha);
}
+void appendPathToCairoContext(cairo_t* to, cairo_t* from)
+{
+ OwnPtr<cairo_path_t> cairoPath(cairo_copy_path(from));
+ cairo_append_path(to, cairoPath.get());
+}
+
+void setPathOnCairoContext(cairo_t* to, cairo_t* from)
+{
+ cairo_new_path(to);
+ appendPathToCairoContext(to, from);
+}
+
+void appendWebCorePathToCairoContext(cairo_t* context, const Path& path)
+{
+ appendPathToCairoContext(context, path.platformPath()->context());
+}
+
+cairo_operator_t toCairoOperator(CompositeOperator op)
+{
+ switch (op) {
+ case CompositeClear:
+ return CAIRO_OPERATOR_CLEAR;
+ case CompositeCopy:
+ return CAIRO_OPERATOR_SOURCE;
+ case CompositeSourceOver:
+ return CAIRO_OPERATOR_OVER;
+ case CompositeSourceIn:
+ return CAIRO_OPERATOR_IN;
+ case CompositeSourceOut:
+ return CAIRO_OPERATOR_OUT;
+ case CompositeSourceAtop:
+ return CAIRO_OPERATOR_ATOP;
+ case CompositeDestinationOver:
+ return CAIRO_OPERATOR_DEST_OVER;
+ case CompositeDestinationIn:
+ return CAIRO_OPERATOR_DEST_IN;
+ case CompositeDestinationOut:
+ return CAIRO_OPERATOR_DEST_OUT;
+ case CompositeDestinationAtop:
+ return CAIRO_OPERATOR_DEST_ATOP;
+ case CompositeXOR:
+ return CAIRO_OPERATOR_XOR;
+ case CompositePlusDarker:
+ return CAIRO_OPERATOR_SATURATE;
+ case CompositeHighlight:
+ // There is no Cairo equivalent for CompositeHighlight.
+ return CAIRO_OPERATOR_OVER;
+ case CompositePlusLighter:
+ return CAIRO_OPERATOR_ADD;
+ default:
+ return CAIRO_OPERATOR_SOURCE;
+ }
+}
+
+void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
+ const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect)
+{
+ // Avoid NaN
+ if (!isfinite(phase.x()) || !isfinite(phase.y()))
+ return;
+
+ cairo_save(cr);
+
+ PlatformRefPtr<cairo_surface_t> clippedImageSurface = 0;
+ if (tileRect.size() != imageSize) {
+ IntRect imageRect = enclosingIntRect(tileRect);
+ clippedImageSurface = adoptPlatformRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, imageRect.width(), imageRect.height()));
+ PlatformRefPtr<cairo_t> clippedImageContext(cairo_create(clippedImageSurface.get()));
+ cairo_set_source_surface(clippedImageContext.get(), image, -tileRect.x(), -tileRect.y());
+ cairo_paint(clippedImageContext.get());
+ image = clippedImageSurface.get();
+ }
+
+ cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
+
+ cairo_matrix_t patternMatrix = cairo_matrix_t(patternTransform);
+ cairo_matrix_t phaseMatrix = {1, 0, 0, 1, phase.x() + tileRect.x() * patternTransform.a(), phase.y() + tileRect.y() * patternTransform.d()};
+ cairo_matrix_t combined;
+ cairo_matrix_multiply(&combined, &patternMatrix, &phaseMatrix);
+ cairo_matrix_invert(&combined);
+ cairo_pattern_set_matrix(pattern, &combined);
+
+ cairo_set_operator(cr, op);
+ cairo_set_source(cr, pattern);
+ cairo_pattern_destroy(pattern);
+ cairo_rectangle(cr, destRect.x(), destRect.y(), destRect.width(), destRect.height());
+ cairo_fill(cr);
+
+ cairo_restore(cr);
+}
+
} // namespace WebCore
diff --git a/WebCore/platform/graphics/cairo/CairoUtilities.h b/WebCore/platform/graphics/cairo/CairoUtilities.h
index 0675b90..d8fff8d 100644
--- a/WebCore/platform/graphics/cairo/CairoUtilities.h
+++ b/WebCore/platform/graphics/cairo/CairoUtilities.h
@@ -26,13 +26,25 @@
#ifndef CairoUtilities_h
#define CairoUtilities_h
-typedef struct _cairo cairo_t;
+#include <GraphicsTypes.h>
+#include <cairo.h>
namespace WebCore {
+class AffineTransform;
class Color;
+class FloatRect;
+class FloatPoint;
+class IntSize;
+class Path;
void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr);
void setSourceRGBAFromColor(cairo_t*, const Color&);
+void appendPathToCairoContext(cairo_t* to, cairo_t* from);
+void setPathOnCairoContext(cairo_t* to, cairo_t* from);
+void appendWebCorePathToCairoContext(cairo_t* context, const Path& path);
+cairo_operator_t toCairoOperator(CompositeOperator op);
+void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
+ const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect);
} // namespace WebCore
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
index 05096a9..ed3b30a 100644
--- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
+++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
@@ -132,26 +132,6 @@ static inline void fillRectSourceOver(cairo_t* cr, const FloatRect& rect, const
cairo_fill(cr);
}
-static void appendPathToCairoContext(cairo_t* to, cairo_t* from)
-{
- OwnPtr<cairo_path_t> cairoPath(cairo_copy_path(from));
- cairo_append_path(to, cairoPath.get());
-}
-
-// We apply the pending path built via addPath to the Cairo context
-// lazily. This prevents interaction between the path and other routines
-// such as fillRect.
-static void setPathOnCairoContext(cairo_t* to, cairo_t* from)
-{
- cairo_new_path(to);
- appendPathToCairoContext(to, from);
-}
-
-static void appendWebCorePathToCairoContext(cairo_t* context, const Path& path)
-{
- appendPathToCairoContext(context, path.platformPath()->context());
-}
-
static void addConvexPolygonToContext(cairo_t* context, size_t numPoints, const FloatPoint* points)
{
cairo_move_to(context, points[0].x(), points[0].y());
@@ -1095,43 +1075,6 @@ float GraphicsContext::getAlpha()
return m_common->state.globalAlpha;
}
-static inline cairo_operator_t toCairoOperator(CompositeOperator op)
-{
- switch (op) {
- case CompositeClear:
- return CAIRO_OPERATOR_CLEAR;
- case CompositeCopy:
- return CAIRO_OPERATOR_SOURCE;
- case CompositeSourceOver:
- return CAIRO_OPERATOR_OVER;
- case CompositeSourceIn:
- return CAIRO_OPERATOR_IN;
- case CompositeSourceOut:
- return CAIRO_OPERATOR_OUT;
- case CompositeSourceAtop:
- return CAIRO_OPERATOR_ATOP;
- case CompositeDestinationOver:
- return CAIRO_OPERATOR_DEST_OVER;
- case CompositeDestinationIn:
- return CAIRO_OPERATOR_DEST_IN;
- case CompositeDestinationOut:
- return CAIRO_OPERATOR_DEST_OUT;
- case CompositeDestinationAtop:
- return CAIRO_OPERATOR_DEST_ATOP;
- case CompositeXOR:
- return CAIRO_OPERATOR_XOR;
- case CompositePlusDarker:
- return CAIRO_OPERATOR_SATURATE;
- case CompositeHighlight:
- // There is no Cairo equivalent for CompositeHighlight.
- return CAIRO_OPERATOR_OVER;
- case CompositePlusLighter:
- return CAIRO_OPERATOR_ADD;
- default:
- return CAIRO_OPERATOR_SOURCE;
- }
-}
-
void GraphicsContext::setCompositeOperation(CompositeOperator op)
{
if (paintingDisabled())
diff --git a/WebCore/platform/graphics/cairo/ImageCairo.cpp b/WebCore/platform/graphics/cairo/ImageCairo.cpp
index 904e819..995f77b 100644
--- a/WebCore/platform/graphics/cairo/ImageCairo.cpp
+++ b/WebCore/platform/graphics/cairo/ImageCairo.cpp
@@ -31,6 +31,7 @@
#if PLATFORM(CAIRO)
#include "AffineTransform.h"
+#include "CairoUtilities.h"
#include "Color.h"
#include "FloatRect.h"
#include "PlatformRefPtrCairo.h"
@@ -172,46 +173,15 @@ void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const Flo
}
void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& destRect)
+ const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator op, const FloatRect& destRect)
{
cairo_surface_t* image = nativeImageForCurrentFrame();
if (!image) // If it's too early we won't have an image yet.
return;
- // Avoid NaN
- if (!isfinite(phase.x()) || !isfinite(phase.y()))
- return;
-
cairo_t* cr = context->platformContext();
- context->save();
-
- PlatformRefPtr<cairo_surface_t> clippedImageSurface = 0;
- if (tileRect.size() != size()) {
- IntRect imageSize = enclosingIntRect(tileRect);
- clippedImageSurface = adoptPlatformRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, imageSize.width(), imageSize.height()));
- PlatformRefPtr<cairo_t> clippedImageContext(cairo_create(clippedImageSurface.get()));
- cairo_set_source_surface(clippedImageContext.get(), image, -tileRect.x(), -tileRect.y());
- cairo_paint(clippedImageContext.get());
- image = clippedImageSurface.get();
- }
-
- cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
- cairo_matrix_t pattern_matrix = cairo_matrix_t(patternTransform);
- cairo_matrix_t phase_matrix = {1, 0, 0, 1, phase.x() + tileRect.x() * patternTransform.a(), phase.y() + tileRect.y() * patternTransform.d()};
- cairo_matrix_t combined;
- cairo_matrix_multiply(&combined, &pattern_matrix, &phase_matrix);
- cairo_matrix_invert(&combined);
- cairo_pattern_set_matrix(pattern, &combined);
-
- context->setCompositeOperation(op);
- cairo_set_source(cr, pattern);
- cairo_pattern_destroy(pattern);
- cairo_rectangle(cr, destRect.x(), destRect.y(), destRect.width(), destRect.height());
- cairo_fill(cr);
-
- context->restore();
+ drawPatternToCairoContext(cr, image, size(), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
if (imageObserver())
imageObserver()->didDraw(this);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list