summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/qt
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics/qt')
-rw-r--r--Source/WebCore/platform/graphics/qt/FontCacheQt.cpp8
-rw-r--r--Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h2
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp34
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp11
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h6
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp151
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp6
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageDecoderQt.h6
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageQt.cpp90
-rw-r--r--Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp142
-rw-r--r--Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h21
-rw-r--r--Source/WebCore/platform/graphics/qt/PathQt.cpp9
-rw-r--r--Source/WebCore/platform/graphics/qt/PatternQt.cpp6
-rw-r--r--Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp12
-rw-r--r--Source/WebCore/platform/graphics/qt/StillImageQt.cpp28
-rw-r--r--Source/WebCore/platform/graphics/qt/StillImageQt.h16
-rw-r--r--Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp2
-rw-r--r--Source/WebCore/platform/graphics/qt/TransparencyLayer.h14
18 files changed, 286 insertions, 278 deletions
diff --git a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp
index b58198fa3..6d1ee72f2 100644
--- a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp
@@ -25,9 +25,9 @@
#include "config.h"
#include "FontCache.h"
+#include "Font.h"
#include "FontDescription.h"
#include "FontPlatformData.h"
-#include "Font.h"
#include <utility>
#include <wtf/ListHashSet.h>
#include <wtf/StdLibExtras.h>
@@ -63,7 +63,7 @@ static QRawFont rawFontForCharacters(const QString& string, const QRawFont& font
return glyphs.rawFont();
}
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
{
QString qstring = QString::fromRawData(reinterpret_cast<const QChar*>(characters), length);
QRawFont computedFont = rawFontForCharacters(qstring, font.rawFont());
@@ -73,12 +73,12 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, cons
return getCachedFontData(&alternateFont, DoNotRetain);
}
-SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
+PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
{
return 0;
}
-SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
+PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
{
const AtomicString fallbackFamily = QFont(fontDescription.family().family()).lastResortFamily();
return getCachedFontData(new FontPlatformData(fontDescription, fallbackFamily), shouldRetain);
diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h
index fbf9a158d..8d4efeca2 100644
--- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h
+++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h
@@ -26,10 +26,10 @@
#include "FontRenderingMode.h"
#include "FontWidthVariant.h"
#include "TextOrientation.h"
+#include <QRawFont>
#include <wtf/FastAllocBase.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
-#include <QRawFont>
namespace WebCore {
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index 1678c49fa..69aa86591 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -69,7 +69,7 @@ public:
#endif
#if USE(GRAPHICS_SURFACE)
virtual uint32_t copyToGraphicsSurface();
- virtual uint64_t graphicsSurfaceToken() const;
+ virtual GraphicsSurfaceToken graphicsSurfaceToken() const;
#endif
QRectF boundingRect() const;
@@ -100,13 +100,6 @@ bool GraphicsContext3D::isGLES2Compliant() const
#endif
}
-#if !USE(OPENGL_ES_2)
-void GraphicsContext3D::releaseShaderCompiler()
-{
- notImplemented();
-}
-#endif
-
GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
: m_context(context)
, m_hostWindow(hostWindow)
@@ -206,6 +199,11 @@ void GraphicsContext3DPrivate::initializeANGLE()
// Always set to 1 for OpenGL ES.
ANGLEResources.MaxDrawBuffers = 1;
+
+ Extensions3D* extensions = m_context->getExtensions();
+ if (extensions->supports("GL_ARB_texture_rectangle"))
+ ANGLEResources.ARB_texture_rectangle = 1;
+
m_context->m_compiler.setResources(ANGLEResources);
}
@@ -291,7 +289,7 @@ uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
return frontBuffer;
}
-uint64_t GraphicsContext3DPrivate::graphicsSurfaceToken() const
+GraphicsSurfaceToken GraphicsContext3DPrivate::graphicsSurfaceToken() const
{
return m_graphicsSurface->exportToken();
}
@@ -492,16 +490,18 @@ bool GraphicsContext3D::getImageData(Image* image,
if (!image)
return false;
- QImage nativeImage;
+ QImage qtImage;
// Is image already loaded? If not, load it.
if (image->data())
- nativeImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size());
- else
- nativeImage = *image->nativeImageForCurrentFrame();
-
+ qtImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size());
+ else {
+ QPixmap* nativePixmap = image->nativeImageForCurrentFrame();
+ // With QPA, we can avoid a deep copy.
+ qtImage = *nativePixmap->handle()->buffer();
+ }
AlphaOp alphaOp = AlphaDoNothing;
- switch (nativeImage.format()) {
+ switch (qtImage.format()) {
case QImage::Format_RGB32:
// For opaque images, we should not premultiply or unmultiply alpha.
break;
@@ -515,7 +515,7 @@ bool GraphicsContext3D::getImageData(Image* image,
break;
default:
// The image has a format that is not supported in packPixels. We have to convert it here.
- nativeImage = nativeImage.convertToFormat(premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32);
+ qtImage = qtImage.convertToFormat(premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32);
break;
}
@@ -526,7 +526,7 @@ bool GraphicsContext3D::getImageData(Image* image,
outputVector.resize(packedSize);
- return packPixels(nativeImage.constBits(), SourceFormatBGRA8, image->width(), image->height(), 0, format, type, alphaOp, outputVector.data());
+ return packPixels(qtImage.constBits(), SourceFormatBGRA8, image->width(), image->height(), 0, format, type, alphaOp, outputVector.data());
}
void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback>)
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index 5c8a3ae24..c2ab6dfb0 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -283,12 +283,13 @@ GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p, cons
GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
{
+ delete shadow;
+
if (!platformContextIsOwned)
return;
QPaintDevice* device = painter->device();
painter->end();
- delete shadow;
delete painter;
delete device;
}
@@ -1066,7 +1067,7 @@ void GraphicsContext::clearPlatformShadow()
m_data->shadow->clear();
}
-void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QImage& alphaMask)
+void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask)
{
QPainter* p = m_data->p();
@@ -1101,7 +1102,7 @@ void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
h = int(qBound(qreal(0), deviceClip.height(), (qreal)h) + 2);
}
- QImage emptyAlphaMask;
+ QPixmap emptyAlphaMask;
m_data->layers.push(new TransparencyLayer(p, QRect(x, y, w, h), opacity, emptyAlphaMask));
++m_data->layerCount;
}
@@ -1115,7 +1116,7 @@ void GraphicsContext::endPlatformTransparencyLayer()
if (!layer->alphaMask.isNull()) {
layer->painter.resetTransform();
layer->painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- layer->painter.drawImage(QPoint(), layer->alphaMask);
+ layer->painter.drawPixmap(QPoint(), layer->alphaMask);
} else
--m_data->layerCount; // see the comment for layerCount
layer->painter.end();
@@ -1124,7 +1125,7 @@ void GraphicsContext::endPlatformTransparencyLayer()
p->save();
p->resetTransform();
p->setOpacity(layer->opacity);
- p->drawImage(layer->offset, layer->image);
+ p->drawPixmap(layer->offset, layer->pixmap);
p->restore();
delete layer;
diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
index 94065d3a6..9cf782bea 100644
--- a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
+++ b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
@@ -25,8 +25,8 @@
#include "Image.h"
-#include <QImage>
#include <QPainter>
+#include <QPixmap>
#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>
@@ -39,7 +39,9 @@ class ImageBufferData {
public:
ImageBufferData(const IntSize&);
- QImage m_nativeImage;
+ 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 32dd39a5f..ac27dc25a 100644
--- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -32,7 +32,6 @@
#include "GraphicsContext.h"
#include "ImageData.h"
#include "MIMETypeRegistry.h"
-#include "NativeImageQt.h"
#include "StillImageQt.h"
#include "TransparencyLayer.h"
#include <wtf/text/CString.h>
@@ -43,22 +42,23 @@
#include <QImage>
#include <QImageWriter>
#include <QPainter>
+#include <QPixmap>
#include <math.h>
namespace WebCore {
ImageBufferData::ImageBufferData(const IntSize& size)
- : m_nativeImage(size, NativeImageQt::defaultFormatForAlphaEnabledImages())
+ : m_pixmap(size)
{
- if (m_nativeImage.isNull())
+ if (m_pixmap.isNull())
return;
- m_nativeImage.fill(QColor(Qt::transparent));
+ m_pixmap.fill(QColor(Qt::transparent));
QPainter* painter = new QPainter;
m_painter = adoptPtr(painter);
- if (!painter->begin(&m_nativeImage))
+ if (!painter->begin(&m_pixmap))
return;
// Since ImageBuffer is used mainly for Canvas, explicitly initialize
@@ -76,7 +76,22 @@ ImageBufferData::ImageBufferData(const IntSize& size)
painter->setBrush(brush);
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
- m_image = StillImage::createForRendering(&m_nativeImage);
+ 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, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, bool& success)
@@ -105,9 +120,9 @@ GraphicsContext* ImageBuffer::context() const
PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior) const
{
if (copyBehavior == CopyBackingStore)
- return StillImage::create(m_data.m_nativeImage);
+ return StillImage::create(m_data.m_pixmap);
- return StillImage::createForRendering(&m_data.m_nativeImage);
+ return StillImage::createForRendering(&m_data.m_pixmap);
}
void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
@@ -134,12 +149,12 @@ void ImageBuffer::drawPattern(GraphicsContext* destContext, const FloatRect& src
void ImageBuffer::clip(GraphicsContext* context, const FloatRect& floatRect) const
{
- QImage* nativeImage = m_data.m_image->nativeImageForCurrentFrame();
+ QPixmap* nativeImage = m_data.m_image->nativeImageForCurrentFrame();
if (!nativeImage)
return;
IntRect rect = enclosingIntRect(floatRect);
- QImage alphaMask = *nativeImage;
+ QPixmap alphaMask = *nativeImage;
context->pushTransparencyLayerInternal(rect, 1.0, alphaMask);
}
@@ -150,7 +165,7 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
if (isPainting)
m_data.m_painter->end();
- QImage image = m_data.m_nativeImage.convertToFormat(QImage::Format_ARGB32);
+ QImage image = m_data.toQImage().convertToFormat(QImage::Format_ARGB32);
ASSERT(!image.isNull());
uchar* bits = image.bits();
@@ -167,10 +182,20 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
}
}
- m_data.m_nativeImage = image;
+ m_data.m_pixmap = QPixmap::fromImage(image);
if (isPainting)
- m_data.m_painter->begin(&m_data.m_nativeImage);
+ m_data.m_painter->begin(&m_data.m_pixmap);
+}
+
+static inline quint32 convertABGRToARGB(quint32 pixel)
+{
+ return ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
+}
+
+static inline quint32 convertARGBToABGR(quint32 pixel)
+{
+ return convertABGRToARGB(pixel);
}
template <Multiply multiplied>
@@ -209,7 +234,7 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBuffe
int numRows = endy - originy;
// NOTE: For unmultiplied data, we undo the premultiplication below.
- QImage image = imageData.m_nativeImage.convertToFormat(NativeImageQt::defaultFormatForAlphaEnabledImages());
+ QImage image = imageData.toQImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
ASSERT(!image.isNull());
@@ -217,40 +242,18 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBuffe
const uchar* bits = image.constBits();
quint32* destRows = reinterpret_cast_ptr<quint32*>(&data[desty * rect.width() * 4 + destx * 4]);
-
- if (multiplied == Unmultiplied) {
- for (int y = 0; y < numRows; ++y) {
- const quint32* scanLine = reinterpret_cast_ptr<const quint32*>(bits + (y + originy) * bytesPerLine);
- for (int x = 0; x < numColumns; x++) {
- QRgb pixel = scanLine[x + originx];
- int alpha = qAlpha(pixel);
- // Un-premultiply and convert RGB to BGR.
- if (alpha == 255)
- destRows[x] = (0xFF000000
- | (qBlue(pixel) << 16)
- | (qGreen(pixel) << 8)
- | (qRed(pixel)));
- else if (alpha > 0)
- destRows[x] = ((alpha << 24)
- | (((255 * qBlue(pixel)) / alpha)) << 16)
- | (((255 * qGreen(pixel)) / alpha) << 8)
- | ((255 * qRed(pixel)) / alpha);
- else
- destRows[x] = 0;
- }
- destRows += rect.width();
- }
- } else {
- for (int y = 0; y < numRows; ++y) {
- const quint32* scanLine = reinterpret_cast_ptr<const quint32*>(bits + (y + originy) * bytesPerLine);
- for (int x = 0; x < numColumns; x++) {
- QRgb pixel = scanLine[x + originx];
- // Convert RGB to BGR.
- destRows[x] = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
-
- }
- destRows += rect.width();
+ for (int y = 0; y < numRows; ++y) {
+ const quint32* scanLine = reinterpret_cast_ptr<const quint32*>(bits + (y + originy) * bytesPerLine);
+ for (int x = 0; x < numColumns; x++) {
+ QRgb pixel = scanLine[x + originx];
+ Color pixelColor;
+ if (multiplied == Unmultiplied)
+ pixelColor = colorFromPremultipliedARGB(Color(qRed(pixel), qGreen(pixel), qBlue(pixel), qAlpha(pixel)).rgb());
+ else
+ pixelColor = Color(qRed(pixel), qGreen(pixel), qBlue(pixel), qAlpha(pixel));
+ destRows[x] = convertARGBToABGR(pixelColor.rgb());
}
+ destRows += rect.width();
}
return result.release();
@@ -266,22 +269,6 @@ PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRe
return getImageData<Premultiplied>(rect, m_data, m_size);
}
-static inline unsigned int premultiplyABGRtoARGB(unsigned int x)
-{
- unsigned int a = x >> 24;
- if (a == 255)
- return (x << 16) | ((x >> 16) & 0xff) | (x & 0xff00ff00);
- unsigned int t = (x & 0xff00ff) * a;
- t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
- t = ((t << 16) | (t >> 16)) & 0xff00ff;
-
- x = ((x >> 8) & 0xff) * a;
- x = (x + ((x >> 8) & 0xff) + 0x80);
- x &= 0xff00;
- x |= t | (a << 24);
- return x;
-}
-
void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)
{
ASSERT(sourceRect.width() > 0);
@@ -319,31 +306,21 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
const quint32* srcScanLine = reinterpret_cast_ptr<const quint32*>(source->data() + originy * srcBytesPerRow + originx * 4);
- if (multiplied == Unmultiplied) {
- for (int y = 0; y < numRows; ++y) {
- quint32* destScanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine);
- for (int x = 0; x < numColumns; x++) {
- // Premultiply and convert BGR to RGB.
- quint32 pixel = srcScanLine[x];
- destScanLine[x] = premultiplyABGRtoARGB(pixel);
- }
- srcScanLine += sourceSize.width();
- }
- } else {
- for (int y = 0; y < numRows; ++y) {
- quint32* destScanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine);
- for (int x = 0; x < numColumns; x++) {
- // Convert BGR to RGB.
- quint32 pixel = srcScanLine[x];
- destScanLine[x] = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
- }
- srcScanLine += sourceSize.width();
+ for (int y = 0; y < numRows; ++y) {
+ quint32* destScanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine);
+ for (int x = 0; x < numColumns; x++) {
+ quint32 pixel = convertABGRToARGB(srcScanLine[x]);
+ if (multiplied == Unmultiplied)
+ destScanLine[x] = premultipliedARGBFromColor(Color(pixel));
+ else
+ destScanLine[x] = pixel;
}
+ srcScanLine += sourceSize.width();
}
bool isPainting = m_data.m_painter->isActive();
if (!isPainting)
- m_data.m_painter->begin(&m_data.m_nativeImage);
+ m_data.m_painter->begin(&m_data.m_pixmap);
else {
m_data.m_painter->save();
@@ -362,7 +339,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
m_data.m_painter->restore();
}
-static bool encodeImage(const QImage& image, const String& format, const double* quality, QByteArray& data)
+static bool encodeImage(const QPixmap& pixmap, const String& format, const double* quality, QByteArray& data)
{
int compressionQuality = 100;
if (quality && *quality >= 0.0 && *quality <= 1.0)
@@ -370,7 +347,7 @@ static bool encodeImage(const QImage& image, const String& format, const double*
QBuffer buffer(&data);
buffer.open(QBuffer::WriteOnly);
- bool success = image.save(&buffer, format.utf8().data(), compressionQuality);
+ bool success = pixmap.save(&buffer, format.utf8().data(), compressionQuality);
buffer.close();
return success;
@@ -382,10 +359,10 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality, Coo
// QImageWriter does not support mimetypes. It does support Qt image formats (png,
// gif, jpeg..., xpm) so skip the image/ to get the Qt image format used to encode
- // the m_nativeImage image.
+ // the m_pixmap image.
QByteArray data;
- if (!encodeImage(m_data.m_nativeImage, mimeType.substring(sizeof "image"), quality, data))
+ if (!encodeImage(m_data.m_pixmap, mimeType.substring(sizeof "image"), quality, data))
return "data:,";
return "data:" + mimeType + ";base64," + data.toBase64().data();
diff --git a/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
index f039e4300..a7d9f7523 100644
--- a/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
@@ -29,8 +29,8 @@
#include "config.h"
#include "ImageDecoderQt.h"
-#include <QtCore/QByteArray>
#include <QtCore/QBuffer>
+#include <QtCore/QByteArray>
#include <QtGui/QImageReader>
namespace WebCore {
@@ -272,7 +272,9 @@ NativeImagePtr ImageFrame::asNewNativeImage() const
else
format = QImage::Format_RGB32;
- return new QImage(reinterpret_cast<uchar*>(m_bytes), m_size.width(), m_size.height(), sizeof(PixelData) * m_size.width(), format);
+ QImage img(reinterpret_cast<uchar*>(m_bytes), m_size.width(), m_size.height(), sizeof(PixelData) * m_size.width(), format);
+
+ return new QPixmap(QPixmap::fromImage(img));
}
}
diff --git a/Source/WebCore/platform/graphics/qt/ImageDecoderQt.h b/Source/WebCore/platform/graphics/qt/ImageDecoderQt.h
index 3e421c336..8ae3b4239 100644
--- a/Source/WebCore/platform/graphics/qt/ImageDecoderQt.h
+++ b/Source/WebCore/platform/graphics/qt/ImageDecoderQt.h
@@ -28,11 +28,11 @@
#define ImageDecoderQt_h
#include "ImageDecoder.h"
+#include <QtCore/QBuffer>
+#include <QtCore/QHash>
+#include <QtCore/QList>
#include <QtGui/QImageReader>
#include <QtGui/QPixmap>
-#include <QtCore/QList>
-#include <QtCore/QHash>
-#include <QtCore/QBuffer>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
diff --git a/Source/WebCore/platform/graphics/qt/ImageQt.cpp b/Source/WebCore/platform/graphics/qt/ImageQt.cpp
index 5be31cea0..fc01c407d 100644
--- a/Source/WebCore/platform/graphics/qt/ImageQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageQt.cpp
@@ -37,7 +37,6 @@
#include "FloatRect.h"
#include "GraphicsContext.h"
#include "ImageObserver.h"
-#include "NativeImageQt.h"
#include "ShadowBlur.h"
#include "StillImageQt.h"
#include <wtf/text/WTFString.h>
@@ -56,7 +55,7 @@
Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP, int hbitmapFormat = 0);
#endif
-typedef QHash<QByteArray, QImage> WebGraphicHash;
+typedef QHash<QByteArray, QPixmap> WebGraphicHash;
Q_GLOBAL_STATIC(WebGraphicHash, _graphics)
static void earlyClearGraphics()
@@ -70,28 +69,28 @@ static WebGraphicHash* graphics()
if (hash->isEmpty()) {
- // prevent ~QImage running after ~QApplication (leaks native images)
+ // prevent ~QPixmap running after ~QApplication (leaks native pixmaps)
qAddPostRoutine(earlyClearGraphics);
// QWebSettings::MissingImageGraphic
- hash->insert("missingImage", QImage(QLatin1String(":webkit/resources/missingImage.png")));
+ hash->insert("missingImage", QPixmap(QLatin1String(":webkit/resources/missingImage.png")));
// QWebSettings::MissingPluginGraphic
- hash->insert("nullPlugin", QImage(QLatin1String(":webkit/resources/nullPlugin.png")));
+ hash->insert("nullPlugin", QPixmap(QLatin1String(":webkit/resources/nullPlugin.png")));
// QWebSettings::DefaultFrameIconGraphic
- hash->insert("urlIcon", QImage(QLatin1String(":webkit/resources/urlIcon.png")));
+ hash->insert("urlIcon", QPixmap(QLatin1String(":webkit/resources/urlIcon.png")));
// QWebSettings::TextAreaSizeGripCornerGraphic
- hash->insert("textAreaResizeCorner", QImage(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
+ hash->insert("textAreaResizeCorner", QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
// QWebSettings::DeleteButtonGraphic
- hash->insert("deleteButton", QImage(QLatin1String(":webkit/resources/deleteButton.png")));
+ hash->insert("deleteButton", QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));
// QWebSettings::InputSpeechButtonGraphic
- hash->insert("inputSpeech", QImage(QLatin1String(":webkit/resources/inputSpeech.png")));
+ hash->insert("inputSpeech", QPixmap(QLatin1String(":webkit/resources/inputSpeech.png")));
}
return hash;
}
// This function loads resources into WebKit
-static QImage loadResourceImage(const char *name)
+static QPixmap loadResourcePixmap(const char *name)
{
return graphics()->value(name);
}
@@ -118,23 +117,23 @@ bool FrameData::clear(bool clearMetadata)
PassRefPtr<Image> Image::loadPlatformResource(const char* name)
{
- return StillImage::create(loadResourceImage(name));
+ return StillImage::create(loadResourcePixmap(name));
}
-void Image::setPlatformResource(const char* name, const QImage& image)
+void Image::setPlatformResource(const char* name, const QPixmap& pixmap)
{
WebGraphicHash* h = graphics();
- if (image.isNull())
+ if (pixmap.isNull())
h->remove(name);
else
- h->insert(name, image);
+ h->insert(name, pixmap);
}
void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& destRect)
{
- QImage* frameImage = nativeImageForCurrentFrame();
- if (!frameImage) // If it's too early we won't have an image yet.
+ QPixmap* framePixmap = nativeImageForCurrentFrame();
+ if (!framePixmap) // If it's too early we won't have an image yet.
return;
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
@@ -149,38 +148,34 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
if (!dr.width() || !dr.height() || !tr.width() || !tr.height())
return;
- QImage image = *frameImage;
- if (tr.x() || tr.y() || tr.width() != image.width() || tr.height() != image.height())
- image = image.copy(tr);
+ QPixmap pixmap = *framePixmap;
+ if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height())
+ pixmap = pixmap.copy(tr);
CompositeOperator previousOperator = ctxt->compositeOperation();
- ctxt->setCompositeOperation(!image.hasAlphaChannel() && op == CompositeSourceOver ? CompositeCopy : op);
+ ctxt->setCompositeOperation(!pixmap.hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
QPainter* p = ctxt->platformContext();
QTransform transform(patternTransform);
- // If this would draw more than one scaled tile, we scale the image first and then use the result to draw.
+ // If this would draw more than one scaled tile, we scale the pixmap first and then use the result to draw.
if (transform.type() == QTransform::TxScale) {
QRectF tileRectInTargetCoords = (transform * QTransform().translate(phase.x(), phase.y())).mapRect(tr);
bool tileWillBePaintedOnlyOnce = tileRectInTargetCoords.contains(dr);
if (!tileWillBePaintedOnlyOnce) {
- QSizeF scaledSize(float(image.width()) * transform.m11(), float(image.height()) * transform.m22());
- QImage scaledImage;
- if (image.hasAlphaChannel()) {
- scaledImage = QImage(scaledSize.toSize(), NativeImageQt::defaultFormatForAlphaEnabledImages());
- scaledImage.fill(Qt::transparent);
- } else
- scaledImage = QImage(scaledSize.toSize(), NativeImageQt::defaultFormatForOpaqueImages());
-
+ QSizeF scaledSize(float(pixmap.width()) * transform.m11(), float(pixmap.height()) * transform.m22());
+ QPixmap scaledPixmap(scaledSize.toSize());
+ if (pixmap.hasAlpha())
+ scaledPixmap.fill(Qt::transparent);
{
- QPainter painter(&scaledImage);
+ QPainter painter(&scaledPixmap);
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.setRenderHints(p->renderHints());
- painter.drawImage(QRect(0, 0, scaledImage.width(), scaledImage.height()), image);
+ painter.drawPixmap(QRect(0, 0, scaledPixmap.width(), scaledPixmap.height()), pixmap);
}
- image = scaledImage;
+ pixmap = scaledPixmap;
transform = QTransform::fromTranslate(transform.dx(), transform.dy());
}
}
@@ -189,7 +184,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
transform *= QTransform().translate(phase.x(), phase.y());
transform.translate(tr.x(), tr.y());
- QBrush b(image);
+ QBrush b(pixmap);
b.setTransform(transform);
p->fillRect(dr, b);
@@ -199,7 +194,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
imageObserver()->didDraw(this);
}
-BitmapImage::BitmapImage(QImage* image, ImageObserver* observer)
+BitmapImage::BitmapImage(QPixmap* pixmap, ImageObserver* observer)
: Image(observer)
, m_currentFrame(0)
, m_frames(0)
@@ -217,14 +212,14 @@ BitmapImage::BitmapImage(QImage* image, ImageObserver* observer)
, m_sizeAvailable(true)
, m_haveFrameCount(true)
{
- int width = image->width();
- int height = image->height();
+ int width = pixmap->width();
+ int height = pixmap->height();
m_decodedSize = width * height * 4;
m_size = IntSize(width, height);
m_frames.grow(1);
- m_frames[0].m_frame = image;
- m_frames[0].m_hasAlpha = image->hasAlphaChannel();
+ m_frames[0].m_frame = pixmap;
+ m_frames[0].m_hasAlpha = pixmap->hasAlpha();
m_frames[0].m_haveMetadata = true;
checkForSolidColor();
}
@@ -245,8 +240,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
if (normalizedSrc.isEmpty() || normalizedDst.isEmpty())
return;
- QImage* image = nativeImageForCurrentFrame();
-
+ QPixmap* image = nativeImageForCurrentFrame();
if (!image)
return;
@@ -260,19 +254,19 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
#endif
CompositeOperator previousOperator = ctxt->compositeOperation();
- ctxt->setCompositeOperation(!image->hasAlphaChannel() && op == CompositeSourceOver ? CompositeCopy : op);
+ ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
if (ctxt->hasShadow()) {
ShadowBlur* shadow = ctxt->shadowBlur();
GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
- shadowPainter->drawImage(normalizedDst, *image, normalizedSrc);
+ shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
shadow->endShadowLayer(ctxt);
}
}
- ctxt->platformContext()->drawImage(normalizedDst, *image, normalizedSrc);
+ ctxt->platformContext()->drawPixmap(normalizedDst, *image, normalizedSrc);
ctxt->setCompositeOperation(previousOperator);
@@ -288,20 +282,20 @@ void BitmapImage::checkForSolidColor()
if (frameCount() > 1)
return;
- QImage* frameImage = frameAtIndex(0);
- if (!frameImage || frameImage->width() != 1 || frameImage->height() != 1)
+ QPixmap* framePixmap = frameAtIndex(0);
+ if (!framePixmap || framePixmap->width() != 1 || framePixmap->height() != 1)
return;
m_isSolidColor = true;
- m_solidColor = QColor::fromRgba(frameImage->pixel(0, 0));
+ m_solidColor = QColor::fromRgba(framePixmap->toImage().pixel(0, 0));
}
#if OS(WINDOWS)
PassRefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
{
- QImage* nativeImage = new QImage(qt_pixmapFromWinHBITMAP(hBitmap).toImage());
+ QPixmap* qPixmap = new QPixmap(qt_pixmapFromWinHBITMAP(hBitmap));
- return BitmapImage::create(nativeImage);
+ return BitmapImage::create(qPixmap);
}
#endif
diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
index 5ad418c23..9ec765caa 100644
--- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
@@ -31,20 +31,16 @@
#include "RenderVideo.h"
#include "TimeRanges.h"
#include "Widget.h"
-#include "qwebframe.h"
-#include "qwebpage.h"
-#include <QGraphicsScene>
-#include <QGraphicsVideoItem>
#include <QMediaPlayerControl>
#include <QMediaService>
#include <QNetworkAccessManager>
+#include <QNetworkCookie>
#include <QNetworkCookieJar>
#include <QNetworkRequest>
#include <QPainter>
#include <QPoint>
#include <QRect>
-#include <QStyleOptionGraphicsItem>
#include <QTime>
#include <QTimer>
#include <QUrl>
@@ -96,7 +92,7 @@ MediaPlayer::SupportsType MediaPlayerPrivateQt::supportsType(const String& mime,
codecListTrimmed.append(codecStrTrimmed);
}
- if (QMediaPlayer::hasSupport(mime, codecListTrimmed) >= QtMultimediaKit::ProbablySupported)
+ if (QMediaPlayer::hasSupport(mime, codecListTrimmed) >= QtMultimedia::ProbablySupported)
return MediaPlayer::IsSupported;
return MediaPlayer::MayBeSupported;
@@ -106,21 +102,17 @@ MediaPlayerPrivateQt::MediaPlayerPrivateQt(MediaPlayer* player)
: m_webCorePlayer(player)
, m_mediaPlayer(new QMediaPlayer)
, m_mediaPlayerControl(0)
- , m_videoItem(new QGraphicsVideoItem)
- , m_videoScene(new QGraphicsScene)
, m_networkState(MediaPlayer::Empty)
, m_readyState(MediaPlayer::HaveNothing)
, m_currentSize(0, 0)
, m_naturalSize(RenderVideo::defaultSize())
- , m_isVisible(false)
, m_isSeeking(false)
, m_composited(false)
, m_preload(MediaPlayer::Auto)
, m_bytesLoadedAtLastDidLoadingProgress(0)
, m_suppressNextPlaybackChanged(false)
{
- m_mediaPlayer->setVideoOutput(m_videoItem);
- m_videoScene->addItem(m_videoItem);
+ m_mediaPlayer->setVideoOutput(this);
// Signal Handlers
connect(m_mediaPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
@@ -139,10 +131,8 @@ MediaPlayerPrivateQt::MediaPlayerPrivateQt(MediaPlayer* player)
this, SLOT(volumeChanged(int)));
connect(m_mediaPlayer, SIGNAL(mutedChanged(bool)),
this, SLOT(mutedChanged(bool)));
- connect(m_videoScene, SIGNAL(changed(QList<QRectF>)),
- this, SLOT(repaint()));
- connect(m_videoItem, SIGNAL(nativeSizeChanged(QSizeF)),
- this, SLOT(nativeSizeChanged(QSizeF)));
+ connect(this, SIGNAL(surfaceFormatChanged(const QVideoSurfaceFormat&)),
+ this, SLOT(surfaceFormatChanged(const QVideoSurfaceFormat&)));
// Grab the player control
if (QMediaService* service = m_mediaPlayer->service()) {
@@ -158,7 +148,6 @@ MediaPlayerPrivateQt::~MediaPlayerPrivateQt()
m_mediaPlayer->setMedia(QMediaContent());
delete m_mediaPlayer;
- delete m_videoScene;
}
bool MediaPlayerPrivateQt::hasVideo() const
@@ -366,8 +355,8 @@ bool MediaPlayerPrivateQt::didLoadingProgress() const
{
unsigned bytesLoaded = 0;
QLatin1String bytesLoadedKey("bytes-loaded");
- if (m_mediaPlayer->availableExtendedMetaData().contains(bytesLoadedKey))
- bytesLoaded = m_mediaPlayer->extendedMetaData(bytesLoadedKey).toInt();
+ if (m_mediaPlayer->availableMetaData().contains(bytesLoadedKey))
+ bytesLoaded = m_mediaPlayer->metaData(bytesLoadedKey).toInt();
else
bytesLoaded = m_mediaPlayer->bufferStatus();
bool didLoadingProgress = bytesLoaded != m_bytesLoadedAtLastDidLoadingProgress;
@@ -377,8 +366,8 @@ bool MediaPlayerPrivateQt::didLoadingProgress() const
unsigned MediaPlayerPrivateQt::totalBytes() const
{
- if (m_mediaPlayer->availableMetaData().contains(QtMultimediaKit::Size))
- return m_mediaPlayer->metaData(QtMultimediaKit::Size).toInt();
+ if (m_mediaPlayer->availableMetaData().contains(QtMultimedia::MetaData::Size))
+ return m_mediaPlayer->metaData(QtMultimedia::MetaData::Size).toInt();
return 100;
}
@@ -420,9 +409,8 @@ MediaPlayer::ReadyState MediaPlayerPrivateQt::readyState() const
return m_readyState;
}
-void MediaPlayerPrivateQt::setVisible(bool visible)
+void MediaPlayerPrivateQt::setVisible(bool)
{
- m_isVisible = visible;
}
void MediaPlayerPrivateQt::mediaStatusChanged(QMediaPlayer::MediaStatus)
@@ -443,15 +431,20 @@ void MediaPlayerPrivateQt::stateChanged(QMediaPlayer::State)
m_suppressNextPlaybackChanged = false;
}
-void MediaPlayerPrivateQt::nativeSizeChanged(const QSizeF& size)
+void MediaPlayerPrivateQt::surfaceFormatChanged(const QVideoSurfaceFormat& format)
{
+ QSize size = format.sizeHint();
LOG(Media, "MediaPlayerPrivateQt::naturalSizeChanged(%dx%d)",
- size.toSize().width(), size.toSize().height());
+ size.width(), size.height());
if (!size.isValid())
return;
- m_naturalSize = size.toSize();
+ IntSize webCoreSize = size;
+ if (webCoreSize == m_naturalSize)
+ return;
+
+ m_naturalSize = webCoreSize;
m_webCorePlayer->sizeChanged();
}
@@ -544,7 +537,6 @@ void MediaPlayerPrivateQt::setSize(const IntSize& size)
return;
m_currentSize = size;
- m_videoItem->setSize(QSizeF(QSize(size)));
}
IntSize MediaPlayerPrivateQt::naturalSize() const
@@ -562,34 +554,58 @@ IntSize MediaPlayerPrivateQt::naturalSize() const
void MediaPlayerPrivateQt::removeVideoItem()
{
- m_oldNaturalSize = m_naturalSize;
- m_mediaPlayer->setVideoOutput(static_cast<QGraphicsVideoItem*>(0));
- m_videoScene->removeItem(m_videoItem);
+ m_mediaPlayer->setVideoOutput(static_cast<QAbstractVideoSurface*>(0));
}
void MediaPlayerPrivateQt::restoreVideoItem()
{
- m_mediaPlayer->setVideoOutput(m_videoItem);
- m_videoScene->addItem(m_videoItem);
- // FIXME: a qtmobility bug, need to reset the size when restore the videoitem, otherwise the size is 0
- // http://bugreports.qt.nokia.com/browse/QTMOBILITY-971
- nativeSizeChanged(QSize(m_oldNaturalSize));
+ m_mediaPlayer->setVideoOutput(this);
+}
+
+// Begin QAbstractVideoSurface implementation.
+
+bool MediaPlayerPrivateQt::start(const QVideoSurfaceFormat& format)
+{
+ m_currentVideoFrame = QVideoFrame();
+ m_frameFormat = format;
+
+ // If the pixel format is not supported by QImage, then we return false here and the QtMultimedia back-end
+ // will re-negotiate and call us again with a better format.
+ if (QVideoFrame::imageFormatFromPixelFormat(m_frameFormat.pixelFormat()) == QImage::Format_Invalid)
+ return false;
+
+ return QAbstractVideoSurface::start(format);
+}
+
+QList<QVideoFrame::PixelFormat> MediaPlayerPrivateQt::supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const
+{
+ QList<QVideoFrame::PixelFormat> formats;
+ switch (handleType) {
+ case QAbstractVideoBuffer::QPixmapHandle:
+ case QAbstractVideoBuffer::NoHandle:
+ formats << QVideoFrame::Format_RGB32 << QVideoFrame::Format_ARGB32 << QVideoFrame::Format_RGB565;
+ break;
+ default: break;
+ }
+ return formats;
+}
+
+bool MediaPlayerPrivateQt::present(const QVideoFrame& frame)
+{
+ m_currentVideoFrame = frame;
+ m_webCorePlayer->repaint();
+ return true;
}
+// End QAbstractVideoSurface implementation.
+
void MediaPlayerPrivateQt::paint(GraphicsContext* context, const IntRect& rect)
{
#if USE(ACCELERATED_COMPOSITING)
if (m_composited)
return;
#endif
- if (context->paintingDisabled())
- return;
-
- if (!m_isVisible)
- return;
-
- QPainter* painter = context->platformContext();
- m_videoScene->render(painter, QRectF(QRect(rect)), m_videoItem->sceneBoundingRect());
+ paintCurrentFrameInContext(context, rect);
}
void MediaPlayerPrivateQt::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect)
@@ -597,32 +613,38 @@ void MediaPlayerPrivateQt::paintCurrentFrameInContext(GraphicsContext* context,
if (context->paintingDisabled())
return;
- if (!m_isVisible)
+ if (!m_currentVideoFrame.isValid())
return;
- // Grab the painter and widget
QPainter* painter = context->platformContext();
- // Render the video, using the item as it might not be in the scene
- m_videoItem->paint(painter, 0, 0);
-}
-
-void MediaPlayerPrivateQt::repaint()
-{
- m_webCorePlayer->repaint();
+ if (m_currentVideoFrame.handleType() == QAbstractVideoBuffer::QPixmapHandle) {
+ painter->drawPixmap(rect, m_currentVideoFrame.handle().value<QPixmap>());
+ } else if (m_currentVideoFrame.map(QAbstractVideoBuffer::ReadOnly)) {
+ QImage image(m_currentVideoFrame.bits(),
+ m_frameFormat.frameSize().width(),
+ m_frameFormat.frameSize().height(),
+ m_currentVideoFrame.bytesPerLine(),
+ QVideoFrame::imageFormatFromPixelFormat(m_frameFormat.pixelFormat()));
+ const QRect target = rect;
+
+ if (m_frameFormat.scanLineDirection() == QVideoSurfaceFormat::BottomToTop) {
+ const QTransform oldTransform = painter->transform();
+ painter->scale(1, -1);
+ painter->translate(0, -target.bottom());
+ painter->drawImage(QRect(target.x(), 0, target.width(), target.height()), image);
+ painter->setTransform(oldTransform);
+ } else {
+ painter->drawImage(target, image);
+ }
+ m_currentVideoFrame.unmap();
+ }
}
#if USE(ACCELERATED_COMPOSITING)
-void MediaPlayerPrivateQt::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture*) const
-{
- GraphicsContext* context = textureMapper->graphicsContext();
- QPainter* painter = context->platformContext();
- painter->save();
- painter->setTransform(matrix);
- painter->setOpacity(opacity);
- m_videoScene->render(painter, QRectF(targetRect), m_videoItem->sceneBoundingRect());
- painter->restore();
+void MediaPlayerPrivateQt::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture*)
+{
}
#endif
diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
index f15af138d..8e31c9d6d 100644
--- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
+++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
@@ -22,8 +22,10 @@
#include "MediaPlayerPrivate.h"
+#include <QAbstractVideoSurface>
#include <QMediaPlayer>
#include <QObject>
+#include <QVideoSurfaceFormat>
QT_BEGIN_NAMESPACE
class QMediaPlayerControl;
@@ -37,9 +39,9 @@ QT_END_NAMESPACE
namespace WebCore {
-class MediaPlayerPrivateQt : public QObject, public MediaPlayerPrivateInterface
+class MediaPlayerPrivateQt : public QAbstractVideoSurface, public MediaPlayerPrivateInterface
#if USE(ACCELERATED_COMPOSITING)
- , public TextureMapperPlatformLayer
+ , public TextureMapperPlatformLayer
#endif
{
@@ -107,7 +109,7 @@ public:
virtual void acceleratedRenderingStateChanged() { }
// Const-casting here is safe, since all of TextureMapperPlatformLayer's functions are const.g
virtual PlatformLayer* platformLayer() const { return 0; }
- virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask) const;
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
#endif
virtual PlatformMedia platformMedia() const;
@@ -116,17 +118,21 @@ public:
void removeVideoItem();
void restoreVideoItem();
+ // QAbstractVideoSurface methods
+ virtual bool start(const QVideoSurfaceFormat& format);
+ virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
+ virtual bool present(const QVideoFrame& frame);
+
private Q_SLOTS:
void mediaStatusChanged(QMediaPlayer::MediaStatus);
void handleError(QMediaPlayer::Error);
void stateChanged(QMediaPlayer::State);
- void nativeSizeChanged(const QSizeF&);
+ void surfaceFormatChanged(const QVideoSurfaceFormat&);
void positionChanged(qint64);
void durationChanged(qint64);
void bufferStatusChanged(int);
void volumeChanged(int);
void mutedChanged(bool);
- void repaint();
private:
void updateStates();
@@ -139,15 +145,14 @@ private:
MediaPlayer* m_webCorePlayer;
QMediaPlayer* m_mediaPlayer;
QMediaPlayerControl* m_mediaPlayerControl;
- QGraphicsVideoItem* m_videoItem;
- QGraphicsScene* m_videoScene;
+ QVideoSurfaceFormat m_frameFormat;
+ QVideoFrame m_currentVideoFrame;
mutable MediaPlayer::NetworkState m_networkState;
mutable MediaPlayer::ReadyState m_readyState;
IntSize m_currentSize;
IntSize m_naturalSize;
- IntSize m_oldNaturalSize;
bool m_isVisible;
bool m_isSeeking;
bool m_composited;
diff --git a/Source/WebCore/platform/graphics/qt/PathQt.cpp b/Source/WebCore/platform/graphics/qt/PathQt.cpp
index 4f65151b7..577023b46 100644
--- a/Source/WebCore/platform/graphics/qt/PathQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/PathQt.cpp
@@ -38,8 +38,8 @@
#include "NativeImageQt.h"
#include "StrokeStyleApplier.h"
#include <QPainterPath>
-#include <QTransform>
#include <QString>
+#include <QTransform>
#include <wtf/MathExtras.h>
#include <wtf/OwnPtr.h>
#include <wtf/text/WTFString.h>
@@ -149,11 +149,16 @@ void Path::translate(const FloatSize& size)
m_path.translate(size.width(), size.height());
}
-FloatRect Path::boundingRect() const
+FloatRect Path::fastBoundingRect() const
{
return m_path.controlPointRect();
}
+FloatRect Path::boundingRect() const
+{
+ return m_path.boundingRect();
+}
+
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
{
GraphicsContext* context = scratchContext();
diff --git a/Source/WebCore/platform/graphics/qt/PatternQt.cpp b/Source/WebCore/platform/graphics/qt/PatternQt.cpp
index 5c9412215..7aae62599 100644
--- a/Source/WebCore/platform/graphics/qt/PatternQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/PatternQt.cpp
@@ -33,12 +33,12 @@ namespace WebCore {
QBrush Pattern::createPlatformPattern() const
{
- QImage* image = tileImage()->nativeImageForCurrentFrame();
- if (!image)
+ QPixmap* pixmap = tileImage()->nativeImageForCurrentFrame();
+ if (!pixmap)
return QBrush();
// Qt merges patter space and user space itself
- QBrush brush(*image);
+ QBrush brush(*pixmap);
brush.setTransform(m_patternSpaceTransformation);
return brush;
diff --git a/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp b/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
index 8ce9f77da..677d6086c 100644
--- a/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
@@ -61,30 +61,30 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
return advances.at(0).x();
}
-PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
+PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
const float scaledSize = lroundf(fontDescription.computedSize() * scaleFactor);
- return adoptPtr(new SimpleFontData(FontPlatformData(m_platformData, scaledSize), isCustomFont(), false));
+ return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont(), false);
}
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
+PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
{
if (!m_derivedFontData)
m_derivedFontData = DerivedFontData::create(isCustomFont());
if (!m_derivedFontData->smallCaps)
m_derivedFontData->smallCaps = createScaledFontData(fontDescription, smallCapsFraction);
- return m_derivedFontData->smallCaps.get();
+ return m_derivedFontData->smallCaps;
}
-SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
+PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
{
if (!m_derivedFontData)
m_derivedFontData = DerivedFontData::create(isCustomFont());
if (!m_derivedFontData->emphasisMark)
m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, emphasisMarkFraction);
- return m_derivedFontData->emphasisMark.get();
+ return m_derivedFontData->emphasisMark;
}
FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const
diff --git a/Source/WebCore/platform/graphics/qt/StillImageQt.cpp b/Source/WebCore/platform/graphics/qt/StillImageQt.cpp
index 041252019..80666ba46 100644
--- a/Source/WebCore/platform/graphics/qt/StillImageQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/StillImageQt.cpp
@@ -36,41 +36,41 @@
namespace WebCore {
-StillImage::StillImage(const QImage& image)
- : m_image(new QImage(image))
- , m_ownsImage(true)
+StillImage::StillImage(const QPixmap& pixmap)
+ : m_pixmap(new QPixmap(pixmap))
+ , m_ownsPixmap(true)
{}
-StillImage::StillImage(const QImage* image)
- : m_image(image)
- , m_ownsImage(false)
+StillImage::StillImage(const QPixmap* pixmap)
+ : m_pixmap(pixmap)
+ , m_ownsPixmap(false)
{}
StillImage::~StillImage()
{
- if (m_ownsImage)
- delete m_image;
+ if (m_ownsPixmap)
+ delete m_pixmap;
}
bool StillImage::currentFrameHasAlpha()
{
- return m_image->hasAlphaChannel();
+ return m_pixmap->hasAlpha();
}
IntSize StillImage::size() const
{
- return IntSize(m_image->width(), m_image->height());
+ return IntSize(m_pixmap->width(), m_pixmap->height());
}
NativeImagePtr StillImage::nativeImageForCurrentFrame()
{
- return const_cast<NativeImagePtr>(m_image);
+ return const_cast<NativeImagePtr>(m_pixmap);
}
void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
const FloatRect& src, ColorSpace, CompositeOperator op)
{
- if (m_image->isNull())
+ if (m_pixmap->isNull())
return;
FloatRect normalizedSrc = src.normalized();
@@ -84,12 +84,12 @@ void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
- shadowPainter->drawImage(normalizedDst, *m_image, normalizedSrc);
+ shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
shadow->endShadowLayer(ctxt);
}
}
- ctxt->platformContext()->drawImage(normalizedDst, *m_image, normalizedSrc);
+ ctxt->platformContext()->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
ctxt->setCompositeOperation(previousOperator);
}
diff --git a/Source/WebCore/platform/graphics/qt/StillImageQt.h b/Source/WebCore/platform/graphics/qt/StillImageQt.h
index 8c9ec0d88..0609b5458 100644
--- a/Source/WebCore/platform/graphics/qt/StillImageQt.h
+++ b/Source/WebCore/platform/graphics/qt/StillImageQt.h
@@ -34,14 +34,14 @@ namespace WebCore {
class StillImage : public Image {
public:
- static PassRefPtr<StillImage> create(const QImage& image)
+ static PassRefPtr<StillImage> create(const QPixmap& pixmap)
{
- return adoptRef(new StillImage(image));
+ return adoptRef(new StillImage(pixmap));
}
- static PassRefPtr<StillImage> createForRendering(const QImage* image)
+ static PassRefPtr<StillImage> createForRendering(const QPixmap* pixmap)
{
- return adoptRef(new StillImage(image));
+ return adoptRef(new StillImage(pixmap));
}
virtual bool currentFrameHasAlpha();
@@ -56,12 +56,12 @@ namespace WebCore {
virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
private:
- StillImage(const QImage&);
- StillImage(const QImage*);
+ StillImage(const QPixmap&);
+ StillImage(const QPixmap*);
virtual ~StillImage();
- const QImage* m_image;
- bool m_ownsImage;
+ const QPixmap* m_pixmap;
+ bool m_ownsPixmap;
};
}
diff --git a/Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp b/Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp
index 7ff432b17..73a0e414f 100644
--- a/Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp
@@ -27,8 +27,8 @@
#include "AffineTransform.h"
#include "TransformationMatrix.h"
-#include "IntRect.h"
#include "FloatRect.h"
+#include "IntRect.h"
namespace WebCore {
diff --git a/Source/WebCore/platform/graphics/qt/TransparencyLayer.h b/Source/WebCore/platform/graphics/qt/TransparencyLayer.h
index 5974017be..f13deb03b 100644
--- a/Source/WebCore/platform/graphics/qt/TransparencyLayer.h
+++ b/Source/WebCore/platform/graphics/qt/TransparencyLayer.h
@@ -36,24 +36,24 @@
#ifndef TransparencyLayer_h
#define TransparencyLayer_h
-#include <NativeImageQt.h>
#include <QPaintEngine>
#include <QPainter>
+#include <QPixmap>
namespace WebCore {
struct TransparencyLayer {
WTF_MAKE_FAST_ALLOCATED;
public:
- TransparencyLayer(const QPainter* p, const QRect &rect, qreal opacity, QImage& alphaMask)
- : image(rect.width(), rect.height(), NativeImageQt::defaultFormatForAlphaEnabledImages())
+ TransparencyLayer(const QPainter* p, const QRect &rect, qreal opacity, QPixmap& alphaMask)
+ : pixmap(rect.width(), rect.height())
, opacity(opacity)
, alphaMask(alphaMask)
, saveCounter(1) // see the comment for saveCounter
{
offset = rect.topLeft();
- image.fill(Qt::transparent);
- painter.begin(&image);
+ pixmap.fill(Qt::transparent);
+ painter.begin(&pixmap);
painter.setRenderHints(p->renderHints());
painter.translate(-offset);
painter.setPen(p->pen());
@@ -67,12 +67,12 @@ public:
{
}
- QImage image;
+ QPixmap pixmap;
QPoint offset;
QPainter painter;
qreal opacity;
// for clipToImageBuffer
- QImage alphaMask;
+ QPixmap alphaMask;
// saveCounter is only used in combination with alphaMask
// otherwise, its value is unspecified
int saveCounter;