diff options
Diffstat (limited to 'WebCore/platform/graphics')
24 files changed, 276 insertions, 301 deletions
diff --git a/WebCore/platform/graphics/ContextShadow.h b/WebCore/platform/graphics/ContextShadow.h index fa778af..26f0a36 100644 --- a/WebCore/platform/graphics/ContextShadow.h +++ b/WebCore/platform/graphics/ContextShadow.h @@ -120,8 +120,10 @@ private: PlatformImage m_layerImage; PlatformContext m_layerContext; +#if PLATFORM(QT) // Used for reference when canvas scale(x,y) was called. FloatRect m_unscaledLayerRect; +#endif void blurLayerImage(unsigned char*, const IntSize& imageSize, int stride); void calculateLayerBoundingRect(const FloatRect& layerArea, const IntRect& clipRect); diff --git a/WebCore/platform/graphics/FloatPoint3D.h b/WebCore/platform/graphics/FloatPoint3D.h index ba0ee9d..b6cbaa8 100644 --- a/WebCore/platform/graphics/FloatPoint3D.h +++ b/WebCore/platform/graphics/FloatPoint3D.h @@ -84,11 +84,6 @@ public: m_z *= sz; } - bool isZero() const - { - return !m_x && !m_y && !m_z; - } - void normalize(); float dot(const FloatPoint3D& a) const @@ -120,8 +115,6 @@ public: float lengthSquared() const { return this->dot(*this); } float length() const { return sqrtf(lengthSquared()); } - - float distanceTo(const FloatPoint3D& a) const; private: float m_x; @@ -167,21 +160,6 @@ inline float operator*(const FloatPoint3D& a, const FloatPoint3D& b) return a.dot(b); } -inline FloatPoint3D operator*(float k, const FloatPoint3D& v) -{ - return FloatPoint3D(k * v.x(), k * v.y(), k * v.z()); -} - -inline FloatPoint3D operator*(const FloatPoint3D& v, float k) -{ - return FloatPoint3D(k * v.x(), k * v.y(), k * v.z()); -} - -inline float FloatPoint3D::distanceTo(const FloatPoint3D& a) const -{ - return (*this - a).length(); -} - } // namespace WebCore #endif // FloatPoint3D_h diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h index 76e897e..1029c90 100644 --- a/WebCore/platform/graphics/GraphicsContext.h +++ b/WebCore/platform/graphics/GraphicsContext.h @@ -135,6 +135,7 @@ namespace WebCore { class GraphicsContextPrivate; class ImageBuffer; class KURL; + class Path; class Pattern; class SharedGraphicsContext3D; class TextRun; @@ -203,7 +204,6 @@ namespace WebCore { #if PLATFORM(CG) void applyStrokePattern(); void applyFillPattern(); - void drawPath(const Path&); #endif #if PLATFORM(ANDROID) @@ -245,8 +245,9 @@ namespace WebCore { void drawEllipse(const IntRect&); void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false); - void fillPath(const Path&); - void strokePath(const Path&); + void drawPath(); + void fillPath(); + void strokePath(); // Arc drawing (used by border-radius in CSS) just supports stroking at the moment. void strokeArc(const IntRect&, int startAngle, int angleSpan); @@ -287,7 +288,7 @@ namespace WebCore { void addInnerRoundedRectClip(const IntRect&, int thickness); void clipOut(const IntRect&); void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); - void clipPath(const Path&, WindRule); + void clipPath(WindRule); void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true); void clipToImageBuffer(ImageBuffer*, const FloatRect&); @@ -336,10 +337,8 @@ namespace WebCore { void setCompositeOperation(CompositeOperator); -#if PLATFORM(SKIA) || PLATFORM(WX) || PLATFORM(OPENVG) || OS(WINCE) void beginPath(); void addPath(const Path&); -#endif void clip(const Path&); @@ -429,6 +428,7 @@ namespace WebCore { #if PLATFORM(QT) bool inTransparencyLayer() const; + PlatformPath* currentPath(); void pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask); void takeOwnershipOfPlatformContext(); static QPainter::CompositionMode toQtCompositionMode(CompositeOperator op); diff --git a/WebCore/platform/graphics/GraphicsContextPrivate.h b/WebCore/platform/graphics/GraphicsContextPrivate.h index 696932e..985cad9 100644 --- a/WebCore/platform/graphics/GraphicsContextPrivate.h +++ b/WebCore/platform/graphics/GraphicsContextPrivate.h @@ -29,6 +29,7 @@ #include "Gradient.h" #include "GraphicsContext.h" #include "Pattern.h" +#include "TransformationMatrix.h" namespace WebCore { @@ -78,6 +79,8 @@ namespace WebCore { bool shadowsIgnoreTransforms; #if PLATFORM(CAIRO) float globalAlpha; +#elif PLATFORM(QT) + TransformationMatrix pathTransform; #endif }; diff --git a/WebCore/platform/graphics/MediaPlayer.cpp b/WebCore/platform/graphics/MediaPlayer.cpp index c9deb4c..dc743bf 100644 --- a/WebCore/platform/graphics/MediaPlayer.cpp +++ b/WebCore/platform/graphics/MediaPlayer.cpp @@ -274,7 +274,6 @@ MediaPlayer::MediaPlayer(MediaPlayerClient* client) MediaPlayer::~MediaPlayer() { - m_mediaPlayerClient = 0; } void MediaPlayer::load(const String& url, const ContentType& contentType) diff --git a/WebCore/platform/graphics/TextRun.h b/WebCore/platform/graphics/TextRun.h index dce5535..79b6cb3 100644 --- a/WebCore/platform/graphics/TextRun.h +++ b/WebCore/platform/graphics/TextRun.h @@ -117,10 +117,7 @@ private: const UChar* m_characters; int m_len; - // m_xpos is the x position relative to the left start of the text line, not relative to the left - // start of the containing block. In the case of right alignment or center alignment, left start of - // the text line is not the same as left start of the containing block. - int m_xpos; + int m_xpos; int m_padding; #if ENABLE(SVG) float m_horizontalGlyphStretch; diff --git a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp index 699edf7..8299b6a 100644 --- a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp +++ b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp @@ -84,8 +84,6 @@ static cairo_surface_t* getScratchBuffer(const IntSize& size) PlatformContext ContextShadow::beginShadowLayer(PlatformContext context, const FloatRect& layerArea) { - m_unscaledLayerRect = layerArea; - double x1, x2, y1, y2; cairo_clip_extents(context, &x1, &y1, &x2, &y2); calculateLayerBoundingRect(layerArea, IntRect(x1, y1, x2 - x1, y2 - y1)); @@ -122,19 +120,7 @@ void ContextShadow::endShadowLayer(cairo_t* cr) cairo_save(cr); setSourceRGBAFromColor(cr, m_color); - - cairo_matrix_t transform; - cairo_get_matrix(cr, &transform); - double x = m_layerRect.x(); - double y = m_layerRect.y(); - - double xScale = sqrt(transform.xx * transform.xx + transform.yx * transform.yx); - double yScale = sqrt(transform.xy * transform.xy + transform.yy * transform.yy); - if (xScale != 1 || yScale != 1) { - x = m_unscaledLayerRect.x() + m_offset.width() / transform.xx - m_blurDistance; - y = m_unscaledLayerRect.y() + m_offset.height() / transform.yy - m_blurDistance; - } - cairo_mask_surface(cr, m_layerImage, x, y); + cairo_mask_surface(cr, m_layerImage, m_layerRect.x(), m_layerRect.y()); cairo_restore(cr); // Schedule a purge of the scratch buffer. We do not need to destroy the surface. diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp index 9c2ff82..1032dc2 100644 --- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp +++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp @@ -531,26 +531,44 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin cairo_set_fill_rule(cr, savedFillRule); } -void GraphicsContext::fillPath(const Path& path) +void GraphicsContext::fillPath() { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; - setPathOnCairoContext(cr, path.platformPath()->context()); + + setPathOnCairoContext(cr, m_data->m_pendingPath.context()); fillCurrentCairoPath(this, m_common, cr); } -void GraphicsContext::strokePath(const Path& path) +void GraphicsContext::strokePath() { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; - setPathOnCairoContext(cr, path.platformPath()->context()); + setPathOnCairoContext(cr, m_data->m_pendingPath.context()); strokeCurrentCairoPath(this, m_common, cr); } +void GraphicsContext::drawPath() +{ + if (paintingDisabled()) + return; + + cairo_t* cr = m_data->cr; + + setPathOnCairoContext(cr, m_data->m_pendingPath.context()); + + cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); + drawPathShadow(this, m_common, FillAndStroke); + + setPlatformFill(this, cr, m_common); + setPlatformStroke(this, cr, m_common); + cairo_new_path(cr); +} + void GraphicsContext::fillRect(const FloatRect& rect) { if (paintingDisabled()) @@ -589,13 +607,12 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->clip(rect); } -void GraphicsContext::clipPath(const Path& path, WindRule clipRule) +void GraphicsContext::clipPath(WindRule clipRule) { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; - setPathOnCairoContext(cr, path.platformPath()->context()); cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); cairo_clip(cr); } @@ -977,6 +994,25 @@ void GraphicsContext::setCompositeOperation(CompositeOperator op) cairo_set_operator(m_data->cr, toCairoOperator(op)); } +void GraphicsContext::beginPath() +{ + if (paintingDisabled()) + return; + + cairo_new_path(m_data->m_pendingPath.context()); +} + +void GraphicsContext::addPath(const Path& path) +{ + if (paintingDisabled()) + return; + + cairo_matrix_t currentMatrix; + cairo_get_matrix(m_data->cr, ¤tMatrix); + cairo_set_matrix(m_data->m_pendingPath.context(), ¤tMatrix); + appendWebCorePathToCairoContext(m_data->m_pendingPath.context(), path); +} + void GraphicsContext::clip(const Path& path) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h index 494b40d..527cb72 100644 --- a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h +++ b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h @@ -27,6 +27,7 @@ #include "GraphicsContext.h" +#include "CairoPath.h" #include "ContextShadow.h" #include <cairo.h> #include <math.h> @@ -96,6 +97,7 @@ public: cairo_t* cr; Vector<float> layers; + CairoPath m_pendingPath; ContextShadow shadow; Vector<ContextShadow> shadowStack; diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index 2eb929e..8d72b85 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -299,12 +299,21 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) // This method is only used to draw the little circles used in lists. void GraphicsContext::drawEllipse(const IntRect& rect) { + // FIXME: CG added CGContextAddEllipseinRect in Tiger, so we should be able to quite easily draw an ellipse. + // This code can only handle circles, not ellipses. But khtml only + // uses it for circles. + ASSERT(rect.width() == rect.height()); + if (paintingDisabled()) return; - Path path; - path.addEllipse(rect); - drawPath(path); + CGContextRef context = platformContext(); + CGContextBeginPath(context); + float r = (float)rect.width() / 2; + CGContextAddArc(context, rect.x() + r, rect.y() + r, r, 0.0f, 2.0f * piFloat, 0); + CGContextClosePath(context); + + drawPath(); } @@ -396,22 +405,21 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp CGContextRestoreGState(context); } -static void addConvexPolygonToPath(Path& path, size_t numberOfPoints, const FloatPoint* points) +static void addConvexPolygonToContext(CGContextRef context, size_t numPoints, const FloatPoint* points) { - ASSERT(numberOfPoints > 0); - - path.moveTo(points[0]); - for (size_t i = 1; i < numberOfPoints; ++i) - path.addLineTo(points[i]); - path.closeSubpath(); + CGContextBeginPath(context); + CGContextMoveToPoint(context, points[0].x(), points[0].y()); + for (size_t i = 1; i < numPoints; i++) + CGContextAddLineToPoint(context, points[i].x(), points[i].y()); + CGContextClosePath(context); } -void GraphicsContext::drawConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased) +void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; - if (numberOfPoints <= 1) + if (npoints <= 1) return; CGContextRef context = platformContext(); @@ -419,30 +427,28 @@ void GraphicsContext::drawConvexPolygon(size_t numberOfPoints, const FloatPoint* if (antialiased != shouldAntialias()) CGContextSetShouldAntialias(context, antialiased); - Path path; - addConvexPolygonToPath(path, numberOfPoints, points); - drawPath(path); + addConvexPolygonToContext(context, npoints, points); + drawPath(); if (antialiased != shouldAntialias()) CGContextSetShouldAntialias(context, shouldAntialias()); } -void GraphicsContext::clipConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialias) +void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialias) { if (paintingDisabled()) return; - if (numberOfPoints <= 1) + if (numPoints <= 1) return; CGContextRef context = platformContext(); if (antialias != shouldAntialias()) CGContextSetShouldAntialias(context, antialias); - - Path path; - addConvexPolygonToPath(path, numberOfPoints, points); - clipPath(path, RULE_NONZERO); + + addConvexPolygonToContext(context, numPoints, points); + clipPath(RULE_NONZERO); if (antialias != shouldAntialias()) CGContextSetShouldAntialias(context, shouldAntialias()); @@ -505,7 +511,7 @@ static inline bool calculateDrawingMode(const GraphicsContextState& state, CGPat return shouldFill || shouldStroke; } -void GraphicsContext::drawPath(const Path& path) +void GraphicsContext::drawPath() { if (paintingDisabled()) return; @@ -515,15 +521,11 @@ void GraphicsContext::drawPath(const Path& path) if (state.fillGradient || state.strokeGradient) { // We don't have any optimized way to fill & stroke a path using gradients - // FIXME: Be smarter about this. - fillPath(path); - strokePath(path); + fillPath(); + strokePath(); return; } - CGContextBeginPath(context); - CGContextAddPath(context, path.platformPath()); - if (state.fillPattern) applyFillPattern(); if (state.strokePattern) @@ -542,16 +544,13 @@ static inline void fillPathWithFillRule(CGContextRef context, WindRule fillRule) CGContextFillPath(context); } -void GraphicsContext::fillPath(const Path& path) +void GraphicsContext::fillPath() { if (paintingDisabled()) return; CGContextRef context = platformContext(); - CGContextBeginPath(context); - CGContextAddPath(context, path.platformPath()); - if (m_common->state.fillGradient) { CGContextSaveGState(context); if (fillRule() == RULE_EVENODD) @@ -569,16 +568,13 @@ void GraphicsContext::fillPath(const Path& path) fillPathWithFillRule(context, fillRule()); } -void GraphicsContext::strokePath(const Path& path) +void GraphicsContext::strokePath() { if (paintingDisabled()) return; CGContextRef context = platformContext(); - CGContextBeginPath(context); - CGContextAddPath(context, path.platformPath()); - if (m_common->state.strokeGradient) { CGContextSaveGState(context); CGContextReplacePathWithStrokedPath(context); @@ -647,7 +643,8 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef Path path; path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); - fillPath(path); + addPath(path); + fillPath(); if (oldFillColor != color || oldColorSpace != colorSpace) setCGFillColor(context, oldFillColor, oldColorSpace); @@ -672,23 +669,19 @@ void GraphicsContext::clipOut(const IntRect& rect) CGContextEOClip(platformContext()); } -void GraphicsContext::clipPath(const Path& path, WindRule clipRule) +void GraphicsContext::clipPath(WindRule clipRule) { if (paintingDisabled()) return; - if (path.isEmpty()) - return; - CGContextRef context = platformContext(); - CGContextBeginPath(platformContext()); - CGContextAddPath(platformContext(), path.platformPath()); - - if (clipRule == RULE_EVENODD) - CGContextEOClip(context); - else - CGContextClip(context); + if (!CGContextIsPathEmpty(context)) { + if (clipRule == RULE_EVENODD) + CGContextEOClip(context); + else + CGContextClip(context); + } } void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) @@ -870,6 +863,16 @@ void GraphicsContext::setLineJoin(LineJoin join) } } +void GraphicsContext::beginPath() +{ + CGContextBeginPath(platformContext()); +} + +void GraphicsContext::addPath(const Path& path) +{ + CGContextAddPath(platformContext(), path.platformPath()); +} + void GraphicsContext::clip(const Path& path) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp index 7dab01f..375a74b 100644 --- a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp +++ b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp @@ -41,7 +41,6 @@ #if PLATFORM(SKIA) #include "NativeImageSkia.h" #include "PlatformContextSkia.h" -#include "SkColorPriv.h" #include "skia/ext/platform_canvas.h" #elif PLATFORM(CG) #include <CoreGraphics/CGBitmapContext.h> @@ -69,22 +68,8 @@ ContentLayerChromium::SharedValues::SharedValues(GraphicsContext3D* context) " v_texCoord = a_texCoord; \n" "} \n"; -#if PLATFORM(SKIA) - // Color is in RGBA order. - char rgbaFragmentShaderString[] = - "precision mediump float; \n" - "varying vec2 v_texCoord; \n" - "uniform sampler2D s_texture; \n" - "uniform float alpha; \n" - "void main() \n" - "{ \n" - " vec4 texColor = texture2D(s_texture, v_texCoord); \n" - " gl_FragColor = texColor * alpha; \n" - "} \n"; -#endif - // Color is in BGRA order. - char bgraFragmentShaderString[] = + char fragmentShaderString[] = "precision mediump float; \n" "varying vec2 v_texCoord; \n" "uniform sampler2D s_texture; \n" @@ -95,12 +80,6 @@ ContentLayerChromium::SharedValues::SharedValues(GraphicsContext3D* context) " gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, texColor.w) * alpha; \n" "} \n"; -#if PLATFORM(SKIA) - // Assuming the packing is either Skia default RGBA or Chromium default BGRA. - char* fragmentShaderString = SK_B32_SHIFT ? rgbaFragmentShaderString : bgraFragmentShaderString; -#else - char* fragmentShaderString = bgraFragmentShaderString; -#endif m_contentShaderProgram = createShaderProgram(m_context, vertexShaderString, fragmentShaderString); if (!m_contentShaderProgram) { LOG_ERROR("ContentLayerChromium: Failed to create shader program"); diff --git a/WebCore/platform/graphics/chromium/FontLinux.cpp b/WebCore/platform/graphics/chromium/FontLinux.cpp index 82b9df7..79b2caf 100644 --- a/WebCore/platform/graphics/chromium/FontLinux.cpp +++ b/WebCore/platform/graphics/chromium/FontLinux.cpp @@ -341,6 +341,7 @@ void TextRunWalker::setPadding(int padding) // amount to each space. The last space gets the smaller amount, if // any. unsigned numWordBreaks = 0; + bool isRTL = m_iterateBackwards; for (unsigned i = 0; i < m_item.stringLength; i++) { if (isWordBreak(i)) @@ -523,7 +524,7 @@ void TextRunWalker::setGlyphXPositions(bool isRTL) // Whitespace must be laid out in logical order, so when inserting // spaces in RTL (but iterating in LTR order) we must insert spaces // _before_ the next glyph. - if (static_cast<unsigned>(i + 1) >= m_item.num_glyphs || m_item.attributes[i + 1].clusterStart) + if (i + 1 >= m_item.num_glyphs || m_item.attributes[i + 1].clusterStart) position += m_letterSpacing; position += determineWordBreakSpacing(logClustersIndex); @@ -540,7 +541,7 @@ void TextRunWalker::setGlyphXPositions(bool isRTL) position += truncateFixedPointToInteger(m_item.advances[i]); } } else { - for (size_t i = 0; i < m_item.num_glyphs; ++i) { + for (int i = 0; i < m_item.num_glyphs; ++i) { m_glyphs16[i] = m_item.glyphs[i]; double offsetX = truncateFixedPointToInteger(m_item.offsets[i].x); m_xPositions[i] = m_offsetX + position + offsetX; @@ -555,7 +556,7 @@ void TextRunWalker::setGlyphXPositions(bool isRTL) if (m_item.attributes[i].clusterStart) advance += m_letterSpacing; - while (static_cast<unsigned>(logClustersIndex) < m_item.item.length && logClusters()[logClustersIndex] == i) + while (logClustersIndex < m_item.item.length && logClusters()[logClustersIndex] == i) logClustersIndex++; position += advance; @@ -707,7 +708,7 @@ static int glyphIndexForXPositionInScriptRun(const TextRunWalker& walker, int x) for (glyphIndex = walker.length() - 1; glyphIndex >= 0; --glyphIndex) { // When iterating LTR over RTL text, we must include the whitespace // _before_ the glyph, so no + 1 here. - if (x < (static_cast<int>(walker.length()) - glyphIndex) * letterSpacing + truncateFixedPointToInteger(advances[glyphIndex])) + if (x < (walker.length() - glyphIndex) * letterSpacing + truncateFixedPointToInteger(advances[glyphIndex])) break; x -= truncateFixedPointToInteger(advances[glyphIndex]); } diff --git a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index dbef4c9..695d1f7 100644 --- a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -177,13 +177,6 @@ void mediaPlayerPrivateVolumeChangedCallback(GObject *element, GParamSpec *pspec mp->volumeChanged(); } -gboolean mediaPlayerPrivateVolumeChangeTimeoutCallback(MediaPlayerPrivateGStreamer* player) -{ - // This is the callback of the timeout source created in ::volumeChanged. - player->notifyPlayerOfVolumeChange(); - return FALSE; -} - void mediaPlayerPrivateMuteChangedCallback(GObject *element, GParamSpec *pspec, gpointer data) { // This is called when playbin receives the notify::mute signal. @@ -191,13 +184,6 @@ void mediaPlayerPrivateMuteChangedCallback(GObject *element, GParamSpec *pspec, mp->muteChanged(); } -gboolean mediaPlayerPrivateMuteChangeTimeoutCallback(MediaPlayerPrivateGStreamer* player) -{ - // This is the callback of the timeout source created in ::muteChanged. - player->notifyPlayerOfMute(); - return FALSE; -} - static float playbackPosition(GstElement* playbin) { @@ -341,18 +327,8 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer() if (m_playBin) { gst_element_set_state(m_playBin, GST_STATE_NULL); gst_object_unref(GST_OBJECT(m_playBin)); - m_playBin = 0; } - m_player = 0; - - if (m_muteTimerHandler) - g_source_remove(m_muteTimerHandler); - m_muteTimerHandler = 0; - - if (m_volumeTimerHandler) - g_source_remove(m_volumeTimerHandler); - m_volumeTimerHandler = 0; } void MediaPlayerPrivateGStreamer::load(const String& url) @@ -608,12 +584,8 @@ void MediaPlayerPrivateGStreamer::setVolume(float volume) g_object_set(m_playBin, "volume", static_cast<double>(volume), NULL); } -void MediaPlayerPrivateGStreamer::notifyPlayerOfVolumeChange() +void MediaPlayerPrivateGStreamer::volumeChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*) { - m_volumeTimerHandler = 0; - - if (!m_player || !m_playBin) - return; double volume; g_object_get(m_playBin, "volume", &volume, NULL); m_player->volumeChanged(static_cast<float>(volume)); @@ -621,9 +593,8 @@ void MediaPlayerPrivateGStreamer::notifyPlayerOfVolumeChange() void MediaPlayerPrivateGStreamer::volumeChanged() { - if (m_volumeTimerHandler) - g_source_remove(m_volumeTimerHandler); - m_volumeTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateVolumeChangeTimeoutCallback), this); + Timer<MediaPlayerPrivateGStreamer> volumeChangedTimer(this, &MediaPlayerPrivateGStreamer::volumeChangedTimerFired); + volumeChangedTimer.startOneShot(0); } void MediaPlayerPrivateGStreamer::setRate(float rate) @@ -1187,13 +1158,8 @@ void MediaPlayerPrivateGStreamer::setMuted(bool muted) g_object_set(m_playBin, "mute", muted, NULL); } -void MediaPlayerPrivateGStreamer::notifyPlayerOfMute() +void MediaPlayerPrivateGStreamer::muteChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*) { - m_muteTimerHandler = 0; - - if (!m_player || !m_playBin) - return; - gboolean muted; g_object_get(m_playBin, "mute", &muted, NULL); m_player->muteChanged(static_cast<bool>(muted)); @@ -1201,9 +1167,8 @@ void MediaPlayerPrivateGStreamer::notifyPlayerOfMute() void MediaPlayerPrivateGStreamer::muteChanged() { - if (m_muteTimerHandler) - g_source_remove(m_muteTimerHandler); - m_muteTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateMuteChangeTimeoutCallback), this); + Timer<MediaPlayerPrivateGStreamer> muteChangedTimer(this, &MediaPlayerPrivateGStreamer::muteChangedTimerFired); + muteChangedTimer.startOneShot(0); } void MediaPlayerPrivateGStreamer::loadingFailed(MediaPlayer::NetworkState error) @@ -1436,8 +1401,6 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin() g_signal_connect(bus, "message", G_CALLBACK(mediaPlayerPrivateMessageCallback), this); gst_object_unref(bus); - g_object_set(m_playBin, "mute", m_player->muted(), "volume", m_player->volume(), NULL); - g_signal_connect(m_playBin, "notify::volume", G_CALLBACK(mediaPlayerPrivateVolumeChangedCallback), this); g_signal_connect(m_playBin, "notify::source", G_CALLBACK(mediaPlayerPrivateSourceChangedCallback), this); g_signal_connect(m_playBin, "notify::mute", G_CALLBACK(mediaPlayerPrivateMuteChangedCallback), this); diff --git a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h index 23095ec..800ca6d 100644 --- a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h +++ b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h @@ -43,14 +43,11 @@ class GraphicsContext; class IntSize; class IntRect; class GStreamerGWorld; -class MediaPlayerPrivateGStreamer; gboolean mediaPlayerPrivateMessageCallback(GstBus* bus, GstMessage* message, gpointer data); void mediaPlayerPrivateVolumeChangedCallback(GObject* element, GParamSpec* pspec, gpointer data); void mediaPlayerPrivateMuteChangedCallback(GObject* element, GParamSpec* pspec, gpointer data); void mediaPlayerPrivateSourceChangedCallback(GObject* element, GParamSpec* pspec, gpointer data); -gboolean mediaPlayerPrivateVolumeChangeTimeoutCallback(MediaPlayerPrivateGStreamer*); -gboolean mediaPlayerPrivateMuteChangeTimeoutCallback(MediaPlayerPrivateGStreamer*); class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { friend gboolean mediaPlayerPrivateMessageCallback(GstBus* bus, GstMessage* message, gpointer data); @@ -84,12 +81,12 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { void setVolume(float); void volumeChanged(); - void notifyPlayerOfVolumeChange(); + void volumeChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*); bool supportsMuting() const; void setMuted(bool); void muteChanged(); - void notifyPlayerOfMute(); + void muteChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*); void setPreload(MediaPlayer::Preload); void fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*); @@ -179,8 +176,6 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { bool m_delayingLoad; bool m_mediaDurationKnown; RefPtr<GStreamerGWorld> m_gstGWorld; - guint m_volumeTimerHandler; - guint m_muteTimerHandler; }; } diff --git a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp index 7dda245..05012e8 100644 --- a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp +++ b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp @@ -132,7 +132,7 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp m_data->m_view->StrokeArc(rect, startAngle, angleSpan, getHaikuStrokeStyle()); } -void GraphicsContext::strokePath(const Path&) +void GraphicsContext::strokePath() { notImplemented(); } @@ -191,7 +191,17 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef // FillRect and FillArc calls are needed. } -void GraphicsContext::fillPath(const Path&) +void GraphicsContext::fillPath() +{ + notImplemented(); +} + +void GraphicsContext::beginPath() +{ + notImplemented(); +} + +void GraphicsContext::addPath(const Path& path) { notImplemented(); } diff --git a/WebCore/platform/graphics/mac/ComplexTextController.cpp b/WebCore/platform/graphics/mac/ComplexTextController.cpp index d353d55..e6a7bef 100644 --- a/WebCore/platform/graphics/mac/ComplexTextController.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextController.cpp @@ -462,7 +462,7 @@ void ComplexTextController::adjustGlyphsAndAdvances() if (ch == '\t' && m_run.allowTabs()) { float tabWidth = m_font.tabWidth(*fontData); advance.width = tabWidth - fmodf(m_run.xPos() + m_totalWidth + widthSinceLastRounding, tabWidth); - } else if (ch == zeroWidthSpace || (Font::treatAsZeroWidthSpace(ch) && !treatAsSpace)) { + } else if (ch == zeroWidthSpace || Font::treatAsZeroWidthSpace(ch) && !treatAsSpace) { advance.width = 0; glyph = fontData->spaceGlyph(); } @@ -518,7 +518,7 @@ void ComplexTextController::adjustGlyphsAndAdvances() // Check to see if the next character is a "rounding hack character", if so, adjust the // width so that the total run width will be on an integer boundary. - if ((m_run.applyWordRounding() && !lastGlyph && Font::isRoundingHackCharacter(nextCh)) || (m_run.applyRunRounding() && lastGlyph)) { + if (m_run.applyWordRounding() && !lastGlyph && Font::isRoundingHackCharacter(nextCh) || m_run.applyRunRounding() && lastGlyph) { CGFloat totalWidth = widthSinceLastRounding + advance.width; widthSinceLastRounding = ceilCGFloat(totalWidth); CGFloat extraWidth = widthSinceLastRounding - totalWidth; diff --git a/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp b/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp index 04a5e26..0d16d4d 100644 --- a/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp +++ b/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp @@ -139,30 +139,30 @@ void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* poin UNUSED_PARAM(shouldAntialias); // FIXME } -void GraphicsContext::fillPath(const Path& path) +void GraphicsContext::fillPath() { if (paintingDisabled()) return; - // FIXME: Be smarter about this. - beginPath(); - addPath(path); - m_data->drawPath(VG_FILL_PATH, m_common->state.fillRule); } -void GraphicsContext::strokePath(const Path& path) +void GraphicsContext::strokePath() { if (paintingDisabled()) return; - // FIXME: Be smarter about this. - beginPath(); - addPath(path); - m_data->drawPath(VG_STROKE_PATH, m_common->state.fillRule); } +void GraphicsContext::drawPath() +{ + if (paintingDisabled()) + return; + + m_data->drawPath(VG_FILL_PATH | VG_STROKE_PATH, m_common->state.fillRule); +} + void GraphicsContext::fillRect(const FloatRect& rect) { if (paintingDisabled()) @@ -221,15 +221,11 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->intersectClipRect(rect); } -void GraphicsContext::clipPath(const Path& path, WindRule clipRule) +void GraphicsContext::clipPath(WindRule clipRule) { if (paintingDisabled()) return; - // FIXME: Be smarter about this. - beginPath(); - addPath(path); - m_data->clipPath(*(m_data->currentPath()), PainterOpenVG::IntersectClip, clipRule); } diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index a840525..b399f4e 100644 --- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -51,6 +51,7 @@ #include "NotImplemented.h" #include "Path.h" #include "Pattern.h" +#include "Pen.h" #include "TransparencyLayer.h" #include <QBrush> @@ -200,6 +201,9 @@ public: InterpolationQuality imageInterpolationQuality; + // Only used by SVG for now. + QPainterPath currentPath; + ContextShadow shadow; QStack<ContextShadow> shadowStack; @@ -208,6 +212,13 @@ public: return shadow.m_type != ContextShadow::NoShadow; } + inline void clearCurrentPath() + { + if (!currentPath.elementCount()) + return; + currentPath = QPainterPath(); + } + QRectF clipBoundingRect() const { #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) @@ -247,8 +258,8 @@ GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate() if (!platformContextIsOwned) return; - QPaintDevice* device = painter->device(); painter->end(); + QPaintDevice* device = painter->device(); delete painter; delete device; } @@ -308,6 +319,11 @@ void GraphicsContext::restorePlatformState() m_data->p()->restore(); + if (!m_data->currentPath.isEmpty() && m_common->state.pathTransform.isInvertible()) { + QTransform matrix = m_common->state.pathTransform; + m_data->currentPath = m_data->currentPath * matrix; + } + if (m_data->shadowStack.isEmpty()) m_data->shadow = ContextShadow(); else @@ -498,40 +514,28 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin p->setRenderHint(QPainter::Antialiasing, painterWasAntialiased); } -void GraphicsContext::fillPath(const Path& path) +void GraphicsContext::fillPath() { if (paintingDisabled()) return; QPainter* p = m_data->p(); - QPainterPath platformPath = path.platformPath(); - platformPath.setFillRule(toQtFillRule(fillRule())); + QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath + path.setFillRule(toQtFillRule(fillRule())); if (m_data->hasShadow()) { ContextShadow* shadow = contextShadow(); if (shadow->m_type != ContextShadow::BlurShadow && !m_common->state.fillPattern && !m_common->state.fillGradient) { - QPointF offset = shadow->offset(); - const QTransform& transform = p->transform(); - if (transform.isScaling()) { - // If scaling is required, find the new coord for shadow origin, - // so that the relative offset to its shape is kept. - QPointF translatedOffset(offset.x() / transform.m11(), - offset.y() / transform.m22()); - platformPath.translate(translatedOffset); - p->fillPath(platformPath, QColor(shadow->m_color)); - platformPath.translate(-translatedOffset); - } else { - p->translate(offset); - p->fillPath(platformPath, QColor(shadow->m_color)); - p->translate(-offset); - } + p->translate(m_data->shadow.offset()); + p->fillPath(path, QColor(m_data->shadow.m_color)); + p->translate(-m_data->shadow.offset()); } else { - QPainter* shadowPainter = shadow->beginShadowLayer(p, platformPath.controlPointRect()); + QPainter* shadowPainter = shadow->beginShadowLayer(p, path.controlPointRect()); if (shadowPainter) { shadowPainter->setCompositionMode(QPainter::CompositionMode_Source); - shadowPainter->fillPath(platformPath, QColor(m_data->shadow.m_color)); + shadowPainter->fillPath(path, QColor(m_data->shadow.m_color)); shadow->endShadowLayer(p); } } @@ -539,24 +543,26 @@ void GraphicsContext::fillPath(const Path& path) } if (m_common->state.fillPattern) { AffineTransform affine; - p->fillPath(platformPath, QBrush(m_common->state.fillPattern->createPlatformPattern(affine))); + p->fillPath(path, QBrush(m_common->state.fillPattern->createPlatformPattern(affine))); } else if (m_common->state.fillGradient) { QBrush brush(*m_common->state.fillGradient->platformGradient()); brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform()); - p->fillPath(platformPath, brush); + p->fillPath(path, brush); } else - p->fillPath(platformPath, p->brush()); + p->fillPath(path, p->brush()); + + m_data->clearCurrentPath(); } -void GraphicsContext::strokePath(const Path& path) +void GraphicsContext::strokePath() { if (paintingDisabled()) return; QPainter* p = m_data->p(); QPen pen(p->pen()); - QPainterPath platformPath = path.platformPath(); - platformPath.setFillRule(toQtFillRule(fillRule())); + QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath + path.setFillRule(toQtFillRule(fillRule())); if (m_data->hasShadow()) { ContextShadow* shadow = contextShadow(); @@ -566,28 +572,16 @@ void GraphicsContext::strokePath(const Path& path) { QPen shadowPen(pen); shadowPen.setColor(m_data->shadow.m_color); - QPointF offset = shadow->offset(); - const QTransform& transform = p->transform(); - if (transform.isScaling()) { - // If scaling is required, find the new coord for shadow origin, - // so that the relative offset to its shape is kept. - QPointF translatedOffset(offset.x() / transform.m11(), - offset.y() / transform.m22()); - platformPath.translate(translatedOffset); - p->strokePath(platformPath, shadowPen); - platformPath.translate(-translatedOffset); - } else { - p->translate(offset); - p->strokePath(platformPath, shadowPen); - p->translate(-offset); - } + p->translate(m_data->shadow.offset()); + p->strokePath(path, shadowPen); + p->translate(-m_data->shadow.offset()); } else { - FloatRect boundingRect = platformPath.controlPointRect(); + FloatRect boundingRect = path.controlPointRect(); boundingRect.inflate(pen.miterLimit() + pen.widthF()); QPainter* shadowPainter = shadow->beginShadowLayer(p, boundingRect); if (shadowPainter) { shadowPainter->setOpacity(static_cast<qreal>(m_data->shadow.m_color.alpha()) / 255); - shadowPainter->strokePath(platformPath, pen); + shadowPainter->strokePath(path, pen); shadow->endShadowLayer(p); } } @@ -597,15 +591,16 @@ void GraphicsContext::strokePath(const Path& path) AffineTransform affine; pen.setBrush(QBrush(m_common->state.strokePattern->createPlatformPattern(affine))); p->setPen(pen); - p->strokePath(platformPath, pen); + p->strokePath(path, pen); } else if (m_common->state.strokeGradient) { QBrush brush(*m_common->state.strokeGradient->platformGradient()); brush.setTransform(m_common->state.strokeGradient->gradientSpaceTransform()); pen.setBrush(brush); p->setPen(pen); - p->strokePath(platformPath, pen); + p->strokePath(path, pen); } else - p->strokePath(platformPath, pen); + p->strokePath(path, pen); + m_data->clearCurrentPath(); } static inline void drawRepeatPattern(QPainter* p, QPixmap* image, const FloatRect& rect, const bool repeatX, const bool repeatY) @@ -721,7 +716,7 @@ void GraphicsContext::fillRect(const FloatRect& rect) // without using the shadow layer at all. QColor shadowColor = shadow->m_color; shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF()); - const QTransform& transform = p->transform(); + const QTransform transform = p->transform(); if (transform.isScaling()) { p->fillRect(normalizedRect.translated(static_cast<qreal>(shadow->offset().x()) / transform.m11(), static_cast<qreal>(shadow->offset().y() / transform.m22())), @@ -792,11 +787,30 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef p->fillPath(path.platformPath(), QColor(color)); } +void GraphicsContext::beginPath() +{ + m_data->clearCurrentPath(); +} + +void GraphicsContext::addPath(const Path& path) +{ + if (!m_data->currentPath.elementCount()) { + m_data->currentPath = path.platformPath(); + return; + } + m_data->currentPath.addPath(path.platformPath()); +} + bool GraphicsContext::inTransparencyLayer() const { return m_data->layerCount; } +PlatformPath* GraphicsContext::currentPath() +{ + return &m_data->currentPath; +} + ContextShadow* GraphicsContext::contextShadow() { return &m_data->shadow; @@ -810,15 +824,15 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->p()->setClipRect(rect, Qt::IntersectClip); } -void GraphicsContext::clipPath(const Path& path, WindRule clipRule) +void GraphicsContext::clipPath(WindRule clipRule) { if (paintingDisabled()) return; QPainter* p = m_data->p(); - QPainterPath platformPath = path.platformPath(); - platformPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill); - p->setClipPath(platformPath, Qt::IntersectClip); + QPainterPath newPath = m_data->currentPath; + newPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill); + p->setClipPath(newPath, Qt::IntersectClip); } void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) @@ -1047,10 +1061,12 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float width) if (paintingDisabled()) return; - Path path; + QPainterPath path; path.addRect(rect); setStrokeThickness(width); - strokePath(path); + m_data->currentPath = path; + + strokePath(); } void GraphicsContext::setLineCap(LineCap lc) @@ -1170,6 +1186,12 @@ void GraphicsContext::translate(float x, float y) return; m_data->p()->translate(x, y); + + if (!m_data->currentPath.isEmpty()) { + QTransform matrix; + m_data->currentPath = m_data->currentPath * matrix.translate(-x, -y); + m_common->state.pathTransform.translate(x, y); + } } void GraphicsContext::rotate(float radians) @@ -1178,6 +1200,12 @@ void GraphicsContext::rotate(float radians) return; m_data->p()->rotate(180 / M_PI*radians); + + if (!m_data->currentPath.isEmpty()) { + QTransform matrix; + m_data->currentPath = m_data->currentPath * matrix.rotate(-180 / M_PI*radians); + m_common->state.pathTransform.rotate(radians); + } } void GraphicsContext::scale(const FloatSize& s) @@ -1186,6 +1214,12 @@ void GraphicsContext::scale(const FloatSize& s) return; m_data->p()->scale(s.width(), s.height()); + + if (!m_data->currentPath.isEmpty()) { + QTransform matrix; + m_data->currentPath = m_data->currentPath * matrix.scale(1 / s.width(), 1 / s.height()); + m_common->state.pathTransform.scaleNonUniform(s.width(), s.height()); + } } void GraphicsContext::clipOut(const IntRect& rect) @@ -1242,6 +1276,15 @@ void GraphicsContext::concatCTM(const AffineTransform& transform) return; m_data->p()->setWorldTransform(transform, true); + + // Transformations to the context shouldn't transform the currentPath. + // We have to undo every change made to the context from the currentPath + // to avoid wrong drawings. + if (!m_data->currentPath.isEmpty() && transform.isInvertible()) { + QTransform matrix = transform.inverse(); + m_data->currentPath = m_data->currentPath * matrix; + m_common->state.pathTransform.multiply(transform.toTransformationMatrix()); + } } void GraphicsContext::setURLForRect(const KURL&, const IntRect&) diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp index 6f6dce8..7c0bcd1 100644 --- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp +++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp @@ -420,15 +420,11 @@ void GraphicsContext::clipOut(const Path& p) platformContext()->canvas()->clipPath(path, SkRegion::kDifference_Op); } -void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule) +void GraphicsContext::clipPath(WindRule clipRule) { if (paintingDisabled()) return; - // FIXME: Be smarter about this. - beginPath(); - addPath(pathToClip); - SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; @@ -727,15 +723,11 @@ void GraphicsContext::drawRect(const IntRect& rect) platformContext()->drawRect(r); } -void GraphicsContext::fillPath(const Path& pathToFill) +void GraphicsContext::fillPath() { if (paintingDisabled()) return; - // FIXME: Be smarter about this. - beginPath(); - addPath(pathToFill); - SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; @@ -1185,15 +1177,11 @@ void GraphicsContext::strokeArc(const IntRect& r, int startAngle, int angleSpan) platformContext()->canvas()->drawPath(path, paint); } -void GraphicsContext::strokePath(const Path& pathToStroke) +void GraphicsContext::strokePath() { if (paintingDisabled()) return; - // FIXME: Be smarter about this. - beginPath(); - addPath(pathToStroke); - SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; diff --git a/WebCore/platform/graphics/skia/ImageSkia.cpp b/WebCore/platform/graphics/skia/ImageSkia.cpp index ae2653a..fee64ca 100644 --- a/WebCore/platform/graphics/skia/ImageSkia.cpp +++ b/WebCore/platform/graphics/skia/ImageSkia.cpp @@ -143,7 +143,9 @@ static ResamplingMode computeResamplingMode(PlatformContextSkia* platformContext // Everything else gets resampled. // If the platform context permits high quality interpolation, use it. - if (platformContext->interpolationQuality() == InterpolationHigh) + // High quality interpolation only enabled for scaling and translation. + if (platformContext->interpolationQuality() == InterpolationHigh + && !(platformContext->canvas()->getTotalMatrix().getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask))) return RESAMPLE_AWESOME; return RESAMPLE_LINEAR; @@ -178,9 +180,17 @@ static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeIm SkIRect resizedImageRect = // Represents the size of the resized image. { 0, 0, destRectRounded.width(), destRectRounded.height() }; - if (srcIsFull && bitmap.hasResizedBitmap(destRectRounded.width(), destRectRounded.height())) { + // Apply forward transform to destRect to estimate required size of + // re-sampled bitmap, and use only in calls required to resize, or that + // check for the required size. + SkRect destRectTransformed; + canvas.getTotalMatrix().mapRect(&destRectTransformed, destRect); + SkIRect destRectTransformedRounded; + destRectTransformed.round(&destRectTransformedRounded); + + if (srcIsFull && bitmap.hasResizedBitmap(destRectTransformedRounded.width(), destRectTransformedRounded.height())) { // Yay, this bitmap frame already has a resized version. - SkBitmap resampled = bitmap.resizedBitmap(destRectRounded.width(), destRectRounded.height()); + SkBitmap resampled = bitmap.resizedBitmap(destRectTransformedRounded.width(), destRectTransformedRounded.height()); canvas.drawBitmapRect(resampled, 0, destRect, &paint); return; } @@ -207,8 +217,8 @@ static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeIm destBitmapSubsetSkI.height())) { // We're supposed to resize the entire image and cache it, even though // we don't need all of it. - SkBitmap resampled = bitmap.resizedBitmap(destRectRounded.width(), - destRectRounded.height()); + SkBitmap resampled = bitmap.resizedBitmap(destRectTransformedRounded.width(), + destRectTransformedRounded.height()); canvas.drawBitmapRect(resampled, 0, destRect, &paint); } else { // We should only resize the exposed part of the bitmap to do the @@ -217,7 +227,7 @@ static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeIm // Resample the needed part of the image. SkBitmap resampled = skia::ImageOperations::Resize(subset, skia::ImageOperations::RESIZE_LANCZOS3, - destRectRounded.width(), destRectRounded.height(), + destRectTransformedRounded.width(), destRectTransformedRounded.height(), destBitmapSubsetSkI); // Compute where the new bitmap should be drawn. Since our new bitmap diff --git a/WebCore/platform/graphics/win/cairo/FontPlatformData.h b/WebCore/platform/graphics/win/cairo/FontPlatformData.h index d8f538a..05f9eab 100644 --- a/WebCore/platform/graphics/win/cairo/FontPlatformData.h +++ b/WebCore/platform/graphics/win/cairo/FontPlatformData.h @@ -3,7 +3,6 @@ * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com * Copyright (C) 2007 Holger Hans Peter Freyther * Copyright (C) 2007 Pioneer Research Center USA, Inc. - * Copyright (C) 2010 Brent Fulgham <bfulgham@webkit.org> * All rights reserved. * * This library is free software; you can redistribute it and/or @@ -26,7 +25,7 @@ #ifndef FontPlatformDataCairoWin_h #define FontPlatformDataCairoWin_h -#include "FontOrientation.h" +#include "FontDescription.h" #include "GlyphBuffer.h" #include "RefCountedGDIHandle.h" #include "StringImpl.h" @@ -38,8 +37,6 @@ typedef struct HFONT__* HFONT; namespace WebCore { -class FontDescription; - class FontPlatformData { public: FontPlatformData(WTF::HashTableDeletedValueType) @@ -76,9 +73,6 @@ public: void setSize(float size) { m_size = size; } bool syntheticBold() const { return m_syntheticBold; } bool syntheticOblique() const { return m_syntheticOblique; } - - FontOrientation orientation() const { return Horizontal; } // FIXME: Implement. - cairo_scaled_font_t* scaledFont() const { return m_scaledFont; } unsigned hash() const diff --git a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp index 4faa29d..0802826 100644 --- a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp +++ b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp @@ -1325,12 +1325,8 @@ Color gradientAverageColor(const Gradient* gradient) , (stop.alpha + lastStop.alpha) * 0.5f); } -void GraphicsContext::fillPath(const Path& path) +void GraphicsContext::fillPath() { - // FIXME: Be smarter about this. - beginPath(); - addPath(path); - Color c = m_common->state.fillGradient ? gradientAverageColor(m_common->state.fillGradient.get()) : fillColor(); @@ -1380,10 +1376,6 @@ void GraphicsContext::strokePath() if (!m_data->m_dc) return; - // FIXME: Be smarter about this. - beginPath(); - addPath(path); - OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); if (m_data->m_opacity < 1.0f || m_data->hasAlpha()) { @@ -1908,7 +1900,7 @@ void GraphicsContext::setLineDash(const DashArray&, float) notImplemented(); } -void GraphicsContext::clipPath(const Path&, WindRule) +void GraphicsContext::clipPath(WindRule) { notImplemented(); } diff --git a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp index ba96352..5007ffe 100644 --- a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp +++ b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp @@ -337,7 +337,7 @@ void GraphicsContext::clipOut(const IntRect&) notImplemented(); } -void GraphicsContext::clipPath(const Path&, WindRule) +void GraphicsContext::clipPath(WindRule) { notImplemented(); } @@ -533,32 +533,30 @@ InterpolationQuality GraphicsContext::imageInterpolationQuality() const return InterpolationDefault; } -void GraphicsContext::fillPath(const Path& path) +void GraphicsContext::fillPath() { #if USE(WXGC) - // FIXME: Be smarter about this. - beginPath(); - addPath(path); - wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); if (gc) gc->FillPath(m_data->currentPath); #endif } -void GraphicsContext::strokePath(const Path& path) +void GraphicsContext::strokePath() { #if USE(WXGC) - // FIXME: Be smarter about this. - beginPath(); - addPath(path); - wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); if (gc) gc->StrokePath(m_data->currentPath); #endif } +void GraphicsContext::drawPath() +{ + fillPath(); + strokePath(); +} + void GraphicsContext::fillRect(const FloatRect& rect) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/WebCore/platform/graphics/wx/ImageBufferWx.cpp index dd45f31..2522cbd 100644 --- a/WebCore/platform/graphics/wx/ImageBufferWx.cpp +++ b/WebCore/platform/graphics/wx/ImageBufferWx.cpp @@ -37,7 +37,7 @@ ImageBufferData::ImageBufferData(const IntSize&) { } -ImageBuffer::ImageBuffer(const IntSize&, ColorSpace imageColorSpace, bool& success) : +ImageBuffer::ImageBuffer(const IntSize&, ImageColorSpace imageColorSpace, bool& success) : m_data(IntSize()) { notImplemented(); |