OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "WebMediaPlayerClientImpl.h" | 6 #include "WebMediaPlayerClientImpl.h" |
7 | 7 |
8 #include "WebDocument.h" | 8 #include "WebDocument.h" |
9 #include "WebFrameClient.h" | 9 #include "WebFrameClient.h" |
10 #include "WebFrameImpl.h" | 10 #include "WebFrameImpl.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // MediaPlayer ------------------------------------------------- | 180 // MediaPlayer ------------------------------------------------- |
181 void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF
::String& url, WebMediaPlayer::CORSMode corsMode) | 181 void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF
::String& url, WebMediaPlayer::CORSMode corsMode) |
182 { | 182 { |
183 ASSERT(!m_webMediaPlayer); | 183 ASSERT(!m_webMediaPlayer); |
184 | 184 |
185 // FIXME: Remove this cast | 185 // FIXME: Remove this cast |
186 LocalFrame* frame = mediaElement().document().frame(); | 186 LocalFrame* frame = mediaElement().document().frame(); |
187 | 187 |
188 WebURL poster = m_client->mediaPlayerPosterURL(); | 188 WebURL poster = m_client->mediaPlayerPosterURL(); |
189 | 189 |
190 // This does not actually check whether the hardware can support accelerated | |
191 // compositing, but only if the flag is set. However, this is checked lazily | |
192 // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there | |
193 // if necessary. | |
194 m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceler
atedCompositing(); | |
195 | |
196 KURL kurl(ParsedURLString, url); | 190 KURL kurl(ParsedURLString, url); |
197 m_webMediaPlayer = createWebMediaPlayer(this, kurl, frame); | 191 m_webMediaPlayer = createWebMediaPlayer(this, kurl, frame); |
198 if (!m_webMediaPlayer) | 192 if (!m_webMediaPlayer) |
199 return; | 193 return; |
200 | 194 |
201 #if ENABLE(WEB_AUDIO) | 195 #if ENABLE(WEB_AUDIO) |
202 // Make sure if we create/re-create the WebMediaPlayer that we update our wr
apper. | 196 // Make sure if we create/re-create the WebMediaPlayer that we update our wr
apper. |
203 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); | 197 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); |
204 #endif | 198 #endif |
205 | 199 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 return 0; | 445 return 0; |
452 } | 446 } |
453 | 447 |
454 #if ENABLE(WEB_AUDIO) | 448 #if ENABLE(WEB_AUDIO) |
455 AudioSourceProvider* WebMediaPlayerClientImpl::audioSourceProvider() | 449 AudioSourceProvider* WebMediaPlayerClientImpl::audioSourceProvider() |
456 { | 450 { |
457 return &m_audioSourceProvider; | 451 return &m_audioSourceProvider; |
458 } | 452 } |
459 #endif | 453 #endif |
460 | 454 |
461 bool WebMediaPlayerClientImpl::needsWebLayerForVideo() const | |
462 { | |
463 return m_needsWebLayerForVideo; | |
464 } | |
465 | |
466 PassOwnPtr<MediaPlayer> WebMediaPlayerClientImpl::create(MediaPlayerClient* clie
nt) | 455 PassOwnPtr<MediaPlayer> WebMediaPlayerClientImpl::create(MediaPlayerClient* clie
nt) |
467 { | 456 { |
468 return adoptPtr(new WebMediaPlayerClientImpl(client)); | 457 return adoptPtr(new WebMediaPlayerClientImpl(client)); |
469 } | 458 } |
470 | 459 |
471 #if OS(ANDROID) | 460 #if OS(ANDROID) |
472 void WebMediaPlayerClientImpl::paintOnAndroid(WebCore::GraphicsContext* context,
const IntRect& rect, uint8_t alpha) | 461 void WebMediaPlayerClientImpl::paintOnAndroid(WebCore::GraphicsContext* context,
const IntRect& rect, uint8_t alpha) |
473 { | 462 { |
474 OwnPtr<blink::WebGraphicsContext3DProvider> provider = adoptPtr(blink::Platf
orm::current()->createSharedOffscreenGraphicsContext3DProvider()); | 463 OwnPtr<blink::WebGraphicsContext3DProvider> provider = adoptPtr(blink::Platf
orm::current()->createSharedOffscreenGraphicsContext3DProvider()); |
475 if (!provider) | 464 if (!provider) |
(...skipping 25 matching lines...) Expand all Loading... |
501 SkPaint paint; | 490 SkPaint paint; |
502 paint.setAlpha(alpha); | 491 paint.setAlpha(alpha); |
503 // It is not necessary to pass the dest into the drawBitmap call since all t
he context have been set up before calling paintCurrentFrameInContext. | 492 // It is not necessary to pass the dest into the drawBitmap call since all t
he context have been set up before calling paintCurrentFrameInContext. |
504 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); | 493 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); |
505 } | 494 } |
506 #endif | 495 #endif |
507 | 496 |
508 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) | 497 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) |
509 : m_client(client) | 498 : m_client(client) |
510 , m_preload(MediaPlayer::Auto) | 499 , m_preload(MediaPlayer::Auto) |
511 , m_needsWebLayerForVideo(false) | |
512 , m_rate(1.0) | 500 , m_rate(1.0) |
513 #if OS(ANDROID) | 501 #if OS(ANDROID) |
514 , m_usePaintOnAndroid(false) | 502 , m_usePaintOnAndroid(false) |
515 #endif | 503 #endif |
516 { | 504 { |
517 ASSERT(m_client); | 505 ASSERT(m_client); |
518 } | 506 } |
519 | 507 |
520 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const | 508 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const |
521 { | 509 { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 | 559 |
572 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) | 560 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) |
573 { | 561 { |
574 if (m_client) | 562 if (m_client) |
575 m_client->setFormat(numberOfChannels, sampleRate); | 563 m_client->setFormat(numberOfChannels, sampleRate); |
576 } | 564 } |
577 | 565 |
578 #endif | 566 #endif |
579 | 567 |
580 } // namespace blink | 568 } // namespace blink |
OLD | NEW |