Title: [98470] branches/safari-534.52-branch/Source/WebCore

Diff

Modified: branches/safari-534.52-branch/Source/WebCore/ChangeLog (98469 => 98470)


--- branches/safari-534.52-branch/Source/WebCore/ChangeLog	2011-10-26 13:10:28 UTC (rev 98469)
+++ branches/safari-534.52-branch/Source/WebCore/ChangeLog	2011-10-26 13:17:04 UTC (rev 98470)
@@ -1,3 +1,27 @@
+2011-10-26  Lucas Forschler  <lforsch...@apple.com>
+
+    Merge 98171
+
+    2011-10-21  Matthew Delaney  <mdela...@apple.com>
+
+            Ensure periodic flushing of canvas drawing context
+            https://bugs.webkit.org/show_bug.cgi?id=70646
+
+            Reviewed by Simon Fraser.
+
+            No new tests. No current way to track tests that cause hangs or
+            non-deterministic drops in performance.
+
+            * platform/graphics/cg/ImageBufferDataCG.h: Adds a timestamp of last tracked flush.
+            * platform/graphics/cg/ImageBufferCG.cpp: Ensures periodic flushes on the drawing context.
+            (WebCore::ImageBuffer::ImageBuffer):
+            (WebCore::ImageBuffer::context): Flushes context if we're beyond flush interval.
+            (WebCore::ImageBuffer::copyNativeImage): Updates last flush timestamp.
+            (WebCore::ImageBuffer::getUnmultipliedImageData): Updates last flush timestamp.
+            (WebCore::ImageBuffer::getPremultipliedImageData): Updates last flush timestamp.
+            (WebCore::ImageBuffer::putUnmultipliedImageData): Updates last flush timestamp.
+            (WebCore::ImageBuffer::putPremultipliedImageData): Updates last flush timestamp.
+
 2011-10-24  Lucas Forschler  <lforsch...@apple.com>
 
         Update Localizable strings.

Modified: branches/safari-534.52-branch/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (98469 => 98470)


--- branches/safari-534.52-branch/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2011-10-26 13:10:28 UTC (rev 98469)
+++ branches/safari-534.52-branch/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2011-10-26 13:17:04 UTC (rev 98470)
@@ -36,6 +36,7 @@
 #include "MIMETypeRegistry.h"
 #include <ApplicationServices/ApplicationServices.h>
 #include <wtf/Assertions.h>
+#include <wtf/CurrentTime.h>
 #include <wtf/text/WTFString.h>
 #include <wtf/OwnArrayPtr.h>
 #include <wtf/RetainPtr.h>
@@ -157,9 +158,10 @@
     if (!cgContext)
         return;
 
-    m_context= adoptPtr(new GraphicsContext(cgContext.get()));
+    m_context = adoptPtr(new GraphicsContext(cgContext.get()));
     m_context->scale(FloatSize(1, -1));
     m_context->translate(0, -size.height());
+    m_data.m_lastFlushTime = currentTimeMS(); 
     success = true;
 }
 
@@ -174,6 +176,18 @@
 
 GraphicsContext* ImageBuffer::context() const
 {
+    // Force a flush if last flush was more than 20ms ago 
+    if (m_context->isAcceleratedContext()) { 
+        double elapsedTime = currentTimeMS() - m_data.m_lastFlushTime; 
+        double maxFlushInterval = 20; // in ms 
+
+        if (elapsedTime > maxFlushInterval) { 
+            CGContextRef context = m_context->platformContext(); 
+            CGContextFlush(context); 
+            m_data.m_lastFlushTime = currentTimeMS(); 
+        } 
+    } 
+    
     return m_context.get();
 }
 
@@ -189,8 +203,10 @@
     if (!m_accelerateRendering)
         ctxImage = CGBitmapContextCreateImage(context()->platformContext());
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
-    else
+    else {
         ctxImage = wkIOSurfaceContextCreateImage(context()->platformContext());
+        m_data.m_lastFlushTime = currentTimeMS(); 
+    }
 #endif
     return BitmapImage::create(ctxImage);
 }
@@ -257,29 +273,37 @@
 
 PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
 {
-    if (m_accelerateRendering)
+    if (m_accelerateRendering) {
         CGContextFlush(context()->platformContext());
+        m_data.m_lastFlushTime = currentTimeMS();
+    }
     return m_data.getData(rect, m_size, m_accelerateRendering, true);
 }
 
 PassRefPtr<ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
 {
-    if (m_accelerateRendering)
+    if (m_accelerateRendering) {
         CGContextFlush(context()->platformContext());
+        m_data.m_lastFlushTime = currentTimeMS(); 
+    }
     return m_data.getData(rect, m_size, m_accelerateRendering, false);
 }
 
 void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
 {
-    if (m_accelerateRendering)
+    if (m_accelerateRendering) {
         CGContextFlush(context()->platformContext());
+        m_data.m_lastFlushTime = currentTimeMS();
+    }
     m_data.putData(source, sourceSize, sourceRect, destPoint, m_size, m_accelerateRendering, true);
 }
 
 void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
 {
-    if (m_accelerateRendering)
+    if (m_accelerateRendering) {
         CGContextFlush(context()->platformContext());
+        m_data.m_lastFlushTime = currentTimeMS();
+    }
     m_data.putData(source, sourceSize, sourceRect, destPoint, m_size, m_accelerateRendering, false);
 }
 

Modified: branches/safari-534.52-branch/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h (98469 => 98470)


--- branches/safari-534.52-branch/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h	2011-10-26 13:10:28 UTC (rev 98469)
+++ branches/safari-534.52-branch/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h	2011-10-26 13:17:04 UTC (rev 98470)
@@ -53,6 +53,7 @@
     unsigned m_bytesPerRow;
     CGColorSpaceRef m_colorSpace;
     RetainPtr<IOSurfaceRef> m_surface;
+    mutable double m_lastFlushTime;
 
     PassRefPtr<ByteArray> getData(const IntRect& rect, const IntSize& size, bool accelerateRendering, bool unmultiplied) const;
     void putData(ByteArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize& size, bool accelerateRendering, bool unmultiplied);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to