Changeset 202901 in webkit
- Timestamp:
- Jul 7, 2016, 6:04:00 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (modified) (1 diff)
-
platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (modified) (8 diffs)
-
platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r202897 r202901 1 2016-07-07 Miguel Gomez <magomez@igalia.com> 2 3 [GTK] Painting a video into a canvas doesn't work when accelerated compositing is enabled 4 https://bugs.webkit.org/show_bug.cgi?id=159405 5 6 Reviewed by Xabier Rodriguez-Calvar. 7 8 Implement video frame painting to the canvas when accelerated compositing is enabled. 9 10 Already covered by existent tests. 11 12 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: 13 (WebCore::MediaPlayerPrivateGStreamer::handleMessage): 14 Replace custom enumeration for the video rotation with the ImageOrientation class. 15 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp: 16 (WebCore::MediaPlayerPrivateGStreamerBase::naturalSize): 17 Replace the orientation value comparison with ImageOrientation::usesWidthAsHeight(). 18 (WebCore::MediaPlayerPrivateGStreamerBase::paint): 19 Perform the frame painting taking into account the video orientation tag. 20 (WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime): 21 Rotate the native image before returning it. 22 (WebCore::MediaPlayerPrivateGStreamerBase::setVideoSourceOrientation): 23 Replace custom enumeration for the video rotation with the ImageOrientation class. 24 (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase): Deleted. 25 Remove orientation initialization. 26 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h: 27 Remove custom enumeration for the video orientation. 28 1 29 2016-07-07 Philippe Normand <pnormand@igalia.com> 2 30 -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r202857 r202901 1033 1033 if (gst_tag_list_get_string(tags, GST_TAG_IMAGE_ORIENTATION, &tag.outPtr())) { 1034 1034 if (!g_strcmp0(tag.get(), "rotate-90")) 1035 setVideoSource Rotation(VideoSourceRotation90);1035 setVideoSourceOrientation(ImageOrientation(OriginRightTop)); 1036 1036 else if (!g_strcmp0(tag.get(), "rotate-180")) 1037 setVideoSource Rotation(VideoSourceRotation180);1037 setVideoSourceOrientation(ImageOrientation(OriginBottomRight)); 1038 1038 else if (!g_strcmp0(tag.get(), "rotate-270")) 1039 setVideoSource Rotation(VideoSourceRotation270);1039 setVideoSourceOrientation(ImageOrientation(OriginLeftBottom)); 1040 1040 } 1041 1041 gst_tag_list_unref(tags); -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
r202897 r202901 40 40 #include <wtf/glib/GMutexLocker.h> 41 41 #include <wtf/text/CString.h> 42 #include <wtf/MathExtras.h> 42 43 43 44 #include <gst/audio/streamvolume.h> … … 154 155 #endif 155 156 , m_usingFallbackVideoSink(false) 156 , m_videoSourceRotation(NoVideoSourceRotation)157 157 #if USE(TEXTURE_MAPPER_GL) 158 158 , m_textureMapperRotationFlag(0) … … 301 301 // When using accelerated compositing, if the video is tagged as rotated 90 or 270 degrees, swap width and height. 302 302 if (m_player->client().mediaPlayerRenderingCanBeAccelerated(m_player)) { 303 if (m_videoSource Rotation == VideoSourceRotation90 || m_videoSourceRotation == VideoSourceRotation270)303 if (m_videoSourceOrientation.usesWidthAsHeight()) 304 304 originalSize = originalSize.transposedSize(); 305 305 } … … 609 609 void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext& context, const FloatRect& rect) 610 610 { 611 #if USE(COORDINATED_GRAPHICS_THREADED)612 return;613 #elif USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)614 if (client())615 return;616 #endif617 618 611 if (context.paintingDisabled()) 619 612 return; … … 626 619 return; 627 620 621 ImagePaintingOptions paintingOptions(CompositeCopy); 622 if (m_player->client().mediaPlayerRenderingCanBeAccelerated(m_player)) 623 paintingOptions.m_orientationDescription.setImageOrientationEnum(m_videoSourceOrientation); 624 628 625 RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_sample.get()); 629 626 if (!gstImage) … … 631 628 632 629 if (Image* image = reinterpret_cast<Image*>(gstImage->image().get())) 633 context.drawImage(*image, rect, gstImage->rect(), CompositeCopy);630 context.drawImage(*image, rect, gstImage->rect(), paintingOptions); 634 631 } 635 632 … … 713 710 unsigned textureID = *reinterpret_cast<unsigned*>(videoFrame.data[0]); 714 711 IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&videoInfo), GST_VIDEO_INFO_HEIGHT(&videoInfo)); 715 cairo_surface_t* surface = cairo_gl_surface_create_for_texture(device, CAIRO_CONTENT_COLOR_ALPHA, textureID, size.width(), size.height()); 712 RefPtr<cairo_surface_t> surface = adoptRef(cairo_gl_surface_create_for_texture(device, CAIRO_CONTENT_COLOR_ALPHA, textureID, size.width(), size.height())); 713 714 IntSize rotatedSize = m_videoSourceOrientation.usesWidthAsHeight() ? size.transposedSize() : size; 715 RefPtr<cairo_surface_t> rotatedSurface = adoptRef(cairo_gl_surface_create(device, CAIRO_CONTENT_COLOR_ALPHA, rotatedSize.width(), rotatedSize.height())); 716 RefPtr<cairo_t> cr = adoptRef(cairo_create(rotatedSurface.get())); 717 718 switch (m_videoSourceOrientation) { 719 case DefaultImageOrientation: 720 break; 721 case OriginRightTop: 722 cairo_translate(cr.get(), rotatedSize.width() * 0.5, rotatedSize.height() * 0.5); 723 cairo_rotate(cr.get(), piOverTwoDouble); 724 cairo_translate(cr.get(), -rotatedSize.height() * 0.5, -rotatedSize.width() * 0.5); 725 break; 726 case OriginBottomRight: 727 cairo_translate(cr.get(), rotatedSize.width() * 0.5, rotatedSize.height() * 0.5); 728 cairo_rotate(cr.get(), piDouble); 729 cairo_translate(cr.get(), -rotatedSize.width() * 0.5, -rotatedSize.height() * 0.5); 730 break; 731 case OriginLeftBottom: 732 cairo_translate(cr.get(), rotatedSize.width() * 0.5, rotatedSize.height() * 0.5); 733 cairo_rotate(cr.get(), 3 * piOverTwoDouble); 734 cairo_translate(cr.get(), -rotatedSize.height() * 0.5, -rotatedSize.width() * 0.5); 735 break; 736 default: 737 ASSERT_NOT_REACHED(); 738 break; 739 } 740 cairo_set_source_surface(cr.get(), surface.get(), 0, 0); 741 cairo_set_operator(cr.get(), CAIRO_OPERATOR_SOURCE); 742 cairo_paint(cr.get()); 743 716 744 gst_video_frame_unmap(&videoFrame); 717 745 718 return adoptRef(surface);719 } 720 #endif 721 722 void MediaPlayerPrivateGStreamerBase::setVideoSource Rotation(VideoSourceRotation rotation)723 { 724 if (m_videoSource Rotation == rotation)725 return; 726 727 m_videoSource Rotation = rotation;746 return rotatedSurface; 747 } 748 #endif 749 750 void MediaPlayerPrivateGStreamerBase::setVideoSourceOrientation(const ImageOrientation& orientation) 751 { 752 if (m_videoSourceOrientation == orientation) 753 return; 754 755 m_videoSourceOrientation = orientation; 728 756 729 757 #if USE(TEXTURE_MAPPER_GL) 730 switch (m_videoSource Rotation) {731 case NoVideoSourceRotation:758 switch (m_videoSourceOrientation) { 759 case DefaultImageOrientation: 732 760 m_textureMapperRotationFlag = 0; 733 761 break; 734 case VideoSourceRotation90:762 case OriginRightTop: 735 763 m_textureMapperRotationFlag = TextureMapperGL::ShouldRotateTexture90; 736 764 break; 737 case VideoSourceRotation180:765 case OriginBottomRight: 738 766 m_textureMapperRotationFlag = TextureMapperGL::ShouldRotateTexture180; 739 767 break; 740 case VideoSourceRotation270:768 case OriginLeftBottom: 741 769 m_textureMapperRotationFlag = TextureMapperGL::ShouldRotateTexture270; 742 770 break; … … 772 800 GstElement* MediaPlayerPrivateGStreamerBase::createVideoSinkGL() 773 801 { 802 // FIXME: Currently it's not possible to get the video frames and caps using this approach until 803 // the pipeline gets into playing state. Due to this, trying to grab a frame and painting it by some 804 // other mean (canvas or webgl) before playing state can result in a crash. 805 // This is being handled in https://bugs.webkit.org/show_bug.cgi?id=159460. 774 806 if (!webkitGstCheckVersion(1, 8, 0)) 775 807 return nullptr; -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h
r202897 r202901 63 63 64 64 public: 65 enum VideoSourceRotation {66 NoVideoSourceRotation,67 VideoSourceRotation90,68 VideoSourceRotation180,69 VideoSourceRotation27070 };71 72 65 virtual ~MediaPlayerPrivateGStreamerBase(); 73 66 … … 130 123 #endif 131 124 132 void setVideoSource Rotation(VideoSourceRotation);125 void setVideoSourceOrientation(const ImageOrientation&); 133 126 134 127 protected: … … 209 202 #endif 210 203 211 VideoSourceRotation m_videoSourceRotation;204 ImageOrientation m_videoSourceOrientation; 212 205 #if USE(TEXTURE_MAPPER_GL) 213 206 TextureMapperGL::Flags m_textureMapperRotationFlag;
Note:
See TracChangeset
for help on using the changeset viewer.