[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
mrobinson at webkit.org
mrobinson at webkit.org
Wed Dec 22 15:42:07 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit d700f2ba22c2b4315267fe1ab843f3dcebf3f9ac
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Nov 10 17:59:20 2010 +0000
2010-11-10 Martin Robinson <mrobinson at igalia.com>
Reviewed by Xan Lopez.
[GTK] Complex text does not have full CSS text-shadow support
https://bugs.webkit.org/show_bug.cgi?id=45597
Add a test which verifies text-shadow on complex text for the GTK+
port. This can easily be made into a cross-platform test with baselines
for other ports.
* platform/gtk/fonts/complex-text-shadows-expected.checksum: Added.
* platform/gtk/fonts/complex-text-shadows-expected.png: Added.
* platform/gtk/fonts/complex-text-shadows-expected.txt: Added.
* platform/gtk/fonts/complex-text-shadows.html: Added.
2010-11-10 Martin Robinson <mrobinson at igalia.com>
Reviewed by Xan Lopez.
[GTK] Complex text does not have full CSS text-shadow support
https://bugs.webkit.org/show_bug.cgi?id=45597
Add ContextShadow support to FontGtk, which enables non-solid shadows
for complex text rendering.
Test: platform/gtk/fonts/complex-text-shadows.html
* platform/graphics/gtk/FontGtk.cpp:
(WebCore::destroyPangoRegion): Added this helper, which helps reduce
the number of #ifdefs when dealing with GTK+ region type differences.
(WebCore::getPangoRegionExtents): Ditto.
(WebCore::drawGlyphsShadow): Added this helper which either renders
a solid shadow manually or uses ContextShadow to render a blurry shadow.
(WebCore::Font::drawComplexText): Use the new helpers.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71750 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7cd17d5..118ab5a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2010-11-10 Martin Robinson <mrobinson at igalia.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Complex text does not have full CSS text-shadow support
+ https://bugs.webkit.org/show_bug.cgi?id=45597
+
+ Add a test which verifies text-shadow on complex text for the GTK+
+ port. This can easily be made into a cross-platform test with baselines
+ for other ports.
+
+ * platform/gtk/fonts/complex-text-shadows-expected.checksum: Added.
+ * platform/gtk/fonts/complex-text-shadows-expected.png: Added.
+ * platform/gtk/fonts/complex-text-shadows-expected.txt: Added.
+ * platform/gtk/fonts/complex-text-shadows.html: Added.
+
2010-11-02 Alexander Pavlov <apavlov at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/LayoutTests/platform/gtk/fonts/complex-text-shadows-expected.checksum b/LayoutTests/platform/gtk/fonts/complex-text-shadows-expected.checksum
new file mode 100644
index 0000000..e5ecafa
--- /dev/null
+++ b/LayoutTests/platform/gtk/fonts/complex-text-shadows-expected.checksum
@@ -0,0 +1 @@
+add76c2f96962451774f63cc0cc61088
\ No newline at end of file
diff --git a/LayoutTests/platform/gtk/fonts/complex-text-shadows-expected.png b/LayoutTests/platform/gtk/fonts/complex-text-shadows-expected.png
new file mode 100644
index 0000000..892a1b5
Binary files /dev/null and b/LayoutTests/platform/gtk/fonts/complex-text-shadows-expected.png differ
diff --git a/LayoutTests/platform/gtk/fonts/complex-text-shadows-expected.txt b/LayoutTests/platform/gtk/fonts/complex-text-shadows-expected.txt
new file mode 100644
index 0000000..591e455
--- /dev/null
+++ b/LayoutTests/platform/gtk/fonts/complex-text-shadows-expected.txt
@@ -0,0 +1,27 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {DIV} at (0,0) size 784x229
+ RenderBlock {P} at (0,0) size 784x19
+ RenderText {#text} at (0,0) size 511x19
+ text run at (0,0) width 511: "This test verifies that the text-shadow CSS property works properly for complex text"
+ RenderBlock {P} at (0,35) size 784x19
+ RenderText {#text} at (0,0) size 255x19
+ text run at (0,0) width 255: "The following text should have no shadow:"
+ RenderBlock {P} at (0,70) size 784x19
+ RenderText {#text} at (0,0) size 351x19
+ text run at (0,0) width 351: "A B C D E F G H I J K L M N O P Q R S T U V X Y Z"
+ RenderBlock {P} at (0,105) size 784x19
+ RenderText {#text} at (0,0) size 316x19
+ text run at (0,0) width 316: "The following text should have a green solid shadow:"
+ RenderBlock {P} at (0,140) size 784x19
+ RenderText {#text} at (0,0) size 351x19
+ text run at (0,0) width 351: "A B C D E F G H I J K L M N O P Q R S T U V X Y Z"
+ RenderBlock {P} at (0,175) size 784x19
+ RenderText {#text} at (0,0) size 493x19
+ text run at (0,0) width 493: "The following text should be rendered with a green shadow with a blur radius of 2:"
+ RenderBlock {P} at (0,210) size 784x19
+ RenderText {#text} at (0,0) size 351x19
+ text run at (0,0) width 351: "A B C D E F G H I J K L M N O P Q R S T U V X Y Z"
diff --git a/LayoutTests/platform/gtk/fonts/complex-text-shadows.html b/LayoutTests/platform/gtk/fonts/complex-text-shadows.html
new file mode 100644
index 0000000..714925d
--- /dev/null
+++ b/LayoutTests/platform/gtk/fonts/complex-text-shadows.html
@@ -0,0 +1,21 @@
+<html>
+<head>
+<style>
+ p.complex { text-size: 20pt; text-rendering: geometricPrecision; }
+ p.solidshadow { text-shadow: green 5px 5px 0px; }
+ p.shadow { text-shadow: green 5px 5px 2px; }
+</style>
+</head>
+<body>
+<div>
+<p>This test verifies that the text-shadow CSS property works properly for complex text</p>
+<p>The following text should have no shadow:</p>
+<p class="complex">A B C D E F G H I J K L M N O P Q R S T U V X Y Z</p>
+<p>The following text should have a green solid shadow:</p>
+<p class="complex solidshadow">A B C D E F G H I J K L M N O P Q R S T U V X Y Z</p>
+<p>The following text should be rendered with a green shadow with a blur radius of 2:</p>
+<p class="complex shadow">A B C D E F G H I J K L M N O P Q R S T U V X Y Z</p>
+</div>
+
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 427c205..3fc3685 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-11-10 Martin Robinson <mrobinson at igalia.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Complex text does not have full CSS text-shadow support
+ https://bugs.webkit.org/show_bug.cgi?id=45597
+
+ Add ContextShadow support to FontGtk, which enables non-solid shadows
+ for complex text rendering.
+
+ Test: platform/gtk/fonts/complex-text-shadows.html
+
+ * platform/graphics/gtk/FontGtk.cpp:
+ (WebCore::destroyPangoRegion): Added this helper, which helps reduce
+ the number of #ifdefs when dealing with GTK+ region type differences.
+ (WebCore::getPangoRegionExtents): Ditto.
+ (WebCore::drawGlyphsShadow): Added this helper which either renders
+ a solid shadow manually or uses ContextShadow to render a blurry shadow.
+ (WebCore::Font::drawComplexText): Use the new helpers.
+
2010-11-10 Alejandro G. Castro <alex at igalia.com>
Reviewed by Martin Robinson.
diff --git a/WebCore/platform/graphics/gtk/FontGtk.cpp b/WebCore/platform/graphics/gtk/FontGtk.cpp
index 328ec4a..54e18c9 100644
--- a/WebCore/platform/graphics/gtk/FontGtk.cpp
+++ b/WebCore/platform/graphics/gtk/FontGtk.cpp
@@ -33,19 +33,51 @@
#include "config.h"
#include "Font.h"
+#include "CairoUtilities.h"
+#include "ContextShadow.h"
#include "GraphicsContext.h"
#include "SimpleFontData.h"
-
#include <cairo.h>
#include <gdk/gdk.h>
#include <pango/pango.h>
#include <pango/pangocairo.h>
+
#if defined(USE_FREETYPE)
#include <pango/pangofc-fontmap.h>
#endif
namespace WebCore {
+#ifdef GTK_API_VERSION_2
+typedef GdkRegion* PangoRegionType;
+
+void destroyPangoRegion(PangoRegionType region)
+{
+ gdk_region_destroy(region);
+}
+
+IntRect getPangoRegionExtents(PangoRegionType region)
+{
+ GdkRectangle rectangle;
+ gdk_region_get_clipbox(region, &rectangle);
+ return IntRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+}
+#else
+typedef cairo_region_t* PangoRegionType;
+
+void destroyPangoRegion(PangoRegionType region)
+{
+ cairo_region_destroy(region);
+}
+
+IntRect getPangoRegionExtents(PangoRegionType region)
+{
+ cairo_rectangle_int_t rectangle;
+ cairo_region_get_extents(region, &rectangle);
+ return IntRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+}
+#endif
+
#define IS_HIGH_SURROGATE(u) ((UChar)(u) >= (UChar)0xd800 && (UChar)(u) <= (UChar)0xdbff)
#define IS_LOW_SURROGATE(u) ((UChar)(u) >= (UChar)0xdc00 && (UChar)(u) <= (UChar)0xdfff)
@@ -181,6 +213,52 @@ bool Font::canReturnFallbackFontsForComplexText()
return false;
}
+static void drawGlyphsShadow(GraphicsContext* graphicsContext, cairo_t* context, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion)
+{
+ ContextShadow* shadow = graphicsContext->contextShadow();
+ ASSERT(shadow);
+
+ if (!(graphicsContext->textDrawingMode() & cTextFill) || shadow->m_type == ContextShadow::NoShadow)
+ return;
+
+ FloatPoint totalOffset(point + shadow->m_offset);
+
+ // Optimize non-blurry shadows, by just drawing text without the ContextShadow.
+ if (shadow->m_type == ContextShadow::SolidShadow) {
+ cairo_save(context);
+ cairo_translate(context, totalOffset.x(), totalOffset.y());
+
+ setSourceRGBAFromColor(context, shadow->m_color);
+ gdk_cairo_region(context, renderRegion);
+ cairo_clip(context);
+ pango_cairo_show_layout_line(context, layoutLine);
+
+ cairo_restore(context);
+ return;
+ }
+
+ FloatRect extents(getPangoRegionExtents(renderRegion));
+ extents.setLocation(FloatPoint(point.x(), point.y() - extents.height()));
+ cairo_t* shadowContext = shadow->beginShadowLayer(context, extents);
+ if (shadowContext) {
+ cairo_translate(shadowContext, point.x(), point.y());
+ pango_cairo_show_layout_line(shadowContext, layoutLine);
+
+ // We need the clipping region to be active when we blit the blurred shadow back,
+ // because we don't want any bits and pieces of characters out of range to be
+ // drawn. Since ContextShadow expects a consistent transform, we have to undo the
+ // translation before calling endShadowLayer as well.
+ cairo_save(context);
+ cairo_translate(context, totalOffset.x(), totalOffset.y());
+ gdk_cairo_region(context, renderRegion);
+ cairo_clip(context);
+ cairo_translate(context, -totalOffset.x(), -totalOffset.y());
+
+ shadow->endShadowLayer(context);
+ cairo_restore(context);
+ }
+}
+
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
#if defined(USE_FREETYPE)
@@ -191,9 +269,6 @@ void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const F
#endif
cairo_t* cr = context->platformContext();
- cairo_save(cr);
- cairo_translate(cr, point.x(), point.y());
-
PangoLayout* layout = pango_cairo_create_layout(cr);
setPangoAttributes(this, run, layout);
@@ -203,59 +278,25 @@ void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const F
// Our layouts are single line
PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
-#ifdef GTK_API_VERSION_2
- GdkRegion* partialRegion = 0;
-#else
- cairo_region_t* partialRegion = 0;
-#endif
-
- if (to - from != run.length()) {
- // Clip the region of the run to be rendered
- char* start = g_utf8_offset_to_pointer(utf8, from);
- char* end = g_utf8_offset_to_pointer(start, to - from);
- int ranges[] = {start - utf8, end - utf8};
- partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);
- }
-
- Color fillColor = context->fillColor();
- float red, green, blue, alpha;
-
- // Text shadow, inspired by FontMac
- FloatSize shadowOffset;
- float shadowBlur = 0;
- Color shadowColor;
- bool hasShadow = context->textDrawingMode() == cTextFill &&
- context->getShadow(shadowOffset, shadowBlur, shadowColor);
-
- // TODO: Blur support
- if (hasShadow) {
- // Disable graphics context shadows (not yet implemented) and paint them manually
- context->clearShadow();
- Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
- cairo_save(cr);
-
- shadowFillColor.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
-
- cairo_translate(cr, shadowOffset.width(), shadowOffset.height());
-
- if (partialRegion) {
- gdk_cairo_region(cr, partialRegion);
- cairo_clip(cr);
- }
+ // Get the region where this text will be laid out. We will use it to clip
+ // the Cairo context, for when we are only painting part of the text run and
+ // to calculate the size of the shadow buffer.
+ PangoRegionType partialRegion = 0;
+ char* start = g_utf8_offset_to_pointer(utf8, from);
+ char* end = g_utf8_offset_to_pointer(start, to - from);
+ int ranges[] = {start - utf8, end - utf8};
+ partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);
- pango_cairo_show_layout_line(cr, layoutLine);
+ drawGlyphsShadow(context, cr, point, layoutLine, partialRegion);
- cairo_restore(cr);
- }
+ cairo_save(cr);
+ cairo_translate(cr, point.x(), point.y());
- fillColor.getRGBA(red, green, blue, alpha);
+ float red, green, blue, alpha;
+ context->fillColor().getRGBA(red, green, blue, alpha);
cairo_set_source_rgba(cr, red, green, blue, alpha);
-
- if (partialRegion) {
- gdk_cairo_region(cr, partialRegion);
- cairo_clip(cr);
- }
+ gdk_cairo_region(cr, partialRegion);
+ cairo_clip(cr);
pango_cairo_show_layout_line(cr, layoutLine);
@@ -268,20 +309,10 @@ void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const F
cairo_stroke(cr);
}
- // Re-enable the platform shadow we disabled earlier
- if (hasShadow)
- context->setShadow(shadowOffset, shadowBlur, shadowColor, ColorSpaceDeviceRGB);
-
// Pango sometimes leaves behind paths we don't want
cairo_new_path(cr);
- if (partialRegion)
-#ifdef GTK_API_VERSION_2
- gdk_region_destroy(partialRegion);
-#else
- cairo_region_destroy(partialRegion);
-#endif
-
+ destroyPangoRegion(partialRegion);
g_free(utf8);
g_object_unref(layout);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list