| 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/browser/renderer_host/compositor_impl_android.h" | 5 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 OutputSurfaceWithoutParent( | 75 OutputSurfaceWithoutParent( |
| 76 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 76 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 77 base::WeakPtr<CompositorImpl> compositor_impl) | 77 base::WeakPtr<CompositorImpl> compositor_impl) |
| 78 : cc::OutputSurface(context_provider), | 78 : cc::OutputSurface(context_provider), |
| 79 swap_buffers_completion_callback_( | 79 swap_buffers_completion_callback_( |
| 80 base::Bind(&OutputSurfaceWithoutParent::OnSwapBuffersCompleted, | 80 base::Bind(&OutputSurfaceWithoutParent::OnSwapBuffersCompleted, |
| 81 base::Unretained(this))) { | 81 base::Unretained(this))) { |
| 82 capabilities_.adjust_deadline_for_parent = false; | 82 capabilities_.adjust_deadline_for_parent = false; |
| 83 capabilities_.max_frames_pending = 2; | 83 capabilities_.max_frames_pending = 2; |
| 84 compositor_impl_ = compositor_impl; | 84 compositor_impl_ = compositor_impl; |
| 85 main_thread_ = base::ThreadTaskRunnerHandle::Get(); | 85 main_thread_ = base::MessageLoopProxy::current(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void SwapBuffers(cc::CompositorFrame* frame) override { | 88 void SwapBuffers(cc::CompositorFrame* frame) override { |
| 89 GetCommandBufferProxy()->SetLatencyInfo(frame->metadata.latency_info); | 89 GetCommandBufferProxy()->SetLatencyInfo(frame->metadata.latency_info); |
| 90 DCHECK(frame->gl_frame_data->sub_buffer_rect == | 90 DCHECK(frame->gl_frame_data->sub_buffer_rect == |
| 91 gfx::Rect(frame->gl_frame_data->size)); | 91 gfx::Rect(frame->gl_frame_data->size)); |
| 92 context_provider_->ContextSupport()->Swap(); | 92 context_provider_->ContextSupport()->Swap(); |
| 93 client_->DidSwapBuffers(); | 93 client_->DidSwapBuffers(); |
| 94 } | 94 } |
| 95 | 95 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 123 void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info, | 123 void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info, |
| 124 gfx::SwapResult result) { | 124 gfx::SwapResult result) { |
| 125 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); | 125 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); |
| 126 OutputSurface::OnSwapBuffersComplete(); | 126 OutputSurface::OnSwapBuffersComplete(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&, | 129 base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&, |
| 130 gfx::SwapResult)> | 130 gfx::SwapResult)> |
| 131 swap_buffers_completion_callback_; | 131 swap_buffers_completion_callback_; |
| 132 | 132 |
| 133 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; | 133 scoped_refptr<base::MessageLoopProxy> main_thread_; |
| 134 base::WeakPtr<CompositorImpl> compositor_impl_; | 134 base::WeakPtr<CompositorImpl> compositor_impl_; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 static bool g_initialized = false; | 137 static bool g_initialized = false; |
| 138 | 138 |
| 139 bool g_use_surface_manager = false; | 139 bool g_use_surface_manager = false; |
| 140 base::LazyInstance<cc::SurfaceManager> g_surface_manager = | 140 base::LazyInstance<cc::SurfaceManager> g_surface_manager = |
| 141 LAZY_INSTANCE_INITIALIZER; | 141 LAZY_INSTANCE_INITIALIZER; |
| 142 | 142 |
| 143 | 143 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 "trigger", trigger, | 300 "trigger", trigger, |
| 301 "delay", delay.InMillisecondsF()); | 301 "delay", delay.InMillisecondsF()); |
| 302 | 302 |
| 303 DCHECK(composite_on_vsync_trigger_ == DO_NOT_COMPOSITE); | 303 DCHECK(composite_on_vsync_trigger_ == DO_NOT_COMPOSITE); |
| 304 if (current_composite_task_) | 304 if (current_composite_task_) |
| 305 current_composite_task_->Cancel(); | 305 current_composite_task_->Cancel(); |
| 306 | 306 |
| 307 // Unretained because we cancel the task on shutdown. | 307 // Unretained because we cancel the task on shutdown. |
| 308 current_composite_task_.reset(new base::CancelableClosure( | 308 current_composite_task_.reset(new base::CancelableClosure( |
| 309 base::Bind(&CompositorImpl::Composite, base::Unretained(this), trigger))); | 309 base::Bind(&CompositorImpl::Composite, base::Unretained(this), trigger))); |
| 310 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 310 base::MessageLoop::current()->PostDelayedTask( |
| 311 FROM_HERE, current_composite_task_->callback(), delay); | 311 FROM_HERE, current_composite_task_->callback(), delay); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void CompositorImpl::Composite(CompositingTrigger trigger) { | 314 void CompositorImpl::Composite(CompositingTrigger trigger) { |
| 315 if (trigger == COMPOSITE_IMMEDIATELY) | 315 if (trigger == COMPOSITE_IMMEDIATELY) |
| 316 will_composite_immediately_ = false; | 316 will_composite_immediately_ = false; |
| 317 | 317 |
| 318 DCHECK(host_); | 318 DCHECK(host_); |
| 319 DCHECK(trigger == COMPOSITE_IMMEDIATELY || trigger == COMPOSITE_EVENTUALLY); | 319 DCHECK(trigger == COMPOSITE_IMMEDIATELY || trigger == COMPOSITE_EVENTUALLY); |
| 320 DCHECK(needs_composite_); | 320 DCHECK(needs_composite_); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 scoped_ptr<cc::OutputSurface> real_output_surface( | 650 scoped_ptr<cc::OutputSurface> real_output_surface( |
| 651 new OutputSurfaceWithoutParent(context_provider, | 651 new OutputSurfaceWithoutParent(context_provider, |
| 652 weak_factory_.GetWeakPtr())); | 652 weak_factory_.GetWeakPtr())); |
| 653 | 653 |
| 654 cc::SurfaceManager* manager = GetSurfaceManager(); | 654 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 655 if (manager) { | 655 if (manager) { |
| 656 display_client_.reset(new cc::OnscreenDisplayClient( | 656 display_client_.reset(new cc::OnscreenDisplayClient( |
| 657 real_output_surface.Pass(), manager, HostSharedBitmapManager::current(), | 657 real_output_surface.Pass(), manager, HostSharedBitmapManager::current(), |
| 658 BrowserGpuMemoryBufferManager::current(), | 658 BrowserGpuMemoryBufferManager::current(), |
| 659 host_->settings().renderer_settings, | 659 host_->settings().renderer_settings, |
| 660 base::ThreadTaskRunnerHandle::Get())); | 660 base::MessageLoopProxy::current())); |
| 661 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 661 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
| 662 new cc::SurfaceDisplayOutputSurface( | 662 new cc::SurfaceDisplayOutputSurface( |
| 663 manager, surface_id_allocator_.get(), context_provider)); | 663 manager, surface_id_allocator_.get(), context_provider)); |
| 664 | 664 |
| 665 display_client_->set_surface_output_surface(surface_output_surface.get()); | 665 display_client_->set_surface_output_surface(surface_output_surface.get()); |
| 666 surface_output_surface->set_display_client(display_client_.get()); | 666 surface_output_surface->set_display_client(display_client_.get()); |
| 667 display_client_->display()->Resize(size_); | 667 display_client_->display()->Resize(size_); |
| 668 host_->SetOutputSurface(surface_output_surface.Pass()); | 668 host_->SetOutputSurface(surface_output_surface.Pass()); |
| 669 } else { | 669 } else { |
| 670 host_->SetOutputSurface(real_output_surface.Pass()); | 670 host_->SetOutputSurface(real_output_surface.Pass()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 | 761 |
| 762 void CompositorImpl::SetNeedsAnimate() { | 762 void CompositorImpl::SetNeedsAnimate() { |
| 763 needs_animate_ = true; | 763 needs_animate_ = true; |
| 764 if (!host_) | 764 if (!host_) |
| 765 return; | 765 return; |
| 766 | 766 |
| 767 host_->SetNeedsAnimate(); | 767 host_->SetNeedsAnimate(); |
| 768 } | 768 } |
| 769 | 769 |
| 770 } // namespace content | 770 } // namespace content |
| OLD | NEW |