diff options
Diffstat (limited to 'WebCore/platform/graphics/qt')
-rw-r--r-- | WebCore/platform/graphics/qt/ContextShadow.cpp | 188 | ||||
-rw-r--r-- | WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp | 9 | ||||
-rw-r--r-- | WebCore/platform/graphics/qt/GraphicsContextQt.cpp | 14 | ||||
-rw-r--r-- | WebCore/platform/graphics/qt/GraphicsLayerQt.cpp | 48 | ||||
-rw-r--r-- | WebCore/platform/graphics/qt/GraphicsLayerQt.h | 1 | ||||
-rw-r--r-- | WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp | 3 | ||||
-rw-r--r-- | WebCore/platform/graphics/qt/PathQt.cpp | 28 | ||||
-rw-r--r-- | WebCore/platform/graphics/qt/TransparencyLayer.h | 3 |
8 files changed, 94 insertions, 200 deletions
diff --git a/WebCore/platform/graphics/qt/ContextShadow.cpp b/WebCore/platform/graphics/qt/ContextShadow.cpp index 829ca82..4609923 100644 --- a/WebCore/platform/graphics/qt/ContextShadow.cpp +++ b/WebCore/platform/graphics/qt/ContextShadow.cpp @@ -139,134 +139,80 @@ void ContextShadow::clear() offset = QPointF(0, 0); } -// Instead of integer division, we use 18.14 for fixed-point division. -static const int BlurSumShift = 14; +// Instead of integer division, we use 17.15 for fixed-point division. +static const int BlurSumShift = 15; -// Note: image must be RGB32 format -static void blurHorizontal(QImage& image, int radius, bool swap = false) -{ - Q_ASSERT(image.format() == QImage::Format_ARGB32_Premultiplied); +// Check http://www.w3.org/TR/SVG/filters.html#feGaussianBlur. +// As noted in the SVG filter specification, running box blur 3x +// approximates a real gaussian blur nicely. +void shadowBlur(QImage& image, int radius, const QColor& shadowColor) +{ // See comments in http://webkit.org/b/40793, it seems sensible - // to follow Skia's limit of 128 pixels of blur radius - radius = qMin(128, radius); - - int imgWidth = image.width(); - int imgHeight = image.height(); + // to follow Skia's limit of 128 pixels for the blur radius. + if (radius > 128) + radius = 128; - // Check http://www.w3.org/TR/SVG/filters.html#feGaussianBlur - // for the approaches when the box-blur radius is even vs odd. + int channels[4] = { 3, 0, 1, 3 }; int dmax = radius >> 1; - int dmin = qMax(0, dmax - 1 + (radius & 1)); - - for (int y = 0; y < imgHeight; ++y) { - - unsigned char* pixels = image.scanLine(y); - - int left; - int right; - int pixelCount; - int prev; - int next; - int firstAlpha; - int lastAlpha; - int totalAlpha; - unsigned char* target; - unsigned char* prevPtr; - unsigned char* nextPtr; - - int invCount; - - static const int alphaChannel = 3; - static const int blueChannel = 0; - static const int greenChannel = 1; - - // For each step, we use sliding window algorithm. This is much more - // efficient than computing the sum of each pixels covered by the box - // kernel size for each x. - - // As noted in the SVG filter specification, running box blur 3x - // approximates a real gaussian blur nicely. - - // Step 1: blur alpha channel and store the result in the blue channel. - left = swap ? dmax : dmin; - right = swap ? dmin : dmax; - pixelCount = left + 1 + right; - invCount = (1 << BlurSumShift) / pixelCount; - prev = -left; - next = 1 + right; - firstAlpha = pixels[alphaChannel]; - lastAlpha = pixels[(imgWidth - 1) * 4 + alphaChannel]; - totalAlpha = 0; - for (int i = 0; i < pixelCount; ++i) - totalAlpha += pixels[qBound(0, i - left, imgWidth - 1) * 4 + alphaChannel]; - target = pixels + blueChannel; - prevPtr = pixels + prev * 4 + alphaChannel; - nextPtr = pixels + next * 4 + alphaChannel; - for (int x = 0; x < imgWidth; ++x, ++prev, ++next, target += 4, prevPtr += 4, nextPtr += 4) { - *target = (totalAlpha * invCount) >> BlurSumShift; - int delta = ((next < imgWidth) ? *nextPtr : lastAlpha) - - ((prev > 0) ? *prevPtr : firstAlpha); - totalAlpha += delta; - } - - // Step 2: blur blue channel and store the result in the green channel. - left = swap ? dmin : dmax; - right = swap ? dmax : dmin; - pixelCount = left + 1 + right; - invCount = (1 << BlurSumShift) / pixelCount; - prev = -left; - next = 1 + right; - firstAlpha = pixels[blueChannel]; - lastAlpha = pixels[(imgWidth - 1) * 4 + blueChannel]; - totalAlpha = 0; - for (int i = 0; i < pixelCount; ++i) - totalAlpha += pixels[qBound(0, i - left, imgWidth - 1) * 4 + blueChannel]; - target = pixels + greenChannel; - prevPtr = pixels + prev * 4 + blueChannel; - nextPtr = pixels + next * 4 + blueChannel; - for (int x = 0; x < imgWidth; ++x, ++prev, ++next, target += 4, prevPtr += 4, nextPtr += 4) { - *target = (totalAlpha * invCount) >> BlurSumShift; - int delta = ((next < imgWidth) ? *nextPtr : lastAlpha) - - ((prev > 0) ? *prevPtr : firstAlpha); - totalAlpha += delta; - } - - // Step 3: blur green channel and store the result in the alpha channel. - left = dmax; - right = dmax; - pixelCount = left + 1 + right; - invCount = (1 << BlurSumShift) / pixelCount; - prev = -left; - next = 1 + right; - firstAlpha = pixels[greenChannel]; - lastAlpha = pixels[(imgWidth - 1) * 4 + greenChannel]; - totalAlpha = 0; - for (int i = 0; i < pixelCount; ++i) - totalAlpha += pixels[qBound(0, i - left, imgWidth - 1) * 4 + greenChannel]; - target = pixels + alphaChannel; - prevPtr = pixels + prev * 4 + greenChannel; - nextPtr = pixels + next * 4 + greenChannel; - for (int x = 0; x < imgWidth; ++x, ++prev, ++next, target += 4, prevPtr += 4, nextPtr += 4) { - *target = (totalAlpha * invCount) >> BlurSumShift; - int delta = ((next < imgWidth) ? *nextPtr : lastAlpha) - - ((prev > 0) ? *prevPtr : firstAlpha); - totalAlpha += delta; + int dmin = dmax - 1 + (radius & 1); + if (dmin < 0) + dmin = 0; + + // Two stages: horizontal and vertical + for (int k = 0; k < 2; ++k) { + + unsigned char* pixels = image.bits(); + int stride = (!k) ? 4 : image.bytesPerLine(); + int delta = (!k) ? image.bytesPerLine() : 4; + int jfinal = (!k) ? image.height() : image.width(); + int dim = (!k) ? image.width() : image.height(); + + for (int j = 0; j < jfinal; ++j, pixels += delta) { + + // For each step, we blur the alpha in a channel and store the result + // in another channel for the subsequent step. + // We use sliding window algorithm to accumulate the alpha values. + // This is much more efficient than computing the sum of each pixels + // covered by the box kernel size for each x. + + for (int step = 0; step < 3; ++step) { + int side1 = (!step) ? dmin : dmax; + int side2 = (step == 1) ? dmin : dmax; + int pixelCount = side1 + 1 + side2; + int invCount = ((1 << BlurSumShift) + pixelCount - 1) / pixelCount; + int ofs = 1 + side2; + int alpha1 = pixels[channels[step]]; + int alpha2 = pixels[(dim - 1) * stride + channels[step]]; + unsigned char* ptr = pixels + channels[step + 1]; + unsigned char* prev = pixels + stride + channels[step]; + unsigned char* next = pixels + ofs * stride + channels[step]; + + int i; + int sum = side1 * alpha1 + alpha1; + int limit = (dim < side2 + 1) ? dim : side2 + 1; + for (i = 1; i < limit; ++i, prev += stride) + sum += *prev; + if (limit <= side2) + sum += (side2 - limit + 1) * alpha2; + + limit = (side1 < dim) ? side1 : dim; + for (i = 0; i < limit; ptr += stride, next += stride, ++i, ++ofs) { + *ptr = (sum * invCount) >> BlurSumShift; + sum += ((ofs < dim) ? *next : alpha2) - alpha1; + } + prev = pixels + channels[step]; + for (; ofs < dim; ptr += stride, prev += stride, next += stride, ++i, ++ofs) { + *ptr = (sum * invCount) >> BlurSumShift; + sum += (*next) - (*prev); + } + for (; i < dim; ptr += stride, prev += stride, ++i) { + *ptr = (sum * invCount) >> BlurSumShift; + sum += alpha2 - (*prev); + } + } } } -} - -static void shadowBlur(QImage& image, int radius, const QColor& shadowColor) -{ - blurHorizontal(image, radius); - - QTransform transform; - transform.rotate(90); - image = image.transformed(transform); - blurHorizontal(image, radius, true); - transform.reset(); - transform.rotate(270); - image = image.transformed(transform); // "Colorize" with the right shadow color. QPainter p(&image); diff --git a/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp index 7918378..0756aa7 100644 --- a/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp +++ b/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp @@ -491,13 +491,16 @@ void* GraphicsContext3DInternal::getProcAddress(const String& proc) return 0; } -PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow) +PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) { - OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs, hostWindow)); + // This implementation doesn't currently support rendering directly to the HostWindow. + if (renderStyle == RenderDirectlyToHostWindow) + return 0; + OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs, hostWindow, false)); return context->m_internal ? context.release() : 0; } -GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow) +GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool) : m_internal(new GraphicsContext3DInternal(attrs, hostWindow)) { if (!m_internal->isContextValid()) diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index c9c74dd..5a29ad4 100644 --- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -174,14 +174,10 @@ public: GraphicsContextPlatformPrivate(QPainter* painter); ~GraphicsContextPlatformPrivate(); - inline QPainter* p() + inline QPainter* p() const { - if (layers.isEmpty()) { - if (redirect) - return redirect; - + if (layers.isEmpty()) return painter; - } return &layers.top()->painter; } @@ -191,7 +187,6 @@ public: // Counting real layers. Required by inTransparencyLayer() calls // For example, layers with valid alphaMask are not real layers int layerCount; - QPainter* redirect; // reuse this brush for solid color (to prevent expensive QBrush construction) QBrush solidColor; @@ -212,9 +207,9 @@ public: QRectF clipBoundingRect() const { #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) - return painter->clipBoundingRect(); + return p()->clipBoundingRect(); #else - return painter->clipRegion().boundingRect(); + return p()->clipRegion().boundingRect(); #endif } @@ -227,7 +222,6 @@ GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p) { painter = p; layerCount = 0; - redirect = 0; solidColor = QBrush(Qt::black); diff --git a/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp b/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp index e164f8c..079d8ba 100644 --- a/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp +++ b/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp @@ -130,22 +130,21 @@ public: TransformChange = (1L << 6), ContentChange = (1L << 7), - GeometryOrientationChange = (1L << 8), - ContentsOrientationChange = (1L << 9), - OpacityChange = (1L << 10), - ContentsRectChange = (1L << 11), - - Preserves3DChange = (1L << 12), - MasksToBoundsChange = (1L << 13), - DrawsContentChange = (1L << 14), - ContentsOpaqueChange = (1L << 15), - - BackfaceVisibilityChange = (1L << 16), - ChildrenTransformChange = (1L << 17), - DisplayChange = (1L << 18), - BackgroundColorChange = (1L << 19), - - DistributesOpacityChange = (1L << 20) + ContentsOrientationChange = (1L << 8), + OpacityChange = (1L << 9), + ContentsRectChange = (1L << 10), + + Preserves3DChange = (1L << 11), + MasksToBoundsChange = (1L << 12), + DrawsContentChange = (1L << 13), + ContentsOpaqueChange = (1L << 14), + + BackfaceVisibilityChange = (1L << 15), + ChildrenTransformChange = (1L << 16), + DisplayChange = (1L << 17), + BackgroundColorChange = (1L << 18), + + DistributesOpacityChange = (1L << 19) }; // The compositor lets us special-case images and colors, so we try to do so. @@ -250,7 +249,6 @@ public: TransformationMatrix childrenTransform; Color backgroundColor; Color currentColor; - GraphicsLayer::CompositingCoordinatesOrientation geoOrientation; GraphicsLayer::CompositingCoordinatesOrientation contentsOrientation; float opacity; QRect contentsRect; @@ -777,7 +775,6 @@ void GraphicsLayerQtImpl::flushChanges(bool recursive, bool forceUpdateTransform m_state.anchorPoint = m_layer->anchorPoint(); m_state.size = m_layer->size(); m_state.transform = m_layer->transform(); - m_state.geoOrientation = m_layer->geometryOrientation(); m_state.contentsOrientation =m_layer->contentsOrientation(); m_state.opacity = m_layer->opacity(); m_state.contentsRect = m_layer->contentsRect(); @@ -837,13 +834,6 @@ PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client) return new GraphicsLayerQt(client); } -/* \reimp (GraphicsLayer.h): Qt is top-down -*/ -GraphicsLayer::CompositingCoordinatesOrientation GraphicsLayer::compositingCoordinatesOrientation() -{ - return CompositingCoordinatesTopDown; -} - /* \reimp (GraphicsLayer.h): The current size might change, thus we need to update the whole display. */ void GraphicsLayerQt::setNeedsDisplay() @@ -1149,14 +1139,6 @@ void GraphicsLayerQt::setContentsToMedia(PlatformLayer* media) /* \reimp (GraphicsLayer.h) */ -void GraphicsLayerQt::setGeometryOrientation(CompositingCoordinatesOrientation orientation) -{ - m_impl->notifyChange(GraphicsLayerQtImpl::GeometryOrientationChange); - GraphicsLayer::setGeometryOrientation(orientation); -} - -/* \reimp (GraphicsLayer.h) -*/ void GraphicsLayerQt::setContentsOrientation(CompositingCoordinatesOrientation orientation) { m_impl->notifyChange(GraphicsLayerQtImpl::ContentsOrientationChange); diff --git a/WebCore/platform/graphics/qt/GraphicsLayerQt.h b/WebCore/platform/graphics/qt/GraphicsLayerQt.h index 4282e64..75ca498 100644 --- a/WebCore/platform/graphics/qt/GraphicsLayerQt.h +++ b/WebCore/platform/graphics/qt/GraphicsLayerQt.h @@ -81,7 +81,6 @@ public: virtual void setContentsToGraphicsContext3D(const GraphicsContext3D*); virtual void setGraphicsContext3DNeedsDisplay(); #endif - virtual void setGeometryOrientation(CompositingCoordinatesOrientation orientation); virtual void setContentsOrientation(CompositingCoordinatesOrientation orientation); virtual void distributeOpacity(float); virtual float accumulatedOpacity() const; diff --git a/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp index 605dcb7..1bf1a3d 100644 --- a/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp +++ b/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp @@ -25,6 +25,7 @@ #include "GraphicsContext.h" #include "HTMLMediaElement.h" #include "HTMLVideoElement.h" +#include "NetworkingContext.h" #include "NotImplemented.h" #include "TimeRanges.h" #include "Widget.h" @@ -192,8 +193,8 @@ void MediaPlayerPrivate::commitLoad(const String& url) // Grab the frame and network manager Frame* frame = document ? document->frame() : 0; + QNetworkAccessManager* manager = frame ? frame->loader()->networkingContext()->networkAccessManager() : 0; FrameLoaderClientQt* frameLoader = frame ? static_cast<FrameLoaderClientQt*>(frame->loader()->client()) : 0; - QNetworkAccessManager* manager = frameLoader ? frameLoader->webFrame()->page()->networkAccessManager() : 0; if (document && manager) { // Set the cookies diff --git a/WebCore/platform/graphics/qt/PathQt.cpp b/WebCore/platform/graphics/qt/PathQt.cpp index df54684..b8b9d5e 100644 --- a/WebCore/platform/graphics/qt/PathQt.cpp +++ b/WebCore/platform/graphics/qt/PathQt.cpp @@ -51,7 +51,6 @@ namespace WebCore { Path::Path() - : m_lastMoveToIndex(0) { } @@ -61,14 +60,12 @@ Path::~Path() Path::Path(const Path& other) : m_path(other.m_path) - , m_lastMoveToIndex(other.m_lastMoveToIndex) { } Path& Path::operator=(const Path& other) { m_path = other.m_path; - m_lastMoveToIndex = other.m_lastMoveToIndex; return *this; } @@ -183,7 +180,6 @@ FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) void Path::moveTo(const FloatPoint& point) { - m_lastMoveToIndex = m_path.elementCount(); m_path.moveTo(point); } @@ -267,30 +263,6 @@ void Path::closeSubpath() m_path.closeSubpath(); } -void Path::closeCanvasSubpath() -{ - const int elementCount = m_path.elementCount(); - - if (!elementCount) - return; - - QPointF lastMoveToPoint = m_path.elementAt(m_lastMoveToIndex); - int elementsInLastSubpath = 0; - - for (int i = m_lastMoveToIndex; i < elementCount; ++i) { - QPainterPath::Element element = m_path.elementAt(i); - if (element.isLineTo() || element.isCurveTo()) { - // All we need to know is if there are 1 or more elements in the last subpath. - if (++elementsInLastSubpath == 2) { - m_path.lineTo(lastMoveToPoint); - return; - } - } - } - - moveTo(lastMoveToPoint); -} - #define DEGREES(t) ((t) * 180.0 / M_PI) void Path::addArc(const FloatPoint& p, float r, float sar, float ear, bool anticlockwise) { diff --git a/WebCore/platform/graphics/qt/TransparencyLayer.h b/WebCore/platform/graphics/qt/TransparencyLayer.h index 1a614ac..6bdfb39 100644 --- a/WebCore/platform/graphics/qt/TransparencyLayer.h +++ b/WebCore/platform/graphics/qt/TransparencyLayer.h @@ -61,9 +61,6 @@ struct TransparencyLayer : FastAllocBase { painter.setFont(p->font()); if (painter.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) painter.setCompositionMode(p->compositionMode()); - // if the path is an empty region, this assignment disables all painting - if (!p->clipPath().isEmpty()) - painter.setClipPath(p->clipPath()); } TransparencyLayer() |