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_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" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "ui/gfx/skia_util.h" | 55 #include "ui/gfx/skia_util.h" |
56 #include "ui/gl/gl_switches.h" | 56 #include "ui/gl/gl_switches.h" |
57 #include "ui/surface/transport_dib.h" | 57 #include "ui/surface/transport_dib.h" |
58 #include "webkit/glue/cursor_utils.h" | 58 #include "webkit/glue/cursor_utils.h" |
59 #include "webkit/glue/webkit_glue.h" | 59 #include "webkit/glue/webkit_glue.h" |
60 #include "webkit/plugins/npapi/webplugin.h" | 60 #include "webkit/plugins/npapi/webplugin.h" |
61 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 61 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
62 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" | 62 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" |
63 | 63 |
64 #if defined(OS_ANDROID) | 64 #if defined(OS_ANDROID) |
65 #include "content/renderer/android/synchronous_compositor_impl.h" | 65 #include "content/renderer/android/synchronous_compositor_factory.h" |
66 #include "content/renderer/android/synchronous_compositor_output_surface.h" | |
67 #endif | 66 #endif |
68 | 67 |
69 #if defined(OS_POSIX) | 68 #if defined(OS_POSIX) |
70 #include "ipc/ipc_channel_posix.h" | 69 #include "ipc/ipc_channel_posix.h" |
71 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 70 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
72 #include "third_party/skia/include/core/SkPixelRef.h" | 71 #include "third_party/skia/include/core/SkPixelRef.h" |
73 #endif // defined(OS_POSIX) | 72 #endif // defined(OS_POSIX) |
74 | 73 |
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" | 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" |
76 | 75 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 if (!is_swapped_out) | 298 if (!is_swapped_out) |
300 RenderProcess::current()->AddRefProcess(); | 299 RenderProcess::current()->AddRefProcess(); |
301 } | 300 } |
302 | 301 |
303 bool RenderWidget::AllowPartialSwap() const { | 302 bool RenderWidget::AllowPartialSwap() const { |
304 return true; | 303 return true; |
305 } | 304 } |
306 | 305 |
307 bool RenderWidget::UsingSynchronousRendererCompositor() const { | 306 bool RenderWidget::UsingSynchronousRendererCompositor() const { |
308 #if defined(OS_ANDROID) | 307 #if defined(OS_ANDROID) |
309 if (CommandLine::ForCurrentProcess()->HasSwitch( | 308 return SynchronousCompositorFactory::GetInstance() != NULL; |
310 switches::kEnableSynchronousRendererCompositor)) { | 309 #else |
311 return true; | 310 return false; |
312 } | |
313 #endif | 311 #endif |
314 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) |
323 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 320 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
324 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 321 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 } | 576 } |
580 | 577 |
581 bool RenderWidget::ForceCompositingModeEnabled() { | 578 bool RenderWidget::ForceCompositingModeEnabled() { |
582 return false; | 579 return false; |
583 } | 580 } |
584 | 581 |
585 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { | 582 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { |
586 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 583 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
587 | 584 |
588 #if defined(OS_ANDROID) | 585 #if defined(OS_ANDROID) |
589 if (GetSynchronousCompositor()) { | 586 if (SynchronousCompositorFactory* factory = |
590 return GetSynchronousCompositor()->CreateOutputSurface(); | 587 SynchronousCompositorFactory::GetInstance()) { |
| 588 return factory->CreateOutputSurface(routing_id()); |
591 } | 589 } |
592 #endif | 590 #endif |
593 | 591 |
594 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { | 592 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { |
595 return scoped_ptr<cc::OutputSurface>( | 593 return scoped_ptr<cc::OutputSurface>( |
596 new CompositorOutputSurface(routing_id(), NULL, | 594 new CompositorOutputSurface(routing_id(), NULL, |
597 new CompositorSoftwareOutputDevice())); | 595 new CompositorSoftwareOutputDevice())); |
598 } | 596 } |
599 | 597 |
600 // Explicitly disable antialiasing for the compositor. As of the time of | 598 // Explicitly disable antialiasing for the compositor. As of the time of |
(...skipping 22 matching lines...) Expand all Loading... |
623 bool composite_to_mailbox = | 621 bool composite_to_mailbox = |
624 command_line.HasSwitch(cc::switches::kCompositeToMailbox) && | 622 command_line.HasSwitch(cc::switches::kCompositeToMailbox) && |
625 !command_line.HasSwitch(switches::kEnableDelegatedRenderer); | 623 !command_line.HasSwitch(switches::kEnableDelegatedRenderer); |
626 // No swap throttling yet when compositing on the main thread. | 624 // No swap throttling yet when compositing on the main thread. |
627 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); | 625 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); |
628 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? | 626 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? |
629 new MailboxOutputSurface(routing_id(), context, NULL) : | 627 new MailboxOutputSurface(routing_id(), context, NULL) : |
630 new CompositorOutputSurface(routing_id(), context, NULL)); | 628 new CompositorOutputSurface(routing_id(), context, NULL)); |
631 } | 629 } |
632 | 630 |
633 #if defined(OS_ANDROID) | |
634 SynchronousCompositorImpl* RenderWidget::GetSynchronousCompositor() { | |
635 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
636 if (!synchronous_compositor_ && | |
637 command_line.HasSwitch(switches::kEnableSynchronousRendererCompositor)) { | |
638 synchronous_compositor_.reset(new SynchronousCompositorImpl(routing_id())); | |
639 } | |
640 return synchronous_compositor_.get(); | |
641 } | |
642 #endif | |
643 | |
644 void RenderWidget::OnViewContextSwapBuffersAborted() { | 631 void RenderWidget::OnViewContextSwapBuffersAborted() { |
645 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); | 632 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); |
646 while (!updates_pending_swap_.empty()) { | 633 while (!updates_pending_swap_.empty()) { |
647 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | 634 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); |
648 updates_pending_swap_.pop_front(); | 635 updates_pending_swap_.pop_front(); |
649 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate | 636 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate |
650 // compositing pass, hence doesn't require an UpdateRect message. | 637 // compositing pass, hence doesn't require an UpdateRect message. |
651 if (msg) | 638 if (msg) |
652 Send(msg); | 639 Send(msg); |
653 } | 640 } |
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2392 | 2379 |
2393 if (!context->Initialize( | 2380 if (!context->Initialize( |
2394 attributes, | 2381 attributes, |
2395 false /* bind generates resources */, | 2382 false /* bind generates resources */, |
2396 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2383 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
2397 return NULL; | 2384 return NULL; |
2398 return context.release(); | 2385 return context.release(); |
2399 } | 2386 } |
2400 | 2387 |
2401 } // namespace content | 2388 } // namespace content |
OLD | NEW |