diff options
author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebCore/platform/graphics/qt | |
parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebCore/platform/graphics/qt')
17 files changed, 278 insertions, 285 deletions
diff --git a/Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp b/Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp index dcea72f..3adc93f 100644 --- a/Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp +++ b/Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp @@ -30,6 +30,7 @@ #include "Extensions3DQt.h" #include "GraphicsContext3D.h" +#include <QGLContext> namespace WebCore { diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h index e8441d2..3996d22 100644 --- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h @@ -25,6 +25,7 @@ #include "FontOrientation.h" #include "FontRenderingMode.h" #include "FontWidthVariant.h" +#include "TextOrientation.h" #include <wtf/FastAllocBase.h> #include <wtf/Forward.h> #include <wtf/Noncopyable.h> @@ -43,7 +44,8 @@ public: // for use with QFontDatabase::addApplicationFont/removeApplicationFont int m_handle; - FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode); + FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, + FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode); static bool supportsFormat(const String&); }; diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp index ec8747d..20f161a 100644 --- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp @@ -34,7 +34,7 @@ FontCustomPlatformData::~FontCustomPlatformData() QFontDatabase::removeApplicationFont(m_handle); } -FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode) +FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode) { QFont font; font.setFamily(QFontDatabase::applicationFontFamilies(m_handle)[0]); diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformData.h b/Source/WebCore/platform/graphics/qt/FontPlatformData.h index 32e8a2d..4a92acf 100644 --- a/Source/WebCore/platform/graphics/qt/FontPlatformData.h +++ b/Source/WebCore/platform/graphics/qt/FontPlatformData.h @@ -141,6 +141,7 @@ public: } FontOrientation orientation() const { return Horizontal; } // FIXME: Implement. + void setOrientation(FontOrientation) { } // FIXME: Implement. unsigned hash() const; diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp index 185ae85..95dabd5 100644 --- a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp @@ -73,9 +73,7 @@ FontPlatformData::FontPlatformData(const FontDescription& description, const Ato font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing); const bool smallCaps = description.smallCaps(); font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase); -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) font.setStyleStrategy(QFont::ForceIntegerMetrics); -#endif m_data->bold = font.bold(); // WebKit allows font size zero but QFont does not. We will return diff --git a/Source/WebCore/platform/graphics/qt/FontQt.cpp b/Source/WebCore/platform/graphics/qt/FontQt.cpp index 646cd0e..3fe90a4 100644 --- a/Source/WebCore/platform/graphics/qt/FontQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontQt.cpp @@ -169,21 +169,16 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float p->restore(); return; } -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) int skipWidth = QFontMetrics(font).width(string, from, Qt::TextBypassShaping); pt.setX(pt.x() + skipWidth); string = fromRawDataWithoutRef(sanitized, from, to - from); -#endif } p->setFont(font); int flags = run.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight; -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) - // See QWebPagePrivate::QWebPagePrivate() where the default path is set to Complex for Qt 4.6 and earlier. if (!isComplexText && !(ctx->textDrawingMode() & TextModeStroke)) flags |= Qt::TextBypassShaping; -#endif QPainterPath textStrokePath; if (ctx->textDrawingMode() & TextModeStroke) @@ -200,11 +195,7 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float 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(ctx, boundingRect); if (shadowPainter) { // Since it will be blurred anyway, we don't care about render hints. @@ -221,11 +212,7 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float 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(ctx, boundingRect); if (shadowPainter) { // Since it will be blurred anyway, we don't care about render hints. @@ -250,11 +237,7 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float void Font::drawSimpleText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const { -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */false); -#else - Q_ASSERT(false); -#endif } void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const @@ -295,7 +278,6 @@ float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer if (!primaryFont()->platformData().size()) return 0; -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) if (!run.length()) return 0; @@ -309,10 +291,6 @@ float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer w -= m_wordSpacing; return w + run.expansion(); -#else - Q_ASSERT(false); - return 0; -#endif } float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*, GlyphOverflow*) const @@ -339,7 +317,6 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon int Font::offsetForPositionForSimpleText(const TextRun& run, float position, bool includePartialGlyphs) const { -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) String sanitized = Font::normalizeSpaces(run.characters(), run.length()); QString string = fromRawDataWithoutRef(sanitized); @@ -359,10 +336,6 @@ int Font::offsetForPositionForSimpleText(const TextRun& run, float position, boo } while (++curPos < string.size()); return curPos; -#else - Q_ASSERT(false); - return 0; -#endif } int Font::offsetForPositionForComplexText(const TextRun& run, float position, bool) const @@ -377,7 +350,6 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float position, bo FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& pt, int h, int from, int to) const { -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) String sanitized = Font::normalizeSpaces(run.characters(), run.length()); QString wholeText = fromRawDataWithoutRef(sanitized); QString selectedText = fromRawDataWithoutRef(sanitized, from, qMin(to - from, wholeText.length() - from)); @@ -386,10 +358,6 @@ FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& int width = QFontMetrics(font()).width(selectedText, -1, Qt::TextBypassShaping); return FloatRect(pt.x() + startX, pt.y(), width, h); -#else - Q_ASSERT(false); - return FloatRect(); -#endif } FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& pt, int h, int from, int to) const diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp index b849214..4daa4dc 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp @@ -27,10 +27,14 @@ #include "HTMLCanvasElement.h" #include "HostWindow.h" #include "ImageBuffer.h" +#include "ImageData.h" #include "NotImplemented.h" #include "QWebPageClient.h" +#include "qwebpage.h" #include <QAbstractScrollArea> +#include <QGraphicsObject> #include <QGLContext> +#include <QStyleOptionGraphicsItem> #include <wtf/UnusedParam.h> #include <wtf/text/CString.h> @@ -42,6 +46,10 @@ namespace WebCore { typedef char GLchar; #endif +#if !defined(GL_DEPTH24_STENCIL8) +#define GL_DEPTH24_STENCIL8 0x88F0 +#endif + #if !defined(APIENTRY) #define APIENTRY #endif @@ -145,13 +153,17 @@ typedef void (APIENTRY* glVertexAttrib4fType) (GLuint, const GLfloat, const GLfl typedef void (APIENTRY* glVertexAttrib4fvType) (GLuint, const GLfloat*); typedef void (APIENTRY* glVertexAttribPointerType) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*); -class GraphicsContext3DInternal { +class GraphicsContext3DInternal : public QGraphicsObject { public: GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow); ~GraphicsContext3DInternal(); - bool isContextValid() { return m_contextValid; } - QGLWidget* getOwnerGLWidget(QWebPageClient* webPageClient); + bool isValid() { return m_valid; } + + QGLWidget* getViewportGLWidget(); + void reshape(int width, int height); + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); + QRectF boundingRect() const; glActiveTextureType activeTexture; glAttachShaderType attachShader; @@ -247,11 +259,13 @@ public: GraphicsContext3D::Attributes m_attrs; HostWindow* m_hostWindow; QGLWidget* m_glWidget; + QGLWidget* m_viewportGLWidget; + QRectF m_boundingRect; GLuint m_texture; - GLuint m_mainFbo; + GLuint m_canvasFbo; GLuint m_currentFbo; GLuint m_depthBuffer; - QImage m_pixels; + bool m_layerComposited; ListHashSet<unsigned int> m_syntheticErrors; OwnPtr<Extensions3DQt> m_extensions; @@ -259,7 +273,7 @@ public: private: void* getProcAddress(const String& proc); - bool m_contextValid; + bool m_valid; }; #if defined (QT_OPENGL_ES_2) @@ -281,39 +295,37 @@ GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attribut : m_attrs(attrs) , m_hostWindow(hostWindow) , m_glWidget(0) + , m_viewportGLWidget(0) , m_texture(0) - , m_mainFbo(0) + , m_canvasFbo(0) , m_currentFbo(0) , m_depthBuffer(0) - , m_contextValid(true) + , m_layerComposited(false) + , m_valid(true) { - QWebPageClient* webPageClient = hostWindow->platformPageClient(); - QGLWidget* ownerGLWidget = getOwnerGLWidget(webPageClient); + m_viewportGLWidget = getViewportGLWidget(); - if (ownerGLWidget) - m_glWidget = new QGLWidget(0, ownerGLWidget); - else { - QGLFormat format; - format.setDepth(true); - format.setSampleBuffers(true); - format.setStencil(false); - - m_glWidget = new QGLWidget(format); - } + if (m_viewportGLWidget) + m_glWidget = new QGLWidget(0, m_viewportGLWidget); + else + m_glWidget = new QGLWidget(); if (!m_glWidget->isValid()) { - LOG_ERROR("GraphicsContext3D: QGLWidget does not have a valid context"); - m_contextValid = false; + LOG_ERROR("GraphicsContext3D: QGLWidget initialization failed."); + m_valid = false; return; } - - QGLFormat format = m_glWidget->format(); - m_attrs.alpha = format.alpha(); - m_attrs.depth = format.depth(); - m_attrs.stencil = format.stencil(); + // Geometry can be set to zero because m_glWidget is used only for its QGLContext. + m_glWidget->setGeometry(0, 0, 0, 0); + +#if defined(QT_OPENGL_ES_2) + m_attrs.stencil = false; +#else + if (m_attrs.stencil) + m_attrs.depth = true; +#endif m_attrs.antialias = false; - m_attrs.premultipliedAlpha = true; m_glWidget->makeCurrent(); @@ -408,60 +420,165 @@ GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attribut vertexAttrib4fv = GET_PROC_ADDRESS(glVertexAttrib4fv); vertexAttribPointer = GET_PROC_ADDRESS(glVertexAttribPointer); - if (!m_contextValid) { + if (!m_valid) { LOG_ERROR("GraphicsContext3D: All needed OpenGL extensions are not available"); - m_contextValid = false; return; } + // Create buffers for the canvas FBO. + genFramebuffers(/* count */ 1, &m_canvasFbo); + glGenTextures(1, &m_texture); glBindTexture(GraphicsContext3D::TEXTURE_2D, m_texture); glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); - glTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 1, 1, 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, 0); glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); - genFramebuffers(/* count */ 1, &m_mainFbo); - m_currentFbo = m_mainFbo; + if (m_attrs.depth) + genRenderbuffers(/* count */ 1, &m_depthBuffer); + + // Bind canvas FBO and set initial clear color to black. + m_currentFbo = m_canvasFbo; + bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_canvasFbo); + glClearColor(0.0, 0.0, 0.0, 0.0); +} + +GraphicsContext3DInternal::~GraphicsContext3DInternal() +{ + delete m_glWidget; + m_glWidget = 0; +} + +QGLWidget* GraphicsContext3DInternal::getViewportGLWidget() +{ + QWebPageClient* webPageClient = m_hostWindow->platformPageClient(); + if (!webPageClient) + return 0; + + QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>(webPageClient->ownerWidget()); + if (scrollArea) + return qobject_cast<QGLWidget*>(scrollArea->viewport()); + + return 0; +} + +static inline quint32 swapBgrToRgb(quint32 pixel) +{ + return ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); +} + +void GraphicsContext3DInternal::reshape(int width, int height) +{ + if (width == m_boundingRect.width() && height == m_boundingRect.height()) + return; + + m_boundingRect = QRectF(QPointF(0, 0), QSizeF(width, height)); + + m_glWidget->makeCurrent(); - bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_mainFbo); + // Create color buffer + glBindTexture(GraphicsContext3D::TEXTURE_2D, m_texture); + if (m_attrs.alpha) + glTexImage2D(GraphicsContext3D::TEXTURE_2D, /* level */ 0, GraphicsContext3D::RGBA, width, height, /* border */ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, /* data */ 0); + else + glTexImage2D(GraphicsContext3D::TEXTURE_2D, /* level */ 0, GraphicsContext3D::RGB, width, height, /* border */ 0, GraphicsContext3D::RGB, GraphicsContext3D::UNSIGNED_BYTE, /* data */ 0); + glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); - genRenderbuffers(/* count */ 1, &m_depthBuffer); - bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthBuffer); + if (m_attrs.depth) { + // Create depth and stencil buffers. + bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthBuffer); #if defined(QT_OPENGL_ES_2) - renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT16, /* width */ 1, /* height */ 1); + renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT16, width, height); #else - renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT, /* width */ 1, /* height */ 1); + if (m_attrs.stencil) + renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + else + renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT, width, height); #endif + bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); + } - bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); - + // Construct canvas FBO. + bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_canvasFbo); framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_texture, 0); - framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer); - glClearColor(/* red */ 0, /* green */ 0, /* blue */ 0, /* alpha */ 0); + if (m_attrs.depth) + framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer); +#if !defined(QT_OPENGL_ES_2) + if (m_attrs.stencil) + framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer); +#endif - if (checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { - LOG_ERROR("GraphicsContext3D: Wasn't able to create the main framebuffer"); - m_contextValid = false; + GLenum status = checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER); + if (status != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { + LOG_ERROR("GraphicsContext3D: Canvas FBO initialization failed."); + return; } -} -GraphicsContext3DInternal::~GraphicsContext3DInternal() -{ - delete m_glWidget; - m_glWidget = 0; + int clearFlags = GraphicsContext3D::COLOR_BUFFER_BIT; + if (m_attrs.depth) + clearFlags |= GraphicsContext3D::DEPTH_BUFFER_BIT; + if (m_attrs.stencil) + clearFlags |= GraphicsContext3D::STENCIL_BUFFER_BIT; + + glClear(clearFlags); + glFlush(); } -QGLWidget* GraphicsContext3DInternal::getOwnerGLWidget(QWebPageClient* webPageClient) +void GraphicsContext3DInternal::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { - QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>(webPageClient->ownerWidget()); + Q_UNUSED(widget); - if (scrollArea) - return qobject_cast<QGLWidget*>(scrollArea->viewport()); + QRectF rect = option ? option->rect : boundingRect(); - return 0; + // Use direct texture mapping if WebGL canvas has a shared OpenGL context + // with browsers OpenGL context. + QGLWidget* viewportGLWidget = getViewportGLWidget(); + if (viewportGLWidget && viewportGLWidget == m_viewportGLWidget && viewportGLWidget == painter->device()) { + viewportGLWidget->drawTexture(rect, m_texture); + return; + } + + // Alternatively read pixels to a memory buffer. + QImage offscreenImage(rect.width(), rect.height(), QImage::Format_ARGB32); + quint32* imagePixels = reinterpret_cast<quint32*>(offscreenImage.bits()); + + m_glWidget->makeCurrent(); + bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_canvasFbo); + glReadPixels(/* x */ 0, /* y */ 0, rect.width(), rect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, imagePixels); + + bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_currentFbo); + + // OpenGL gives us ABGR on 32 bits, and with the origin at the bottom left + // We need RGB32 or ARGB32_PM, with the origin at the top left. + quint32* pixelsSrc = imagePixels; + const int height = static_cast<int>(rect.height()); + const int width = static_cast<int>(rect.width()); + const int halfHeight = height / 2; + for (int row = 0; row < halfHeight; ++row) { + const int targetIdx = (height - 1 - row) * width; + quint32* pixelsDst = imagePixels + targetIdx; + for (int column = 0; column < width; ++column) { + quint32 tempPixel = *pixelsSrc; + *pixelsSrc = swapBgrToRgb(*pixelsDst); + *pixelsDst = swapBgrToRgb(tempPixel); + ++pixelsSrc; + ++pixelsDst; + } + } + if (static_cast<int>(height) % 2) { + for (int column = 0; column < width; ++column) { + *pixelsSrc = swapBgrToRgb(*pixelsSrc); + ++pixelsSrc; + } + } + painter->drawImage(/* x */ 0, /* y */ 0, offscreenImage); +} + +QRectF GraphicsContext3DInternal::boundingRect() const +{ + return m_boundingRect; } void* GraphicsContext3DInternal::getProcAddress(const String& proc) @@ -477,7 +594,7 @@ void* GraphicsContext3DInternal::getProcAddress(const String& proc) } LOG_ERROR("GraphicsContext3D: Did not find GL function %s", proc.utf8().data()); - m_contextValid = false; + m_valid = false; return 0; } @@ -493,7 +610,7 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool) : m_internal(new GraphicsContext3DInternal(attrs, hostWindow)) { - if (!m_internal->isContextValid()) + if (!m_internal->isValid()) m_internal = 0; } @@ -511,6 +628,11 @@ Platform3DObject GraphicsContext3D::platformTexture() const return m_internal->m_texture; } +PlatformLayer* GraphicsContext3D::platformLayer() const +{ + return m_internal.get(); +} + void GraphicsContext3D::makeContextCurrent() { m_internal->m_glWidget->makeCurrent(); @@ -522,62 +644,25 @@ void GraphicsContext3D::paintRenderingResultsToCanvas(CanvasRenderingContext* co HTMLCanvasElement* canvas = context->canvas(); ImageBuffer* imageBuffer = canvas->buffer(); QPainter* painter = imageBuffer->context()->platformContext(); - paint(painter, QRect(QPoint(0, 0), QSize(m_currentWidth, m_currentHeight))); + m_internal->paint(painter, 0, 0); } -void GraphicsContext3D::paint(QPainter* painter, const QRect& rect) const +PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData() { -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) - QWebPageClient* webPageClient = m_internal->m_hostWindow->platformPageClient(); - QGLWidget* ownerGLWidget = m_internal->getOwnerGLWidget(webPageClient); - if (ownerGLWidget) { - ownerGLWidget->drawTexture(rect, m_internal->m_texture); - return; - } -#endif - m_internal->m_glWidget->makeCurrent(); - m_internal->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_internal->m_mainFbo); - glReadPixels(/* x */ 0, /* y */ 0, m_currentWidth, m_currentHeight, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, m_internal->m_pixels.bits()); - painter->drawImage(/* x */ 0, /* y */ 0, m_internal->m_pixels.rgbSwapped().transformed(QMatrix().rotate(180))); - m_internal->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_internal->m_currentFbo); + // FIXME: This needs to be implemented for proper non-premultiplied-alpha + // support. + return 0; } void GraphicsContext3D::reshape(int width, int height) { - if (((width == m_currentWidth) && (height == m_currentHeight)) || (!m_internal)) + if (width == m_currentWidth && height == m_currentHeight || (!m_internal)) return; - + m_currentWidth = width; m_currentHeight = height; - m_internal->m_pixels = QImage(m_currentWidth, m_currentHeight, QImage::Format_ARGB32); - - m_internal->m_glWidget->makeCurrent(); - - glBindTexture(GraphicsContext3D::TEXTURE_2D, m_internal->m_texture); - glTexImage2D(GraphicsContext3D::TEXTURE_2D, /* level */ 0, GraphicsContext3D::RGBA, width, height, /* border */ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, /* data */ 0); - glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); - - m_internal->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_internal->m_mainFbo); - m_internal->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_internal->m_depthBuffer); -#if defined(QT_OPENGL_ES_2) - renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT16, width, height); -#else - renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT, width, height); -#endif - m_internal->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); - - m_internal->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_internal->m_texture, 0); - m_internal->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_internal->m_depthBuffer); - - GLenum status = m_internal->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER); - if (status != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { - LOG_ERROR("GraphicsContext3D: Wasn't able to reshape the main framebuffer"); - notImplemented(); - } - - glClear(GraphicsContext3D::COLOR_BUFFER_BIT); - glFlush(); + m_internal->reshape(width, height); } IntSize GraphicsContext3D::getInternalFramebufferSize() @@ -626,7 +711,7 @@ void GraphicsContext3D::bindBuffer(GC3Denum target, Platform3DObject buffer) void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer) { m_internal->m_glWidget->makeCurrent(); - m_internal->m_currentFbo = buffer ? buffer : m_internal->m_mainFbo; + m_internal->m_currentFbo = buffer ? buffer : m_internal->m_canvasFbo; m_internal->bindFramebuffer(target, m_internal->m_currentFbo); } @@ -1064,6 +1149,23 @@ void GraphicsContext3D::releaseShaderCompiler() void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) { m_internal->m_glWidget->makeCurrent(); +#if !defined(QT_OPENGL_ES_2) + switch (internalformat) { + case DEPTH_STENCIL: + internalformat = GL_DEPTH24_STENCIL8; + break; + case DEPTH_COMPONENT16: + internalformat = DEPTH_COMPONENT; + break; + case RGBA4: + case RGB5_A1: + internalformat = RGBA; + break; + case RGB565: + internalformat = RGB; + break; + } +#endif m_internal->renderbufferStorage(target, internalformat, width, height); } @@ -1598,6 +1700,22 @@ void GraphicsContext3D::synthesizeGLError(GC3Denum error) m_internal->m_syntheticErrors.add(error); } +void GraphicsContext3D::markLayerComposited() +{ + m_internal->m_layerComposited = true; +} + +void GraphicsContext3D::markContextChanged() +{ + // FIXME: Any accelerated compositor needs to be told to re-read from here. + m_internal->m_layerComposited = false; +} + +bool GraphicsContext3D::layerComposited() const +{ + return m_internal->m_layerComposited; +} + Extensions3D* GraphicsContext3D::getExtensions() { if (!m_internal->m_extensions) diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 9742755..e3e0fa6 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -9,6 +9,7 @@ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de> * Copyright (C) 2010, 2011 Sencha, Inc. + * Copyright (C) 2011 Andreas Kling <kling@webkit.org> * * All rights reserved. * @@ -672,8 +673,6 @@ void GraphicsContext::fillRect(const FloatRect& rect) ContextShadow* shadow = contextShadow(); if (m_state.fillPattern) { - AffineTransform affine; - QBrush brush(m_state.fillPattern->createPlatformPattern(affine)); QPixmap* image = m_state.fillPattern->tileImage()->nativeImageForCurrentFrame(); QPainter* shadowPainter = hasShadow() ? shadow->beginShadowLayer(this, normalizedRect) : 0; if (shadowPainter) { diff --git a/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp index f3cfc47..1f77fc2 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp @@ -310,10 +310,6 @@ public: } } m_state; -#if ENABLE(WEBGL) - const GraphicsContext3D* m_gc3D; -#endif - #ifndef QT_NO_ANIMATION friend class AnimationQtBase; #endif @@ -340,9 +336,6 @@ GraphicsLayerQtImpl::GraphicsLayerQtImpl(GraphicsLayerQt* newLayer) #if ENABLE(TILED_BACKING_STORE) , m_tiledBackingStore(0) #endif -#if ENABLE(WEBGL) - , m_gc3D(0) -#endif { // We use graphics-view for compositing-only, not for interactivity. setAcceptedMouseButtons(Qt::NoButton); @@ -665,11 +658,6 @@ void GraphicsLayerQtImpl::paint(QPainter* painter, const QStyleOptionGraphicsIte case MediaContentType: // we don't need to paint anything: we have a QGraphicsItem from the media element break; -#if ENABLE(WEBGL) - case Canvas3DContentType: - m_gc3D->paint(painter, option->rect); - break; -#endif } } @@ -808,16 +796,6 @@ void GraphicsLayerQtImpl::flushChanges(bool recursive, bool forceUpdateTransform setFlag(ItemHasNoContents, !m_layer->drawsContent()); break; - -#if ENABLE(WEBGL) - case Canvas3DContentType: - if (m_pendingContent.contentType != m_currentContent.contentType) - update(); - - setCacheMode(NoCache); - setFlag(ItemHasNoContents, false); - break; -#endif } } @@ -1268,23 +1246,6 @@ void GraphicsLayerQt::setContentsBackgroundColor(const Color& color) GraphicsLayer::setContentsBackgroundColor(color); } -#if ENABLE(WEBGL) -void GraphicsLayerQt::setContentsToGraphicsContext3D(const GraphicsContext3D* ctx) -{ - if (ctx == m_impl->m_gc3D) - return; - - m_impl->m_pendingContent.contentType = GraphicsLayerQtImpl::Canvas3DContentType; - m_impl->m_gc3D = ctx; - m_impl->notifyChange(GraphicsLayerQtImpl::ContentChange); -} - -void GraphicsLayerQt::setGraphicsContext3DNeedsDisplay() -{ - setNeedsDisplay(); -} -#endif - void GraphicsLayerQt::setContentsToMedia(PlatformLayer* media) { if (media) { @@ -1297,6 +1258,11 @@ void GraphicsLayerQt::setContentsToMedia(PlatformLayer* media) GraphicsLayer::setContentsToMedia(media); } +void GraphicsLayerQt::setContentsToCanvas(PlatformLayer* canvas) +{ + setContentsToMedia(canvas); +} + /* \reimp (GraphicsLayer.h) */ void GraphicsLayerQt::setContentsOrientation(CompositingCoordinatesOrientation orientation) diff --git a/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.h b/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.h index 569bd8d..2af98fd 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.h +++ b/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.h @@ -20,9 +20,6 @@ #ifndef GraphicsLayerQt_h #define GraphicsLayerQt_h -#if ENABLE(WEBGL) -#include "GraphicsContext3D.h" -#endif #include "GraphicsLayer.h" #include "GraphicsLayerClient.h" @@ -78,11 +75,8 @@ public: virtual void setContentsToImage(Image*); virtual void setContentsNeedsDisplay(); virtual void setContentsToMedia(PlatformLayer*); + virtual void setContentsToCanvas(PlatformLayer*); virtual void setContentsBackgroundColor(const Color&); -#if ENABLE(WEBGL) - virtual void setContentsToGraphicsContext3D(const GraphicsContext3D*); - virtual void setGraphicsContext3DNeedsDisplay(); -#endif virtual void setContentsOrientation(CompositingCoordinatesOrientation orientation); virtual void distributeOpacity(float); virtual float accumulatedOpacity() const; diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferData.h b/Source/WebCore/platform/graphics/qt/ImageBufferData.h index aa32253..602197e 100644 --- a/Source/WebCore/platform/graphics/qt/ImageBufferData.h +++ b/Source/WebCore/platform/graphics/qt/ImageBufferData.h @@ -42,6 +42,8 @@ class ImageBufferData { public: ImageBufferData(const IntSize&); + QImage toQImage() const; + QPixmap m_pixmap; OwnPtr<QPainter> m_painter; RefPtr<Image> m_image; diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp index 62f5c3e..f7d63ca 100644 --- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp +++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp @@ -80,6 +80,21 @@ ImageBufferData::ImageBufferData(const IntSize& size) m_image = StillImage::createForRendering(&m_pixmap); } +QImage ImageBufferData::toQImage() const +{ + QPaintEngine* paintEngine = m_pixmap.paintEngine(); + if (!paintEngine || paintEngine->type() != QPaintEngine::Raster) + return m_pixmap.toImage(); + + // QRasterPixmapData::toImage() will deep-copy the backing QImage if there's an active QPainter on it. + // For performance reasons, we don't want that here, so we temporarily redirect the paint engine. + QPaintDevice* currentPaintDevice = paintEngine->paintDevice(); + paintEngine->setPaintDevice(0); + QImage image = m_pixmap.toImage(); + paintEngine->setPaintDevice(currentPaintDevice); + return image; +} + ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, RenderingMode, bool& success) : m_data(size) , m_size(size) @@ -159,7 +174,7 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable) if (isPainting) m_data.m_painter->end(); - QImage image = m_data.m_pixmap.toImage().convertToFormat(QImage::Format_ARGB32); + QImage image = m_data.toQImage().convertToFormat(QImage::Format_ARGB32); ASSERT(!image.isNull()); uchar* bits = image.bits(); @@ -214,16 +229,12 @@ PassRefPtr<ByteArray> getImageData(const IntRect& rect, const ImageBufferData& i int numRows = endy - originy; // NOTE: For unmultiplied data, we undo the premultiplication below. - QImage image = imageData.m_pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); + QImage image = imageData.toQImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); ASSERT(!image.isNull()); const int bytesPerLine = image.bytesPerLine(); -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) const uchar* bits = image.constBits(); -#else - const uchar* bits = image.bits(); -#endif quint32* destRows = reinterpret_cast_ptr<quint32*>(&data[desty * rect.width() * 4 + destx * 4]); diff --git a/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp index 3540994..8cda231 100644 --- a/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp +++ b/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp @@ -194,15 +194,7 @@ void ImageDecoderQt::internalReadImage(size_t frameIndex) bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex) { - QPixmap pixmap; - -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) - pixmap = QPixmap::fromImageReader(m_reader.get()); -#else - QImage img; - if (m_reader->read(&img)) - pixmap = QPixmap::fromImage(img); -#endif + QPixmap pixmap = QPixmap::fromImageReader(m_reader.get()); if (pixmap.isNull()) { frameCount(); diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp index 001d45b..bc43acf 100644 --- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp +++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp @@ -74,7 +74,7 @@ void MediaPlayerPrivateQt::getSupportedTypes(HashSet<String> &supported) for (int i = 0; i < types.size(); i++) { QString mime = types.at(i); - if (mime.startsWith("audio/") || mime.startsWith("video/")) + if (mime.startsWith(QString::fromLatin1("audio/")) || mime.startsWith(QString::fromLatin1("video/"))) supported.add(mime); } } @@ -103,7 +103,6 @@ MediaPlayerPrivateQt::MediaPlayerPrivateQt(MediaPlayer* player) , m_isVisible(false) , m_isSeeking(false) , m_composited(false) - , m_queuedSeek(-1) , m_preload(MediaPlayer::Auto) , m_suppressNextPlaybackChanged(false) { @@ -195,7 +194,7 @@ void MediaPlayerPrivateQt::commitLoad(const String& url) HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient()); // Construct the media content with a network request if the resource is http[s] - if (scheme == "http" || scheme == "https") { + if (scheme == QString::fromLatin1("http") || scheme == QString::fromLatin1("https")) { QNetworkRequest request = QNetworkRequest(rUrl); // Grab the current document @@ -220,7 +219,7 @@ void MediaPlayerPrivateQt::commitLoad(const String& url) // Set the refferer, but not when requesting insecure content from a secure page QUrl documentUrl = QUrl(QString(document->documentURI())); - if (documentUrl.scheme().toLower() == "http" || scheme == "https") + if (documentUrl.scheme().toLower() == QString::fromLatin1("http") || scheme == QString::fromLatin1("https")) request.setRawHeader("Referer", documentUrl.toEncoded()); // Set the user agent @@ -296,32 +295,8 @@ void MediaPlayerPrivateQt::seek(float position) if (m_mediaPlayerControl && !m_mediaPlayerControl->availablePlaybackRanges().contains(position * 1000)) return; - if (m_isSeeking) - return; - - if (position > duration()) - position = duration(); - - // Seeking is most reliable when we're paused. - // Webkit will try to pause before seeking, but due to the asynchronous nature - // of the backend, the player may not actually be paused yet. - // In this case, we should queue the seek and wait until pausing has completed - // before attempting to seek. - if (m_mediaPlayer->state() == QMediaPlayer::PlayingState) { - m_mediaPlayer->pause(); - m_isSeeking = true; - m_queuedSeek = static_cast<qint64>(position * 1000); - - // Set a timeout, so that in the event that we don't get a state changed - // signal, we still attempt the seek. - QTimer::singleShot(1000, this, SLOT(queuedSeekTimeout())); - } else { - m_isSeeking = true; - m_mediaPlayer->setPosition(static_cast<qint64>(position * 1000)); - - // Set a timeout, in case we don't get a position changed signal - QTimer::singleShot(10000, this, SLOT(seekTimeout())); - } + m_isSeeking = true; + m_mediaPlayer->setPosition(static_cast<qint64>(position * 1000)); } bool MediaPlayerPrivateQt::seeking() const @@ -443,13 +418,8 @@ void MediaPlayerPrivateQt::handleError(QMediaPlayer::Error) updateStates(); } -void MediaPlayerPrivateQt::stateChanged(QMediaPlayer::State state) +void MediaPlayerPrivateQt::stateChanged(QMediaPlayer::State) { - if (state != QMediaPlayer::PlayingState && m_isSeeking && m_queuedSeek >= 0) { - m_mediaPlayer->setPosition(m_queuedSeek); - m_queuedSeek = -1; - } - if (!m_suppressNextPlaybackChanged) m_webCorePlayer->playbackStateChanged(); else @@ -468,34 +438,12 @@ void MediaPlayerPrivateQt::nativeSizeChanged(const QSizeF& size) m_webCorePlayer->sizeChanged(); } -void MediaPlayerPrivateQt::queuedSeekTimeout() -{ - // If we haven't heard anything, assume the player is now paused - // and we can attempt the seek - if (m_isSeeking && m_queuedSeek >= 0) { - m_mediaPlayer->setPosition(m_queuedSeek); - m_queuedSeek = -1; - - // Set a timeout, in case we don't get a position changed signal - QTimer::singleShot(10000, this, SLOT(seekTimeout())); - } -} - -void MediaPlayerPrivateQt::seekTimeout() -{ - // If we haven't heard anything, assume the seek succeeded - if (m_isSeeking) { - m_webCorePlayer->timeChanged(); - m_isSeeking = false; - } -} - void MediaPlayerPrivateQt::positionChanged(qint64) { // Only propagate this event if we are seeking - if (m_isSeeking && m_queuedSeek == -1) { - m_webCorePlayer->timeChanged(); + if (m_isSeeking) { m_isSeeking = false; + m_webCorePlayer->timeChanged(); } } @@ -649,7 +597,7 @@ void MediaPlayerPrivateQt::repaint() #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) -class TextureMapperVideoLayerQt : public virtual TextureMapperVideoLayer { +class TextureMapperVideoLayerQt : public virtual TextureMapperMediaLayer { public: TextureMapperVideoLayerQt(QGraphicsVideoItem* videoItem) : m_videoItem(videoItem) diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h index 81cdd79..c6398c9 100644 --- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h +++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h @@ -33,7 +33,7 @@ QT_END_NAMESPACE namespace WebCore { -class TextureMapperVideoLayer; +class TextureMapperMediaLayer; class MediaPlayerPrivateQt : public QObject, public MediaPlayerPrivateInterface { @@ -120,8 +120,6 @@ private slots: void handleError(QMediaPlayer::Error); void stateChanged(QMediaPlayer::State); void nativeSizeChanged(const QSizeF&); - void queuedSeekTimeout(); - void seekTimeout(); void positionChanged(qint64); void durationChanged(qint64); void bufferStatusChanged(int); @@ -141,7 +139,7 @@ private: QGraphicsVideoItem* m_videoItem; QGraphicsScene* m_videoScene; #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) - OwnPtr<TextureMapperVideoLayer> m_platformLayer; + OwnPtr<TextureMapperMediaLayer> m_platformLayer; #endif mutable MediaPlayer::NetworkState m_networkState; @@ -153,7 +151,6 @@ private: bool m_isVisible; bool m_isSeeking; bool m_composited; - qint64 m_queuedSeek; MediaPlayer::Preload m_preload; bool m_delayingLoad; String m_mediaUrl; diff --git a/Source/WebCore/platform/graphics/qt/PathQt.cpp b/Source/WebCore/platform/graphics/qt/PathQt.cpp index ad482f7..ccc7f3d 100644 --- a/Source/WebCore/platform/graphics/qt/PathQt.cpp +++ b/Source/WebCore/platform/graphics/qt/PathQt.cpp @@ -154,7 +154,7 @@ FloatRect Path::boundingRect() const return m_path.boundingRect(); } -FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) +FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const { GraphicsContext* context = scratchContext(); QPainterPathStroker stroke; @@ -398,23 +398,15 @@ void Path::apply(void* info, PathApplierFunction function) const void Path::transform(const AffineTransform& transform) { QTransform qTransform(transform); -#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) - // Workaround for http://bugreports.qt.nokia.com/browse/QTBUG-11264 - // QTransform.map doesn't handle the MoveTo element because of the isEmpty issue - if (m_path.isEmpty() && m_path.elementCount()) { - QPointF point = qTransform.map(m_path.currentPosition()); - moveTo(point); - } else -#endif - m_path = qTransform.map(m_path); -} - -float Path::length() + m_path = qTransform.map(m_path); +} + +float Path::length() const { return m_path.length(); } -FloatPoint Path::pointAtLength(float length, bool& ok) +FloatPoint Path::pointAtLength(float length, bool& ok) const { ok = (length >= 0 && length <= m_path.length()); @@ -424,7 +416,7 @@ FloatPoint Path::pointAtLength(float length, bool& ok) return point; } -float Path::normalAngleAtLength(float length, bool& ok) +float Path::normalAngleAtLength(float length, bool& ok) const { ok = (length >= 0 && length <= m_path.length()); diff --git a/Source/WebCore/platform/graphics/qt/TileQt.cpp b/Source/WebCore/platform/graphics/qt/TileQt.cpp index 096ce14..8723cd4 100644 --- a/Source/WebCore/platform/graphics/qt/TileQt.cpp +++ b/Source/WebCore/platform/graphics/qt/TileQt.cpp @@ -91,10 +91,10 @@ void Tile::invalidate(const IntRect& dirtyRect) *m_dirtyRegion += tileDirtyRect; } -void Tile::updateBackBuffer() +Vector<IntRect> Tile::updateBackBuffer() { if (m_buffer && !isDirty()) - return; + return Vector<IntRect>(); if (!m_backBuffer) { if (!m_buffer) { @@ -115,15 +115,19 @@ void Tile::updateBackBuffer() GraphicsContext context(&painter); context.translate(-m_rect.x(), -m_rect.y()); + Vector<IntRect> updatedRects; int size = dirtyRects.size(); for (int n = 0; n < size; ++n) { context.save(); IntRect rect = dirtyRects[n]; + updatedRects.append(rect); context.clip(FloatRect(rect)); context.scale(FloatSize(m_backingStore->m_contentsScale, m_backingStore->m_contentsScale)); m_backingStore->m_client->tiledBackingStorePaint(&context, m_backingStore->mapToContents(rect)); context.restore(); } + + return updatedRects; } void Tile::swapBackBufferToFront() |