Title: [151844] trunk/Source/WebCore
Revision
151844
Author
[email protected]
Date
2013-06-21 10:52:16 -0700 (Fri, 21 Jun 2013)

Log Message

[iOS] Hang drawing captions after pressing the home button while playing a video
https://bugs.webkit.org/show_bug.cgi?id=117882

Reviewed by Eric Carlson.

Instead of rendering in a callback on the main thread, pre-render the captions and pass to the main
thread as a CGImage. As such, rename paintTextTrackRepresentation() to createTextTrackRepresentationImage().

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage): Renamed from
    paintTextTrackRepresentation. Now returns an Image object.
* html/shadow/MediaControlElements.h:
* platform/graphics/MediaPlayer.h:
* platform/graphics/TextTrackRepresentation.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (151843 => 151844)


--- trunk/Source/WebCore/ChangeLog	2013-06-21 17:42:52 UTC (rev 151843)
+++ trunk/Source/WebCore/ChangeLog	2013-06-21 17:52:16 UTC (rev 151844)
@@ -1,3 +1,20 @@
+2013-06-21  Jer Noble  <[email protected]>
+
+        [iOS] Hang drawing captions after pressing the home button while playing a video
+        https://bugs.webkit.org/show_bug.cgi?id=117882
+
+        Reviewed by Eric Carlson.
+
+        Instead of rendering in a callback on the main thread, pre-render the captions and pass to the main
+        thread as a CGImage. As such, rename paintTextTrackRepresentation() to createTextTrackRepresentationImage().
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage): Renamed from
+            paintTextTrackRepresentation. Now returns an Image object.
+        * html/shadow/MediaControlElements.h:
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/TextTrackRepresentation.h:
+
 2013-06-21  Radu Stavila  <[email protected]>
 
         [CSS Regions] Move overset compute code from flow thread to named flow thread

Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (151843 => 151844)


--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2013-06-21 17:42:52 UTC (rev 151843)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2013-06-21 17:52:16 UTC (rev 151844)
@@ -41,6 +41,7 @@
 #include "Frame.h"
 #include "GraphicsContext.h"
 #include "HTMLVideoElement.h"
+#include "ImageBuffer.h"
 #include "Language.h"
 #include "LocalizedStrings.h"
 #include "MediaControls.h"
@@ -1367,40 +1368,48 @@
     m_updateTimer.startOneShot(0);
 }
 
-void MediaControlTextTrackContainerElement::paintTextTrackRepresentation(GraphicsContext* context, const IntRect& contextRect)
+PassRefPtr<Image> MediaControlTextTrackContainerElement::createTextTrackRepresentationImage()
 {
     if (!hasChildNodes())
-        return;
+        return 0;
 
     RenderObject* renderer = this->renderer();
     if (!renderer)
-        return;
+        return 0;
 
     Frame* frame = document()->frame();
     if (!frame)
-        return;
+        return 0;
 
     document()->updateLayout();
 
     LayoutRect topLevelRect;
     IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
 
+    float deviceScaleFactor = 1;
+    if (Page* page = document()->page())
+        deviceScaleFactor = page->deviceScaleFactor();
+
+    OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceScaleFactor, ColorSpaceDeviceRGB));
+    if (!buffer)
+        return 0;
+
     // Translate the renderer painting rect into graphics context coordinates.
     FloatSize translation(-paintingRect.x(), -paintingRect.y());
 
-    // But anchor to the bottom of the graphics context rect.
-    translation.expand(max(0, contextRect.width() - paintingRect.width()), max(0, contextRect.height() - paintingRect.height()));
+    buffer->context()->translate(translation);
 
-    context->translate(translation);
+    RenderLayer* layer = frame->contentRenderer()->layer();
+    layer->paint(buffer->context(), paintingRect, PaintBehaviorFlattenCompositingLayers, renderer, 0, RenderLayer::PaintLayerPaintingCompositingAllPhases);
 
-    RenderLayer* layer = frame->contentRenderer()->layer();
-    layer->paint(context, paintingRect, PaintBehaviorFlattenCompositingLayers, renderer, 0, RenderLayer::PaintLayerPaintingCompositingAllPhases);
+    return buffer->copyImage();
 }
 
 void MediaControlTextTrackContainerElement::textTrackRepresentationBoundsChanged(const IntRect&)
 {
     updateSizes();
 }
+
 #endif // ENABLE(VIDEO_TRACK)
 
 // ----------------------------

Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.h (151843 => 151844)


--- trunk/Source/WebCore/html/shadow/MediaControlElements.h	2013-06-21 17:42:52 UTC (rev 151843)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.h	2013-06-21 17:52:16 UTC (rev 151844)
@@ -455,7 +455,7 @@
 
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
 
-    virtual void paintTextTrackRepresentation(GraphicsContext*, const IntRect&) OVERRIDE;
+    virtual PassRefPtr<Image> createTextTrackRepresentationImage() OVERRIDE;
     virtual void textTrackRepresentationBoundsChanged(const IntRect&) OVERRIDE;
     OwnPtr<TextTrackRepresentation> m_textTrackRepresentation;
 

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (151843 => 151844)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2013-06-21 17:42:52 UTC (rev 151843)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2013-06-21 17:52:16 UTC (rev 151844)
@@ -228,7 +228,6 @@
     virtual void mediaPlayerDidRemoveVideoTrack(PassRefPtr<VideoTrackPrivate>) { }
 
     virtual void textTrackRepresentationBoundsChanged(const IntRect&) { }
-    virtual void paintTextTrackRepresentation(GraphicsContext*, const IntRect&) { }
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.h (151843 => 151844)


--- trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.h	2013-06-21 17:42:52 UTC (rev 151843)
+++ trunk/Source/WebCore/platform/graphics/TextTrackRepresentation.h	2013-06-21 17:52:16 UTC (rev 151844)
@@ -35,13 +35,14 @@
 namespace WebCore {
 
 class GraphicsContext;
+class Image;
 class IntRect;
 
 class TextTrackRepresentationClient {
 public:
     virtual ~TextTrackRepresentationClient() { }
 
-    virtual void paintTextTrackRepresentation(GraphicsContext*, const IntRect&) = 0;
+    virtual PassRefPtr<Image> createTextTrackRepresentationImage() = 0;
     virtual void textTrackRepresentationBoundsChanged(const IntRect&) = 0;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to