Chromium Code Reviews| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 219 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| 220 popup_type_(popup_type), | 220 popup_type_(popup_type), |
| 221 pending_window_rect_count_(0), | 221 pending_window_rect_count_(0), |
| 222 suppress_next_char_events_(false), | 222 suppress_next_char_events_(false), |
| 223 is_accelerated_compositing_active_(false), | 223 is_accelerated_compositing_active_(false), |
| 224 animation_update_pending_(false), | 224 animation_update_pending_(false), |
| 225 invalidation_task_posted_(false), | 225 invalidation_task_posted_(false), |
| 226 screen_info_(screen_info), | 226 screen_info_(screen_info), |
| 227 device_scale_factor_(screen_info_.deviceScaleFactor), | 227 device_scale_factor_(screen_info_.deviceScaleFactor), |
| 228 is_threaded_compositing_enabled_(false), | 228 is_threaded_compositing_enabled_(false), |
| 229 next_output_surface_id_(0), | |
| 229 weak_ptr_factory_(this) { | 230 weak_ptr_factory_(this) { |
| 230 if (!swapped_out) | 231 if (!swapped_out) |
| 231 RenderProcess::current()->AddRefProcess(); | 232 RenderProcess::current()->AddRefProcess(); |
| 232 DCHECK(RenderThread::Get()); | 233 DCHECK(RenderThread::Get()); |
| 233 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 234 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 234 switches::kDisableGpuVsync); | 235 switches::kDisableGpuVsync); |
| 235 is_threaded_compositing_enabled_ = | 236 is_threaded_compositing_enabled_ = |
| 236 CommandLine::ForCurrentProcess()->HasSwitch( | 237 CommandLine::ForCurrentProcess()->HasSwitch( |
| 237 switches::kEnableThreadedCompositing); | 238 switches::kEnableThreadedCompositing); |
| 238 | 239 |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 630 bool RenderWidget::ForceCompositingModeEnabled() { | 631 bool RenderWidget::ForceCompositingModeEnabled() { |
| 631 return false; | 632 return false; |
| 632 } | 633 } |
| 633 | 634 |
| 634 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { | 635 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { |
| 635 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 636 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 636 | 637 |
| 637 #if defined(OS_ANDROID) | 638 #if defined(OS_ANDROID) |
| 638 if (SynchronousCompositorFactory* factory = | 639 if (SynchronousCompositorFactory* factory = |
| 639 SynchronousCompositorFactory::GetInstance()) { | 640 SynchronousCompositorFactory::GetInstance()) { |
| 640 return factory->CreateOutputSurface(routing_id()); | 641 return factory->CreateOutputSurface(routing_id()); |
|
piman
2013/07/16 04:24:30
note: I believe we don't need to pass the output_s
| |
| 641 } | 642 } |
| 642 #endif | 643 #endif |
| 643 | 644 |
| 645 uint32 output_surface_id = next_output_surface_id_++; | |
| 646 | |
| 644 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { | 647 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { |
| 645 return scoped_ptr<cc::OutputSurface>( | 648 return scoped_ptr<cc::OutputSurface>( |
| 646 new CompositorOutputSurface(routing_id(), NULL, | 649 new CompositorOutputSurface(routing_id(), output_surface_id, NULL, |
| 647 new CompositorSoftwareOutputDevice(), true)); | 650 new CompositorSoftwareOutputDevice(), true)); |
| 648 } | 651 } |
| 649 | 652 |
| 650 // Explicitly disable antialiasing for the compositor. As of the time of | 653 // Explicitly disable antialiasing for the compositor. As of the time of |
| 651 // this writing, the only platform that supported antialiasing for the | 654 // this writing, the only platform that supported antialiasing for the |
| 652 // compositor was Mac OS X, because the on-screen OpenGL context creation | 655 // compositor was Mac OS X, because the on-screen OpenGL context creation |
| 653 // code paths on Windows and Linux didn't yet have multisampling support. | 656 // code paths on Windows and Linux didn't yet have multisampling support. |
| 654 // Mac OS X essentially always behaves as though it's rendering offscreen. | 657 // Mac OS X essentially always behaves as though it's rendering offscreen. |
| 655 // Multisampling has a heavy cost especially on devices with relatively low | 658 // Multisampling has a heavy cost especially on devices with relatively low |
| 656 // fill rate like most notebooks, and the Mac implementation would need to | 659 // fill rate like most notebooks, and the Mac implementation would need to |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 667 attributes.stencil = true; | 670 attributes.stencil = true; |
| 668 WebGraphicsContext3DCommandBufferImpl* context = | 671 WebGraphicsContext3DCommandBufferImpl* context = |
| 669 CreateGraphicsContext3D(attributes); | 672 CreateGraphicsContext3D(attributes); |
| 670 if (!context) | 673 if (!context) |
| 671 return scoped_ptr<cc::OutputSurface>(); | 674 return scoped_ptr<cc::OutputSurface>(); |
| 672 | 675 |
| 673 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer) && | 676 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer) && |
| 674 !command_line.HasSwitch(switches::kDisableDelegatedRenderer)) { | 677 !command_line.HasSwitch(switches::kDisableDelegatedRenderer)) { |
| 675 DCHECK(is_threaded_compositing_enabled_); | 678 DCHECK(is_threaded_compositing_enabled_); |
| 676 return scoped_ptr<cc::OutputSurface>( | 679 return scoped_ptr<cc::OutputSurface>( |
| 677 new DelegatedCompositorOutputSurface(routing_id(), context, NULL)); | 680 new DelegatedCompositorOutputSurface(routing_id(), output_surface_id, |
| 681 context, NULL)); | |
| 678 } | 682 } |
| 679 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { | 683 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
| 680 DCHECK(is_threaded_compositing_enabled_); | 684 DCHECK(is_threaded_compositing_enabled_); |
| 681 return scoped_ptr<cc::OutputSurface>( | 685 return scoped_ptr<cc::OutputSurface>( |
| 682 new MailboxOutputSurface(routing_id(), context, NULL)); | 686 new MailboxOutputSurface(routing_id(), output_surface_id, |
| 687 context, NULL)); | |
| 683 } | 688 } |
| 684 return scoped_ptr<cc::OutputSurface>( | 689 return scoped_ptr<cc::OutputSurface>( |
| 685 new CompositorOutputSurface(routing_id(), context, NULL, false)); | 690 new CompositorOutputSurface(routing_id(), output_surface_id, |
| 691 context, NULL, false)); | |
| 686 } | 692 } |
| 687 | 693 |
| 688 void RenderWidget::OnViewContextSwapBuffersAborted() { | 694 void RenderWidget::OnViewContextSwapBuffersAborted() { |
| 689 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); | 695 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); |
| 690 while (!updates_pending_swap_.empty()) { | 696 while (!updates_pending_swap_.empty()) { |
| 691 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | 697 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); |
| 692 updates_pending_swap_.pop_front(); | 698 updates_pending_swap_.pop_front(); |
| 693 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate | 699 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate |
| 694 // compositing pass, hence doesn't require an UpdateRect message. | 700 // compositing pass, hence doesn't require an UpdateRect message. |
| 695 if (msg) | 701 if (msg) |
| (...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2481 | 2487 |
| 2482 if (!context->InitializeWithDefaultBufferSizes( | 2488 if (!context->InitializeWithDefaultBufferSizes( |
| 2483 attributes, | 2489 attributes, |
| 2484 false /* bind generates resources */, | 2490 false /* bind generates resources */, |
| 2485 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) | 2491 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) |
| 2486 return NULL; | 2492 return NULL; |
| 2487 return context.release(); | 2493 return context.release(); |
| 2488 } | 2494 } |
| 2489 | 2495 |
| 2490 } // namespace content | 2496 } // namespace content |
| OLD | NEW |