OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 , m_objcObserver(AdoptNS, [[WebCoreMovieObserver alloc] initWithCallback:thi
s]) | 180 , m_objcObserver(AdoptNS, [[WebCoreMovieObserver alloc] initWithCallback:thi
s]) |
181 , m_seekTo(-1) | 181 , m_seekTo(-1) |
182 , m_endTime(numeric_limits<float>::infinity()) | 182 , m_endTime(numeric_limits<float>::infinity()) |
183 , m_seekTimer(this, &MediaPlayerPrivate::seekTimerFired) | 183 , m_seekTimer(this, &MediaPlayerPrivate::seekTimerFired) |
184 , m_endPointTimer(this, &MediaPlayerPrivate::endPointTimerFired) | 184 , m_endPointTimer(this, &MediaPlayerPrivate::endPointTimerFired) |
185 , m_networkState(MediaPlayer::Empty) | 185 , m_networkState(MediaPlayer::Empty) |
186 , m_readyState(MediaPlayer::DataUnavailable) | 186 , m_readyState(MediaPlayer::DataUnavailable) |
187 , m_startedPlaying(false) | 187 , m_startedPlaying(false) |
188 , m_isStreaming(false) | 188 , m_isStreaming(false) |
189 , m_visible(false) | 189 , m_visible(false) |
| 190 , m_rect() |
190 #if DRAW_FRAME_RATE | 191 #if DRAW_FRAME_RATE |
191 , m_frameCountWhilePlaying(0) | 192 , m_frameCountWhilePlaying(0) |
192 , m_timeStartedPlaying(0) | 193 , m_timeStartedPlaying(0) |
193 , m_timeStoppedPlaying(0) | 194 , m_timeStoppedPlaying(0) |
194 #endif | 195 #endif |
195 { | 196 { |
196 } | 197 } |
197 | 198 |
198 MediaPlayerPrivate::~MediaPlayerPrivate() | 199 MediaPlayerPrivate::~MediaPlayerPrivate() |
199 { | 200 { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 Class QTMovieContentViewClass = NSClassFromString(@"QTMovieContentView")
; | 289 Class QTMovieContentViewClass = NSClassFromString(@"QTMovieContentView")
; |
289 ASSERT(QTMovieContentViewClass); | 290 ASSERT(QTMovieContentViewClass); |
290 | 291 |
291 Method mainThreadSetNeedsDisplayMethod = class_getInstanceMethod(QTMovie
ContentViewClass, @selector(_mainThreadSetNeedsDisplay)); | 292 Method mainThreadSetNeedsDisplayMethod = class_getInstanceMethod(QTMovie
ContentViewClass, @selector(_mainThreadSetNeedsDisplay)); |
292 ASSERT(mainThreadSetNeedsDisplayMethod); | 293 ASSERT(mainThreadSetNeedsDisplayMethod); |
293 | 294 |
294 method_setImplementation(mainThreadSetNeedsDisplayMethod, reinterpret_ca
st<IMP>(mainThreadSetNeedsDisplay)); | 295 method_setImplementation(mainThreadSetNeedsDisplayMethod, reinterpret_ca
st<IMP>(mainThreadSetNeedsDisplay)); |
295 addedCustomMethods = true; | 296 addedCustomMethods = true; |
296 } | 297 } |
297 | 298 |
| 299 // delay callbacks as we *will* get notifications during setup |
| 300 [m_objcObserver.get() setDelayCallbacks:YES]; |
| 301 |
298 m_qtMovieView.adoptNS([[QTMovieView alloc] init]); | 302 m_qtMovieView.adoptNS([[QTMovieView alloc] init]); |
299 setRect(m_player->rect()); | 303 setSize(m_player->size()); |
300 NSView* parentView = m_player->frameView()->documentView(); | 304 NSView* parentView = m_player->frameView()->documentView(); |
301 [parentView addSubview:m_qtMovieView.get()]; | 305 [parentView addSubview:m_qtMovieView.get()]; |
302 #ifdef BUILDING_ON_TIGER | 306 #ifdef BUILDING_ON_TIGER |
303 // setDelegate: isn't a public call in Tiger, so use performSelector to keep
the compiler happy | 307 // setDelegate: isn't a public call in Tiger, so use performSelector to keep
the compiler happy |
304 [m_qtMovieView.get() performSelector:@selector(setDelegate:) withObject:m_ob
jcObserver.get()]; | 308 [m_qtMovieView.get() performSelector:@selector(setDelegate:) withObject:m_ob
jcObserver.get()]; |
305 #else | 309 #else |
306 [m_qtMovieView.get() setDelegate:m_objcObserver.get()]; | 310 [m_qtMovieView.get() setDelegate:m_objcObserver.get()]; |
307 #endif | 311 #endif |
308 [m_objcObserver.get() setView:m_qtMovieView.get()]; | 312 [m_objcObserver.get() setView:m_qtMovieView.get()]; |
309 [m_qtMovieView.get() setMovie:m_qtMovie.get()]; | 313 [m_qtMovieView.get() setMovie:m_qtMovie.get()]; |
310 [m_qtMovieView.get() setControllerVisible:NO]; | 314 [m_qtMovieView.get() setControllerVisible:NO]; |
311 [m_qtMovieView.get() setPreservesAspectRatio:NO]; | 315 [m_qtMovieView.get() setPreservesAspectRatio:NO]; |
312 // the area not covered by video should be transparent | 316 // the area not covered by video should be transparent |
313 [m_qtMovieView.get() setFillColor:[NSColor clearColor]]; | 317 [m_qtMovieView.get() setFillColor:[NSColor clearColor]]; |
314 | 318 |
315 // If we're in a media document, allow QTMovieView to render in its default
mode; | 319 // If we're in a media document, allow QTMovieView to render in its default
mode; |
316 // otherwise tell it to draw synchronously. | 320 // otherwise tell it to draw synchronously. |
317 // Note that we expect mainThreadSetNeedsDisplay to be invoked only when syn
chronous drawing is requested. | 321 // Note that we expect mainThreadSetNeedsDisplay to be invoked only when syn
chronous drawing is requested. |
318 if (!m_player->inMediaDocument()) | 322 if (!m_player->inMediaDocument()) |
319 wkQTMovieViewSetDrawSynchronously(m_qtMovieView.get(), YES); | 323 wkQTMovieViewSetDrawSynchronously(m_qtMovieView.get(), YES); |
| 324 |
| 325 [m_objcObserver.get() setDelayCallbacks:NO]; |
320 } | 326 } |
321 | 327 |
322 void MediaPlayerPrivate::detachQTMovieView() | 328 void MediaPlayerPrivate::detachQTMovieView() |
323 { | 329 { |
324 if (m_qtMovieView) { | 330 if (m_qtMovieView) { |
325 [m_objcObserver.get() setView:nil]; | 331 [m_objcObserver.get() setView:nil]; |
326 #ifdef BUILDING_ON_TIGER | 332 #ifdef BUILDING_ON_TIGER |
327 // setDelegate: isn't a public call in Tiger, so use performSelector to
keep the compiler happy | 333 // setDelegate: isn't a public call in Tiger, so use performSelector to
keep the compiler happy |
328 [m_qtMovieView.get() performSelector:@selector(setDelegate:) withObject:
nil]; | 334 [m_qtMovieView.get() performSelector:@selector(setDelegate:) withObject:
nil]; |
329 #else | 335 #else |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 { | 731 { |
726 m_endPointTimer.stop(); | 732 m_endPointTimer.stop(); |
727 m_startedPlaying = false; | 733 m_startedPlaying = false; |
728 #if DRAW_FRAME_RATE | 734 #if DRAW_FRAME_RATE |
729 m_timeStoppedPlaying = [NSDate timeIntervalSinceReferenceDate]; | 735 m_timeStoppedPlaying = [NSDate timeIntervalSinceReferenceDate]; |
730 #endif | 736 #endif |
731 updateStates(); | 737 updateStates(); |
732 m_player->timeChanged(); | 738 m_player->timeChanged(); |
733 } | 739 } |
734 | 740 |
735 void MediaPlayerPrivate::setRect(const IntRect& r) | 741 void MediaPlayerPrivate::setSize(const IntSize& size) |
736 { | 742 { |
737 if (!m_qtMovieView) | 743 if (!m_qtMovieView) |
738 return; | 744 return; |
739 | 745 |
| 746 m_rect.setSize(size); |
740 if (m_player->inMediaDocument()) | 747 if (m_player->inMediaDocument()) |
741 // We need the QTMovieView to be placed in the proper location for docum
ent mode. | 748 // We need the QTMovieView to be placed in the proper location for docum
ent mode. |
742 [m_qtMovieView.get() setFrame:r]; | 749 [m_qtMovieView.get() setFrame:m_rect]; |
743 else { | 750 else { |
744 // We don't really need the QTMovieView in any specific location so let'
s just get it out of the way | 751 // We don't really need the QTMovieView in any specific location so let'
s just get it out of the way |
745 // where it won't intercept events or try to bring up the context menu. | 752 // where it won't intercept events or try to bring up the context menu. |
746 IntRect farAwayButCorrectSize(r); | 753 IntRect farAwayButCorrectSize(m_rect); |
747 farAwayButCorrectSize.move(-1000000, -1000000); | 754 farAwayButCorrectSize.move(-1000000, -1000000); |
748 [m_qtMovieView.get() setFrame:farAwayButCorrectSize]; | 755 [m_qtMovieView.get() setFrame:farAwayButCorrectSize]; |
749 } | 756 } |
750 } | 757 } |
751 | 758 |
752 void MediaPlayerPrivate::setVisible(bool b) | 759 void MediaPlayerPrivate::setVisible(bool b) |
753 { | 760 { |
754 if (m_visible != b) { | 761 if (m_visible != b) { |
755 m_visible = b; | 762 m_visible = b; |
756 if (b) { | 763 if (b) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 AutodrainedPool pool; | 803 AutodrainedPool pool; |
797 #endif | 804 #endif |
798 NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithGraphi
csPort:context->platformContext() flipped:NO]; | 805 NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithGraphi
csPort:context->platformContext() flipped:NO]; |
799 | 806 |
800 // draw the current video frame | 807 // draw the current video frame |
801 if (qtVideoRenderer) { | 808 if (qtVideoRenderer) { |
802 [NSGraphicsContext saveGraphicsState]; | 809 [NSGraphicsContext saveGraphicsState]; |
803 [NSGraphicsContext setCurrentContext:newContext]; | 810 [NSGraphicsContext setCurrentContext:newContext]; |
804 [(id<WebKitVideoRenderingDetails>)qtVideoRenderer drawInRect:paintRect]; | 811 [(id<WebKitVideoRenderingDetails>)qtVideoRenderer drawInRect:paintRect]; |
805 [NSGraphicsContext restoreGraphicsState]; | 812 [NSGraphicsContext restoreGraphicsState]; |
806 } else | 813 } else { |
| 814 if (m_player->inMediaDocument() && r != m_rect) { |
| 815 // the QTMovieView needs to be placed in the proper location for doc
ument mode |
| 816 m_rect = r; |
| 817 [view setFrame:m_rect]; |
| 818 } |
807 [view displayRectIgnoringOpacity:paintRect inContext:newContext]; | 819 [view displayRectIgnoringOpacity:paintRect inContext:newContext]; |
| 820 } |
808 | 821 |
809 #if DRAW_FRAME_RATE | 822 #if DRAW_FRAME_RATE |
810 // Draw the frame rate only after having played more than 10 frames. | 823 // Draw the frame rate only after having played more than 10 frames. |
811 if (m_frameCountWhilePlaying > 10) { | 824 if (m_frameCountWhilePlaying > 10) { |
812 Frame* frame = m_player->frameView() ? m_player->frameView()->frame() :
NULL; | 825 Frame* frame = m_player->frameView() ? m_player->frameView()->frame() :
NULL; |
813 Document* document = frame ? frame->document() : NULL; | 826 Document* document = frame ? frame->document() : NULL; |
814 RenderObject* renderer = document ? document->renderer() : NULL; | 827 RenderObject* renderer = document ? document->renderer() : NULL; |
815 RenderStyle* styleToUse = renderer ? renderer->style() : NULL; | 828 RenderStyle* styleToUse = renderer ? renderer->style() : NULL; |
816 if (styleToUse) { | 829 if (styleToUse) { |
817 double frameRate = (m_frameCountWhilePlaying - 1) / ( m_startedPlayi
ng ? ([NSDate timeIntervalSinceReferenceDate] - m_timeStartedPlaying) : | 830 double frameRate = (m_frameCountWhilePlaying - 1) / ( m_startedPlayi
ng ? ([NSDate timeIntervalSinceReferenceDate] - m_timeStartedPlaying) : |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 } | 1078 } |
1066 | 1079 |
1067 - (void)setDelayCallbacks:(BOOL)shouldDelay | 1080 - (void)setDelayCallbacks:(BOOL)shouldDelay |
1068 { | 1081 { |
1069 m_delayCallbacks = shouldDelay; | 1082 m_delayCallbacks = shouldDelay; |
1070 } | 1083 } |
1071 | 1084 |
1072 @end | 1085 @end |
1073 | 1086 |
1074 #endif | 1087 #endif |
OLD | NEW |