summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics/gtk')
-rw-r--r--Source/WebCore/platform/graphics/gtk/FontGtk.cpp23
-rw-r--r--Source/WebCore/platform/graphics/gtk/IconGtk.cpp6
-rw-r--r--Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp2
-rw-r--r--Source/WebCore/platform/graphics/gtk/ImageGtk.cpp5
4 files changed, 21 insertions, 15 deletions
diff --git a/Source/WebCore/platform/graphics/gtk/FontGtk.cpp b/Source/WebCore/platform/graphics/gtk/FontGtk.cpp
index 216fb56..d14b052 100644
--- a/Source/WebCore/platform/graphics/gtk/FontGtk.cpp
+++ b/Source/WebCore/platform/graphics/gtk/FontGtk.cpp
@@ -35,6 +35,7 @@
#include "CairoUtilities.h"
#include "ContextShadow.h"
+#include "PlatformContextCairo.h"
#include "GraphicsContext.h"
#include "NotImplemented.h"
#include "SimpleFontData.h"
@@ -44,7 +45,7 @@
#include <pango/pango.h>
#include <pango/pangocairo.h>
-#if defined(USE_FREETYPE)
+#if USE(FREETYPE)
#include <pango/pangofc-fontmap.h>
#endif
@@ -171,13 +172,13 @@ static gchar* convertUniCharToUTF8(const UChar* characters, gint length, int fro
static void setPangoAttributes(const Font* font, const TextRun& run, PangoLayout* layout)
{
-#if defined(USE_FREETYPE)
+#if USE(FREETYPE)
if (font->primaryFont()->platformData().m_pattern) {
PangoFontDescription* desc = pango_fc_font_description_from_pattern(font->primaryFont()->platformData().m_pattern.get(), FALSE);
pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);
}
-#elif defined(USE_PANGO)
+#elif USE(PANGO)
if (font->primaryFont()->platformData().m_font) {
PangoFontDescription* desc = pango_font_describe(font->primaryFont()->platformData().m_font);
pango_layout_set_font_description(layout, desc);
@@ -220,7 +221,7 @@ bool Font::canExpandAroundIdeographsInComplexText()
return false;
}
-static void drawGlyphsShadow(GraphicsContext* graphicsContext, cairo_t* context, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion)
+static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion)
{
ContextShadow* shadow = graphicsContext->contextShadow();
ASSERT(shadow);
@@ -232,6 +233,7 @@ static void drawGlyphsShadow(GraphicsContext* graphicsContext, cairo_t* context,
// Optimize non-blurry shadows, by just drawing text without the ContextShadow.
if (!shadow->mustUseContextShadow(graphicsContext)) {
+ cairo_t* context = graphicsContext->platformContext()->cr();
cairo_save(context);
cairo_translate(context, totalOffset.x(), totalOffset.y());
@@ -255,6 +257,7 @@ static void drawGlyphsShadow(GraphicsContext* graphicsContext, cairo_t* context,
// 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_t* context = graphicsContext->platformContext()->cr();
cairo_save(context);
cairo_translate(context, totalOffset.x(), totalOffset.y());
gdk_cairo_region(context, renderRegion);
@@ -268,14 +271,14 @@ static void drawGlyphsShadow(GraphicsContext* graphicsContext, cairo_t* context,
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
-#if defined(USE_FREETYPE)
+#if USE(FREETYPE)
if (!primaryFont()->platformData().m_pattern) {
drawSimpleText(context, run, point, from, to);
return;
}
#endif
- cairo_t* cr = context->platformContext();
+ cairo_t* cr = context->platformContext()->cr();
PangoLayout* layout = pango_cairo_create_layout(cr);
setPangoAttributes(this, run, layout);
@@ -294,7 +297,7 @@ void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const F
int ranges[] = {start - utf8, end - utf8};
partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);
- drawGlyphsShadow(context, cr, point, layoutLine, partialRegion);
+ drawGlyphsShadow(context, point, layoutLine, partialRegion);
cairo_save(cr);
cairo_translate(cr, point.x(), point.y());
@@ -348,7 +351,7 @@ static PangoLayout* getDefaultPangoLayout(const TextRun& run)
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* overflow) const
{
-#if defined(USE_FREETYPE)
+#if USE(FREETYPE)
if (!primaryFont()->platformData().m_pattern)
return floatWidthForSimpleText(run, 0, fallbackFonts, overflow);
#endif
@@ -373,7 +376,7 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon
int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, bool includePartialGlyphs) const
{
-#if defined(USE_FREETYPE)
+#if USE(FREETYPE)
if (!primaryFont()->platformData().m_pattern)
return offsetForPositionForSimpleText(run, xFloat, includePartialGlyphs);
#endif
@@ -401,7 +404,7 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, bool
FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
{
-#if defined(USE_FREETYPE)
+#if USE(FREETYPE)
if (!primaryFont()->platformData().m_pattern)
return selectionRectForSimpleText(run, point, h, from, to);
#endif
diff --git a/Source/WebCore/platform/graphics/gtk/IconGtk.cpp b/Source/WebCore/platform/graphics/gtk/IconGtk.cpp
index d56b52d..7fdc1f6 100644
--- a/Source/WebCore/platform/graphics/gtk/IconGtk.cpp
+++ b/Source/WebCore/platform/graphics/gtk/IconGtk.cpp
@@ -33,9 +33,9 @@
#include "GraphicsContext.h"
#include "MIMETypeRegistry.h"
#include "PassRefPtr.h"
-#include <wtf/text/CString.h>
-
+#include "PlatformContextCairo.h"
#include <gtk/gtk.h>
+#include <wtf/text/CString.h>
namespace WebCore {
@@ -117,7 +117,7 @@ void Icon::paint(GraphicsContext* context, const IntRect& rect)
return;
// TODO: Scale/clip the image if necessary.
- cairo_t* cr = context->platformContext();
+ cairo_t* cr = context->platformContext()->cr();
cairo_save(cr);
gdk_cairo_set_source_pixbuf(cr, m_icon, rect.x(), rect.y());
cairo_paint(cr);
diff --git a/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp b/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
index 2aa016e..3da0f9b 100644
--- a/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
+++ b/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
@@ -54,7 +54,7 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con
GError* error = 0;
gboolean success = FALSE;
if (type == "jpeg" && quality && *quality >= 0.0 && *quality <= 1.0) {
- String qualityString = String::format("%f", *quality);
+ String qualityString = String::format("%f", *quality * 100.0);
success = gdk_pixbuf_save_to_buffer(pixbuf.get(), &buffer.outPtr(), &bufferSize,
type.utf8().data(), &error, "quality", qualityString.utf8().data(), NULL);
} else {
diff --git a/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp b/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp
index 623ace6..9dd82a9 100644
--- a/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp
+++ b/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp
@@ -152,7 +152,10 @@ PassRefPtr<Image> Image::loadPlatformThemeIcon(const char* name, int size)
GdkPixbuf* BitmapImage::getGdkPixbuf()
{
- return cairoImageSurfaceToGdkPixbuf(frameAtIndex(currentFrame()));
+ cairo_surface_t* frame = frameAtIndex(currentFrame());
+ if (!frame)
+ return 0;
+ return cairoImageSurfaceToGdkPixbuf(frame);
}
}