diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2010-12-07 17:22:45 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2010-12-22 14:15:40 -0800 |
commit | 4576aa36e9a9671459299c7963ac95aa94beaea9 (patch) | |
tree | 3863574e050f168c0126ecb47c83319fab0972d8 /WebCore/platform/graphics | |
parent | 55323ac613cc31553107b68603cb627264d22bb0 (diff) | |
download | external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.zip external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.gz external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.bz2 |
Merge WebKit at r73109: Initial merge by git.
Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8
Diffstat (limited to 'WebCore/platform/graphics')
93 files changed, 848 insertions, 647 deletions
diff --git a/WebCore/platform/graphics/ContextShadow.h b/WebCore/platform/graphics/ContextShadow.h index 2b779f7..fa778af 100644 --- a/WebCore/platform/graphics/ContextShadow.h +++ b/WebCore/platform/graphics/ContextShadow.h @@ -120,6 +120,9 @@ private: PlatformImage m_layerImage; PlatformContext m_layerContext; + // Used for reference when canvas scale(x,y) was called. + FloatRect m_unscaledLayerRect; + void blurLayerImage(unsigned char*, const IntSize& imageSize, int stride); void calculateLayerBoundingRect(const FloatRect& layerArea, const IntRect& clipRect); #if PLATFORM(CAIRO) diff --git a/WebCore/platform/graphics/FloatPoint3D.h b/WebCore/platform/graphics/FloatPoint3D.h index b6cbaa8..ba0ee9d 100644 --- a/WebCore/platform/graphics/FloatPoint3D.h +++ b/WebCore/platform/graphics/FloatPoint3D.h @@ -84,6 +84,11 @@ public: m_z *= sz; } + bool isZero() const + { + return !m_x && !m_y && !m_z; + } + void normalize(); float dot(const FloatPoint3D& a) const @@ -115,6 +120,8 @@ public: float lengthSquared() const { return this->dot(*this); } float length() const { return sqrtf(lengthSquared()); } + + float distanceTo(const FloatPoint3D& a) const; private: float m_x; @@ -160,6 +167,21 @@ 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 e8ba0e4..76e897e 100644 --- a/WebCore/platform/graphics/GraphicsContext.h +++ b/WebCore/platform/graphics/GraphicsContext.h @@ -135,7 +135,6 @@ namespace WebCore { class GraphicsContextPrivate; class ImageBuffer; class KURL; - class Path; class Pattern; class SharedGraphicsContext3D; class TextRun; @@ -204,6 +203,7 @@ namespace WebCore { #if PLATFORM(CG) void applyStrokePattern(); void applyFillPattern(); + void drawPath(const Path&); #endif #if PLATFORM(ANDROID) @@ -245,9 +245,8 @@ namespace WebCore { void drawEllipse(const IntRect&); void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false); - void drawPath(); - void fillPath(); - void strokePath(); + void fillPath(const Path&); + void strokePath(const Path&); // Arc drawing (used by border-radius in CSS) just supports stroking at the moment. void strokeArc(const IntRect&, int startAngle, int angleSpan); @@ -288,7 +287,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(WindRule); + void clipPath(const Path&, WindRule); void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true); void clipToImageBuffer(ImageBuffer*, const FloatRect&); @@ -323,7 +322,7 @@ namespace WebCore { void clearShadow(); void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&); - void drawFocusRing(const Vector<Path>&, int width, int offset, const Color&); + void drawFocusRing(const Path&, int width, int offset, const Color&); void setLineCap(LineCap); void setLineDash(const DashArray&, float dashOffset); @@ -337,8 +336,10 @@ 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&); @@ -428,7 +429,6 @@ 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 985cad9..696932e 100644 --- a/WebCore/platform/graphics/GraphicsContextPrivate.h +++ b/WebCore/platform/graphics/GraphicsContextPrivate.h @@ -29,7 +29,6 @@ #include "Gradient.h" #include "GraphicsContext.h" #include "Pattern.h" -#include "TransformationMatrix.h" namespace WebCore { @@ -79,8 +78,6 @@ namespace WebCore { bool shadowsIgnoreTransforms; #if PLATFORM(CAIRO) float globalAlpha; -#elif PLATFORM(QT) - TransformationMatrix pathTransform; #endif }; diff --git a/WebCore/platform/graphics/GraphicsTypes.cpp b/WebCore/platform/graphics/GraphicsTypes.cpp index 761bf40..dd52ba9 100644 --- a/WebCore/platform/graphics/GraphicsTypes.cpp +++ b/WebCore/platform/graphics/GraphicsTypes.cpp @@ -47,7 +47,7 @@ static const char* const compositeOperatorNames[] = { "highlight", "lighter" }; -const int numCompositeOperatorNames = sizeof(compositeOperatorNames) / sizeof(compositeOperatorNames[0]); +const int numCompositeOperatorNames = WTF_ARRAY_LENGTH(compositeOperatorNames); bool parseCompositeOperator(const String& s, CompositeOperator& op) { diff --git a/WebCore/platform/graphics/MediaPlayer.cpp b/WebCore/platform/graphics/MediaPlayer.cpp index dc743bf..c9deb4c 100644 --- a/WebCore/platform/graphics/MediaPlayer.cpp +++ b/WebCore/platform/graphics/MediaPlayer.cpp @@ -274,6 +274,7 @@ MediaPlayer::MediaPlayer(MediaPlayerClient* client) MediaPlayer::~MediaPlayer() { + m_mediaPlayerClient = 0; } void MediaPlayer::load(const String& url, const ContentType& contentType) diff --git a/WebCore/platform/graphics/Path.h b/WebCore/platform/graphics/Path.h index 86ba831..ba25dc2 100644 --- a/WebCore/platform/graphics/Path.h +++ b/WebCore/platform/graphics/Path.h @@ -28,7 +28,6 @@ #ifndef Path_h #define Path_h -#include <algorithm> #include <wtf/FastAllocBase.h> #include <wtf/Forward.h> @@ -109,8 +108,6 @@ namespace WebCore { Path(const Path&); Path& operator=(const Path&); - void swap(Path& other) { std::swap(m_path, other.m_path); } - bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const; bool strokeContains(StrokeStyleApplier*, const FloatPoint&) const; FloatRect boundingRect() const; diff --git a/WebCore/platform/graphics/SimpleFontData.h b/WebCore/platform/graphics/SimpleFontData.h index 432a164..ea053cd 100644 --- a/WebCore/platform/graphics/SimpleFontData.h +++ b/WebCore/platform/graphics/SimpleFontData.h @@ -106,6 +106,7 @@ public: #endif Glyph spaceGlyph() const { return m_spaceGlyph; } + bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthSpaceGlyph && glyph; } virtual const SimpleFontData* fontDataForCharacter(UChar32) const; virtual bool containsCharacters(const UChar*, int length) const; @@ -267,7 +268,7 @@ private: #if !PLATFORM(QT) ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const { - if (glyph == m_zeroWidthSpaceGlyph && glyph) + if (isZeroWidthSpaceGlyph(glyph)) return FloatRect(); FloatRect bounds; @@ -286,7 +287,7 @@ ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const { - if (glyph == m_zeroWidthSpaceGlyph && glyph) + if (isZeroWidthSpaceGlyph(glyph)) return 0; float width = m_glyphToWidthMap.metricsForGlyph(glyph); diff --git a/WebCore/platform/graphics/TextRun.h b/WebCore/platform/graphics/TextRun.h index 79b6cb3..dce5535 100644 --- a/WebCore/platform/graphics/TextRun.h +++ b/WebCore/platform/graphics/TextRun.h @@ -117,7 +117,10 @@ private: const UChar* m_characters; int m_len; - int m_xpos; + // 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_padding; #if ENABLE(SVG) float m_horizontalGlyphStretch; diff --git a/WebCore/platform/graphics/WOFFFileFormat.cpp b/WebCore/platform/graphics/WOFFFileFormat.cpp index 5391f30..b1400ba 100644 --- a/WebCore/platform/graphics/WOFFFileFormat.cpp +++ b/WebCore/platform/graphics/WOFFFileFormat.cpp @@ -36,11 +36,11 @@ #endif #if PLATFORM(BREWMP) -#include <AEEStdLib.h> -#define htonl(x) HTONL(x) -#define htons(x) HTONS(x) -#define ntohl(x) NTOHL(x) -#define ntohs(x) NTOHS(x) +#include <AEEstd.h> +#define htonl(x) std_htonl(x) +#define htons(x) std_htons(x) +#define ntohl(x) std_ntohl(x) +#define ntohs(x) std_ntohs(x) #endif #if PLATFORM(WIN) diff --git a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp index 8299b6a..699edf7 100644 --- a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp +++ b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp @@ -84,6 +84,8 @@ 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)); @@ -120,7 +122,19 @@ void ContextShadow::endShadowLayer(cairo_t* cr) cairo_save(cr); setSourceRGBAFromColor(cr, m_color); - cairo_mask_surface(cr, m_layerImage, m_layerRect.x(), m_layerRect.y()); + + 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_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 755adff..9c2ff82 100644 --- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp +++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp @@ -531,44 +531,26 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin cairo_set_fill_rule(cr, savedFillRule); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; - - setPathOnCairoContext(cr, m_data->m_pendingPath.context()); + setPathOnCairoContext(cr, path.platformPath()->context()); fillCurrentCairoPath(this, m_common, cr); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& path) { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; - setPathOnCairoContext(cr, m_data->m_pendingPath.context()); + setPathOnCairoContext(cr, path.platformPath()->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()) @@ -607,17 +589,18 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->clip(rect); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& path, 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); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -994,25 +977,6 @@ 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 527cb72..494b40d 100644 --- a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h +++ b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h @@ -27,7 +27,6 @@ #include "GraphicsContext.h" -#include "CairoPath.h" #include "ContextShadow.h" #include <cairo.h> #include <math.h> @@ -97,7 +96,6 @@ 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 8d72b85..2eb929e 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -299,21 +299,12 @@ 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; - 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(); + Path path; + path.addEllipse(rect); + drawPath(path); } @@ -405,21 +396,22 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp CGContextRestoreGState(context); } -static void addConvexPolygonToContext(CGContextRef context, size_t numPoints, const FloatPoint* points) +static void addConvexPolygonToPath(Path& path, size_t numberOfPoints, const FloatPoint* points) { - 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); + ASSERT(numberOfPoints > 0); + + path.moveTo(points[0]); + for (size_t i = 1; i < numberOfPoints; ++i) + path.addLineTo(points[i]); + path.closeSubpath(); } -void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool antialiased) +void GraphicsContext::drawConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; - if (npoints <= 1) + if (numberOfPoints <= 1) return; CGContextRef context = platformContext(); @@ -427,28 +419,30 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points if (antialiased != shouldAntialias()) CGContextSetShouldAntialias(context, antialiased); - addConvexPolygonToContext(context, npoints, points); - drawPath(); + Path path; + addConvexPolygonToPath(path, numberOfPoints, points); + drawPath(path); if (antialiased != shouldAntialias()) CGContextSetShouldAntialias(context, shouldAntialias()); } -void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialias) +void GraphicsContext::clipConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialias) { if (paintingDisabled()) return; - if (numPoints <= 1) + if (numberOfPoints <= 1) return; CGContextRef context = platformContext(); if (antialias != shouldAntialias()) CGContextSetShouldAntialias(context, antialias); - - addConvexPolygonToContext(context, numPoints, points); - clipPath(RULE_NONZERO); + + Path path; + addConvexPolygonToPath(path, numberOfPoints, points); + clipPath(path, RULE_NONZERO); if (antialias != shouldAntialias()) CGContextSetShouldAntialias(context, shouldAntialias()); @@ -511,7 +505,7 @@ static inline bool calculateDrawingMode(const GraphicsContextState& state, CGPat return shouldFill || shouldStroke; } -void GraphicsContext::drawPath() +void GraphicsContext::drawPath(const Path& path) { if (paintingDisabled()) return; @@ -521,11 +515,15 @@ void GraphicsContext::drawPath() if (state.fillGradient || state.strokeGradient) { // We don't have any optimized way to fill & stroke a path using gradients - fillPath(); - strokePath(); + // FIXME: Be smarter about this. + fillPath(path); + strokePath(path); return; } + CGContextBeginPath(context); + CGContextAddPath(context, path.platformPath()); + if (state.fillPattern) applyFillPattern(); if (state.strokePattern) @@ -544,13 +542,16 @@ static inline void fillPathWithFillRule(CGContextRef context, WindRule fillRule) CGContextFillPath(context); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { if (paintingDisabled()) return; CGContextRef context = platformContext(); + CGContextBeginPath(context); + CGContextAddPath(context, path.platformPath()); + if (m_common->state.fillGradient) { CGContextSaveGState(context); if (fillRule() == RULE_EVENODD) @@ -568,13 +569,16 @@ void GraphicsContext::fillPath() fillPathWithFillRule(context, fillRule()); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& path) { if (paintingDisabled()) return; CGContextRef context = platformContext(); + CGContextBeginPath(context); + CGContextAddPath(context, path.platformPath()); + if (m_common->state.strokeGradient) { CGContextSaveGState(context); CGContextReplacePathWithStrokedPath(context); @@ -643,8 +647,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef Path path; path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); - addPath(path); - fillPath(); + fillPath(path); if (oldFillColor != color || oldColorSpace != colorSpace) setCGFillColor(context, oldFillColor, oldColorSpace); @@ -669,19 +672,23 @@ void GraphicsContext::clipOut(const IntRect& rect) CGContextEOClip(platformContext()); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& path, WindRule clipRule) { if (paintingDisabled()) return; + if (path.isEmpty()) + return; + CGContextRef context = platformContext(); - if (!CGContextIsPathEmpty(context)) { - if (clipRule == RULE_EVENODD) - CGContextEOClip(context); - else - CGContextClip(context); - } + CGContextBeginPath(platformContext()); + CGContextAddPath(platformContext(), path.platformPath()); + + if (clipRule == RULE_EVENODD) + CGContextEOClip(context); + else + CGContextClip(context); } void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) @@ -863,16 +870,6 @@ 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 375a74b..7dab01f 100644 --- a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp +++ b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp @@ -41,6 +41,7 @@ #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> @@ -68,8 +69,22 @@ 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 fragmentShaderString[] = + char bgraFragmentShaderString[] = "precision mediump float; \n" "varying vec2 v_texCoord; \n" "uniform sampler2D s_texture; \n" @@ -80,6 +95,12 @@ 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/CrossProcessFontLoading.mm b/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm index a7ec03a..72e3369 100644 --- a/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm +++ b/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm @@ -181,11 +181,10 @@ MemoryActivatedFont::~MemoryActivatedFont() // that was picked in the end. The caller is responsible for calling // CFRelease() on this parameter when done with it. // * fontID - on output, the ID corresponding to nsFont. -void FontPlatformData::loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFont, CGFontRef& cgFont, ATSUFontID& fontID) +void FontPlatformData::loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFont, CGFontRef& cgFont) { outNSFont = nsFont; cgFont = CTFontCopyGraphicsFont(toCTFontRef(outNSFont), 0); - MemoryActivatedFont* memFont = 0; if (OutOfProcessFontLoadingEnabled() && outNSFont && cgFont && isLastResortFont(cgFont)) { // Release old CGFontRef since it points at the LastResort font which we don't want. CFRelease(cgFont); @@ -206,12 +205,6 @@ void FontPlatformData::loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFo cgFont = CTFontCopyGraphicsFont(toCTFontRef(outNSFont), 0); } } - - if (memFont) { - fontID = m_inMemoryFont->atsFontRef(); - } else { - fontID = CTFontGetPlatformFont(toCTFontRef(outNSFont), 0); - } } } // namespace WebCore diff --git a/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp b/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp index 384b1c5..347a3fb 100644 --- a/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp +++ b/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp @@ -211,9 +211,8 @@ static bool LookupAltName(const String& name, String& altName) static NameMap* fontNameMap = 0; if (!fontNameMap) { - size_t numElements = sizeof(namePairs) / sizeof(NamePair); fontNameMap = new NameMap; - for (size_t i = 0; i < numElements; ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(namePairs); ++i) fontNameMap->set(String(namePairs[i].name), &(namePairs[i].altNameCodepage)); } diff --git a/WebCore/platform/graphics/chromium/FontLinux.cpp b/WebCore/platform/graphics/chromium/FontLinux.cpp index 9fc7558..82b9df7 100644 --- a/WebCore/platform/graphics/chromium/FontLinux.cpp +++ b/WebCore/platform/graphics/chromium/FontLinux.cpp @@ -234,6 +234,7 @@ private: static bool isCodepointSpace(HB_UChar16 c) { return c == ' ' || c == '\t'; } const Font* const m_font; + const SimpleFontData* m_currentFontData; HB_ShaperItem m_item; uint16_t* m_glyphs16; // A vector of 16-bit glyph ids. SkScalar* m_xPositions; // A vector of x positions for each glyph. @@ -340,7 +341,6 @@ 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)) @@ -381,6 +381,7 @@ bool TextRunWalker::nextScriptRun() // (and the glyphs in each A, C and T section are backwards too) if (!hb_utf16_script_run_prev(&m_numCodePoints, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; + m_currentFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false, false).fontData; } else { if (!hb_utf16_script_run_next(&m_numCodePoints, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; @@ -392,11 +393,11 @@ bool TextRunWalker::nextScriptRun() // in the harfbuzz data structures to e.g. pick the correct script's shaper. // So we allow that to run first, then do a second pass over the range it // found and take the largest subregion that stays within a single font. - const FontData* glyphData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false, false).fontData; + m_currentFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false, false).fontData; unsigned endOfRun; for (endOfRun = 1; endOfRun < m_item.item.length; ++endOfRun) { - const FontData* nextGlyphData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos + endOfRun], false, false).fontData; - if (nextGlyphData != glyphData) + const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos + endOfRun], false, false).fontData; + if (nextFontData != m_currentFontData) break; } m_item.item.length = endOfRun; @@ -518,13 +519,15 @@ void TextRunWalker::setGlyphXPositions(bool isRTL) // Glyphs are stored in logical order, but for layout purposes we // always go left to right. for (int i = m_item.num_glyphs - 1; i >= 0; --i) { - // 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 (i + 1 >= m_item.num_glyphs || m_item.attributes[i + 1].clusterStart) - position += m_letterSpacing; - - position += determineWordBreakSpacing(logClustersIndex); + if (!m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i])) { + // 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) + position += m_letterSpacing; + + position += determineWordBreakSpacing(logClustersIndex); + } m_glyphs16[i] = m_item.glyphs[i]; double offsetX = truncateFixedPointToInteger(m_item.offsets[i].x); @@ -533,14 +536,18 @@ void TextRunWalker::setGlyphXPositions(bool isRTL) while (logClustersIndex > 0 && logClusters()[logClustersIndex] == i) logClustersIndex--; - position += truncateFixedPointToInteger(m_item.advances[i]); + if (!m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i])) + position += truncateFixedPointToInteger(m_item.advances[i]); } } else { - for (int i = 0; i < m_item.num_glyphs; ++i) { + for (size_t 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; + if (m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i])) + continue; + double advance = truncateFixedPointToInteger(m_item.advances[i]); advance += determineWordBreakSpacing(logClustersIndex); @@ -548,7 +555,7 @@ void TextRunWalker::setGlyphXPositions(bool isRTL) if (m_item.attributes[i].clusterStart) advance += m_letterSpacing; - while (logClustersIndex < m_item.item.length && logClusters()[logClustersIndex] == i) + while (static_cast<unsigned>(logClustersIndex) < m_item.item.length && logClusters()[logClustersIndex] == i) logClustersIndex++; position += advance; @@ -569,6 +576,8 @@ void TextRunWalker::normalizeSpacesAndMirrorChars(const UChar* source, bool rtl, U16_NEXT(source, nextPosition, length, character); if (Font::treatAsSpace(character)) character = ' '; + else if (Font::treatAsZeroWidthSpace(character)) + character = zeroWidthSpace; else if (rtl) character = u_charMirror(character); U16_APPEND(destination, position, length, character, error); @@ -592,7 +601,7 @@ const TextRun& TextRunWalker::getNormalizedTextRun(const TextRun& originalRun, O // 2) Convert spacing characters into plain spaces, as some fonts will provide glyphs // for characters like '\n' otherwise. // 3) Convert mirrored characters such as parenthesis for rtl text. - + // Convert to NFC form if the text has diacritical marks. icu::UnicodeString normalizedString; UErrorCode error = U_ZERO_ERROR; @@ -698,7 +707,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 < (walker.length() - glyphIndex) * letterSpacing + truncateFixedPointToInteger(advances[glyphIndex])) + if (x < (static_cast<int>(walker.length()) - glyphIndex) * letterSpacing + truncateFixedPointToInteger(advances[glyphIndex])) break; x -= truncateFixedPointToInteger(advances[glyphIndex]); } diff --git a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp index 0da873b..3944775 100644 --- a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp +++ b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp @@ -130,7 +130,7 @@ String FontPlatformData::description() const void FontPlatformData::setupPaint(SkPaint* paint) const { - const float ts = m_textSize > 0 ? m_textSize : 12; + const float ts = m_textSize >= 0 ? m_textSize : 12; paint->setAntiAlias(m_style.useAntiAlias == FontRenderStyle::NoPreference ? isSkiaAntiAlias : m_style.useAntiAlias); switch (m_style.useHinting) { diff --git a/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp b/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp index e725c50..bea0572 100644 --- a/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp +++ b/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp @@ -150,14 +150,14 @@ void initializeScriptFontMap(ScriptToFontMap& scriptFontMap) {USCRIPT_MYANMAR, myanmarFonts}, }; - for (int i = 0; i < sizeof(fontMap) / sizeof(fontMap[0]); ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontMap); ++i) scriptFontMap[fontMap[i].script] = fontMap[i].family; // FIXME: Instead of scanning the hard-coded list, we have to // use EnumFont* to 'inspect' fonts to pick up fonts covering scripts // when it's possible (e.g. using OS/2 table). If we do that, this // had better be pulled out of here. - for (int i = 0; i < sizeof(scriptToFontFamilies) / sizeof(scriptToFontFamilies[0]); ++i) { + for (size_t i = 0; i < WTF_ARRAY_LENGTH(scriptToFontFamilies); ++i) { UScriptCode script = scriptToFontFamilies[i].script; scriptFontMap[script] = 0; const UChar** familyPtr = scriptToFontFamilies[i].families; diff --git a/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp b/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp index deebd31..bcef1fe 100644 --- a/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp +++ b/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp @@ -53,6 +53,18 @@ static inline float scaleEmToUnits(float x, int unitsPerEm) void SimpleFontData::platformInit() { + if (!m_platformData.size()) { + m_ascent = 0; + m_descent = 0; + m_lineGap = 0; + m_lineSpacing = 0; + m_avgCharWidth = 0; + m_maxCharWidth = 0; + m_xHeight = 0; + m_unitsPerEm = 0; + return; + } + HDC dc = GetDC(0); HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont()); @@ -155,6 +167,9 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const float SimpleFontData::platformWidthForGlyph(Glyph glyph) const { + if (!m_platformData.size()) + return 0; + HDC dc = GetDC(0); HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont()); diff --git a/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp b/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp index e7ff9ee..c5190fc 100644 --- a/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp +++ b/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp @@ -53,6 +53,18 @@ static const size_t maxVDMXTableSize = 1024 * 1024; // 1 MB void SimpleFontData::platformInit() { + if (!m_platformData.size()) { + m_ascent = 0; + m_descent = 0; + m_lineGap = 0; + m_lineSpacing = 0; + m_avgCharWidth = 0; + m_maxCharWidth = 0; + m_xHeight = 0; + m_unitsPerEm = 0; + return; + } + SkPaint paint; SkPaint::FontMetrics metrics; @@ -177,6 +189,9 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const float SimpleFontData::platformWidthForGlyph(Glyph glyph) const { + if (!m_platformData.size()) + return 0; + SkASSERT(sizeof(glyph) == 2); // compile-time assert SkPaint paint; diff --git a/WebCore/platform/graphics/cocoa/FontPlatformData.h b/WebCore/platform/graphics/cocoa/FontPlatformData.h index 7ab84f5..8cf08fb 100644 --- a/WebCore/platform/graphics/cocoa/FontPlatformData.h +++ b/WebCore/platform/graphics/cocoa/FontPlatformData.h @@ -63,7 +63,6 @@ class FontPlatformData { : m_syntheticBold(syntheticBold) , m_syntheticOblique(syntheticOblique) , m_orientation(orientation) - , m_atsuFontID(0) , m_size(size) , m_font(0) #ifdef BUILDING_ON_TIGER @@ -75,11 +74,10 @@ class FontPlatformData { FontPlatformData(NSFont *nsFont, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = Horizontal); - FontPlatformData(CGFontRef cgFont, ATSUFontID fontID, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation) + FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation) : m_syntheticBold(syntheticBold) , m_syntheticOblique(syntheticOblique) , m_orientation(orientation) - , m_atsuFontID(fontID) , m_size(size) , m_font(0) , m_cgFont(cgFont) @@ -103,7 +101,6 @@ class FontPlatformData { bool m_syntheticOblique; FontOrientation m_orientation; - ATSUFontID m_atsuFontID; float m_size; unsigned hash() const @@ -118,7 +115,7 @@ class FontPlatformData { bool operator==(const FontPlatformData& other) const { return m_font == other.m_font && m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique && - m_cgFont == other.m_cgFont && m_size == other.m_size && m_atsuFontID == other.m_atsuFontID && m_orientation == other.m_orientation; + m_cgFont == other.m_cgFont && m_size == other.m_size && m_orientation == other.m_orientation; } NSFont *font() const { return m_font; } @@ -149,8 +146,7 @@ private: // * outNSFont - The font that was actually loaded, for the Chromium port this may be different than nsFont. // The caller is responsible for calling CFRelease() on this parameter when done with it. // * cgFont - CGFontRef representing the input font at the specified point size. - // * fontID - ID of loaded font. - void loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFont, CGFontRef& cgFont, ATSUFontID& fontID); + void loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFont, CGFontRef& cgFont); NSFont *m_font; diff --git a/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm b/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm index 52a88ed..8dacbe3 100644 --- a/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm +++ b/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm @@ -31,15 +31,13 @@ namespace WebCore { #if PLATFORM(MAC) -void FontPlatformData::loadFont(NSFont* nsFont, float, NSFont*& outNSFont, CGFontRef& cgFont, ATSUFontID& fontID) +void FontPlatformData::loadFont(NSFont* nsFont, float, NSFont*& outNSFont, CGFontRef& cgFont) { outNSFont = nsFont; #ifndef BUILDING_ON_TIGER cgFont = CTFontCopyGraphicsFont(toCTFontRef(nsFont), 0); - fontID = CTFontGetPlatformFont(toCTFontRef(nsFont), 0); #else cgFont = wkGetCGFontFromNSFont(nsFont); - fontID = wkGetNSFontATSUFontId(nsFont); #endif } #endif // PLATFORM(MAC) @@ -60,7 +58,7 @@ FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool syntheticBol ASSERT_ARG(nsFont, nsFont); CGFontRef cgFont = 0; - loadFont(nsFont, size, m_font, cgFont, m_atsuFontID); + loadFont(nsFont, size, m_font, cgFont); m_orientation = orientation; @@ -82,7 +80,6 @@ FontPlatformData::FontPlatformData(const FontPlatformData& f) m_syntheticOblique = f.m_syntheticOblique; m_size = f.m_size; m_cgFont = f.m_cgFont; - m_atsuFontID = f.m_atsuFontID; m_isColorBitmapFont = f.m_isColorBitmapFont; m_orientation = f.m_orientation; m_CTFont = f.m_CTFont; @@ -103,7 +100,6 @@ const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& f) m_syntheticOblique = f.m_syntheticOblique; m_size = f.m_size; m_cgFont = f.m_cgFont; - m_atsuFontID = f.m_atsuFontID; if (m_font == f.m_font) return *this; if (f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1)) @@ -136,7 +132,7 @@ void FontPlatformData::setFont(NSFont *font) CGFontRef cgFont = 0; NSFont* loadedFont = 0; - loadFont(m_font, m_size, loadedFont, cgFont, m_atsuFontID); + loadFont(m_font, m_size, loadedFont, cgFont); #if PLATFORM(CHROMIUM) && OS(DARWIN) // If loadFont replaced m_font with a fallback font, then release the diff --git a/WebCore/platform/graphics/filters/FEBlend.cpp b/WebCore/platform/graphics/filters/FEBlend.cpp index 03b95c3..89b44e0 100644 --- a/WebCore/platform/graphics/filters/FEBlend.cpp +++ b/WebCore/platform/graphics/filters/FEBlend.cpp @@ -35,15 +35,15 @@ typedef unsigned char (*BlendType)(unsigned char colorA, unsigned char colorB, u namespace WebCore { -FEBlend::FEBlend(BlendModeType mode) - : FilterEffect() +FEBlend::FEBlend(Filter* filter, BlendModeType mode) + : FilterEffect(filter) , m_mode(mode) { } -PassRefPtr<FEBlend> FEBlend::create(BlendModeType mode) +PassRefPtr<FEBlend> FEBlend::create(Filter* filter, BlendModeType mode) { - return adoptRef(new FEBlend(mode)); + return adoptRef(new FEBlend(filter, mode)); } BlendModeType FEBlend::blendMode() const @@ -86,19 +86,19 @@ static unsigned char lighten(unsigned char colorA, unsigned char colorB, unsigne return ((std::max((255 - alphaA) * colorB + colorA * 255, (255 - alphaB) * colorA + colorB * 255)) / 255); } -void FEBlend::apply(Filter* filter) +void FEBlend::apply() { FilterEffect* in = inputEffect(0); FilterEffect* in2 = inputEffect(1); - in->apply(filter); - in2->apply(filter); + in->apply(); + in2->apply(); if (!in->resultImage() || !in2->resultImage()) return; if (m_mode <= FEBLEND_MODE_UNKNOWN || m_mode > FEBLEND_MODE_LIGHTEN) return; - if (!effectContext(filter)) + if (!effectContext()) return; IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); diff --git a/WebCore/platform/graphics/filters/FEBlend.h b/WebCore/platform/graphics/filters/FEBlend.h index a6569e2..4c59578 100644 --- a/WebCore/platform/graphics/filters/FEBlend.h +++ b/WebCore/platform/graphics/filters/FEBlend.h @@ -40,18 +40,18 @@ enum BlendModeType { class FEBlend : public FilterEffect { public: - static PassRefPtr<FEBlend> create(BlendModeType); + static PassRefPtr<FEBlend> create(Filter*, BlendModeType); BlendModeType blendMode() const; void setBlendMode(BlendModeType); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEBlend(BlendModeType); + FEBlend(Filter*, BlendModeType); BlendModeType m_mode; }; diff --git a/WebCore/platform/graphics/filters/FEColorMatrix.cpp b/WebCore/platform/graphics/filters/FEColorMatrix.cpp index acf7d4a..1c99b1e 100644 --- a/WebCore/platform/graphics/filters/FEColorMatrix.cpp +++ b/WebCore/platform/graphics/filters/FEColorMatrix.cpp @@ -33,16 +33,16 @@ namespace WebCore { -FEColorMatrix::FEColorMatrix(ColorMatrixType type, const Vector<float>& values) - : FilterEffect() +FEColorMatrix::FEColorMatrix(Filter* filter, ColorMatrixType type, const Vector<float>& values) + : FilterEffect(filter) , m_type(type) , m_values(values) { } -PassRefPtr<FEColorMatrix> FEColorMatrix::create(ColorMatrixType type, const Vector<float>& values) +PassRefPtr<FEColorMatrix> FEColorMatrix::create(Filter* filter, ColorMatrixType type, const Vector<float>& values) { - return adoptRef(new FEColorMatrix(type, values)); + return adoptRef(new FEColorMatrix(filter, type, values)); } ColorMatrixType FEColorMatrix::type() const @@ -148,14 +148,14 @@ void effectType(ByteArray* pixelArray, const Vector<float>& values) } } -void FEColorMatrix::apply(Filter* filter) +void FEColorMatrix::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/platform/graphics/filters/FEColorMatrix.h b/WebCore/platform/graphics/filters/FEColorMatrix.h index b898b17..a3ced7e 100644 --- a/WebCore/platform/graphics/filters/FEColorMatrix.h +++ b/WebCore/platform/graphics/filters/FEColorMatrix.h @@ -40,7 +40,7 @@ enum ColorMatrixType { class FEColorMatrix : public FilterEffect { public: - static PassRefPtr<FEColorMatrix> create(ColorMatrixType, const Vector<float>&); + static PassRefPtr<FEColorMatrix> create(Filter*, ColorMatrixType, const Vector<float>&); ColorMatrixType type() const; void setType(ColorMatrixType); @@ -48,13 +48,13 @@ public: const Vector<float>& values() const; void setValues(const Vector<float>&); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEColorMatrix(ColorMatrixType, const Vector<float>&); + FEColorMatrix(Filter*, ColorMatrixType, const Vector<float>&); ColorMatrixType m_type; Vector<float> m_values; diff --git a/WebCore/platform/graphics/filters/FEComponentTransfer.cpp b/WebCore/platform/graphics/filters/FEComponentTransfer.cpp index 5cffac7..cfab50b 100644 --- a/WebCore/platform/graphics/filters/FEComponentTransfer.cpp +++ b/WebCore/platform/graphics/filters/FEComponentTransfer.cpp @@ -36,9 +36,9 @@ namespace WebCore { typedef void (*TransferType)(unsigned char*, const ComponentTransferFunction&); -FEComponentTransfer::FEComponentTransfer(const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, +FEComponentTransfer::FEComponentTransfer(Filter* filter, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc) - : FilterEffect() + : FilterEffect(filter) , m_redFunc(redFunc) , m_greenFunc(greenFunc) , m_blueFunc(blueFunc) @@ -46,10 +46,10 @@ FEComponentTransfer::FEComponentTransfer(const ComponentTransferFunction& redFun { } -PassRefPtr<FEComponentTransfer> FEComponentTransfer::create(const ComponentTransferFunction& redFunc, +PassRefPtr<FEComponentTransfer> FEComponentTransfer::create(Filter* filter, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc) { - return adoptRef(new FEComponentTransfer(redFunc, greenFunc, blueFunc, alphaFunc)); + return adoptRef(new FEComponentTransfer(filter, redFunc, greenFunc, blueFunc, alphaFunc)); } ComponentTransferFunction FEComponentTransfer::redFunction() const @@ -147,14 +147,14 @@ static void gamma(unsigned char* values, const ComponentTransferFunction& transf } } -void FEComponentTransfer::apply(Filter* filter) +void FEComponentTransfer::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; unsigned char rValues[256], gValues[256], bValues[256], aValues[256]; diff --git a/WebCore/platform/graphics/filters/FEComponentTransfer.h b/WebCore/platform/graphics/filters/FEComponentTransfer.h index d3145d4..bbe3ebb 100644 --- a/WebCore/platform/graphics/filters/FEComponentTransfer.h +++ b/WebCore/platform/graphics/filters/FEComponentTransfer.h @@ -63,7 +63,7 @@ struct ComponentTransferFunction { class FEComponentTransfer : public FilterEffect { public: - static PassRefPtr<FEComponentTransfer> create(const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, + static PassRefPtr<FEComponentTransfer> create(Filter*, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc); ComponentTransferFunction redFunction() const; @@ -78,13 +78,13 @@ public: ComponentTransferFunction alphaFunction() const; void setAlphaFunction(const ComponentTransferFunction&); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEComponentTransfer(const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, + FEComponentTransfer(Filter*, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc); ComponentTransferFunction m_redFunc; diff --git a/WebCore/platform/graphics/filters/FEComposite.cpp b/WebCore/platform/graphics/filters/FEComposite.cpp index aad71e3..d27321f 100644 --- a/WebCore/platform/graphics/filters/FEComposite.cpp +++ b/WebCore/platform/graphics/filters/FEComposite.cpp @@ -32,8 +32,8 @@ namespace WebCore { -FEComposite::FEComposite(const CompositeOperationType& type, float k1, float k2, float k3, float k4) - : FilterEffect() +FEComposite::FEComposite(Filter* filter, const CompositeOperationType& type, float k1, float k2, float k3, float k4) + : FilterEffect(filter) , m_type(type) , m_k1(k1) , m_k2(k2) @@ -42,9 +42,9 @@ FEComposite::FEComposite(const CompositeOperationType& type, float k1, float k2, { } -PassRefPtr<FEComposite> FEComposite::create(const CompositeOperationType& type, float k1, float k2, float k3, float k4) +PassRefPtr<FEComposite> FEComposite::create(Filter* filter, const CompositeOperationType& type, float k1, float k2, float k3, float k4) { - return adoptRef(new FEComposite(type, k1, k2, k3, k4)); + return adoptRef(new FEComposite(filter, type, k1, k2, k3, k4)); } CompositeOperationType FEComposite::operation() const @@ -114,7 +114,7 @@ inline void arithmetic(const ByteArray* srcPixelArrayA, ByteArray* srcPixelArray } } -void FEComposite::determineAbsolutePaintRect(Filter* filter) +void FEComposite::determineAbsolutePaintRect() { switch (m_type) { case FECOMPOSITE_OPERATOR_IN: @@ -130,21 +130,21 @@ void FEComposite::determineAbsolutePaintRect(Filter* filter) return; default: // Take the union of both input effects. - FilterEffect::determineAbsolutePaintRect(filter); + FilterEffect::determineAbsolutePaintRect(); return; } } -void FEComposite::apply(Filter* filter) +void FEComposite::apply() { FilterEffect* in = inputEffect(0); FilterEffect* in2 = inputEffect(1); - in->apply(filter); - in2->apply(filter); + in->apply(); + in2->apply(); if (!in->resultImage() || !in2->resultImage()) return; - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/platform/graphics/filters/FEComposite.h b/WebCore/platform/graphics/filters/FEComposite.h index ecdb037..b846902 100644 --- a/WebCore/platform/graphics/filters/FEComposite.h +++ b/WebCore/platform/graphics/filters/FEComposite.h @@ -42,7 +42,7 @@ enum CompositeOperationType { class FEComposite : public FilterEffect { public: - static PassRefPtr<FEComposite> create(const CompositeOperationType&, float, float, float, float); + static PassRefPtr<FEComposite> create(Filter*, const CompositeOperationType&, float, float, float, float); CompositeOperationType operation() const; void setOperation(CompositeOperationType); @@ -59,15 +59,15 @@ public: float k4() const; void setK4(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEComposite(const CompositeOperationType&, float, float, float, float); + FEComposite(Filter*, const CompositeOperationType&, float, float, float, float); CompositeOperationType m_type; float m_k1; diff --git a/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp b/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp index d487a47..198d764 100644 --- a/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp +++ b/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp @@ -32,10 +32,10 @@ namespace WebCore { -FEConvolveMatrix::FEConvolveMatrix(const IntSize& kernelSize, +FEConvolveMatrix::FEConvolveMatrix(Filter* filter, const IntSize& kernelSize, float divisor, float bias, const IntPoint& targetOffset, EdgeModeType edgeMode, const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix) - : FilterEffect() + : FilterEffect(filter) , m_kernelSize(kernelSize) , m_divisor(divisor) , m_bias(bias) @@ -47,11 +47,11 @@ FEConvolveMatrix::FEConvolveMatrix(const IntSize& kernelSize, { } -PassRefPtr<FEConvolveMatrix> FEConvolveMatrix::create(const IntSize& kernelSize, +PassRefPtr<FEConvolveMatrix> FEConvolveMatrix::create(Filter* filter, const IntSize& kernelSize, float divisor, float bias, const IntPoint& targetOffset, EdgeModeType edgeMode, const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix) { - return adoptRef(new FEConvolveMatrix(kernelSize, divisor, bias, targetOffset, edgeMode, kernelUnitLength, + return adoptRef(new FEConvolveMatrix(filter, kernelSize, divisor, bias, targetOffset, edgeMode, kernelUnitLength, preserveAlpha, kernelMatrix)); } @@ -370,14 +370,14 @@ ALWAYS_INLINE void FEConvolveMatrix::setOuterPixels(PaintingData& paintingData, fastSetOuterPixels<false>(paintingData, x1, y1, x2, y2); } -void FEConvolveMatrix::apply(Filter* filter) +void FEConvolveMatrix::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; IntRect imageRect(IntPoint(), resultImage()->size()); diff --git a/WebCore/platform/graphics/filters/FEConvolveMatrix.h b/WebCore/platform/graphics/filters/FEConvolveMatrix.h index 8d3439e..6811a1b 100644 --- a/WebCore/platform/graphics/filters/FEConvolveMatrix.h +++ b/WebCore/platform/graphics/filters/FEConvolveMatrix.h @@ -44,7 +44,7 @@ class CanvasPixelArray; class FEConvolveMatrix : public FilterEffect { public: - static PassRefPtr<FEConvolveMatrix> create(const IntSize&, + static PassRefPtr<FEConvolveMatrix> create(Filter*, const IntSize&, float, float, const IntPoint&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&); @@ -72,15 +72,15 @@ public: bool preserveAlpha() const; void setPreserveAlpha(bool); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEConvolveMatrix(const IntSize&, float, float, + FEConvolveMatrix(Filter*, const IntSize&, float, float, const IntPoint&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&); struct PaintingData { diff --git a/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp b/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp index 98b5adf..14d57f4 100644 --- a/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp +++ b/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp @@ -28,17 +28,17 @@ namespace WebCore { -FEDiffuseLighting::FEDiffuseLighting(const Color& lightingColor, float surfaceScale, +FEDiffuseLighting::FEDiffuseLighting(Filter* filter, const Color& lightingColor, float surfaceScale, float diffuseConstant, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) - : FELighting(DiffuseLighting, lightingColor, surfaceScale, diffuseConstant, 0, 0, kernelUnitLengthX, kernelUnitLengthY, lightSource) + : FELighting(filter, DiffuseLighting, lightingColor, surfaceScale, diffuseConstant, 0, 0, kernelUnitLengthX, kernelUnitLengthY, lightSource) { } -PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(const Color& lightingColor, +PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(Filter* filter, const Color& lightingColor, float surfaceScale, float diffuseConstant, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) { - return adoptRef(new FEDiffuseLighting(lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource)); + return adoptRef(new FEDiffuseLighting(filter, lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource)); } FEDiffuseLighting::~FEDiffuseLighting() diff --git a/WebCore/platform/graphics/filters/FEDiffuseLighting.h b/WebCore/platform/graphics/filters/FEDiffuseLighting.h index 5273144..b58b47a 100644 --- a/WebCore/platform/graphics/filters/FEDiffuseLighting.h +++ b/WebCore/platform/graphics/filters/FEDiffuseLighting.h @@ -31,7 +31,7 @@ class LightSource; class FEDiffuseLighting : public FELighting { public: - static PassRefPtr<FEDiffuseLighting> create(const Color&, float, float, + static PassRefPtr<FEDiffuseLighting> create(Filter*, const Color&, float, float, float, float, PassRefPtr<LightSource>); virtual ~FEDiffuseLighting(); @@ -58,7 +58,7 @@ public: virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEDiffuseLighting(const Color&, float, float, float, float, PassRefPtr<LightSource>); + FEDiffuseLighting(Filter*, const Color&, float, float, float, float, PassRefPtr<LightSource>); }; } // namespace WebCore diff --git a/WebCore/platform/graphics/filters/FEDisplacementMap.cpp b/WebCore/platform/graphics/filters/FEDisplacementMap.cpp index 4c62ca7..55321e6 100644 --- a/WebCore/platform/graphics/filters/FEDisplacementMap.cpp +++ b/WebCore/platform/graphics/filters/FEDisplacementMap.cpp @@ -32,18 +32,18 @@ namespace WebCore { -FEDisplacementMap::FEDisplacementMap(ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float scale) - : FilterEffect() +FEDisplacementMap::FEDisplacementMap(Filter* filter, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float scale) + : FilterEffect(filter) , m_xChannelSelector(xChannelSelector) , m_yChannelSelector(yChannelSelector) , m_scale(scale) { } -PassRefPtr<FEDisplacementMap> FEDisplacementMap::create(ChannelSelectorType xChannelSelector, +PassRefPtr<FEDisplacementMap> FEDisplacementMap::create(Filter* filter, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float scale) { - return adoptRef(new FEDisplacementMap(xChannelSelector, yChannelSelector, scale)); + return adoptRef(new FEDisplacementMap(filter, xChannelSelector, yChannelSelector, scale)); } ChannelSelectorType FEDisplacementMap::xChannelSelector() const @@ -76,19 +76,19 @@ void FEDisplacementMap::setScale(float scale) m_scale = scale; } -void FEDisplacementMap::apply(Filter* filter) +void FEDisplacementMap::apply() { FilterEffect* in = inputEffect(0); FilterEffect* in2 = inputEffect(1); - in->apply(filter); - in2->apply(filter); + in->apply(); + in2->apply(); if (!in->resultImage() || !in2->resultImage()) return; if (m_xChannelSelector == CHANNEL_UNKNOWN || m_yChannelSelector == CHANNEL_UNKNOWN) return; - if (!effectContext(filter)) + if (!effectContext()) return; IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); @@ -105,6 +105,7 @@ void FEDisplacementMap::apply(Filter* filter) ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length()); + Filter* filter = this->filter(); float scaleX = filter->applyHorizontalScale(m_scale / 255); float scaleY = filter->applyVerticalScale(m_scale / 255); float scaleAdjustmentX = filter->applyHorizontalScale(0.5f - 0.5f * m_scale); diff --git a/WebCore/platform/graphics/filters/FEDisplacementMap.h b/WebCore/platform/graphics/filters/FEDisplacementMap.h index c5b97a7..ffb8f0e 100644 --- a/WebCore/platform/graphics/filters/FEDisplacementMap.h +++ b/WebCore/platform/graphics/filters/FEDisplacementMap.h @@ -39,7 +39,7 @@ enum ChannelSelectorType { class FEDisplacementMap : public FilterEffect { public: - static PassRefPtr<FEDisplacementMap> create(ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float); + static PassRefPtr<FEDisplacementMap> create(Filter*, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float); ChannelSelectorType xChannelSelector() const; void setXChannelSelector(const ChannelSelectorType); @@ -50,15 +50,15 @@ public: float scale() const; void setScale(float scale); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEDisplacementMap(ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float); + FEDisplacementMap(Filter*, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float); ChannelSelectorType m_xChannelSelector; ChannelSelectorType m_yChannelSelector; diff --git a/WebCore/platform/graphics/filters/FEFlood.cpp b/WebCore/platform/graphics/filters/FEFlood.cpp index b51a422..bc6721b 100644 --- a/WebCore/platform/graphics/filters/FEFlood.cpp +++ b/WebCore/platform/graphics/filters/FEFlood.cpp @@ -30,16 +30,16 @@ namespace WebCore { -FEFlood::FEFlood(const Color& floodColor, float floodOpacity) - : FilterEffect() +FEFlood::FEFlood(Filter* filter, const Color& floodColor, float floodOpacity) + : FilterEffect(filter) , m_floodColor(floodColor) , m_floodOpacity(floodOpacity) { } -PassRefPtr<FEFlood> FEFlood::create(const Color& floodColor, float floodOpacity) +PassRefPtr<FEFlood> FEFlood::create(Filter* filter, const Color& floodColor, float floodOpacity) { - return adoptRef(new FEFlood(floodColor, floodOpacity)); + return adoptRef(new FEFlood(filter, floodColor, floodOpacity)); } Color FEFlood::floodColor() const @@ -62,9 +62,9 @@ void FEFlood::setFloodOpacity(float floodOpacity) m_floodOpacity = floodOpacity; } -void FEFlood::apply(Filter* filter) +void FEFlood::apply() { - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/platform/graphics/filters/FEFlood.h b/WebCore/platform/graphics/filters/FEFlood.h index e6a9574..2e8824f 100644 --- a/WebCore/platform/graphics/filters/FEFlood.h +++ b/WebCore/platform/graphics/filters/FEFlood.h @@ -31,7 +31,7 @@ namespace WebCore { class FEFlood : public FilterEffect { public: - static PassRefPtr<FEFlood> create(const Color&, float); + static PassRefPtr<FEFlood> create(Filter* filter, const Color&, float); Color floodColor() const; void setFloodColor(const Color &); @@ -39,15 +39,15 @@ public: float floodOpacity() const; void setFloodOpacity(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEFlood(const Color&, float); + FEFlood(Filter*, const Color&, float); Color m_floodColor; float m_floodOpacity; diff --git a/WebCore/platform/graphics/filters/FEGaussianBlur.cpp b/WebCore/platform/graphics/filters/FEGaussianBlur.cpp index bb70537..876e4b3 100644 --- a/WebCore/platform/graphics/filters/FEGaussianBlur.cpp +++ b/WebCore/platform/graphics/filters/FEGaussianBlur.cpp @@ -40,16 +40,16 @@ static const unsigned gMaxKernelSize = 1000; namespace WebCore { -FEGaussianBlur::FEGaussianBlur(float x, float y) - : FilterEffect() +FEGaussianBlur::FEGaussianBlur(Filter* filter, float x, float y) + : FilterEffect(filter) , m_stdX(x) , m_stdY(y) { } -PassRefPtr<FEGaussianBlur> FEGaussianBlur::create(float x, float y) +PassRefPtr<FEGaussianBlur> FEGaussianBlur::create(Filter* filter, float x, float y) { - return adoptRef(new FEGaussianBlur(x, y)); + return adoptRef(new FEGaussianBlur(filter, x, y)); } float FEGaussianBlur::stdDeviationX() const @@ -147,14 +147,14 @@ inline void calculateKernelSize(Filter* filter, unsigned& kernelSizeX, unsigned& kernelSizeY = gMaxKernelSize; } -void FEGaussianBlur::determineAbsolutePaintRect(Filter* filter) +void FEGaussianBlur::determineAbsolutePaintRect() { FloatRect absolutePaintRect = inputEffect(0)->absolutePaintRect(); absolutePaintRect.intersect(maxEffectRect()); unsigned kernelSizeX = 0; unsigned kernelSizeY = 0; - calculateKernelSize(filter, kernelSizeX, kernelSizeY, m_stdX, m_stdY); + calculateKernelSize(filter(), kernelSizeX, kernelSizeY, m_stdX, m_stdY); // We take the half kernel size and multiply it with three, because we run box blur three times. absolutePaintRect.inflateX(3 * kernelSizeX * 0.5f); @@ -162,14 +162,14 @@ void FEGaussianBlur::determineAbsolutePaintRect(Filter* filter) setAbsolutePaintRect(enclosingIntRect(absolutePaintRect)); } -void FEGaussianBlur::apply(Filter* filter) +void FEGaussianBlur::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; setIsAlphaImage(in->isAlphaImage()); @@ -185,7 +185,7 @@ void FEGaussianBlur::apply(Filter* filter) unsigned kernelSizeX = 0; unsigned kernelSizeY = 0; - calculateKernelSize(filter, kernelSizeX, kernelSizeY, m_stdX, m_stdY); + calculateKernelSize(filter(), kernelSizeX, kernelSizeY, m_stdX, m_stdY); ByteArray* srcPixelArray = srcImageData->data()->data(); RefPtr<ImageData> tmpImageData = ImageData::create(imageRect.width(), imageRect.height()); diff --git a/WebCore/platform/graphics/filters/FEGaussianBlur.h b/WebCore/platform/graphics/filters/FEGaussianBlur.h index 50fc610..79f9a45 100644 --- a/WebCore/platform/graphics/filters/FEGaussianBlur.h +++ b/WebCore/platform/graphics/filters/FEGaussianBlur.h @@ -30,7 +30,7 @@ namespace WebCore { class FEGaussianBlur : public FilterEffect { public: - static PassRefPtr<FEGaussianBlur> create(float, float); + static PassRefPtr<FEGaussianBlur> create(Filter*, float, float); float stdDeviationX() const; void setStdDeviationX(float); @@ -40,15 +40,15 @@ public: static float calculateStdDeviation(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEGaussianBlur(float, float); + FEGaussianBlur(Filter*, float, float); float m_stdX; float m_stdY; diff --git a/WebCore/platform/graphics/filters/FELighting.cpp b/WebCore/platform/graphics/filters/FELighting.cpp index 803b9c1..812920c 100644 --- a/WebCore/platform/graphics/filters/FELighting.cpp +++ b/WebCore/platform/graphics/filters/FELighting.cpp @@ -35,10 +35,10 @@ namespace WebCore { -FELighting::FELighting(LightingType lightingType, const Color& lightingColor, float surfaceScale, +FELighting::FELighting(Filter* filter, LightingType lightingType, const Color& lightingColor, float surfaceScale, float diffuseConstant, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) - : FilterEffect() + : FilterEffect(filter) , m_lightingType(lightingType) , m_lightSource(lightSource) , m_lightingColor(lightingColor) @@ -329,14 +329,14 @@ bool FELighting::drawLighting(ByteArray* pixels, int width, int height) return true; } -void FELighting::apply(Filter* filter) +void FELighting::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; setIsAlphaImage(false); diff --git a/WebCore/platform/graphics/filters/FELighting.h b/WebCore/platform/graphics/filters/FELighting.h index c0f62ab..fa1c0aa 100644 --- a/WebCore/platform/graphics/filters/FELighting.h +++ b/WebCore/platform/graphics/filters/FELighting.h @@ -40,9 +40,9 @@ namespace WebCore { class FELighting : public FilterEffect { public: - virtual void apply(Filter*); + virtual void apply(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } protected: enum LightingType { @@ -69,7 +69,7 @@ protected: inline void bottomRight(int offset, IntPoint& normalVector); }; - FELighting(LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>); + FELighting(Filter*, LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>); bool drawLighting(ByteArray*, int, int); inline void inlineSetPixel(int offset, LightingData&, LightSource::PaintingData&, diff --git a/WebCore/platform/graphics/filters/FEMerge.cpp b/WebCore/platform/graphics/filters/FEMerge.cpp index b136af3..ca53a86 100644 --- a/WebCore/platform/graphics/filters/FEMerge.cpp +++ b/WebCore/platform/graphics/filters/FEMerge.cpp @@ -29,28 +29,28 @@ namespace WebCore { -FEMerge::FEMerge() - : FilterEffect() +FEMerge::FEMerge(Filter* filter) + : FilterEffect(filter) { } -PassRefPtr<FEMerge> FEMerge::create() +PassRefPtr<FEMerge> FEMerge::create(Filter* filter) { - return adoptRef(new FEMerge); + return adoptRef(new FEMerge(filter)); } -void FEMerge::apply(Filter* filter) +void FEMerge::apply() { unsigned size = numberOfEffectInputs(); ASSERT(size > 0); for (unsigned i = 0; i < size; ++i) { FilterEffect* in = inputEffect(i); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; } - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/platform/graphics/filters/FEMerge.h b/WebCore/platform/graphics/filters/FEMerge.h index 46b882f..24d071e 100644 --- a/WebCore/platform/graphics/filters/FEMerge.h +++ b/WebCore/platform/graphics/filters/FEMerge.h @@ -31,15 +31,15 @@ namespace WebCore { class FEMerge : public FilterEffect { public: - static PassRefPtr<FEMerge> create(); + static PassRefPtr<FEMerge> create(Filter*); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEMerge(); + FEMerge(Filter*); }; } // namespace WebCore diff --git a/WebCore/platform/graphics/filters/FEMorphology.cpp b/WebCore/platform/graphics/filters/FEMorphology.cpp index 0b67f9a..dd7659a 100644 --- a/WebCore/platform/graphics/filters/FEMorphology.cpp +++ b/WebCore/platform/graphics/filters/FEMorphology.cpp @@ -36,17 +36,17 @@ using std::max; namespace WebCore { -FEMorphology::FEMorphology(MorphologyOperatorType type, float radiusX, float radiusY) - : FilterEffect() +FEMorphology::FEMorphology(Filter* filter, MorphologyOperatorType type, float radiusX, float radiusY) + : FilterEffect(filter) , m_type(type) , m_radiusX(radiusX) , m_radiusY(radiusY) { } -PassRefPtr<FEMorphology> FEMorphology::create(MorphologyOperatorType type, float radiusX, float radiusY) +PassRefPtr<FEMorphology> FEMorphology::create(Filter* filter, MorphologyOperatorType type, float radiusX, float radiusY) { - return adoptRef(new FEMorphology(type, radiusX, radiusY)); + return adoptRef(new FEMorphology(filter, type, radiusX, radiusY)); } MorphologyOperatorType FEMorphology::morphologyOperator() const @@ -74,9 +74,10 @@ float FEMorphology::radiusY() const return m_radiusY; } -void FEMorphology::determineAbsolutePaintRect(Filter* filter) +void FEMorphology::determineAbsolutePaintRect() { FloatRect paintRect = inputEffect(0)->absolutePaintRect(); + Filter* filter = this->filter(); paintRect.inflateX(filter->applyHorizontalScale(m_radiusX)); paintRect.inflateY(filter->applyVerticalScale(m_radiusY)); paintRect.intersect(maxEffectRect()); @@ -88,20 +89,21 @@ void FEMorphology::setRadiusY(float radiusY) m_radiusY = radiusY; } -void FEMorphology::apply(Filter* filter) +void FEMorphology::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; setIsAlphaImage(in->isAlphaImage()); if (m_radiusX <= 0 || m_radiusY <= 0) return; + Filter* filter = this->filter(); int radiusX = static_cast<int>(floorf(filter->applyHorizontalScale(m_radiusX))); int radiusY = static_cast<int>(floorf(filter->applyVerticalScale(m_radiusY))); diff --git a/WebCore/platform/graphics/filters/FEMorphology.h b/WebCore/platform/graphics/filters/FEMorphology.h index 913671d..683e7d0 100644 --- a/WebCore/platform/graphics/filters/FEMorphology.h +++ b/WebCore/platform/graphics/filters/FEMorphology.h @@ -36,7 +36,7 @@ enum MorphologyOperatorType { class FEMorphology : public FilterEffect { public: - static PassRefPtr<FEMorphology> create(MorphologyOperatorType, float radiusX, float radiusY); + static PassRefPtr<FEMorphology> create(Filter*, MorphologyOperatorType, float radiusX, float radiusY); MorphologyOperatorType morphologyOperator() const; void setMorphologyOperator(MorphologyOperatorType); @@ -46,15 +46,15 @@ public: float radiusY() const; void setRadiusY(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEMorphology(MorphologyOperatorType, float radiusX, float radiusY); + FEMorphology(Filter*, MorphologyOperatorType, float radiusX, float radiusY); MorphologyOperatorType m_type; float m_radiusX; diff --git a/WebCore/platform/graphics/filters/FEOffset.cpp b/WebCore/platform/graphics/filters/FEOffset.cpp index 6ca56aa..b640054 100644 --- a/WebCore/platform/graphics/filters/FEOffset.cpp +++ b/WebCore/platform/graphics/filters/FEOffset.cpp @@ -31,16 +31,16 @@ namespace WebCore { -FEOffset::FEOffset(float dx, float dy) - : FilterEffect() +FEOffset::FEOffset(Filter* filter, float dx, float dy) + : FilterEffect(filter) , m_dx(dx) , m_dy(dy) { } -PassRefPtr<FEOffset> FEOffset::create(float dx, float dy) +PassRefPtr<FEOffset> FEOffset::create(Filter* filter, float dx, float dy) { - return adoptRef(new FEOffset(dx, dy)); + return adoptRef(new FEOffset(filter, dx, dy)); } float FEOffset::dx() const @@ -63,28 +63,30 @@ void FEOffset::setDy(float dy) m_dy = dy; } -void FEOffset::determineAbsolutePaintRect(Filter* filter) +void FEOffset::determineAbsolutePaintRect() { FloatRect paintRect = inputEffect(0)->absolutePaintRect(); + Filter* filter = this->filter(); paintRect.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy)); paintRect.intersect(maxEffectRect()); setAbsolutePaintRect(enclosingIntRect(paintRect)); } -void FEOffset::apply(Filter* filter) +void FEOffset::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; setIsAlphaImage(in->isAlphaImage()); FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect()); + Filter* filter = this->filter(); drawingRegion.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy)); filterContext->drawImageBuffer(in->resultImage(), ColorSpaceDeviceRGB, drawingRegion); } diff --git a/WebCore/platform/graphics/filters/FEOffset.h b/WebCore/platform/graphics/filters/FEOffset.h index 36575c5..5aa5c38 100644 --- a/WebCore/platform/graphics/filters/FEOffset.h +++ b/WebCore/platform/graphics/filters/FEOffset.h @@ -30,7 +30,7 @@ namespace WebCore { class FEOffset : public FilterEffect { public: - static PassRefPtr<FEOffset> create(float dx, float dy); + static PassRefPtr<FEOffset> create(Filter*, float dx, float dy); float dx() const; void setDx(float); @@ -38,15 +38,15 @@ public: float dy() const; void setDy(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEOffset(float dx, float dy); + FEOffset(Filter*, float dx, float dy); float m_dx; float m_dy; diff --git a/WebCore/platform/graphics/filters/FESpecularLighting.cpp b/WebCore/platform/graphics/filters/FESpecularLighting.cpp index 2606600..d21dafd 100644 --- a/WebCore/platform/graphics/filters/FESpecularLighting.cpp +++ b/WebCore/platform/graphics/filters/FESpecularLighting.cpp @@ -28,18 +28,18 @@ namespace WebCore { -FESpecularLighting::FESpecularLighting(const Color& lightingColor, float surfaceScale, +FESpecularLighting::FESpecularLighting(Filter* filter, const Color& lightingColor, float surfaceScale, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) - : FELighting(SpecularLighting, lightingColor, surfaceScale, 0, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, lightSource) + : FELighting(filter, SpecularLighting, lightingColor, surfaceScale, 0, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, lightSource) { } -PassRefPtr<FESpecularLighting> FESpecularLighting::create(const Color& lightingColor, +PassRefPtr<FESpecularLighting> FESpecularLighting::create(Filter* filter, const Color& lightingColor, float surfaceScale, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) { - return adoptRef(new FESpecularLighting(lightingColor, surfaceScale, specularConstant, specularExponent, + return adoptRef(new FESpecularLighting(filter, lightingColor, surfaceScale, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, lightSource)); } diff --git a/WebCore/platform/graphics/filters/FESpecularLighting.h b/WebCore/platform/graphics/filters/FESpecularLighting.h index f6e7b66..b3ccfbc 100644 --- a/WebCore/platform/graphics/filters/FESpecularLighting.h +++ b/WebCore/platform/graphics/filters/FESpecularLighting.h @@ -29,7 +29,7 @@ namespace WebCore { class FESpecularLighting : public FELighting { public: - static PassRefPtr<FESpecularLighting> create(const Color&, float, float, + static PassRefPtr<FESpecularLighting> create(Filter*, const Color&, float, float, float, float, float, PassRefPtr<LightSource>); virtual ~FESpecularLighting(); @@ -59,7 +59,7 @@ public: virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FESpecularLighting(const Color&, float, float, float, float, float, PassRefPtr<LightSource>); + FESpecularLighting(Filter*, const Color&, float, float, float, float, float, PassRefPtr<LightSource>); }; } // namespace WebCore diff --git a/WebCore/platform/graphics/filters/FETile.cpp b/WebCore/platform/graphics/filters/FETile.cpp index 57160ed..6b11401 100644 --- a/WebCore/platform/graphics/filters/FETile.cpp +++ b/WebCore/platform/graphics/filters/FETile.cpp @@ -31,26 +31,26 @@ namespace WebCore { -FETile::FETile() - : FilterEffect() +FETile::FETile(Filter* filter) + : FilterEffect(filter) { } -PassRefPtr<FETile> FETile::create() +PassRefPtr<FETile> FETile::create(Filter* filter) { - return adoptRef(new FETile); + return adoptRef(new FETile(filter)); } -void FETile::apply(Filter* filter) +void FETile::apply() { // FIXME: See bug 47315. This is a hack to work around a compile failure, but is incorrect behavior otherwise. #if ENABLE(SVG) FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; @@ -62,6 +62,7 @@ void FETile::apply(Filter* filter) FloatPoint inMaxEffectLocation = tileRect.location(); FloatPoint maxEffectLocation = maxEffectRect().location(); if (in->filterEffectType() == FilterEffectTypeSourceInput) { + Filter* filter = this->filter(); tileRect = filter->filterRegion(); tileRect.scale(filter->filterResolution().width(), filter->filterResolution().height()); } diff --git a/WebCore/platform/graphics/filters/FETile.h b/WebCore/platform/graphics/filters/FETile.h index 5f21433..9b02b4c 100644 --- a/WebCore/platform/graphics/filters/FETile.h +++ b/WebCore/platform/graphics/filters/FETile.h @@ -30,19 +30,19 @@ namespace WebCore { class FETile : public FilterEffect { public: - static PassRefPtr<FETile> create(); + static PassRefPtr<FETile> create(Filter* filter); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual FilterEffectType filterEffectType() const { return FilterEffectTypeTile; } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FETile(); + FETile(Filter*); }; } // namespace WebCore diff --git a/WebCore/platform/graphics/filters/FETurbulence.cpp b/WebCore/platform/graphics/filters/FETurbulence.cpp index 9ad27cf..8914db7 100644 --- a/WebCore/platform/graphics/filters/FETurbulence.cpp +++ b/WebCore/platform/graphics/filters/FETurbulence.cpp @@ -47,8 +47,8 @@ static const int s_randAmplitude = 16807; // 7**5; primitive root of m static const int s_randQ = 127773; // m / a static const int s_randR = 2836; // m % a -FETurbulence::FETurbulence(TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) - : FilterEffect() +FETurbulence::FETurbulence(Filter* filter, TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) + : FilterEffect(filter) , m_type(type) , m_baseFrequencyX(baseFrequencyX) , m_baseFrequencyY(baseFrequencyY) @@ -58,9 +58,9 @@ FETurbulence::FETurbulence(TurbulanceType type, float baseFrequencyX, float base { } -PassRefPtr<FETurbulence> FETurbulence::create(TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) +PassRefPtr<FETurbulence> FETurbulence::create(Filter* filter, TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) { - return adoptRef(new FETurbulence(type, baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles)); + return adoptRef(new FETurbulence(filter, type, baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles)); } TurbulanceType FETurbulence::type() const @@ -318,9 +318,9 @@ unsigned char FETurbulence::calculateTurbulenceValueForPoint(PaintingData& paint return static_cast<unsigned char>(turbulenceFunctionResult * 255); } -void FETurbulence::apply(Filter* filter) +void FETurbulence::apply() { - if (!effectContext(filter)) + if (!effectContext()) return; IntRect imageRect(IntPoint(), resultImage()->size()); @@ -342,7 +342,7 @@ void FETurbulence::apply(Filter* filter) for (int x = 0; x < imageRect.width(); ++x) { point.setX(point.x() + 1); for (paintingData.channel = 0; paintingData.channel < 4; ++paintingData.channel, ++indexOfPixelChannel) - pixelArray->set(indexOfPixelChannel, calculateTurbulenceValueForPoint(paintingData, filter->mapAbsolutePointToLocalPoint(point))); + pixelArray->set(indexOfPixelChannel, calculateTurbulenceValueForPoint(paintingData, filter()->mapAbsolutePointToLocalPoint(point))); } } resultImage()->putUnmultipliedImageData(imageData.get(), imageRect, IntPoint()); diff --git a/WebCore/platform/graphics/filters/FETurbulence.h b/WebCore/platform/graphics/filters/FETurbulence.h index c15d7d1..1bad123 100644 --- a/WebCore/platform/graphics/filters/FETurbulence.h +++ b/WebCore/platform/graphics/filters/FETurbulence.h @@ -38,7 +38,7 @@ enum TurbulanceType { class FETurbulence : public FilterEffect { public: - static PassRefPtr<FETurbulence> create(TurbulanceType, float, float, int, float, bool); + static PassRefPtr<FETurbulence> create(Filter*, TurbulanceType, float, float, int, float, bool); TurbulanceType type() const; void setType(TurbulanceType); @@ -58,10 +58,10 @@ public: bool stitchTiles() const; void setStitchTiles(bool); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual TextStream& externalRepresentation(TextStream&, int indention) const; @@ -84,7 +84,7 @@ private: inline long random(); }; - FETurbulence(TurbulanceType, float, float, int, float, bool); + FETurbulence(Filter*, TurbulanceType, float, float, int, float, bool); inline void initPaint(PaintingData&); float noise2D(PaintingData&, const FloatPoint&); diff --git a/WebCore/platform/graphics/filters/FilterEffect.cpp b/WebCore/platform/graphics/filters/FilterEffect.cpp index ad351a5..c228731 100644 --- a/WebCore/platform/graphics/filters/FilterEffect.cpp +++ b/WebCore/platform/graphics/filters/FilterEffect.cpp @@ -26,20 +26,22 @@ namespace WebCore { -FilterEffect::FilterEffect() +FilterEffect::FilterEffect(Filter* filter) : m_alphaImage(false) + , m_filter(filter) , m_hasX(false) , m_hasY(false) , m_hasWidth(false) , m_hasHeight(false) { + ASSERT(m_filter); } FilterEffect::~FilterEffect() { } -void FilterEffect::determineAbsolutePaintRect(Filter*) +void FilterEffect::determineAbsolutePaintRect() { m_absolutePaintRect = IntRect(); unsigned size = m_inputEffects.size(); @@ -70,9 +72,9 @@ FilterEffect* FilterEffect::inputEffect(unsigned number) const return m_inputEffects.at(number).get(); } -GraphicsContext* FilterEffect::effectContext(Filter* filter) +GraphicsContext* FilterEffect::effectContext() { - determineAbsolutePaintRect(filter); + determineAbsolutePaintRect(); if (m_absolutePaintRect.isEmpty()) return 0; m_effectBuffer = ImageBuffer::create(m_absolutePaintRect.size(), ColorSpaceLinearRGB); diff --git a/WebCore/platform/graphics/filters/FilterEffect.h b/WebCore/platform/graphics/filters/FilterEffect.h index 25db57b..f9674e2 100644 --- a/WebCore/platform/graphics/filters/FilterEffect.h +++ b/WebCore/platform/graphics/filters/FilterEffect.h @@ -56,7 +56,7 @@ public: // Creates the ImageBuffer for the current filter primitive result in the size of the // repaintRect. Gives back the GraphicsContext of the own ImageBuffer. - GraphicsContext* effectContext(Filter*); + GraphicsContext* effectContext(); FilterEffectVector& inputEffects() { return m_inputEffects; } FilterEffect* inputEffect(unsigned) const; @@ -75,10 +75,10 @@ public: IntRect maxEffectRect() const { return m_maxEffectRect; } void setMaxEffectRect(const IntRect& maxEffectRect) { m_maxEffectRect = maxEffectRect; } - virtual void apply(Filter*) = 0; + virtual void apply() = 0; virtual void dump() = 0; - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual FilterEffectType filterEffectType() const { return FilterEffectTypeUnknown; } @@ -105,8 +105,10 @@ public: FloatRect effectBoundaries() const { return m_effectBoundaries; } void setEffectBoundaries(const FloatRect& effectBoundaries) { m_effectBoundaries = effectBoundaries; } + Filter* filter() { return m_filter; } + protected: - FilterEffect(); + FilterEffect(Filter*); private: OwnPtr<ImageBuffer> m_effectBuffer; @@ -119,6 +121,7 @@ private: // The maximum size of a filter primitive. In SVG this is the primitive subregion in absolute coordinate space. // The absolute paint rect should never be bigger than m_maxEffectRect. IntRect m_maxEffectRect; + Filter* m_filter; private: // The following member variables are SVG specific and will move to RenderSVGResourceFilterPrimitive. diff --git a/WebCore/platform/graphics/filters/SourceAlpha.cpp b/WebCore/platform/graphics/filters/SourceAlpha.cpp index 7dc56d9..a505b4b 100644 --- a/WebCore/platform/graphics/filters/SourceAlpha.cpp +++ b/WebCore/platform/graphics/filters/SourceAlpha.cpp @@ -31,9 +31,9 @@ namespace WebCore { -PassRefPtr<SourceAlpha> SourceAlpha::create() +PassRefPtr<SourceAlpha> SourceAlpha::create(Filter* filter) { - return adoptRef(new SourceAlpha); + return adoptRef(new SourceAlpha(filter)); } const AtomicString& SourceAlpha::effectName() @@ -42,16 +42,18 @@ const AtomicString& SourceAlpha::effectName() return s_effectName; } -void SourceAlpha::determineAbsolutePaintRect(Filter* filter) +void SourceAlpha::determineAbsolutePaintRect() { + Filter* filter = this->filter(); FloatRect paintRect = filter->sourceImageRect(); paintRect.scale(filter->filterResolution().width(), filter->filterResolution().height()); setAbsolutePaintRect(enclosingIntRect(paintRect)); } -void SourceAlpha::apply(Filter* filter) +void SourceAlpha::apply() { - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); + Filter* filter = this->filter(); if (!filterContext || !filter->sourceImage()) return; diff --git a/WebCore/platform/graphics/filters/SourceAlpha.h b/WebCore/platform/graphics/filters/SourceAlpha.h index 83704e5..c6f95d3 100644 --- a/WebCore/platform/graphics/filters/SourceAlpha.h +++ b/WebCore/platform/graphics/filters/SourceAlpha.h @@ -30,21 +30,24 @@ namespace WebCore { class SourceAlpha : public FilterEffect { public: - static PassRefPtr<SourceAlpha> create(); + static PassRefPtr<SourceAlpha> create(Filter*); static const AtomicString& effectName(); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual FilterEffectType filterEffectType() const { return FilterEffectTypeSourceInput; } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - SourceAlpha() { } + SourceAlpha(Filter* filter) + : FilterEffect(filter) + { + } }; } //namespace WebCore diff --git a/WebCore/platform/graphics/filters/SourceGraphic.cpp b/WebCore/platform/graphics/filters/SourceGraphic.cpp index fbb711a..6aac367 100644 --- a/WebCore/platform/graphics/filters/SourceGraphic.cpp +++ b/WebCore/platform/graphics/filters/SourceGraphic.cpp @@ -30,9 +30,9 @@ namespace WebCore { -PassRefPtr<SourceGraphic> SourceGraphic::create() +PassRefPtr<SourceGraphic> SourceGraphic::create(Filter* filter) { - return adoptRef(new SourceGraphic); + return adoptRef(new SourceGraphic(filter)); } const AtomicString& SourceGraphic::effectName() @@ -41,16 +41,18 @@ const AtomicString& SourceGraphic::effectName() return s_effectName; } -void SourceGraphic::determineAbsolutePaintRect(Filter* filter) +void SourceGraphic::determineAbsolutePaintRect() { + Filter* filter = this->filter(); FloatRect paintRect = filter->sourceImageRect(); paintRect.scale(filter->filterResolution().width(), filter->filterResolution().height()); setAbsolutePaintRect(enclosingIntRect(paintRect)); } -void SourceGraphic::apply(Filter* filter) +void SourceGraphic::apply() { - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); + Filter* filter = this->filter(); if (!filterContext || !filter->sourceImage()) return; diff --git a/WebCore/platform/graphics/filters/SourceGraphic.h b/WebCore/platform/graphics/filters/SourceGraphic.h index a13337d..fa47f12 100644 --- a/WebCore/platform/graphics/filters/SourceGraphic.h +++ b/WebCore/platform/graphics/filters/SourceGraphic.h @@ -31,21 +31,24 @@ namespace WebCore { class SourceGraphic : public FilterEffect { public: - static PassRefPtr<SourceGraphic> create(); + static PassRefPtr<SourceGraphic> create(Filter*); static const AtomicString& effectName(); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual FilterEffectType filterEffectType() const { return FilterEffectTypeSourceInput; } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - SourceGraphic() { } + SourceGraphic(Filter* filter) + : FilterEffect(filter) + { + } }; } //namespace WebCore diff --git a/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp b/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp index 394082d..c0756ee 100644 --- a/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp +++ b/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp @@ -228,7 +228,9 @@ bool FontPlatformData::operator==(const FontPlatformData& other) const return true; if (!m_pattern || !other.m_pattern) return false; - return FcPatternEqual(m_pattern.get(), other.m_pattern.get()); + return FcPatternEqual(m_pattern.get(), other.m_pattern.get()) + && m_scaledFont == other.m_scaledFont && m_size == other.m_size + && m_syntheticOblique == other.m_syntheticOblique && m_syntheticBold == other.m_syntheticBold; } #ifndef NDEBUG diff --git a/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/WebCore/platform/graphics/gpu/DrawingBuffer.cpp index d812e28..8cb6d0c 100644 --- a/WebCore/platform/graphics/gpu/DrawingBuffer.cpp +++ b/WebCore/platform/graphics/gpu/DrawingBuffer.cpp @@ -167,20 +167,29 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); // Initialize renderbuffers to 0. - unsigned char colorMask[] = {true, true, true, true}, depthMask = true, stencilMask = true; + float clearColor[] = {0, 0, 0, 0}, clearDepth = 0; + int clearStencil = 0; + unsigned char colorMask[] = {true, true, true, true}, depthMask = true; + unsigned int stencilMask = 0xffffffff; unsigned char isScissorEnabled = false; unsigned char isDitherEnabled = false; unsigned long clearMask = GraphicsContext3D::COLOR_BUFFER_BIT; + m_context->getFloatv(GraphicsContext3D::COLOR_CLEAR_VALUE, clearColor); + m_context->clearColor(0, 0, 0, 0); m_context->getBooleanv(GraphicsContext3D::COLOR_WRITEMASK, colorMask); m_context->colorMask(true, true, true, true); if (attributes.depth) { + m_context->getFloatv(GraphicsContext3D::DEPTH_CLEAR_VALUE, &clearDepth); + m_context->clearDepth(1); m_context->getBooleanv(GraphicsContext3D::DEPTH_WRITEMASK, &depthMask); m_context->depthMask(true); clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; } if (attributes.stencil) { - m_context->getBooleanv(GraphicsContext3D::STENCIL_WRITEMASK, &stencilMask); - m_context->stencilMask(true); + m_context->getIntegerv(GraphicsContext3D::STENCIL_CLEAR_VALUE, &clearStencil); + m_context->clearStencil(0); + m_context->getIntegerv(GraphicsContext3D::STENCIL_WRITEMASK, reinterpret_cast<int*>(&stencilMask)); + m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xffffffff); clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; } isScissorEnabled = m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST); @@ -190,11 +199,16 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->clear(clearMask); + m_context->clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); m_context->colorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]); - if (attributes.depth) + if (attributes.depth) { + m_context->clearDepth(clearDepth); m_context->depthMask(depthMask); - if (attributes.stencil) - m_context->stencilMask(stencilMask); + } + if (attributes.stencil) { + m_context->clearStencil(clearStencil); + m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, stencilMask); + } if (isScissorEnabled) m_context->enable(GraphicsContext3D::SCISSOR_TEST); else diff --git a/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp b/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp index 1cb561e..b18bf84 100644 --- a/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp +++ b/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp @@ -87,6 +87,9 @@ bool GStreamerGWorld::enterFullscreen() GOwnPtr<GstElement> videoSink; g_object_get(m_pipeline, "video-sink", &videoSink.outPtr(), NULL); GstElement* tee = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee"); + GstElement* valve = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoValve"); + + g_object_set(valve, "drop-probability", 1.0, NULL); // Add and link a queue, ffmpegcolorspace and sink in the bin. gst_bin_add_many(GST_BIN(videoSink.get()), platformVideoSink, videoScale, colorspace, queue, NULL); @@ -158,6 +161,10 @@ void GStreamerGWorld::exitFullscreen() GstElement* colorspace = gst_bin_get_by_name(GST_BIN(videoSink.get()), "colorspace"); GstElement* videoScale = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoScale"); + GstElement* valve = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoValve"); + + g_object_set(valve, "drop-probability", 0.0, NULL); + // Get pads to unlink and remove. GstPad* srcPad = gst_element_get_static_pad(tee, m_dynamicPadName); GstPad* sinkPad = gst_element_get_static_pad(queue, "sink"); diff --git a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index 7012c9f..dbef4c9 100644 --- a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -177,6 +177,13 @@ 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. @@ -184,6 +191,13 @@ 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) { @@ -327,8 +341,18 @@ 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) @@ -584,8 +608,12 @@ void MediaPlayerPrivateGStreamer::setVolume(float volume) g_object_set(m_playBin, "volume", static_cast<double>(volume), NULL); } -void MediaPlayerPrivateGStreamer::volumeChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*) +void MediaPlayerPrivateGStreamer::notifyPlayerOfVolumeChange() { + 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)); @@ -593,8 +621,9 @@ void MediaPlayerPrivateGStreamer::volumeChangedTimerFired(Timer<MediaPlayerPriva void MediaPlayerPrivateGStreamer::volumeChanged() { - Timer<MediaPlayerPrivateGStreamer> volumeChangedTimer(this, &MediaPlayerPrivateGStreamer::volumeChangedTimerFired); - volumeChangedTimer.startOneShot(0); + if (m_volumeTimerHandler) + g_source_remove(m_volumeTimerHandler); + m_volumeTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateVolumeChangeTimeoutCallback), this); } void MediaPlayerPrivateGStreamer::setRate(float rate) @@ -1158,8 +1187,13 @@ void MediaPlayerPrivateGStreamer::setMuted(bool muted) g_object_set(m_playBin, "mute", muted, NULL); } -void MediaPlayerPrivateGStreamer::muteChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*) +void MediaPlayerPrivateGStreamer::notifyPlayerOfMute() { + 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)); @@ -1167,8 +1201,9 @@ void MediaPlayerPrivateGStreamer::muteChangedTimerFired(Timer<MediaPlayerPrivate void MediaPlayerPrivateGStreamer::muteChanged() { - Timer<MediaPlayerPrivateGStreamer> muteChangedTimer(this, &MediaPlayerPrivateGStreamer::muteChangedTimerFired); - muteChangedTimer.startOneShot(0); + if (m_muteTimerHandler) + g_source_remove(m_muteTimerHandler); + m_muteTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateMuteChangeTimeoutCallback), this); } void MediaPlayerPrivateGStreamer::loadingFailed(MediaPlayer::NetworkState error) @@ -1401,6 +1436,8 @@ 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); @@ -1412,16 +1449,17 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin() m_videoSinkBin = gst_bin_new("sink"); GstElement* videoTee = gst_element_factory_make("tee", "videoTee"); GstElement* queue = gst_element_factory_make("queue", 0); + GstElement* identity = gst_element_factory_make("identity", "videoValve"); // Take ownership. - g_object_ref_sink(m_videoSinkBin); + gst_object_ref_sink(m_videoSinkBin); // Build a new video sink consisting of a bin containing a tee // (meant to distribute data to multiple video sinks) and our // internal video sink. For fullscreen we create an autovideosink // and initially block the data flow towards it and configure it - gst_bin_add_many(GST_BIN(m_videoSinkBin), videoTee, queue, NULL); + gst_bin_add_many(GST_BIN(m_videoSinkBin), videoTee, queue, identity, NULL); // Link a new src pad from tee to queue1. GstPad* srcPad = gst_element_get_request_pad(videoTee, "src%d"); @@ -1445,7 +1483,7 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin() } } else { gst_bin_add(GST_BIN(m_videoSinkBin), m_webkitVideoSink); - gst_element_link(queue, m_webkitVideoSink); + gst_element_link_many(queue, identity, m_webkitVideoSink, NULL); } // Add a ghostpad to the bin so it can proxy to tee. diff --git a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h index 800ca6d..23095ec 100644 --- a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h +++ b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h @@ -43,11 +43,14 @@ 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); @@ -81,12 +84,12 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { void setVolume(float); void volumeChanged(); - void volumeChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*); + void notifyPlayerOfVolumeChange(); bool supportsMuting() const; void setMuted(bool); void muteChanged(); - void muteChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*); + void notifyPlayerOfMute(); void setPreload(MediaPlayer::Preload); void fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*); @@ -176,6 +179,8 @@ 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 6911b31..7dda245 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() +void GraphicsContext::strokePath(const Path&) { notImplemented(); } @@ -191,17 +191,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef // FillRect and FillArc calls are needed. } -void GraphicsContext::fillPath() -{ - notImplemented(); -} - -void GraphicsContext::beginPath() -{ - notImplemented(); -} - -void GraphicsContext::addPath(const Path& path) +void GraphicsContext::fillPath(const Path&) { notImplemented(); } @@ -215,7 +205,7 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->m_view->ConstrainClippingRegion(®ion); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } diff --git a/WebCore/platform/graphics/mac/ComplexTextController.cpp b/WebCore/platform/graphics/mac/ComplexTextController.cpp index e6a7bef..d353d55 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/mac/ComplexTextControllerATSUI.cpp b/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp index 7ff316c..c24a914 100644 --- a/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp @@ -280,7 +280,7 @@ static ATSUStyle initializeATSUStyle(const SimpleFontData* fontData, Typesetting if (!addResult.second) return atsuStyle; - ATSUFontID fontID = fontData->platformData().m_atsuFontID; + ATSUFontID fontID = fontData->platformData().ctFont() ? CTFontGetPlatformFont(fontData->platformData().ctFont(), 0) : 0; if (!fontID) { LOG_ERROR("unable to get ATSUFontID for %p", fontData->platformData().font()); fontData->m_ATSUStyleMap.remove(addResult.first); diff --git a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp index cbb7610..42e7897 100644 --- a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp @@ -138,8 +138,8 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC const short rtlForcedEmbeddingLevelValue = 1; static const void* ltrOptionValues[] = { CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, <rForcedEmbeddingLevelValue) }; static const void* rtlOptionValues[] = { CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &rtlForcedEmbeddingLevelValue) }; - static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, WTF_ARRAY_LENGTH(optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, WTF_ARRAY_LENGTH(optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) ProviderInfo info = { cp, length, fontData->getCFStringAttributes(m_font.typesettingFeatures()) }; diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp b/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp index cead71b..d04d0e4 100644 --- a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp +++ b/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp @@ -40,7 +40,7 @@ FontCustomPlatformData::~FontCustomPlatformData() FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontRenderingMode) { - return FontPlatformData(m_cgFont, (ATSUFontID)m_atsFont, size, bold, italic, orientation); + return FontPlatformData(m_cgFont, size, bold, italic, orientation); } FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) @@ -66,7 +66,6 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) #endif ATSFontContainerRef containerRef = 0; - ATSFontRef fontRef = 0; RetainPtr<CGFontRef> cgFontRef; @@ -93,6 +92,7 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) return 0; } + ATSFontRef fontRef = 0; ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 1, &fontRef, NULL); if (!fontRef) { ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault); @@ -111,7 +111,7 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) } #endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) - return new FontCustomPlatformData(containerRef, fontRef, cgFontRef.releaseRef()); + return new FontCustomPlatformData(containerRef, cgFontRef.releaseRef()); } bool FontCustomPlatformData::supportsFormat(const String& format) diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.h b/WebCore/platform/graphics/mac/FontCustomPlatformData.h index 7702457..c11858c 100644 --- a/WebCore/platform/graphics/mac/FontCustomPlatformData.h +++ b/WebCore/platform/graphics/mac/FontCustomPlatformData.h @@ -37,9 +37,12 @@ class FontPlatformData; class SharedBuffer; struct FontCustomPlatformData : Noncopyable { - FontCustomPlatformData(ATSFontContainerRef container, ATSFontRef atsFont, CGFontRef cgFont) - : m_atsContainer(container), m_atsFont(atsFont), m_cgFont(cgFont) - {} + FontCustomPlatformData(ATSFontContainerRef container, CGFontRef cgFont) + : m_atsContainer(container) + , m_cgFont(cgFont) + { + } + ~FontCustomPlatformData(); FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontRenderingMode = NormalRenderingMode); @@ -47,11 +50,10 @@ struct FontCustomPlatformData : Noncopyable { static bool supportsFormat(const String&); ATSFontContainerRef m_atsContainer; - ATSFontRef m_atsFont; CGFontRef m_cgFont; }; -FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer); +FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*); } diff --git a/WebCore/platform/graphics/mac/GraphicsContextMac.mm b/WebCore/platform/graphics/mac/GraphicsContextMac.mm index 15cae20..c149d70 100644 --- a/WebCore/platform/graphics/mac/GraphicsContextMac.mm +++ b/WebCore/platform/graphics/mac/GraphicsContextMac.mm @@ -57,23 +57,19 @@ static void drawFocusRingToContext(CGContextRef context, CGPathRef focusRingPath #endif } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int /*offset*/, const Color& color) { + // FIXME: Use 'offset' for something? http://webkit.org/b/49909 + if (paintingDisabled()) return; - + int radius = (width - 1) / 2; - offset += radius; CGColorRef colorRef = color.isValid() ? cachedCGColor(color, ColorSpaceDeviceRGB) : 0; - RetainPtr<CGMutablePathRef> focusRingPath(AdoptCF, CGPathCreateMutable()); - unsigned pathCount = paths.size(); - for (unsigned i = 0; i < pathCount; i++) - CGPathAddPath(focusRingPath.get(), 0, paths[i].platformPath()); - - drawFocusRingToContext(platformContext(), focusRingPath.get(), colorRef, radius); -} - + drawFocusRingToContext(platformContext(), path.platformPath(), colorRef, radius); +} + void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm index a2325da..1538e07 100644 --- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm +++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm @@ -316,7 +316,7 @@ static void disableComponentsOnce() {'imdc', 'pdf ', 'appl', 0, 0}, }; - for (size_t i = 0; i < sizeof(componentsToDisable)/sizeof(componentsToDisable[0]); ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(componentsToDisable); ++i) wkQTMovieDisableComponent(componentsToDisable[i]); } @@ -896,12 +896,12 @@ void MediaPlayerPrivateQTKit::setPreservesPitch(bool preservesPitch) if ([[m_qtMovie.get() attributeForKey:QTMovieRateChangesPreservePitchAttribute] boolValue] == preservesPitch) return; - NSDictionary *movieAttributes = [[m_qtMovie.get() movieAttributes] mutableCopy]; + RetainPtr<NSDictionary> movieAttributes(AdoptNS, [[m_qtMovie.get() movieAttributes] mutableCopy]); ASSERT(movieAttributes); - [movieAttributes setValue:[NSNumber numberWithBool:preservesPitch] forKey:QTMovieRateChangesPreservePitchAttribute]; + [movieAttributes.get() setValue:[NSNumber numberWithBool:preservesPitch] forKey:QTMovieRateChangesPreservePitchAttribute]; m_timeToRestore = currentTime(); - createQTMovie([movieAttributes valueForKey:QTMovieURLAttribute], movieAttributes); + createQTMovie([movieAttributes.get() valueForKey:QTMovieURLAttribute], movieAttributes.get()); } PassRefPtr<TimeRanges> MediaPlayerPrivateQTKit::buffered() const diff --git a/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm b/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm index beea018..4b2e7b2 100644 --- a/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm +++ b/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm @@ -48,8 +48,8 @@ void SimpleFontData::checkShapesArabic() const ASSERT(!m_checkedShapesArabic); m_checkedShapesArabic = true; - - ATSUFontID fontID = m_platformData.m_atsuFontID; + + ATSUFontID fontID = m_platformData.ctFont() ? CTFontGetPlatformFont(m_platformData.ctFont(), 0) : 0; if (!fontID) { LOG_ERROR("unable to get ATSUFontID for %@", m_platformData.font()); return; @@ -59,7 +59,7 @@ void SimpleFontData::checkShapesArabic() const // heuristic is that if such a font has a glyph metamorphosis table, then // it includes shaping information for Arabic. FourCharCode tables[] = { 'morx', 'mort' }; - for (unsigned i = 0; i < sizeof(tables) / sizeof(tables[0]); ++i) { + for (size_t i = 0; i < WTF_ARRAY_LENGTH(tables); ++i) { ByteCount tableSize; OSStatus status = ATSFontGetTable(fontID, tables[i], 0, 0, 0, &tableSize); if (status == noErr) { diff --git a/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp b/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp index db6de49..452bd54 100644 --- a/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp +++ b/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp @@ -62,15 +62,13 @@ CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typese const void* valuesWithKerningDisabled[] = { platformData().ctFont(), kerningAdjustment, allowLigatures ? ligaturesAllowed : ligaturesNotAllowed, orientation() == Vertical ? kCFBooleanTrue : kCFBooleanFalse }; attributesDictionary.adoptCF(CFDictionaryCreate(0, keysWithKerningDisabled, valuesWithKerningDisabled, - sizeof(keysWithKerningDisabled) / sizeof(*keysWithKerningDisabled), - &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + WTF_ARRAY_LENGTH(keysWithKerningDisabled), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); } else { // By omitting the kCTKernAttributeName attribute, we get Core Text's standard kerning. static const void* keysWithKerningEnabled[] = { kCTFontAttributeName, kCTLigatureAttributeName, kCTVerticalFormsAttributeName }; const void* valuesWithKerningEnabled[] = { platformData().ctFont(), allowLigatures ? ligaturesAllowed : ligaturesNotAllowed, orientation() == Vertical ? kCFBooleanTrue : kCFBooleanFalse }; attributesDictionary.adoptCF(CFDictionaryCreate(0, keysWithKerningEnabled, valuesWithKerningEnabled, - sizeof(keysWithKerningEnabled) / sizeof(*keysWithKerningEnabled), - &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + WTF_ARRAY_LENGTH(keysWithKerningEnabled), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); } return attributesDictionary.get(); diff --git a/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp index 85089a0..d295abb 100644 --- a/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp +++ b/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp @@ -211,20 +211,29 @@ void GraphicsContext3D::reshape(int width, int height) } // Initialize renderbuffers to 0. - GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE, stencilMask = GL_TRUE; + GLfloat clearColor[] = {0, 0, 0, 0}, clearDepth = 0; + GLint clearStencil = 0; + GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE; + GLuint stencilMask = 0xffffffff; GLboolean isScissorEnabled = GL_FALSE; GLboolean isDitherEnabled = GL_FALSE; GLbitfield clearMask = GL_COLOR_BUFFER_BIT; + ::glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); + ::glClearColor(0, 0, 0, 0); ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask); ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); if (m_attrs.depth) { + ::glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth); + ::glClearDepth(1); ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask); ::glDepthMask(GL_TRUE); clearMask |= GL_DEPTH_BUFFER_BIT; } if (m_attrs.stencil) { - ::glGetBooleanv(GL_STENCIL_WRITEMASK, &stencilMask); - ::glStencilMask(GL_TRUE); + ::glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil); + ::glClearStencil(0); + ::glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask)); + ::glStencilMaskSeparate(GL_FRONT, 0xffffffff); clearMask |= GL_STENCIL_BUFFER_BIT; } isScissorEnabled = ::glIsEnabled(GL_SCISSOR_TEST); @@ -234,11 +243,16 @@ void GraphicsContext3D::reshape(int width, int height) ::glClear(clearMask); + ::glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]); - if (m_attrs.depth) + if (m_attrs.depth) { + ::glClearDepth(clearDepth); ::glDepthMask(depthMask); - if (m_attrs.stencil) - ::glStencilMask(stencilMask); + } + if (m_attrs.stencil) { + ::glClearStencil(clearStencil); + ::glStencilMaskSeparate(GL_FRONT, stencilMask); + } if (isScissorEnabled) ::glEnable(GL_SCISSOR_TEST); else diff --git a/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp b/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp index 0d16d4d..04a5e26 100644 --- a/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp +++ b/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp @@ -139,28 +139,28 @@ void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* poin UNUSED_PARAM(shouldAntialias); // FIXME } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { if (paintingDisabled()) return; + // FIXME: Be smarter about this. + beginPath(); + addPath(path); + m_data->drawPath(VG_FILL_PATH, m_common->state.fillRule); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& path) { if (paintingDisabled()) return; - m_data->drawPath(VG_STROKE_PATH, m_common->state.fillRule); -} + // FIXME: Be smarter about this. + beginPath(); + addPath(path); -void GraphicsContext::drawPath() -{ - if (paintingDisabled()) - return; - - m_data->drawPath(VG_FILL_PATH | VG_STROKE_PATH, m_common->state.fillRule); + m_data->drawPath(VG_STROKE_PATH, m_common->state.fillRule); } void GraphicsContext::fillRect(const FloatRect& rect) @@ -221,11 +221,15 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->intersectClipRect(rect); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& path, 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/ContextShadowQt.cpp b/WebCore/platform/graphics/qt/ContextShadowQt.cpp index 342e027..f7c70f6 100644 --- a/WebCore/platform/graphics/qt/ContextShadowQt.cpp +++ b/WebCore/platform/graphics/qt/ContextShadowQt.cpp @@ -114,6 +114,7 @@ PlatformContext ContextShadow::beginShadowLayer(PlatformContext p, const FloatRe else clipRect = p->transform().inverted().mapRect(p->window()); + m_unscaledLayerRect = layerArea; calculateLayerBoundingRect(layerArea, IntRect(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height())); // Don't paint if we are totally outside the clip region. @@ -144,7 +145,9 @@ void ContextShadow::endShadowLayer(PlatformContext p) if (m_type == BlurShadow) { blurLayerImage(m_layerImage.bits(), IntSize(m_layerImage.width(), m_layerImage.height()), m_layerImage.bytesPerLine()); + } + if (m_type != NoShadow) { // "Colorize" with the right shadow color. QPainter p(&m_layerImage); p.setCompositionMode(QPainter::CompositionMode_SourceIn); @@ -152,7 +155,14 @@ void ContextShadow::endShadowLayer(PlatformContext p) p.end(); } - p->drawImage(m_layerRect.topLeft(), m_layerImage); + const QTransform transform = p->transform(); + if (transform.isScaling()) { + qreal x = m_unscaledLayerRect.x() + m_offset.width() / transform.m11() - m_blurDistance; + qreal y = m_unscaledLayerRect.y() + m_offset.height() / transform.m22() - m_blurDistance; + p->drawImage(QPointF(x, y), m_layerImage); + } else + p->drawImage(m_layerRect.topLeft(), m_layerImage); + scratchShadowBuffer()->schedulePurge(); } diff --git a/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp b/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp index 0565deb..35e9e0c 100644 --- a/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp +++ b/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp @@ -26,7 +26,7 @@ namespace WebCore { -static inline bool isEmtpyValue(const float size, const bool bold, const bool oblique) +static inline bool isEmptyValue(const float size, const bool bold, const bool oblique) { // this is the empty value by definition of the trait FontDataCacheKeyTraits return !bold && !oblique && size == 0.f; @@ -34,7 +34,7 @@ static inline bool isEmtpyValue(const float size, const bool bold, const bool ob FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) { - if (isEmtpyValue(size, bold, oblique)) + if (isEmptyValue(size, bold, oblique)) m_data = 0; else m_data = new FontPlatformDataPrivate(size, bold, oblique); diff --git a/WebCore/platform/graphics/qt/FontQt.cpp b/WebCore/platform/graphics/qt/FontQt.cpp index b049181..89dfd00 100644 --- a/WebCore/platform/graphics/qt/FontQt.cpp +++ b/WebCore/platform/graphics/qt/FontQt.cpp @@ -182,32 +182,62 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float if (!isComplexText && !(ctx->textDrawingMode() & cTextStroke)) flags |= Qt::TextBypassShaping; #endif - if (ctx->contextShadow()->m_type != ContextShadow::NoShadow) { - ContextShadow* ctxShadow = ctx->contextShadow(); - if (ctxShadow->m_type != ContextShadow::BlurShadow) { - p->save(); - p->setPen(ctxShadow->m_color); - p->translate(ctxShadow->offset()); - p->drawText(pt, string, flags, run.padding()); - p->restore(); - } else { - QFontMetrics fm(font); - QRectF boundingRect(point.x(), point.y() - fm.ascent(), fm.width(string), fm.height()); - QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect); - if (shadowPainter) { - // Since it will be blurred anyway, we don't care about render hints. - shadowPainter->setFont(p->font()); - shadowPainter->setPen(ctxShadow->m_color); - shadowPainter->drawText(pt, string, flags, run.padding()); - ctxShadow->endShadowLayer(p); + + QPainterPath textStrokePath; + if (ctx->textDrawingMode() & cTextStroke) + textStrokePath.addText(pt, font, string); + + ContextShadow* ctxShadow = ctx->contextShadow(); + if (ctxShadow->m_type != ContextShadow::NoShadow) { + if (ctx->textDrawingMode() & cTextFill) { + if (ctxShadow->m_type != ContextShadow::BlurShadow) { + p->save(); + p->setPen(ctxShadow->m_color); + p->translate(ctxShadow->offset()); + p->drawText(pt, string, flags, run.padding()); + p->restore(); + } else { + QFontMetrics fm(font); +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1, flags), fm.height()); +#else + QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string), fm.height()); +#endif + QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect); + if (shadowPainter) { + // Since it will be blurred anyway, we don't care about render hints. + shadowPainter->setFont(p->font()); + shadowPainter->setPen(ctxShadow->m_color); + shadowPainter->drawText(pt, string, flags, run.padding()); + ctxShadow->endShadowLayer(p); + } + } + } else if (ctx->textDrawingMode() & cTextStroke) { + if (ctxShadow->m_type != ContextShadow::BlurShadow) { + p->translate(ctxShadow->offset()); + p->strokePath(textStrokePath, QPen(ctxShadow->m_color)); + p->translate(-ctxShadow->offset()); + } else { + QFontMetrics fm(font); +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1, flags), fm.height()); +#else + QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string), fm.height()); +#endif + QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect); + if (shadowPainter) { + // Since it will be blurred anyway, we don't care about render hints. + shadowPainter->setFont(p->font()); + shadowPainter->strokePath(textStrokePath, QPen(ctxShadow->m_color)); + ctxShadow->endShadowLayer(p); + } } } } - if (ctx->textDrawingMode() & cTextStroke) { - QPainterPath path; - path.addText(pt, font, string); - p->strokePath(path, textStrokePen); - } + + if (ctx->textDrawingMode() & cTextStroke) + p->strokePath(textStrokePath, textStrokePen); + if (ctx->textDrawingMode() & cTextFill) { QPen previousPen = p->pen(); p->setPen(textFillPen); @@ -314,7 +344,7 @@ FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) String sanitized = Font::normalizeSpaces(String(run.characters(), run.length())); QString wholeText = fromRawDataWithoutRef(sanitized); - QString selectedText = fromRawDataWithoutRef(sanitized, from, to - from); + QString selectedText = fromRawDataWithoutRef(sanitized, from, qMin(to - from, wholeText.length() - from)); int startX = QFontMetrics(font()).width(wholeText, from, Qt::TextBypassShaping); int width = QFontMetrics(font()).width(selectedText, -1, Qt::TextBypassShaping); diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 06e1e1c..a840525 100644 --- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -51,7 +51,6 @@ #include "NotImplemented.h" #include "Path.h" #include "Pattern.h" -#include "Pen.h" #include "TransparencyLayer.h" #include <QBrush> @@ -104,6 +103,8 @@ QPainter::CompositionMode GraphicsContext::toQtCompositionMode(CompositeOperator return QPainter::CompositionMode_SourceOver; case CompositePlusLighter: return QPainter::CompositionMode_Plus; + default: + ASSERT_NOT_REACHED(); } return QPainter::CompositionMode_SourceOver; @@ -118,6 +119,8 @@ static inline Qt::PenCapStyle toQtLineCap(LineCap lc) return Qt::RoundCap; case SquareCap: return Qt::SquareCap; + default: + ASSERT_NOT_REACHED(); } return Qt::FlatCap; @@ -132,9 +135,11 @@ static inline Qt::PenJoinStyle toQtLineJoin(LineJoin lj) return Qt::RoundJoin; case BevelJoin: return Qt::BevelJoin; + default: + ASSERT_NOT_REACHED(); } - return Qt::MiterJoin; + return Qt::SvgMiterJoin; } static Qt::PenStyle toQPenStyle(StrokeStyle style) @@ -152,8 +157,9 @@ static Qt::PenStyle toQPenStyle(StrokeStyle style) case DashedStroke: return Qt::DashLine; break; + default: + ASSERT_NOT_REACHED(); } - qWarning("couldn't recognize the pen style"); return Qt::NoPen; } @@ -164,8 +170,9 @@ static inline Qt::FillRule toQtFillRule(WindRule rule) return Qt::OddEvenFill; case RULE_NONZERO: return Qt::WindingFill; + default: + ASSERT_NOT_REACHED(); } - qDebug("Qt: unrecognized wind rule!"); return Qt::OddEvenFill; } @@ -193,9 +200,6 @@ public: InterpolationQuality imageInterpolationQuality; - // Only used by SVG for now. - QPainterPath currentPath; - ContextShadow shadow; QStack<ContextShadow> shadowStack; @@ -204,13 +208,6 @@ 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) @@ -250,8 +247,8 @@ GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate() if (!platformContextIsOwned) return; - painter->end(); QPaintDevice* device = painter->device(); + painter->end(); delete painter; delete device; } @@ -311,11 +308,6 @@ 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 @@ -444,32 +436,6 @@ void GraphicsContext::drawEllipse(const IntRect& rect) m_data->p()->drawEllipse(rect); } -void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan) -{ - if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f) - return; - - QPainter* p = m_data->p(); - const bool antiAlias = p->testRenderHint(QPainter::Antialiasing); - p->setRenderHint(QPainter::Antialiasing, true); - - startAngle *= 16; - angleSpan *= 16; - - if (m_data->hasShadow()) { - p->save(); - p->translate(m_data->shadow.offset()); - QPen pen(p->pen()); - pen.setColor(m_data->shadow.m_color); - p->setPen(pen); - p->drawArc(rect, startAngle, angleSpan); - p->restore(); - } - p->drawArc(rect, startAngle, angleSpan); - - p->setRenderHint(QPainter::Antialiasing, antiAlias); -} - void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias) { if (paintingDisabled()) @@ -484,8 +450,10 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points polygon[i] = points[i]; QPainter* p = m_data->p(); - p->save(); + + const bool antiAlias = p->testRenderHint(QPainter::Antialiasing); p->setRenderHint(QPainter::Antialiasing, shouldAntialias); + if (m_data->hasShadow()) { p->save(); p->translate(m_data->shadow.offset()); @@ -500,7 +468,8 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points p->restore(); } p->drawConvexPolygon(polygon); - p->restore(); + + p->setRenderHint(QPainter::Antialiasing, antiAlias); } void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) @@ -529,64 +498,114 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin p->setRenderHint(QPainter::Antialiasing, painterWasAntialiased); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { if (paintingDisabled()) return; QPainter* p = m_data->p(); - QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath - path.setFillRule(toQtFillRule(fillRule())); + QPainterPath platformPath = path.platformPath(); + platformPath.setFillRule(toQtFillRule(fillRule())); if (m_data->hasShadow()) { - p->translate(m_data->shadow.offset()); - p->fillPath(path, QColor(m_data->shadow.m_color)); - p->translate(-m_data->shadow.offset()); + 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); + } + } else { + QPainter* shadowPainter = shadow->beginShadowLayer(p, platformPath.controlPointRect()); + if (shadowPainter) { + shadowPainter->setCompositionMode(QPainter::CompositionMode_Source); + shadowPainter->fillPath(platformPath, QColor(m_data->shadow.m_color)); + shadow->endShadowLayer(p); + } + } + } if (m_common->state.fillPattern) { AffineTransform affine; - p->fillPath(path, QBrush(m_common->state.fillPattern->createPlatformPattern(affine))); + p->fillPath(platformPath, 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(path, brush); + p->fillPath(platformPath, brush); } else - p->fillPath(path, p->brush()); - - m_data->clearCurrentPath(); + p->fillPath(platformPath, p->brush()); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& path) { if (paintingDisabled()) return; QPainter* p = m_data->p(); QPen pen(p->pen()); - QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath - path.setFillRule(toQtFillRule(fillRule())); + QPainterPath platformPath = path.platformPath(); + platformPath.setFillRule(toQtFillRule(fillRule())); if (m_data->hasShadow()) { - p->translate(m_data->shadow.offset()); - QPen shadowPen(pen); - shadowPen.setColor(m_data->shadow.m_color); - p->strokePath(path, shadowPen); - p->translate(-m_data->shadow.offset()); + ContextShadow* shadow = contextShadow(); + + if (shadow->m_type != ContextShadow::BlurShadow + && !m_common->state.strokePattern && !m_common->state.strokeGradient) + { + 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); + } + } else { + FloatRect boundingRect = platformPath.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); + shadow->endShadowLayer(p); + } + } } + if (m_common->state.strokePattern) { AffineTransform affine; pen.setBrush(QBrush(m_common->state.strokePattern->createPlatformPattern(affine))); p->setPen(pen); - p->strokePath(path, pen); + p->strokePath(platformPath, 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(path, pen); + p->strokePath(platformPath, pen); } else - p->strokePath(path, pen); - m_data->clearCurrentPath(); + p->strokePath(platformPath, pen); } static inline void drawRepeatPattern(QPainter* p, QPixmap* image, const FloatRect& rect, const bool repeatX, const bool repeatY) @@ -693,6 +712,7 @@ void GraphicsContext::fillRect(const FloatRect& rect) if (shadow->m_type == ContextShadow::BlurShadow) { QPainter* shadowPainter = shadow->beginShadowLayer(p, normalizedRect); if (shadowPainter) { + shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255); shadowPainter->fillRect(normalizedRect, p->brush()); shadow->endShadowLayer(p); } @@ -701,9 +721,16 @@ 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()); - p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor); + 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())), + shadowColor); + } else + p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor); } } + p->fillRect(normalizedRect, p->brush()); } } @@ -765,30 +792,11 @@ 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; @@ -802,26 +810,45 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->p()->setClipRect(rect, Qt::IntersectClip); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& path, WindRule clipRule) { if (paintingDisabled()) return; QPainter* p = m_data->p(); - QPainterPath newPath = m_data->currentPath; - newPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill); - p->setClipPath(newPath, Qt::IntersectClip); + QPainterPath platformPath = path.platformPath(); + platformPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill); + p->setClipPath(platformPath, Qt::IntersectClip); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { - // FIXME: implement + // FIXME: Use 'width' and 'offset' for something? http://webkit.org/b/49909 + + if (paintingDisabled() || !color.isValid()) + return; + + QPainter* p = m_data->p(); + const bool antiAlias = p->testRenderHint(QPainter::Antialiasing); + p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines); + + const QBrush oldBrush = p->brush(); + + QPen nPen = p->pen(); + nPen.setColor(color); + p->setBrush(Qt::NoBrush); + nPen.setStyle(Qt::DotLine); + + p->strokePath(path.platformPath(), nPen); + p->setBrush(oldBrush); + + p->setRenderHint(QPainter::Antialiasing, antiAlias); } /** - * Focus ring handling is not handled here. Qt style in + * Focus ring handling for form controls is not handled here. Qt style in * RenderTheme handles drawing focus on widgets which - * need it. + * need it. It is still handled here for links. */ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color) { @@ -1020,12 +1047,10 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float width) if (paintingDisabled()) return; - QPainterPath path; + Path path; path.addRect(rect); setStrokeThickness(width); - m_data->currentPath = path; - - strokePath(); + strokePath(path); } void GraphicsContext::setLineCap(LineCap lc) @@ -1145,12 +1170,6 @@ 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) @@ -1159,12 +1178,6 @@ 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) @@ -1173,12 +1186,6 @@ 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) @@ -1235,15 +1242,6 @@ 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/qt/ImageQt.cpp b/WebCore/platform/graphics/qt/ImageQt.cpp index 7b46b71..3611308 100644 --- a/WebCore/platform/graphics/qt/ImageQt.cpp +++ b/WebCore/platform/graphics/qt/ImageQt.cpp @@ -3,6 +3,7 @@ * Copyright (C) 2006 Zack Rusin <zack@kde.org> * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org> * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ + * Copyright (C) 2010 Sencha, Inc. * * All rights reserved. * @@ -32,11 +33,12 @@ #include "Image.h" #include "AffineTransform.h" -#include "ImageObserver.h" #include "BitmapImage.h" +#include "ContextShadow.h" #include "FloatRect.h" -#include "PlatformString.h" #include "GraphicsContext.h" +#include "ImageObserver.h" +#include "PlatformString.h" #include "StillImageQt.h" #include "qwebsettings.h" @@ -102,12 +104,13 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const if (!framePixmap) // If it's too early we won't have an image yet. return; + // Qt interprets 0 width/height as full width/height so just short circuit. QRectF dr = QRectF(destRect).normalized(); - if (!dr.width() || !dr.height()) // Qt interprets 0 width/height as full width/height so just short circuit. + QRect tr = QRectF(tileRect).toRect().normalized(); + if (!dr.width() || !dr.height() || !tr.width() || !tr.height()) return; QPixmap pixmap = *framePixmap; - QRect tr = QRectF(tileRect).toRect().normalized(); if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height()) pixmap = pixmap.copy(tr); @@ -177,11 +180,14 @@ void BitmapImage::invalidatePlatformData() void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op) { - FloatRect normalizedDst = dst.normalized(); - FloatRect normalizedSrc = src.normalized(); + QRectF normalizedDst = dst.normalized(); + QRectF normalizedSrc = src.normalized(); startAnimation(); + if (normalizedSrc.isEmpty() || normalizedDst.isEmpty()) + return; + QPixmap* image = nativeImageForCurrentFrame(); if (!image) return; @@ -201,21 +207,14 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, QPainter::CompositionMode lastCompositionMode = painter->compositionMode(); painter->setCompositionMode(compositionMode); - FloatSize shadowOffset; - float shadowBlur; - Color shadowColor; - if (ctxt->getShadow(shadowOffset, shadowBlur, shadowColor)) { - FloatRect shadowImageRect(normalizedDst); - shadowImageRect.move(shadowOffset.width(), shadowOffset.height()); - - QImage shadowImage(QSize(static_cast<int>(normalizedSrc.width()), static_cast<int>(normalizedSrc.height())), QImage::Format_ARGB32_Premultiplied); - QPainter p(&shadowImage); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(shadowImage.rect(), shadowColor); - p.setCompositionMode(QPainter::CompositionMode_DestinationIn); - p.drawPixmap(QRect(0, 0, normalizedDst.width(), normalizedDst.height()), *image, normalizedSrc); - p.end(); - painter->drawImage(shadowImageRect, shadowImage, normalizedSrc); + ContextShadow* shadow = ctxt->contextShadow(); + if (shadow->m_type != ContextShadow::NoShadow) { + QPainter* shadowPainter = shadow->beginShadowLayer(painter, normalizedDst); + if (shadowPainter) { + shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255); + shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc); + shadow->endShadowLayer(painter); + } } // Test using example site at diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp index e506e5d..6f6dce8 100644 --- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp +++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp @@ -420,11 +420,15 @@ void GraphicsContext::clipOut(const Path& p) platformContext()->canvas()->clipPath(path, SkRegion::kDifference_Op); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule) { if (paintingDisabled()) return; + // FIXME: Be smarter about this. + beginPath(); + addPath(pathToClip); + SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; @@ -513,7 +517,7 @@ void GraphicsContext::drawEllipse(const IntRect& elipseRect) } } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -723,11 +727,15 @@ void GraphicsContext::drawRect(const IntRect& rect) platformContext()->drawRect(r); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& pathToFill) { if (paintingDisabled()) return; + // FIXME: Be smarter about this. + beginPath(); + addPath(pathToFill); + SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; @@ -1177,11 +1185,15 @@ void GraphicsContext::strokeArc(const IntRect& r, int startAngle, int angleSpan) platformContext()->canvas()->drawPath(path, paint); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& pathToStroke) { 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/ImageBufferSkia.cpp b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp index 0db96cf..adb732b 100644 --- a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp +++ b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp @@ -183,6 +183,9 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap, endX = size.width(); int numColumns = endX - originX; + if (numColumns <= 0) + return result; + int originY = rect.y(); int destY = 0; if (originY < 0) { @@ -194,6 +197,9 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap, endY = size.height(); int numRows = endY - originY; + if (numRows <= 0) + return result; + ASSERT(bitmap.config() == SkBitmap::kARGB_8888_Config); SkAutoLockPixels bitmapLock(bitmap); diff --git a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp index c9288e5..1ad6bc1 100644 --- a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp +++ b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp @@ -124,7 +124,7 @@ void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& po CGContextDrawImage(m_data->m_cgContext.get(), CGRectMake(point.x(), point.y(), image->size().width(), image->size().height()), cgImage.get()); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -228,20 +228,17 @@ void GraphicsContext::drawLineForTextChecking(const IntPoint& point, int width, const float lowerOpacity = 0.88f; //Top line - CGContextSetLineDash(context, edge_offset, edge_dash_lengths, - sizeof(edge_dash_lengths) / sizeof(edge_dash_lengths[0])); + CGContextSetLineDash(context, edge_offset, edge_dash_lengths, WTF_ARRAY_LENGTH(edge_dash_lengths)); CGContextSetAlpha(context, upperOpacity); CGContextStrokeLineSegments(context, upperPoints, 2); // Middle line - CGContextSetLineDash(context, middle_offset, middle_dash_lengths, - sizeof(middle_dash_lengths) / sizeof(middle_dash_lengths[0])); + CGContextSetLineDash(context, middle_offset, middle_dash_lengths, WTF_ARRAY_LENGTH(middle_dash_lengths)); CGContextSetAlpha(context, middleOpacity); CGContextStrokeLineSegments(context, middlePoints, 2); // Bottom line - CGContextSetLineDash(context, edge_offset, edge_dash_lengths, - sizeof(edge_dash_lengths) / sizeof(edge_dash_lengths[0])); + CGContextSetLineDash(context, edge_offset, edge_dash_lengths, WTF_ARRAY_LENGTH(edge_dash_lengths)); CGContextSetAlpha(context, lowerOpacity); CGContextStrokeLineSegments(context, lowerPoints, 2); diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp index 34a8817..2b24a24 100644 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp @@ -254,7 +254,8 @@ void MediaPlayerPrivateQuickTimeVisualContext::setUpCookiesForQuickTime(const St // WebCore loaded the page with the movie URL with CFNetwork but QuickTime will // use WinINet to download the movie, so we need to copy any cookies needed to // download the movie into WinInet before asking QuickTime to open it. - Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : 0; + Document* document = m_player->mediaPlayerClient()->mediaPlayerOwningDocument(); + Frame* frame = document ? document->frame() : 0; if (!frame || !frame->page() || !frame->page()->cookieEnabled()) return; @@ -315,7 +316,7 @@ static void disableComponentsOnce() {'eat ', 'TEXT', 'tx3g', 0, 0}, }; - for (size_t i = 0; i < sizeof(componentsToDisable) / sizeof(componentsToDisable[0]); ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(componentsToDisable); ++i) QTMovie::disableComponent(componentsToDisable[i]); } diff --git a/WebCore/platform/graphics/win/QTMovie.cpp b/WebCore/platform/graphics/win/QTMovie.cpp index e425bf8..efaf218 100644 --- a/WebCore/platform/graphics/win/QTMovie.cpp +++ b/WebCore/platform/graphics/win/QTMovie.cpp @@ -548,7 +548,7 @@ void QTMovie::load(CFURLRef url, bool preservesPitch) movieProps[moviePropCount].propStatus = 0; moviePropCount++; - ASSERT(moviePropCount <= sizeof(movieProps) / sizeof(movieProps[0])); + ASSERT(moviePropCount <= WTF_ARRAY_LENGTH(movieProps)); m_private->m_loadError = NewMovieFromProperties(moviePropCount, movieProps, 0, 0, &m_private->m_movie); end: diff --git a/WebCore/platform/graphics/win/cairo/FontPlatformData.h b/WebCore/platform/graphics/win/cairo/FontPlatformData.h index 05f9eab..d8f538a 100644 --- a/WebCore/platform/graphics/win/cairo/FontPlatformData.h +++ b/WebCore/platform/graphics/win/cairo/FontPlatformData.h @@ -3,6 +3,7 @@ * 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 @@ -25,7 +26,7 @@ #ifndef FontPlatformDataCairoWin_h #define FontPlatformDataCairoWin_h -#include "FontDescription.h" +#include "FontOrientation.h" #include "GlyphBuffer.h" #include "RefCountedGDIHandle.h" #include "StringImpl.h" @@ -37,6 +38,8 @@ typedef struct HFONT__* HFONT; namespace WebCore { +class FontDescription; + class FontPlatformData { public: FontPlatformData(WTF::HashTableDeletedValueType) @@ -73,6 +76,9 @@ 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 8af6ef7..4faa29d 100644 --- a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp +++ b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp @@ -982,7 +982,7 @@ void GraphicsContext::clipOut(const IntRect& rect) ExcludeClipRect(m_data->m_dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom()); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -1325,8 +1325,12 @@ Color gradientAverageColor(const Gradient* gradient) , (stop.alpha + lastStop.alpha) * 0.5f); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { + // FIXME: Be smarter about this. + beginPath(); + addPath(path); + Color c = m_common->state.fillGradient ? gradientAverageColor(m_common->state.fillGradient.get()) : fillColor(); @@ -1376,6 +1380,10 @@ 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()) { @@ -1900,7 +1908,7 @@ void GraphicsContext::setLineDash(const DashArray&, float) notImplemented(); } -void GraphicsContext::clipPath(WindRule) +void GraphicsContext::clipPath(const Path&, WindRule) { notImplemented(); } diff --git a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp index 53a9ccd..ba96352 100644 --- a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp +++ b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp @@ -289,7 +289,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef notImplemented(); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -337,7 +337,7 @@ void GraphicsContext::clipOut(const IntRect&) notImplemented(); } -void GraphicsContext::clipPath(WindRule) +void GraphicsContext::clipPath(const Path&, WindRule) { notImplemented(); } @@ -533,30 +533,32 @@ InterpolationQuality GraphicsContext::imageInterpolationQuality() const return InterpolationDefault; } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { #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() +void GraphicsContext::strokePath(const Path& path) { #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 2522cbd..dd45f31 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&, ImageColorSpace imageColorSpace, bool& success) : +ImageBuffer::ImageBuffer(const IntSize&, ColorSpace imageColorSpace, bool& success) : m_data(IntSize()) { notImplemented(); |