#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
-#if PLATFORM(QT)
-#include <QImage>
-#endif
-
namespace WebCore {
class IntSize;
{
if (!m_cropRect.isEmpty())
return FloatRect(m_cropRect);
-
- // Default rectangle used by GraphicsContext::drawImage().
- return FloatRect(0, 0, -1, -1);
+ ASSERT(m_image);
+ return FloatRect(0, 0, m_image->size().width(), m_image->size().height());
}
private:
ImageGStreamer(GstBuffer*, GstCaps*);
RefPtr<BitmapImage> m_image;
FloatRect m_cropRect;
+
+#if USE(CAIRO) && defined(GST_API_VERSION_1)
+ GRefPtr<GstBuffer> m_buffer;
+ GstMapInfo m_mapInfo;
+#endif
};
}
using namespace WebCore;
ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
+#ifdef GST_API_VERSION_1
+ : m_buffer(buffer)
+#endif
{
GstVideoFormat format;
IntSize size;
getVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride);
#ifdef GST_API_VERSION_1
- GstMapInfo mapInfo;
- gst_buffer_map(buffer, &mapInfo, GST_MAP_READ);
- unsigned char* bufferData = reinterpret_cast<unsigned char*>(mapInfo.data);
+ gst_buffer_map(buffer, &m_mapInfo, GST_MAP_READ);
+ unsigned char* bufferData = reinterpret_cast<unsigned char*>(m_mapInfo.data);
#else
unsigned char* bufferData = reinterpret_cast<unsigned char*>(GST_BUFFER_DATA(buffer));
#endif
#ifdef GST_API_VERSION_1
if (GstVideoCropMeta* cropMeta = gst_buffer_get_video_crop_meta(buffer))
setCropRect(FloatRect(cropMeta->x, cropMeta->y, cropMeta->width, cropMeta->height));
-
- gst_buffer_unmap(buffer, &mapInfo);
#endif
}
m_image.clear();
m_image = 0;
+
+#ifdef GST_API_VERSION_1
+ // We keep the buffer memory mapped until the image is destroyed because the internal
+ // cairo_surface_t was created using cairo_image_surface_create_for_data().
+ gst_buffer_unmap(m_buffer.get(), &m_mapInfo);
+#endif
}
#endif // USE(GSTREAMER)
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
image.invertPixels(invertMode);
#endif
-
- m_image = BitmapImage::create(new QImage(image));
+ QPixmap* surface = new QPixmap;
+ surface->convertFromImage(image);
+ m_image = BitmapImage::create(surface);
#ifdef GST_API_VERSION_1
if (GstVideoCropMeta* cropMeta = gst_buffer_get_video_crop_meta(buffer))