Changeset 98171 in webkit
- Timestamp:
- Oct 21, 2011 5:01:58 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r98164 r98171 1 2011-10-21 Matthew Delaney <mdelaney@apple.com> 2 3 Ensure periodic flushing of canvas drawing context 4 https://bugs.webkit.org/show_bug.cgi?id=70646 5 6 Reviewed by Simon Fraser. 7 8 No new tests. No current way to track tests that cause hangs or 9 non-deterministic drops in performance. 10 11 * platform/graphics/cg/ImageBufferDataCG.h: Adds a timestamp of last tracked flush. 12 * platform/graphics/cg/ImageBufferCG.cpp: Ensures periodic flushes on the drawing context. 13 (WebCore::ImageBuffer::ImageBuffer): 14 (WebCore::ImageBuffer::context): Flushes context if we're beyond flush interval. 15 (WebCore::ImageBuffer::copyNativeImage): Updates last flush timestamp. 16 (WebCore::ImageBuffer::getUnmultipliedImageData): Updates last flush timestamp. 17 (WebCore::ImageBuffer::getPremultipliedImageData): Updates last flush timestamp. 18 (WebCore::ImageBuffer::putUnmultipliedImageData): Updates last flush timestamp. 19 (WebCore::ImageBuffer::putPremultipliedImageData): Updates last flush timestamp. 20 1 21 2011-10-21 Adam Barth <abarth@webkit.org> 2 22 -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
r97946 r98171 39 39 #include <wtf/Assertions.h> 40 40 #include <wtf/CheckedArithmetic.h> 41 #include <wtf/CurrentTime.h> 41 42 #include <wtf/MainThread.h> 42 43 #include <wtf/OwnArrayPtr.h> … … 165 166 return; 166 167 167 m_context = adoptPtr(new GraphicsContext(cgContext.get()));168 m_context = adoptPtr(new GraphicsContext(cgContext.get())); 168 169 m_context->scale(FloatSize(1, -1)); 169 170 m_context->translate(0, -height.unsafeGet()); 170 171 m_context->setIsAcceleratedContext(accelerateRendering); 172 m_data.m_lastFlushTime = currentTimeMS(); 171 173 success = true; 172 174 } … … 183 185 GraphicsContext* ImageBuffer::context() const 184 186 { 187 // Force a flush if last flush was more than 20ms ago 188 if (m_context->isAcceleratedContext()) { 189 double elapsedTime = currentTimeMS() - m_data.m_lastFlushTime; 190 double maxFlushInterval = 20; // in ms 191 192 if (elapsedTime > maxFlushInterval) { 193 CGContextRef context = m_context->platformContext(); 194 CGContextFlush(context); 195 m_data.m_lastFlushTime = currentTimeMS(); 196 } 197 } 198 185 199 return m_context.get(); 186 200 } … … 213 227 } 214 228 #if USE(IOSURFACE_CANVAS_BACKING_STORE) 215 else 229 else { 216 230 image = wkIOSurfaceContextCreateImage(context()->platformContext()); 231 m_data.m_lastFlushTime = currentTimeMS(); 232 } 217 233 #endif 218 234 … … 263 279 PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const 264 280 { 265 if (m_context->isAcceleratedContext()) 281 if (m_context->isAcceleratedContext()) { 266 282 CGContextFlush(context()->platformContext()); 283 m_data.m_lastFlushTime = currentTimeMS(); 284 } 267 285 return m_data.getData(rect, m_size, m_context->isAcceleratedContext(), true); 268 286 } … … 270 288 PassRefPtr<ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const 271 289 { 272 if (m_context->isAcceleratedContext()) 290 if (m_context->isAcceleratedContext()) { 273 291 CGContextFlush(context()->platformContext()); 292 m_data.m_lastFlushTime = currentTimeMS(); 293 } 274 294 return m_data.getData(rect, m_size, m_context->isAcceleratedContext(), false); 275 295 } … … 277 297 void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint) 278 298 { 279 if (m_context->isAcceleratedContext()) 299 if (m_context->isAcceleratedContext()) { 280 300 CGContextFlush(context()->platformContext()); 301 m_data.m_lastFlushTime = currentTimeMS(); 302 } 281 303 m_data.putData(source, sourceSize, sourceRect, destPoint, m_size, m_context->isAcceleratedContext(), true); 282 304 } … … 284 306 void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint) 285 307 { 286 if (m_context->isAcceleratedContext()) 308 if (m_context->isAcceleratedContext()) { 287 309 CGContextFlush(context()->platformContext()); 310 m_data.m_lastFlushTime = currentTimeMS(); 311 } 288 312 m_data.putData(source, sourceSize, sourceRect, destPoint, m_size, m_context->isAcceleratedContext(), false); 289 313 } -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h
r95901 r98171 55 55 CGColorSpaceRef m_colorSpace; 56 56 RetainPtr<IOSurfaceRef> m_surface; 57 mutable double m_lastFlushTime; 57 58 58 59 PassRefPtr<ByteArray> getData(const IntRect& rect, const IntSize& size, bool accelerateRendering, bool unmultiplied) const;
Note: See TracChangeset
for help on using the changeset viewer.