Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 10798006: Implement WebCompositorOutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | ipc/ipc_forwarding_message_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "content/renderer/browser_plugin/old/browser_plugin_channel_manager.h" 62 #include "content/renderer/browser_plugin/old/browser_plugin_channel_manager.h"
63 #include "content/renderer/browser_plugin/old/browser_plugin_constants.h" 63 #include "content/renderer/browser_plugin/old/browser_plugin_constants.h"
64 #include "content/renderer/browser_plugin/old/guest_to_embedder_channel.h" 64 #include "content/renderer/browser_plugin/old/guest_to_embedder_channel.h"
65 #include "content/renderer/device_orientation_dispatcher.h" 65 #include "content/renderer/device_orientation_dispatcher.h"
66 #include "content/renderer/devtools_agent.h" 66 #include "content/renderer/devtools_agent.h"
67 #include "content/renderer/dom_automation_controller.h" 67 #include "content/renderer/dom_automation_controller.h"
68 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 68 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
69 #include "content/renderer/external_popup_menu.h" 69 #include "content/renderer/external_popup_menu.h"
70 #include "content/renderer/geolocation_dispatcher.h" 70 #include "content/renderer/geolocation_dispatcher.h"
71 #include "content/renderer/gpu/compositor_thread.h" 71 #include "content/renderer/gpu/compositor_thread.h"
72 #include "content/renderer/gpu/compositor_output_surface.h"
72 #include "content/renderer/idle_user_detector.h" 73 #include "content/renderer/idle_user_detector.h"
73 #include "content/renderer/input_tag_speech_dispatcher.h" 74 #include "content/renderer/input_tag_speech_dispatcher.h"
74 #include "content/renderer/java/java_bridge_dispatcher.h" 75 #include "content/renderer/java/java_bridge_dispatcher.h"
75 #include "content/renderer/load_progress_tracker.h" 76 #include "content/renderer/load_progress_tracker.h"
76 #include "content/renderer/media/media_stream_dependency_factory.h" 77 #include "content/renderer/media/media_stream_dependency_factory.h"
77 #include "content/renderer/media/media_stream_dispatcher.h" 78 #include "content/renderer/media/media_stream_dispatcher.h"
78 #include "content/renderer/media/media_stream_impl.h" 79 #include "content/renderer/media/media_stream_impl.h"
79 #include "content/renderer/media/render_audiosourceprovider.h" 80 #include "content/renderer/media/render_audiosourceprovider.h"
80 #include "content/renderer/media/render_media_log.h" 81 #include "content/renderer/media/render_media_log.h"
81 #include "content/renderer/media/renderer_gpu_video_decoder_factories.h" 82 #include "content/renderer/media/renderer_gpu_video_decoder_factories.h"
(...skipping 19 matching lines...) Expand all
101 #include "content/renderer/websharedworker_proxy.h" 102 #include "content/renderer/websharedworker_proxy.h"
102 #include "media/base/filter_collection.h" 103 #include "media/base/filter_collection.h"
103 #include "media/base/media_switches.h" 104 #include "media/base/media_switches.h"
104 #include "media/base/message_loop_factory.h" 105 #include "media/base/message_loop_factory.h"
105 #include "media/filters/audio_renderer_impl.h" 106 #include "media/filters/audio_renderer_impl.h"
106 #include "media/filters/gpu_video_decoder.h" 107 #include "media/filters/gpu_video_decoder.h"
107 #include "net/base/data_url.h" 108 #include "net/base/data_url.h"
108 #include "net/base/escape.h" 109 #include "net/base/escape.h"
109 #include "net/base/net_errors.h" 110 #include "net/base/net_errors.h"
110 #include "net/http/http_util.h" 111 #include "net/http/http_util.h"
112 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput Surface.h"
111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h"
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h" 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h"
113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h" 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h"
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h"
118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h"
119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" 122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h"
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 return widget; 1752 return widget;
1751 } 1753 }
1752 1754
1753 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace( 1755 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace(
1754 unsigned quota) { 1756 unsigned quota) {
1755 CHECK(session_storage_namespace_id_ != 1757 CHECK(session_storage_namespace_id_ !=
1756 dom_storage::kInvalidSessionStorageNamespaceId); 1758 dom_storage::kInvalidSessionStorageNamespaceId);
1757 return new WebStorageNamespaceImpl(session_storage_namespace_id_); 1759 return new WebStorageNamespaceImpl(session_storage_namespace_id_);
1758 } 1760 }
1759 1761
1760 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( 1762 WebKit::WebCompositorOutputSurface* RenderViewImpl::createOutputSurface() {
1761 const WebGraphicsContext3D::Attributes& attributes) { 1763 // TODO(aelias): if force-software-mode is on, create an output surface
1762 if (!webview()) 1764 // without a 3D context.
1765
1766 // Explicitly disable antialiasing for the compositor. As of the time of
1767 // this writing, the only platform that supported antialiasing for the
1768 // compositor was Mac OS X, because the on-screen OpenGL context creation
1769 // code paths on Windows and Linux didn't yet have multisampling support.
1770 // Mac OS X essentially always behaves as though it's rendering offscreen.
1771 // Multisampling has a heavy cost especially on devices with relatively low
1772 // fill rate like most notebooks, and the Mac implementation would need to
1773 // be optimized to resolve directly into the IOSurface shared between the
1774 // GPU and browser processes. For these reasons and to avoid platform
1775 // disparities we explicitly disable antialiasing.
1776 WebKit::WebGraphicsContext3D::Attributes attributes;
1777 attributes.antialias = false;
1778 attributes.shareResources = true;
1779 WebGraphicsContext3D* context = CreateGraphicsContext3D(attributes);
1780 if (!context)
1763 return NULL; 1781 return NULL;
1764 1782
1765 if (GetGuestToEmbedderChannel()) { 1783 return new CompositorOutputSurface(routing_id(), context);
1766 WebGraphicsContext3DCommandBufferImpl* context =
1767 GetGuestToEmbedderChannel()->CreateWebGraphicsContext3D(
1768 this, attributes, false);
1769 if (!guest_pp_instance()) {
1770 guest_uninitialized_context_ = context;
1771 guest_attributes_ = attributes;
1772 }
1773 return context;
1774 }
1775
1776 // The WebGraphicsContext3DInProcessImpl code path is used for
1777 // layout tests (though not through this code) as well as for
1778 // debugging and bringing up new ports.
1779 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) {
1780 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
1781 attributes, true);
1782 } else {
1783 GURL url;
1784 if (webview()->mainFrame())
1785 url = GURL(webview()->mainFrame()->document().url());
1786 else
1787 url = GURL("chrome://gpu/RenderViewImpl::createGraphicsContext3D");
1788
1789 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
1790 new WebGraphicsContext3DCommandBufferImpl(
1791 surface_id(),
1792 url,
1793 RenderThreadImpl::current(),
1794 AsWeakPtr()));
1795
1796 if (!context->Initialize(
1797 attributes,
1798 false /* bind generates resources */,
1799 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_ INITIALIZE))
1800 return NULL;
1801 return context.release();
1802 }
1803 } 1784 }
1804 1785
1805 void RenderViewImpl::didAddMessageToConsole( 1786 void RenderViewImpl::didAddMessageToConsole(
1806 const WebConsoleMessage& message, const WebString& source_name, 1787 const WebConsoleMessage& message, const WebString& source_name,
1807 unsigned source_line) { 1788 unsigned source_line) {
1808 logging::LogSeverity log_severity = logging::LOG_VERBOSE; 1789 logging::LogSeverity log_severity = logging::LOG_VERBOSE;
1809 switch (message.level) { 1790 switch (message.level) {
1810 case WebConsoleMessage::LevelTip: 1791 case WebConsoleMessage::LevelTip:
1811 log_severity = logging::LOG_VERBOSE; 1792 log_severity = logging::LOG_VERBOSE;
1812 break; 1793 break;
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after
3567 size.set_height(static_cast<int>(size.height() * zoom_factor)); 3548 size.set_height(static_cast<int>(size.height() * zoom_factor));
3568 3549
3569 if (size == preferred_size_) 3550 if (size == preferred_size_)
3570 return; 3551 return;
3571 3552
3572 preferred_size_ = size; 3553 preferred_size_ = size;
3573 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, 3554 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_,
3574 preferred_size_)); 3555 preferred_size_));
3575 } 3556 }
3576 3557
3558 WebGraphicsContext3D* RenderViewImpl::CreateGraphicsContext3D(
3559 const WebGraphicsContext3D::Attributes& attributes) {
3560 if (!webview())
3561 return NULL;
3562
3563 if (GetGuestToEmbedderChannel()) {
3564 WebGraphicsContext3DCommandBufferImpl* context =
3565 GetGuestToEmbedderChannel()->CreateWebGraphicsContext3D(
3566 this, attributes, false);
3567 if (!guest_pp_instance()) {
3568 guest_uninitialized_context_ = context;
3569 guest_attributes_ = attributes;
3570 }
3571 return context;
3572 }
3573
3574 // The WebGraphicsContext3DInProcessImpl code path is used for
3575 // layout tests (though not through this code) as well as for
3576 // debugging and bringing up new ports.
3577 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) {
3578 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
3579 attributes, true);
3580 } else {
3581 GURL url;
3582 if (webview()->mainFrame())
3583 url = GURL(webview()->mainFrame()->document().url());
3584 else
3585 url = GURL("chrome://gpu/RenderViewImpl::createGraphicsContext3D");
3586
3587 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
3588 new WebGraphicsContext3DCommandBufferImpl(
3589 surface_id(),
3590 url,
3591 RenderThreadImpl::current(),
3592 AsWeakPtr()));
3593
3594 if (!context->Initialize(
3595 attributes,
3596 false /* bind generates resources */,
3597 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_ INITIALIZE))
3598 return NULL;
3599 return context.release();
3600 }
3601 }
3602
3577 void RenderViewImpl::EnsureMediaStreamImpl() { 3603 void RenderViewImpl::EnsureMediaStreamImpl() {
3578 if (!RenderThreadImpl::current()) // Will be NULL during unit tests. 3604 if (!RenderThreadImpl::current()) // Will be NULL during unit tests.
3579 return; 3605 return;
3580 3606
3581 #if defined(ENABLE_WEBRTC) 3607 #if defined(ENABLE_WEBRTC)
3582 if (!p2p_socket_dispatcher_) 3608 if (!p2p_socket_dispatcher_)
3583 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); 3609 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
3584 3610
3585 if (!media_stream_dispatcher_) 3611 if (!media_stream_dispatcher_)
3586 media_stream_dispatcher_ = new MediaStreamDispatcher(this); 3612 media_stream_dispatcher_ = new MediaStreamDispatcher(this);
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after
5767 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5793 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5768 return !!RenderThreadImpl::current()->compositor_thread(); 5794 return !!RenderThreadImpl::current()->compositor_thread();
5769 } 5795 }
5770 5796
5771 void RenderViewImpl::OnJavaBridgeInit() { 5797 void RenderViewImpl::OnJavaBridgeInit() {
5772 DCHECK(!java_bridge_dispatcher_); 5798 DCHECK(!java_bridge_dispatcher_);
5773 #if defined(ENABLE_JAVA_BRIDGE) 5799 #if defined(ENABLE_JAVA_BRIDGE)
5774 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); 5800 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this);
5775 #endif 5801 #endif
5776 } 5802 }
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | ipc/ipc_forwarding_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698