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

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

Issue 16119003: Move SynchronousCompositor into content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
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_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "cc/base/switches.h" 17 #include "cc/base/switches.h"
18 #include "cc/base/thread.h" 18 #include "cc/base/thread.h"
19 #include "cc/base/thread_impl.h" 19 #include "cc/base/thread_impl.h"
20 #include "cc/output/output_surface.h" 20 #include "cc/output/output_surface.h"
21 #include "cc/trees/layer_tree_host.h" 21 #include "cc/trees/layer_tree_host.h"
22 // #include "content/browser/android/in_process/synchronous_compositor_impl.h"
22 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 23 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
23 #include "content/common/input_messages.h" 24 #include "content/common/input_messages.h"
24 #include "content/common/swapped_out_messages.h" 25 #include "content/common/swapped_out_messages.h"
25 #include "content/common/view_messages.h" 26 #include "content/common/view_messages.h"
26 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
27 #include "content/renderer/android/synchronous_compositor_impl.h"
28 #include "content/renderer/gpu/compositor_output_surface.h" 28 #include "content/renderer/gpu/compositor_output_surface.h"
29 #include "content/renderer/gpu/compositor_software_output_device.h" 29 #include "content/renderer/gpu/compositor_software_output_device.h"
30 #include "content/renderer/gpu/input_handler_manager.h" 30 #include "content/renderer/gpu/input_handler_manager.h"
31 #include "content/renderer/gpu/mailbox_output_surface.h" 31 #include "content/renderer/gpu/mailbox_output_surface.h"
32 #include "content/renderer/gpu/render_widget_compositor.h" 32 #include "content/renderer/gpu/render_widget_compositor.h"
33 #include "content/renderer/ime_event_guard.h" 33 #include "content/renderer/ime_event_guard.h"
34 #include "content/renderer/render_process.h" 34 #include "content/renderer/render_process.h"
35 #include "content/renderer/render_thread_impl.h" 35 #include "content/renderer/render_thread_impl.h"
36 #include "content/renderer/renderer_webkitplatformsupport_impl.h" 36 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
37 #include "ipc/ipc_sync_message.h" 37 #include "ipc/ipc_sync_message.h"
(...skipping 18 matching lines...) Expand all
56 #include "ui/gfx/skia_util.h" 56 #include "ui/gfx/skia_util.h"
57 #include "ui/gl/gl_switches.h" 57 #include "ui/gl/gl_switches.h"
58 #include "ui/surface/transport_dib.h" 58 #include "ui/surface/transport_dib.h"
59 #include "webkit/glue/cursor_utils.h" 59 #include "webkit/glue/cursor_utils.h"
60 #include "webkit/glue/webkit_glue.h" 60 #include "webkit/glue/webkit_glue.h"
61 #include "webkit/plugins/npapi/webplugin.h" 61 #include "webkit/plugins/npapi/webplugin.h"
62 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 62 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
63 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" 63 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h"
64 64
65 #if defined(OS_ANDROID) 65 #if defined(OS_ANDROID)
66 #include "content/renderer/android/synchronous_compositor_output_surface.h" 66 #include "content/renderer/android/synchronous_compositor_factory.h"
67 #endif 67 #endif
68 68
69 #if defined(OS_POSIX) 69 #if defined(OS_POSIX)
70 #include "ipc/ipc_channel_posix.h" 70 #include "ipc/ipc_channel_posix.h"
71 #include "third_party/skia/include/core/SkMallocPixelRef.h" 71 #include "third_party/skia/include/core/SkMallocPixelRef.h"
72 #include "third_party/skia/include/core/SkPixelRef.h" 72 #include "third_party/skia/include/core/SkPixelRef.h"
73 #endif // defined(OS_POSIX) 73 #endif // defined(OS_POSIX)
74 74
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
76 76
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (!is_swapped_out) 299 if (!is_swapped_out)
300 RenderProcess::current()->AddRefProcess(); 300 RenderProcess::current()->AddRefProcess();
301 } 301 }
302 302
303 bool RenderWidget::AllowPartialSwap() const { 303 bool RenderWidget::AllowPartialSwap() const {
304 return true; 304 return true;
305 } 305 }
306 306
307 bool RenderWidget::UsingSynchronousRendererCompositor() const { 307 bool RenderWidget::UsingSynchronousRendererCompositor() const {
308 #if defined(OS_ANDROID) 308 #if defined(OS_ANDROID)
309 if (CommandLine::ForCurrentProcess()->HasSwitch( 309 return SynchronousCompositorFactory::HasInstance();
310 switches::kEnableSynchronousRendererCompositor)) {
311 return true;
312 }
313 #endif 310 #endif
314 return false; 311 return false;
315 } 312 }
316 313
317 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { 314 bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
318 bool handled = true; 315 bool handled = true;
319 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) 316 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
320 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) 317 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
321 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, 318 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
322 OnCursorVisibilityChange) 319 OnCursorVisibilityChange)
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 return GURL(); 577 return GURL();
581 } 578 }
582 579
583 bool RenderWidget::ForceCompositingModeEnabled() { 580 bool RenderWidget::ForceCompositingModeEnabled() {
584 return false; 581 return false;
585 } 582 }
586 583
587 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { 584 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() {
588 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 585 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
589 586
590 if (GetSynchronousCompositor()) { 587 #if defined(OS_ANDROID)
591 return GetSynchronousCompositor()->CreateOutputSurface(); 588 if (SynchronousCompositorFactory::HasInstance()) {
589 return SynchronousCompositorFactory::GetInstance()->CreateOutputSurface(
590 routing_id());
592 } 591 }
592 #endif
593 593
594 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { 594 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) {
595 return scoped_ptr<cc::OutputSurface>( 595 return scoped_ptr<cc::OutputSurface>(
596 new CompositorOutputSurface(routing_id(), NULL, 596 new CompositorOutputSurface(routing_id(), NULL,
597 new CompositorSoftwareOutputDevice())); 597 new CompositorSoftwareOutputDevice()));
598 } 598 }
599 599
600 // Explicitly disable antialiasing for the compositor. As of the time of 600 // Explicitly disable antialiasing for the compositor. As of the time of
601 // this writing, the only platform that supported antialiasing for the 601 // this writing, the only platform that supported antialiasing for the
602 // compositor was Mac OS X, because the on-screen OpenGL context creation 602 // compositor was Mac OS X, because the on-screen OpenGL context creation
(...skipping 20 matching lines...) Expand all
623 bool composite_to_mailbox = 623 bool composite_to_mailbox =
624 command_line.HasSwitch(cc::switches::kCompositeToMailbox) && 624 command_line.HasSwitch(cc::switches::kCompositeToMailbox) &&
625 !command_line.HasSwitch(switches::kEnableDelegatedRenderer); 625 !command_line.HasSwitch(switches::kEnableDelegatedRenderer);
626 // No swap throttling yet when compositing on the main thread. 626 // No swap throttling yet when compositing on the main thread.
627 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); 627 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_);
628 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? 628 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ?
629 new MailboxOutputSurface(routing_id(), context, NULL) : 629 new MailboxOutputSurface(routing_id(), context, NULL) :
630 new CompositorOutputSurface(routing_id(), context, NULL)); 630 new CompositorOutputSurface(routing_id(), context, NULL));
631 } 631 }
632 632
633 SynchronousCompositorImpl* RenderWidget::GetSynchronousCompositor() {
634 #if defined(OS_ANDROID)
635 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
636 if (command_line.HasSwitch(switches::kEnableSynchronousRendererCompositor)) {
637 synchronous_compositor_.reset(new SynchronousCompositorImpl(routing_id()));
638 }
639 return synchronous_compositor_.get();
640 #else
641 return NULL;
642 #endif
643 }
644
645 void RenderWidget::OnViewContextSwapBuffersAborted() { 633 void RenderWidget::OnViewContextSwapBuffersAborted() {
646 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); 634 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted");
647 while (!updates_pending_swap_.empty()) { 635 while (!updates_pending_swap_.empty()) {
648 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); 636 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
649 updates_pending_swap_.pop_front(); 637 updates_pending_swap_.pop_front();
650 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate 638 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
651 // compositing pass, hence doesn't require an UpdateRect message. 639 // compositing pass, hence doesn't require an UpdateRect message.
652 if (msg) 640 if (msg)
653 Send(msg); 641 Send(msg);
654 } 642 }
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 2387
2400 if (!context->Initialize( 2388 if (!context->Initialize(
2401 attributes, 2389 attributes,
2402 false /* bind generates resources */, 2390 false /* bind generates resources */,
2403 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) 2391 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) )
2404 return NULL; 2392 return NULL;
2405 return context.release(); 2393 return context.release();
2406 } 2394 }
2407 2395
2408 } // namespace content 2396 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698