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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 #include "content/renderer/browser_plugin/old/browser_plugin_channel_manager.h" | 59 #include "content/renderer/browser_plugin/old/browser_plugin_channel_manager.h" |
60 #include "content/renderer/browser_plugin/old/browser_plugin_constants.h" | 60 #include "content/renderer/browser_plugin/old/browser_plugin_constants.h" |
61 #include "content/renderer/browser_plugin/old/guest_to_embedder_channel.h" | 61 #include "content/renderer/browser_plugin/old/guest_to_embedder_channel.h" |
62 #include "content/renderer/device_orientation_dispatcher.h" | 62 #include "content/renderer/device_orientation_dispatcher.h" |
63 #include "content/renderer/devtools_agent.h" | 63 #include "content/renderer/devtools_agent.h" |
64 #include "content/renderer/dom_automation_controller.h" | 64 #include "content/renderer/dom_automation_controller.h" |
65 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 65 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
66 #include "content/renderer/external_popup_menu.h" | 66 #include "content/renderer/external_popup_menu.h" |
67 #include "content/renderer/geolocation_dispatcher.h" | 67 #include "content/renderer/geolocation_dispatcher.h" |
68 #include "content/renderer/gpu/compositor_thread.h" | 68 #include "content/renderer/gpu/compositor_thread.h" |
69 #include "content/renderer/gpu/compositor_output_surface.h" | |
69 #include "content/renderer/idle_user_detector.h" | 70 #include "content/renderer/idle_user_detector.h" |
70 #include "content/renderer/input_tag_speech_dispatcher.h" | 71 #include "content/renderer/input_tag_speech_dispatcher.h" |
71 #include "content/renderer/java/java_bridge_dispatcher.h" | 72 #include "content/renderer/java/java_bridge_dispatcher.h" |
72 #include "content/renderer/load_progress_tracker.h" | 73 #include "content/renderer/load_progress_tracker.h" |
73 #include "content/renderer/media/media_stream_dependency_factory.h" | 74 #include "content/renderer/media/media_stream_dependency_factory.h" |
74 #include "content/renderer/media/media_stream_dispatcher.h" | 75 #include "content/renderer/media/media_stream_dispatcher.h" |
75 #include "content/renderer/media/media_stream_impl.h" | 76 #include "content/renderer/media/media_stream_impl.h" |
76 #include "content/renderer/media/render_audiosourceprovider.h" | 77 #include "content/renderer/media/render_audiosourceprovider.h" |
77 #include "content/renderer/media/render_media_log.h" | 78 #include "content/renderer/media/render_media_log.h" |
78 #include "content/renderer/media/renderer_gpu_video_decoder_factories.h" | 79 #include "content/renderer/media/renderer_gpu_video_decoder_factories.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
98 #include "content/renderer/websharedworker_proxy.h" | 99 #include "content/renderer/websharedworker_proxy.h" |
99 #include "media/base/filter_collection.h" | 100 #include "media/base/filter_collection.h" |
100 #include "media/base/media_switches.h" | 101 #include "media/base/media_switches.h" |
101 #include "media/base/message_loop_factory.h" | 102 #include "media/base/message_loop_factory.h" |
102 #include "media/filters/audio_renderer_impl.h" | 103 #include "media/filters/audio_renderer_impl.h" |
103 #include "media/filters/gpu_video_decoder.h" | 104 #include "media/filters/gpu_video_decoder.h" |
104 #include "net/base/data_url.h" | 105 #include "net/base/data_url.h" |
105 #include "net/base/escape.h" | 106 #include "net/base/escape.h" |
106 #include "net/base/net_errors.h" | 107 #include "net/base/net_errors.h" |
107 #include "net/http/http_util.h" | 108 #include "net/http/http_util.h" |
109 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput Surface.h" | |
108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" | 110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" |
109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h" | 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h" |
110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h" | 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h" |
111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" | 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" |
115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" | 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" |
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" | 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" |
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" | 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" |
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1747 return widget; | 1749 return widget; |
1748 } | 1750 } |
1749 | 1751 |
1750 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace( | 1752 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace( |
1751 unsigned quota) { | 1753 unsigned quota) { |
1752 CHECK(session_storage_namespace_id_ != | 1754 CHECK(session_storage_namespace_id_ != |
1753 dom_storage::kInvalidSessionStorageNamespaceId); | 1755 dom_storage::kInvalidSessionStorageNamespaceId); |
1754 return new WebStorageNamespaceImpl(session_storage_namespace_id_); | 1756 return new WebStorageNamespaceImpl(session_storage_namespace_id_); |
1755 } | 1757 } |
1756 | 1758 |
1757 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( | 1759 WebKit::WebCompositorOutputSurface* RenderViewImpl::createOutputSurface() { |
1758 const WebGraphicsContext3D::Attributes& attributes) { | 1760 // TODO(aelias): if force-software-mode is on, create an output surface |
1759 if (!webview()) | 1761 // without a 3D context. |
1762 | |
1763 // Explicitly disable antialiasing for the compositor. As of the time of | |
1764 // this writing, the only platform that supported antialiasing for the | |
1765 // compositor was Mac OS X, because the on-screen OpenGL context creation | |
1766 // code paths on Windows and Linux didn't yet have multisampling support. | |
1767 // Mac OS X essentially always behaves as though it's rendering offscreen. | |
1768 // Multisampling has a heavy cost especially on devices with relatively low | |
1769 // fill rate like most notebooks, and the Mac implementation would need to | |
1770 // be optimized to resolve directly into the IOSurface shared between the | |
1771 // GPU and browser processes. For these reasons and to avoid platform | |
1772 // disparities we explicitly disable antialiasing. | |
piman
2012/08/08 16:47:43
qq, is that the current behavior from what webkit
| |
1773 WebKit::WebGraphicsContext3D::Attributes attributes; | |
1774 attributes.antialias = false; | |
1775 attributes.shareResources = true; | |
1776 WebGraphicsContext3D* context = CreateGraphicsContext3D(attributes); | |
1777 if (!context) | |
1760 return NULL; | 1778 return NULL; |
1761 | 1779 |
1762 if (GetGuestToEmbedderChannel()) { | 1780 return new CompositorOutputSurface(routing_id(), context); |
1763 WebGraphicsContext3DCommandBufferImpl* context = | |
1764 GetGuestToEmbedderChannel()->CreateWebGraphicsContext3D( | |
1765 this, attributes, false); | |
1766 if (!guest_pp_instance()) { | |
1767 guest_uninitialized_context_ = context; | |
1768 guest_attributes_ = attributes; | |
1769 } | |
1770 return context; | |
1771 } | |
1772 | |
1773 // The WebGraphicsContext3DInProcessImpl code path is used for | |
1774 // layout tests (though not through this code) as well as for | |
1775 // debugging and bringing up new ports. | |
1776 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { | |
1777 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( | |
1778 attributes, true); | |
1779 } else { | |
1780 GURL url; | |
1781 if (webview()->mainFrame()) | |
1782 url = GURL(webview()->mainFrame()->document().url()); | |
1783 else | |
1784 url = GURL("chrome://gpu/RenderViewImpl::createGraphicsContext3D"); | |
1785 | |
1786 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | |
1787 new WebGraphicsContext3DCommandBufferImpl( | |
1788 surface_id(), | |
1789 url, | |
1790 RenderThreadImpl::current(), | |
1791 AsWeakPtr())); | |
1792 | |
1793 if (!context->Initialize( | |
1794 attributes, | |
1795 false /* bind generates resources */, | |
1796 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_ INITIALIZE)) | |
1797 return NULL; | |
1798 return context.release(); | |
1799 } | |
1800 } | 1781 } |
1801 | 1782 |
1802 void RenderViewImpl::didAddMessageToConsole( | 1783 void RenderViewImpl::didAddMessageToConsole( |
1803 const WebConsoleMessage& message, const WebString& source_name, | 1784 const WebConsoleMessage& message, const WebString& source_name, |
1804 unsigned source_line) { | 1785 unsigned source_line) { |
1805 logging::LogSeverity log_severity = logging::LOG_VERBOSE; | 1786 logging::LogSeverity log_severity = logging::LOG_VERBOSE; |
1806 switch (message.level) { | 1787 switch (message.level) { |
1807 case WebConsoleMessage::LevelTip: | 1788 case WebConsoleMessage::LevelTip: |
1808 log_severity = logging::LOG_VERBOSE; | 1789 log_severity = logging::LOG_VERBOSE; |
1809 break; | 1790 break; |
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3554 size.set_height(static_cast<int>(size.height() * zoom_factor)); | 3535 size.set_height(static_cast<int>(size.height() * zoom_factor)); |
3555 | 3536 |
3556 if (size == preferred_size_) | 3537 if (size == preferred_size_) |
3557 return; | 3538 return; |
3558 | 3539 |
3559 preferred_size_ = size; | 3540 preferred_size_ = size; |
3560 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, | 3541 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
3561 preferred_size_)); | 3542 preferred_size_)); |
3562 } | 3543 } |
3563 | 3544 |
3545 WebGraphicsContext3D* RenderViewImpl::CreateGraphicsContext3D( | |
3546 const WebGraphicsContext3D::Attributes& attributes) { | |
3547 if (!webview()) | |
3548 return NULL; | |
3549 | |
3550 if (GetGuestToEmbedderChannel()) { | |
3551 WebGraphicsContext3DCommandBufferImpl* context = | |
3552 GetGuestToEmbedderChannel()->CreateWebGraphicsContext3D( | |
3553 this, attributes, false); | |
3554 if (!guest_pp_instance()) { | |
3555 guest_uninitialized_context_ = context; | |
3556 guest_attributes_ = attributes; | |
3557 } | |
3558 return context; | |
3559 } | |
3560 | |
3561 // The WebGraphicsContext3DInProcessImpl code path is used for | |
3562 // layout tests (though not through this code) as well as for | |
3563 // debugging and bringing up new ports. | |
3564 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { | |
3565 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( | |
3566 attributes, true); | |
3567 } else { | |
3568 GURL url; | |
3569 if (webview()->mainFrame()) | |
3570 url = GURL(webview()->mainFrame()->document().url()); | |
3571 else | |
3572 url = GURL("chrome://gpu/RenderViewImpl::createGraphicsContext3D"); | |
3573 | |
3574 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | |
3575 new WebGraphicsContext3DCommandBufferImpl( | |
3576 surface_id(), | |
3577 url, | |
3578 RenderThreadImpl::current(), | |
3579 AsWeakPtr())); | |
3580 | |
3581 if (!context->Initialize( | |
3582 attributes, | |
3583 false /* bind generates resources */, | |
3584 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_ INITIALIZE)) | |
3585 return NULL; | |
3586 return context.release(); | |
3587 } | |
3588 } | |
3589 | |
3564 void RenderViewImpl::EnsureMediaStreamImpl() { | 3590 void RenderViewImpl::EnsureMediaStreamImpl() { |
3565 if (!RenderThreadImpl::current()) // Will be NULL during unit tests. | 3591 if (!RenderThreadImpl::current()) // Will be NULL during unit tests. |
3566 return; | 3592 return; |
3567 | 3593 |
3568 #if defined(ENABLE_WEBRTC) | 3594 #if defined(ENABLE_WEBRTC) |
3569 if (!p2p_socket_dispatcher_) | 3595 if (!p2p_socket_dispatcher_) |
3570 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); | 3596 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
3571 | 3597 |
3572 if (!media_stream_dispatcher_) | 3598 if (!media_stream_dispatcher_) |
3573 media_stream_dispatcher_ = new MediaStreamDispatcher(this); | 3599 media_stream_dispatcher_ = new MediaStreamDispatcher(this); |
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5774 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5800 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
5775 return !!RenderThreadImpl::current()->compositor_thread(); | 5801 return !!RenderThreadImpl::current()->compositor_thread(); |
5776 } | 5802 } |
5777 | 5803 |
5778 void RenderViewImpl::OnJavaBridgeInit() { | 5804 void RenderViewImpl::OnJavaBridgeInit() { |
5779 DCHECK(!java_bridge_dispatcher_); | 5805 DCHECK(!java_bridge_dispatcher_); |
5780 #if defined(ENABLE_JAVA_BRIDGE) | 5806 #if defined(ENABLE_JAVA_BRIDGE) |
5781 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); | 5807 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
5782 #endif | 5808 #endif |
5783 } | 5809 } |
OLD | NEW |