Changeset 157055 in webkit
- Timestamp:
- Oct 7, 2013, 1:04:46 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r157053 r157055 1 2013-10-07 Jer Noble <jer.noble@apple.com> 2 3 [Mac] Drawing video into canvas doesn't work on the first attempt 4 https://bugs.webkit.org/show_bug.cgi?id=122404 5 6 Reviewed by Eric Carlson. 7 8 * media/video-canvas-drawing-expected.png: Added. 9 * media/video-canvas-drawing-expected.txt: Added. 10 * media/video-canvas-drawing.html: Added. 11 1 12 2013-10-07 Tim Horton <timothy_horton@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r157054 r157055 1 2013-10-07 Jer Noble <jer.noble@apple.com> 2 3 [Mac] Drawing video into canvas doesn't work on the first attempt 4 https://bugs.webkit.org/show_bug.cgi?id=122404 5 6 Reviewed by Eric Carlson. 7 8 Test: media/video-canvas-drawing.html 9 10 If creating and painting from an AVPlayerItemVideoOutput fails, fall back 11 to the (much slower) AVAssetImageGenerator path. Make sure to revert to the 12 AVPlayerItemVideoOutput path when that object begins to have available 13 images, however. 14 15 To do so, remove the "__MAC_OS_X_VERSION_MIN_REQUIRED < 1080" check around 16 the AVAssetImageGenerator code, and allow both the image generator and video 17 output to exist simultaneously. 18 19 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 20 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 21 (WebCore::MediaPlayerPrivateAVFoundationObjC::hasContextRenderer): 22 (WebCore::MediaPlayerPrivateAVFoundationObjC::destroyContextVideoRenderer): 23 (WebCore::MediaPlayerPrivateAVFoundationObjC::destroyImageGenerator): 24 (WebCore::MediaPlayerPrivateAVFoundationObjC::paintCurrentFrameInContext): 25 (WebCore::MediaPlayerPrivateAVFoundationObjC::videoOutputHasAvailableFrame): 26 (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput): 27 1 28 2013-10-07 Jer Noble <jer.noble@apple.com> 2 29 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r157044 r157055 155 155 virtual bool hasSingleSecurityOrigin() const; 156 156 157 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080158 157 void createImageGenerator(); 159 158 void destroyImageGenerator(); 160 159 RetainPtr<CGImageRef> createImageForTimeInRect(float, const IntRect&); 161 160 void paintWithImageGenerator(GraphicsContext*, const IntRect&); 162 #else 161 162 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 163 163 void createVideoOutput(); 164 164 void destroyVideoOutput(); 165 165 RetainPtr<CVPixelBufferRef> createPixelBuffer(); 166 bool videoOutputHasAvailableFrame(); 166 167 void paintWithVideoOutput(GraphicsContext*, const IntRect&); 167 168 #endif … … 202 203 bool m_haveCheckedPlayability; 203 204 204 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080205 205 RetainPtr<AVAssetImageGenerator> m_imageGenerator; 206 # else206 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 207 207 RetainPtr<AVPlayerItemVideoOutput> m_videoOutput; 208 208 RetainPtr<CVPixelBufferRef> m_lastImage; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r156726 r157055 313 313 { 314 314 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 315 return m_videoOutput; 316 #else 315 if (m_videoOutput) 316 return true; 317 #endif 317 318 return m_imageGenerator; 318 #endif319 319 } 320 320 … … 328 328 } 329 329 330 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080331 330 void MediaPlayerPrivateAVFoundationObjC::createImageGenerator() 332 331 { … … 345 344 LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createImageGenerator(%p) - returning %p", this, m_imageGenerator.get()); 346 345 } 347 #endif348 346 349 347 void MediaPlayerPrivateAVFoundationObjC::destroyContextVideoRenderer() … … 351 349 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 352 350 destroyVideoOutput(); 353 #e lse351 #endif 354 352 destroyImageGenerator(); 355 #endif 356 } 357 358 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080 353 } 354 359 355 void MediaPlayerPrivateAVFoundationObjC::destroyImageGenerator() 360 356 { … … 366 362 m_imageGenerator = 0; 367 363 } 368 #endif369 364 370 365 void MediaPlayerPrivateAVFoundationObjC::createVideoLayer() … … 803 798 804 799 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 805 paintWithVideoOutput(context, rect); 806 #else 807 paintWithImageGenerator(context, rect); 808 #endif 800 if (videoOutputHasAvailableFrame()) 801 paintWithVideoOutput(context, rect); 802 else 803 #endif 804 paintWithImageGenerator(context, rect); 809 805 810 806 END_BLOCK_OBJC_EXCEPTIONS; … … 826 822 } 827 823 828 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080829 824 void MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator(GraphicsContext* context, const IntRect& rect) 830 825 { … … 840 835 } 841 836 } 842 #endif843 837 844 838 static HashSet<String> mimeTypeCache() … … 858 852 } 859 853 860 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080861 854 RetainPtr<CGImageRef> MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect(float time, const IntRect& rect) 862 855 { … … 879 872 return image; 880 873 } 881 #endif882 874 883 875 void MediaPlayerPrivateAVFoundationObjC::getSupportedTypes(HashSet<String>& supportedTypes) … … 1260 1252 } 1261 1253 1254 bool MediaPlayerPrivateAVFoundationObjC::videoOutputHasAvailableFrame() 1255 { 1256 if (!m_avPlayerItem) 1257 return false; 1258 1259 if (m_lastImage) 1260 return true; 1261 1262 if (!m_videoOutput) 1263 createVideoOutput(); 1264 1265 return [m_videoOutput hasNewPixelBufferForItemTime:[m_avPlayerItem currentTime]]; 1266 } 1267 1262 1268 void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext* context, const IntRect& rect) 1263 1269 { … … 1282 1288 CGRect imageRect = CGRectMake(0, 0, CVPixelBufferGetWidth(m_lastImage.get()), CVPixelBufferGetHeight(m_lastImage.get())); 1283 1289 [ciContext drawImage:image.get() inRect:outputRect fromRect:imageRect]; 1290 1291 // If we have created an AVAssetImageGenerator in the past due to m_videoOutput not having an available 1292 // video frame, destroy it now that it is no longer needed. 1293 if (m_imageGenerator) 1294 destroyImageGenerator(); 1284 1295 } 1285 1296 }
Note:
See TracChangeset
for help on using the changeset viewer.