Skip to content

Commit

Permalink
Merge r234979 - [GTK] Never return an uninitialized ImageGStreamer ob…
Browse files Browse the repository at this point in the history
…ject.

https://bugs.webkit.org/show_bug.cgi?id=188305

Reviewed by Philippe Normand.

The single caller was already checking for a null return value, so
make that check actually do something. Also remove the null-check on
the return value of image(), which asserted that it would never return
null.

Test: fast/canvas/canvas-createPattern-video-loading.html

* platform/graphics/gstreamer/ImageGStreamer.h:
(WebCore::ImageGStreamer::createImage): Return null if m_image wasn't created.
(WebCore::ImageGStreamer::image): Return a reference.
(WebCore::ImageGStreamer::rect): Always assert that m_image is present.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::paint): Update for new signature.
  • Loading branch information
Ms2ger authored and carlosgcampos committed Aug 20, 2018
1 parent d1eb409 commit 6405cdb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
21 changes: 21 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,24 @@
2018-08-17 Ms2ger <Ms2ger@igalia.com>

[GTK] Never return an uninitialized ImageGStreamer object.
https://bugs.webkit.org/show_bug.cgi?id=188305

Reviewed by Philippe Normand.

The single caller was already checking for a null return value, so
make that check actually do something. Also remove the null-check on
the return value of image(), which asserted that it would never return
null.

Test: fast/canvas/canvas-createPattern-video-loading.html

* platform/graphics/gstreamer/ImageGStreamer.h:
(WebCore::ImageGStreamer::createImage): Return null if m_image wasn't created.
(WebCore::ImageGStreamer::image): Return a reference.
(WebCore::ImageGStreamer::rect): Always assert that m_image is present.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::paint): Update for new signature.

2018-08-17 Philippe Normand <philn@igalia.com>

[GStreamer] Enable fpsdisplaysink only when MEDIA_STATISTICS is enabled
Expand Down
14 changes: 9 additions & 5 deletions Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h
Expand Up @@ -38,24 +38,28 @@ class IntSize;

class ImageGStreamer : public RefCounted<ImageGStreamer> {
public:
static Ref<ImageGStreamer> createImage(GstSample* sample)
static RefPtr<ImageGStreamer> createImage(GstSample* sample)
{
return adoptRef(*new ImageGStreamer(sample));
auto image = adoptRef(*new ImageGStreamer(sample));
if (!image->m_image)
return nullptr;

return image;
}
~ImageGStreamer();

BitmapImage* image()
BitmapImage& image()
{
ASSERT(m_image);
return m_image.get();
return *m_image.get();
}

void setCropRect(FloatRect rect) { m_cropRect = rect; }
FloatRect rect()
{
ASSERT(m_image);
if (!m_cropRect.isEmpty())
return FloatRect(m_cropRect);
ASSERT(m_image);
return FloatRect(0, 0, m_image->size().width(), m_image->size().height());
}

Expand Down
Expand Up @@ -966,8 +966,7 @@ void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext& context, const Floa
if (!gstImage)
return;

if (Image* image = reinterpret_cast<Image*>(gstImage->image()))
context.drawImage(*image, rect, gstImage->rect(), paintingOptions);
context.drawImage(gstImage->image(), rect, gstImage->rect(), paintingOptions);
}

#if USE(GSTREAMER_GL)
Expand Down

0 comments on commit 6405cdb

Please sign in to comment.