Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "content/public/common/url_constants.h" | 45 #include "content/public/common/url_constants.h" |
| 46 #include "content/public/renderer/content_renderer_client.h" | 46 #include "content/public/renderer/content_renderer_client.h" |
| 47 #include "content/public/renderer/document_state.h" | 47 #include "content/public/renderer/document_state.h" |
| 48 #include "content/public/renderer/navigation_state.h" | 48 #include "content/public/renderer/navigation_state.h" |
| 49 #include "content/public/renderer/render_view_observer.h" | 49 #include "content/public/renderer/render_view_observer.h" |
| 50 #include "content/public/renderer/render_view_visitor.h" | 50 #include "content/public/renderer/render_view_visitor.h" |
| 51 #include "content/renderer/device_orientation_dispatcher.h" | 51 #include "content/renderer/device_orientation_dispatcher.h" |
| 52 #include "content/renderer/devtools_agent.h" | 52 #include "content/renderer/devtools_agent.h" |
| 53 #include "content/renderer/external_popup_menu.h" | 53 #include "content/renderer/external_popup_menu.h" |
| 54 #include "content/renderer/geolocation_dispatcher.h" | 54 #include "content/renderer/geolocation_dispatcher.h" |
| 55 #include "content/renderer/gpu/command_buffer_proxy.h" | |
| 56 #include "content/renderer/gpu/gpu_channel_host.h" | |
| 55 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" | 57 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" |
| 56 #include "content/renderer/idle_user_detector.h" | 58 #include "content/renderer/idle_user_detector.h" |
| 57 #include "content/renderer/intents_dispatcher.h" | 59 #include "content/renderer/intents_dispatcher.h" |
| 58 #include "content/renderer/java/java_bridge_dispatcher.h" | 60 #include "content/renderer/java/java_bridge_dispatcher.h" |
| 59 #include "content/renderer/load_progress_tracker.h" | 61 #include "content/renderer/load_progress_tracker.h" |
| 60 #include "content/renderer/media/audio_message_filter.h" | 62 #include "content/renderer/media/audio_message_filter.h" |
| 61 #include "content/renderer/media/audio_renderer_impl.h" | 63 #include "content/renderer/media/audio_renderer_impl.h" |
| 62 #include "content/renderer/media/media_stream_impl.h" | 64 #include "content/renderer/media/media_stream_impl.h" |
| 63 #include "content/renderer/media/render_media_log.h" | 65 #include "content/renderer/media/render_media_log.h" |
| 64 #include "content/renderer/mhtml_generator.h" | 66 #include "content/renderer/mhtml_generator.h" |
| 65 #include "content/renderer/notification_provider.h" | 67 #include "content/renderer/notification_provider.h" |
| 66 #include "content/renderer/p2p/socket_dispatcher.h" | 68 #include "content/renderer/p2p/socket_dispatcher.h" |
| 67 #include "content/renderer/plugin_channel_host.h" | 69 #include "content/renderer/plugin_channel_host.h" |
| 68 #include "content/renderer/render_process.h" | 70 #include "content/renderer/render_process.h" |
| 69 #include "content/renderer/render_thread_impl.h" | 71 #include "content/renderer/render_thread_impl.h" |
| 70 #include "content/renderer/render_widget_fullscreen_pepper.h" | 72 #include "content/renderer/render_widget_fullscreen_pepper.h" |
| 71 #include "content/renderer/renderer_accessibility.h" | 73 #include "content/renderer/renderer_accessibility.h" |
| 72 #include "content/renderer/renderer_webapplicationcachehost_impl.h" | 74 #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
| 73 #include "content/renderer/renderer_webstoragenamespace_impl.h" | 75 #include "content/renderer/renderer_webstoragenamespace_impl.h" |
| 74 #include "content/renderer/speech_input_dispatcher.h" | 76 #include "content/renderer/speech_input_dispatcher.h" |
| 75 #include "content/renderer/text_input_client_observer.h" | 77 #include "content/renderer/text_input_client_observer.h" |
| 76 #include "content/renderer/v8_value_converter_impl.h" | 78 #include "content/renderer/v8_value_converter_impl.h" |
| 77 #include "content/renderer/web_ui_bindings.h" | 79 #include "content/renderer/web_ui_bindings.h" |
| 78 #include "content/renderer/webplugin_delegate_proxy.h" | 80 #include "content/renderer/webplugin_delegate_proxy.h" |
| 79 #include "content/renderer/websharedworker_proxy.h" | 81 #include "content/renderer/websharedworker_proxy.h" |
| 82 #include "gpu/command_buffer/client/gles2_implementation.h" | |
| 80 #include "media/base/filter_collection.h" | 83 #include "media/base/filter_collection.h" |
| 81 #include "media/base/media_switches.h" | 84 #include "media/base/media_switches.h" |
| 82 #include "media/base/message_loop_factory_impl.h" | 85 #include "media/base/message_loop_factory_impl.h" |
| 86 #include "media/filters/gpu_video_decoder.h" | |
| 83 #include "net/base/escape.h" | 87 #include "net/base/escape.h" |
| 84 #include "net/base/net_errors.h" | 88 #include "net/base/net_errors.h" |
| 85 #include "net/http/http_util.h" | 89 #include "net/http/http_util.h" |
| 86 #include "ppapi/c/private/ppb_flash_net_connector.h" | 90 #include "ppapi/c/private/ppb_flash_net_connector.h" |
| 87 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" | 91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" |
| 88 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " | 92 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " |
| 89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
| 90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 91 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData. h" | 95 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData. h" |
| 92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 #include "webkit/glue/context_menu.h" | 144 #include "webkit/glue/context_menu.h" |
| 141 #include "webkit/glue/dom_operations.h" | 145 #include "webkit/glue/dom_operations.h" |
| 142 #include "webkit/glue/form_data.h" | 146 #include "webkit/glue/form_data.h" |
| 143 #include "webkit/glue/form_field.h" | 147 #include "webkit/glue/form_field.h" |
| 144 #include "webkit/glue/glue_serialize.h" | 148 #include "webkit/glue/glue_serialize.h" |
| 145 #include "webkit/glue/password_form_dom_manager.h" | 149 #include "webkit/glue/password_form_dom_manager.h" |
| 146 #include "webkit/glue/webdropdata.h" | 150 #include "webkit/glue/webdropdata.h" |
| 147 #include "webkit/glue/webkit_constants.h" | 151 #include "webkit/glue/webkit_constants.h" |
| 148 #include "webkit/glue/webkit_glue.h" | 152 #include "webkit/glue/webkit_glue.h" |
| 149 #include "webkit/glue/weburlloader_impl.h" | 153 #include "webkit/glue/weburlloader_impl.h" |
| 150 #include "webkit/media/video_renderer_impl.h" | |
| 151 #include "webkit/media/webmediaplayer_impl.h" | 154 #include "webkit/media/webmediaplayer_impl.h" |
| 152 #include "webkit/plugins/npapi/plugin_list.h" | 155 #include "webkit/plugins/npapi/plugin_list.h" |
| 153 #include "webkit/plugins/npapi/webplugin_delegate.h" | 156 #include "webkit/plugins/npapi/webplugin_delegate.h" |
| 154 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 157 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 155 #include "webkit/plugins/npapi/webplugin_impl.h" | 158 #include "webkit/plugins/npapi/webplugin_impl.h" |
| 156 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" | 159 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
| 157 | 160 |
| 158 #if defined(OS_WIN) | 161 #if defined(OS_WIN) |
| 159 // TODO(port): these files are currently Windows only because they concern: | 162 // TODO(port): these files are currently Windows only because they concern: |
| 160 // * theming | 163 // * theming |
| (...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1920 return NULL; | 1923 return NULL; |
| 1921 } else { | 1924 } else { |
| 1922 return new WebSharedWorkerProxy(RenderThreadImpl::current(), | 1925 return new WebSharedWorkerProxy(RenderThreadImpl::current(), |
| 1923 document_id, | 1926 document_id, |
| 1924 exists, | 1927 exists, |
| 1925 route_id, | 1928 route_id, |
| 1926 routing_id_); | 1929 routing_id_); |
| 1927 } | 1930 } |
| 1928 } | 1931 } |
| 1929 | 1932 |
| 1933 // Glue code to expose functionality needed by media::GpuVideoDecoder. | |
| 1934 class GpuVideoDecoderFactories : public media::GpuVideoDecoder::Factories { | |
|
scherkus (not reviewing)
2011/12/09 00:26:20
render_view_impl.cc is approaching 5000 lines
can
Ami GONE FROM CHROMIUM
2011/12/09 22:55:50
Done.
| |
| 1935 public: | |
| 1936 virtual ~GpuVideoDecoderFactories() {} | |
| 1937 // Takes a ref on |gpu_channel_host| and tests |context| for NULL before each | |
| 1938 // use. | |
| 1939 GpuVideoDecoderFactories(GpuChannelHost* gpu_channel_host, | |
| 1940 base::WeakPtr<RendererGLContext> context) | |
| 1941 : gpu_channel_host_(gpu_channel_host), context_(context) { | |
| 1942 } | |
| 1943 | |
| 1944 media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( | |
| 1945 media::VideoDecodeAccelerator::Profile profile, | |
| 1946 media::VideoDecodeAccelerator::Client* client) OVERRIDE { | |
| 1947 if (!context_) | |
| 1948 return NULL; | |
| 1949 return gpu_channel_host_->CreateVideoDecoder( | |
| 1950 context_->GetCommandBufferProxy()->route_id(), profile, client); | |
| 1951 } | |
| 1952 | |
| 1953 virtual bool CreateTextures(int32 count, const gfx::Size& size, | |
| 1954 std::vector<uint32>* texture_ids) OVERRIDE { | |
| 1955 if (!context_) | |
| 1956 return false; | |
| 1957 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); | |
| 1958 texture_ids->resize(count); | |
| 1959 gles2->GenTextures(count, &texture_ids->at(0)); | |
| 1960 for (int i = 0; i < count; ++i) { | |
| 1961 gles2->ActiveTexture(GL_TEXTURE0); | |
| 1962 uint32 texture_id = texture_ids->at(i); | |
| 1963 gles2->BindTexture(GL_TEXTURE_2D, texture_id); | |
| 1964 gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
| 1965 gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
| 1966 gles2->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 1967 gles2->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 1968 gles2->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), | |
| 1969 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); | |
| 1970 } | |
| 1971 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR)); | |
| 1972 return true; | |
| 1973 } | |
| 1974 | |
| 1975 virtual bool DeleteTexture(uint32 texture_id) OVERRIDE { | |
| 1976 if (!context_) | |
| 1977 return false; | |
| 1978 gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); | |
| 1979 gles2->DeleteTextures(1, &texture_id); | |
| 1980 DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR)); | |
| 1981 return true; | |
| 1982 } | |
| 1983 | |
| 1984 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE { | |
| 1985 return ChildThread::current()->AllocateSharedMemory(size); | |
| 1986 } | |
| 1987 | |
| 1988 private: | |
| 1989 scoped_refptr<GpuChannelHost> gpu_channel_host_; | |
| 1990 base::WeakPtr<RendererGLContext> context_; | |
| 1991 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecoderFactories); | |
| 1992 }; | |
| 1993 | |
| 1930 WebMediaPlayer* RenderViewImpl::createMediaPlayer( | 1994 WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
| 1931 WebFrame* frame, WebMediaPlayerClient* client) { | 1995 WebFrame* frame, WebMediaPlayerClient* client) { |
| 1932 FOR_EACH_OBSERVER( | 1996 FOR_EACH_OBSERVER( |
| 1933 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); | 1997 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); |
| 1934 | 1998 |
| 1935 scoped_ptr<media::MessageLoopFactory> message_loop_factory( | 1999 scoped_ptr<media::MessageLoopFactory> message_loop_factory( |
| 1936 new media::MessageLoopFactoryImpl()); | 2000 new media::MessageLoopFactoryImpl()); |
| 1937 scoped_ptr<media::FilterCollection> collection( | 2001 scoped_ptr<media::FilterCollection> collection( |
| 1938 new media::FilterCollection()); | 2002 new media::FilterCollection()); |
| 1939 | 2003 |
| 1940 // Add in any custom filter factories first. | 2004 // Add in any custom filter factories first. |
| 1941 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 2005 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 1942 if (!cmd_line->HasSwitch(switches::kDisableAudio)) { | 2006 if (!cmd_line->HasSwitch(switches::kDisableAudio)) { |
| 1943 // Add the chrome specific audio renderer. | 2007 // Add the chrome specific audio renderer. |
| 1944 collection->AddAudioRenderer(new AudioRendererImpl()); | 2008 collection->AddAudioRenderer(new AudioRendererImpl()); |
| 1945 } | 2009 } |
| 1946 | 2010 |
| 2011 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | |
| 2012 // Currently only cros/arm has any HW video decode support in | |
| 2013 // GpuVideoDecodeAccelerator so we don't even try to use it on other | |
| 2014 // platforms. This is a startup-time optimization. When new VDA | |
| 2015 // implementations are added, relax the #if above. | |
| 2016 WebKit::WebGraphicsContext3D* wk_context3d = webview()->graphicsContext3D(); | |
| 2017 if (wk_context3d) { | |
| 2018 WebGraphicsContext3DCommandBufferImpl* context3d = | |
| 2019 static_cast<WebGraphicsContext3DCommandBufferImpl*>(wk_context3d); | |
| 2020 GpuChannelHost* gpu_channel_host = | |
| 2021 RenderThreadImpl::current()->EstablishGpuChannelSync( | |
| 2022 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | |
| 2023 collection->AddVideoDecoder(new media::GpuVideoDecoder( | |
| 2024 MessageLoop::current(), | |
| 2025 new GpuVideoDecoderFactories(gpu_channel_host, | |
| 2026 context3d->context()->AsWeakPtr()))); | |
| 2027 } | |
| 2028 #endif | |
| 2029 | |
| 1947 scoped_ptr<webkit_media::WebMediaPlayerImpl> result( | 2030 scoped_ptr<webkit_media::WebMediaPlayerImpl> result( |
| 1948 new webkit_media::WebMediaPlayerImpl(client, | 2031 new webkit_media::WebMediaPlayerImpl(client, |
| 1949 AsWeakPtr(), | 2032 AsWeakPtr(), |
| 1950 collection.release(), | 2033 collection.release(), |
| 1951 message_loop_factory.release(), | 2034 message_loop_factory.release(), |
| 1952 media_stream_impl_.get(), | 2035 media_stream_impl_.get(), |
| 1953 new RenderMediaLog())); | 2036 new RenderMediaLog())); |
| 1954 if (!result->Initialize(frame, | 2037 if (!result->Initialize(frame, |
| 1955 cmd_line->HasSwitch(switches::kSimpleDataSource))) { | 2038 cmd_line->HasSwitch(switches::kSimpleDataSource))) { |
| 1956 return NULL; | 2039 return NULL; |
| (...skipping 2831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4788 return !!RenderThreadImpl::current()->compositor_thread(); | 4871 return !!RenderThreadImpl::current()->compositor_thread(); |
| 4789 } | 4872 } |
| 4790 | 4873 |
| 4791 void RenderViewImpl::OnJavaBridgeInit( | 4874 void RenderViewImpl::OnJavaBridgeInit( |
| 4792 const IPC::ChannelHandle& channel_handle) { | 4875 const IPC::ChannelHandle& channel_handle) { |
| 4793 DCHECK(!java_bridge_dispatcher_.get()); | 4876 DCHECK(!java_bridge_dispatcher_.get()); |
| 4794 #if defined(ENABLE_JAVA_BRIDGE) | 4877 #if defined(ENABLE_JAVA_BRIDGE) |
| 4795 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); | 4878 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); |
| 4796 #endif | 4879 #endif |
| 4797 } | 4880 } |
| OLD | NEW |