Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2491 } | 2491 } |
| 2492 } | 2492 } |
| 2493 | 2493 |
| 2494 WebMediaPlayer* RenderViewImpl::createMediaPlayer( | 2494 WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
| 2495 WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) { | 2495 WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) { |
| 2496 FOR_EACH_OBSERVER( | 2496 FOR_EACH_OBSERVER( |
| 2497 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); | 2497 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); |
| 2498 | 2498 |
| 2499 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 2499 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 2500 #if defined(OS_ANDROID) | 2500 #if defined(OS_ANDROID) |
| 2501 // TODO(qinmin): upstream the implementation of getting WebGraphicsContext3D | 2501 // Leak |resource_context| similar to SharedGraphicsContext3D to avoid |
| 2502 // and GpuChannelHost here to replace the NULL params. | 2502 // shutdown races. |
| 2503 // TODO(sievers): Expose the shared context from webkit to be used here. | |
|
jamesr
2012/09/22 00:42:22
the shared context is exposed from WebKit. Specif
qinmin
2012/09/22 01:45:28
Done.
| |
| 2504 static WebGraphicsContext3DCommandBufferImpl* resource_context = NULL; | |
| 2505 if (!resource_context) { | |
| 2506 // Create a main-thread context for resource allocation. | |
| 2507 int surface = 0; | |
| 2508 GURL url; | |
| 2509 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; | |
| 2510 | |
| 2511 resource_context = new WebGraphicsContext3DCommandBufferImpl( | |
| 2512 surface, url, RenderThreadImpl::current(), swap_client); | |
| 2513 WebKit::WebGraphicsContext3D::Attributes attributes; | |
| 2514 attributes.antialias = false; | |
| 2515 attributes.shareResources = true; | |
| 2516 attributes.depth = false; | |
| 2517 attributes.stencil = false; | |
| 2518 if (!resource_context->Initialize( | |
| 2519 attributes, | |
| 2520 false, | |
| 2521 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE)) { | |
| 2522 delete resource_context; | |
| 2523 resource_context = NULL; | |
| 2524 LOG(ERROR) << "Failed to create graphics context for video resources"; | |
| 2525 return NULL; | |
| 2526 } | |
| 2527 } | |
| 2528 | |
| 2529 GpuChannelHost* gpu_channel_host = | |
| 2530 RenderThreadImpl::current()->EstablishGpuChannelSync( | |
| 2531 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | |
| 2532 if (!gpu_channel_host) { | |
| 2533 LOG(ERROR) << "Failed to establish GPU channel for media player"; | |
| 2534 return NULL; | |
| 2535 } | |
| 2536 | |
| 2503 if (cmd_line->HasSwitch(switches::kMediaPlayerInRenderProcess)) { | 2537 if (cmd_line->HasSwitch(switches::kMediaPlayerInRenderProcess)) { |
| 2504 if (!media_bridge_manager_.get()) { | 2538 if (!media_bridge_manager_.get()) { |
| 2505 media_bridge_manager_.reset( | 2539 media_bridge_manager_.reset( |
| 2506 new webkit_media::MediaPlayerBridgeManagerImpl(1)); | 2540 new webkit_media::MediaPlayerBridgeManagerImpl(1)); |
| 2507 } | 2541 } |
| 2508 return new webkit_media::WebMediaPlayerInProcessAndroid( | 2542 return new webkit_media::WebMediaPlayerInProcessAndroid( |
| 2509 frame, | 2543 frame, |
| 2510 client, | 2544 client, |
| 2511 cookieJar(frame), | 2545 cookieJar(frame), |
| 2512 media_player_manager_.get(), | 2546 media_player_manager_.get(), |
| 2513 media_bridge_manager_.get(), | 2547 media_bridge_manager_.get(), |
| 2514 new content::StreamTextureFactoryImpl( | 2548 new content::StreamTextureFactoryImpl( |
| 2515 NULL, NULL, routing_id_), | 2549 resource_context, gpu_channel_host, routing_id_), |
| 2516 cmd_line->HasSwitch(switches::kDisableMediaHistoryLogging)); | 2550 cmd_line->HasSwitch(switches::kDisableMediaHistoryLogging)); |
| 2517 } | 2551 } |
| 2518 if (!media_player_proxy_) { | 2552 if (!media_player_proxy_) { |
| 2519 media_player_proxy_ = new content::WebMediaPlayerProxyImplAndroid( | 2553 media_player_proxy_ = new content::WebMediaPlayerProxyImplAndroid( |
| 2520 this, media_player_manager_.get()); | 2554 this, media_player_manager_.get()); |
| 2521 } | 2555 } |
| 2522 return new webkit_media::WebMediaPlayerImplAndroid( | 2556 return new webkit_media::WebMediaPlayerImplAndroid( |
| 2523 frame, | 2557 frame, |
| 2524 client, | 2558 client, |
| 2525 media_player_manager_.get(), | 2559 media_player_manager_.get(), |
| 2526 media_player_proxy_, | 2560 media_player_proxy_, |
| 2527 new content::StreamTextureFactoryImpl( | 2561 new content::StreamTextureFactoryImpl( |
| 2528 NULL, NULL, routing_id_)); | 2562 resource_context, gpu_channel_host, routing_id_)); |
| 2529 #endif | 2563 #endif |
| 2530 | 2564 |
| 2531 media::MessageLoopFactory* message_loop_factory = | 2565 media::MessageLoopFactory* message_loop_factory = |
| 2532 new media::MessageLoopFactory(); | 2566 new media::MessageLoopFactory(); |
| 2533 media::FilterCollection* collection = new media::FilterCollection(); | 2567 media::FilterCollection* collection = new media::FilterCollection(); |
| 2534 RenderMediaLog* render_media_log = new RenderMediaLog(); | 2568 RenderMediaLog* render_media_log = new RenderMediaLog(); |
| 2535 | 2569 |
| 2536 RenderAudioSourceProvider* audio_source_provider = NULL; | 2570 RenderAudioSourceProvider* audio_source_provider = NULL; |
| 2537 | 2571 |
| 2538 // Add in any custom filter factories first. | 2572 // Add in any custom filter factories first. |
| (...skipping 3700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6239 | 6273 |
| 6240 updating_frame_tree_ = true; | 6274 updating_frame_tree_ = true; |
| 6241 active_frame_id_map_.clear(); | 6275 active_frame_id_map_.clear(); |
| 6242 | 6276 |
| 6243 target_process_id_ = process_id; | 6277 target_process_id_ = process_id; |
| 6244 target_routing_id_ = route_id; | 6278 target_routing_id_ = route_id; |
| 6245 CreateFrameTree(webview()->mainFrame(), frames); | 6279 CreateFrameTree(webview()->mainFrame(), frames); |
| 6246 | 6280 |
| 6247 updating_frame_tree_ = false; | 6281 updating_frame_tree_ = false; |
| 6248 } | 6282 } |
| OLD | NEW |