| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 OutputSurfaceWithoutParent( | 74 OutputSurfaceWithoutParent( |
| 75 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 75 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 76 base::WeakPtr<CompositorImpl> compositor_impl) | 76 base::WeakPtr<CompositorImpl> compositor_impl) |
| 77 : cc::OutputSurface(context_provider), | 77 : cc::OutputSurface(context_provider), |
| 78 swap_buffers_completion_callback_( | 78 swap_buffers_completion_callback_( |
| 79 base::Bind(&OutputSurfaceWithoutParent::OnSwapBuffersCompleted, | 79 base::Bind(&OutputSurfaceWithoutParent::OnSwapBuffersCompleted, |
| 80 base::Unretained(this))) { | 80 base::Unretained(this))) { |
| 81 capabilities_.adjust_deadline_for_parent = false; | 81 capabilities_.adjust_deadline_for_parent = false; |
| 82 capabilities_.max_frames_pending = 2; | 82 capabilities_.max_frames_pending = 2; |
| 83 compositor_impl_ = compositor_impl; | 83 compositor_impl_ = compositor_impl; |
| 84 main_thread_ = base::MessageLoopProxy::current(); | 84 main_thread_ = base::ThreadTaskRunnerHandle::Get(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void SwapBuffers(cc::CompositorFrame* frame) override { | 87 void SwapBuffers(cc::CompositorFrame* frame) override { |
| 88 GetCommandBufferProxy()->SetLatencyInfo(frame->metadata.latency_info); | 88 GetCommandBufferProxy()->SetLatencyInfo(frame->metadata.latency_info); |
| 89 DCHECK(frame->gl_frame_data->sub_buffer_rect == | 89 DCHECK(frame->gl_frame_data->sub_buffer_rect == |
| 90 gfx::Rect(frame->gl_frame_data->size)); | 90 gfx::Rect(frame->gl_frame_data->size)); |
| 91 context_provider_->ContextSupport()->Swap(); | 91 context_provider_->ContextSupport()->Swap(); |
| 92 client_->DidSwapBuffers(); | 92 client_->DidSwapBuffers(); |
| 93 } | 93 } |
| 94 | 94 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 122 void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info, | 122 void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info, |
| 123 gfx::SwapResult result) { | 123 gfx::SwapResult result) { |
| 124 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); | 124 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); |
| 125 OutputSurface::OnSwapBuffersComplete(); | 125 OutputSurface::OnSwapBuffersComplete(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&, | 128 base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&, |
| 129 gfx::SwapResult)> | 129 gfx::SwapResult)> |
| 130 swap_buffers_completion_callback_; | 130 swap_buffers_completion_callback_; |
| 131 | 131 |
| 132 scoped_refptr<base::MessageLoopProxy> main_thread_; | 132 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; |
| 133 base::WeakPtr<CompositorImpl> compositor_impl_; | 133 base::WeakPtr<CompositorImpl> compositor_impl_; |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 static bool g_initialized = false; | 136 static bool g_initialized = false; |
| 137 | 137 |
| 138 bool g_use_surface_manager = false; | 138 bool g_use_surface_manager = false; |
| 139 base::LazyInstance<cc::SurfaceManager> g_surface_manager = | 139 base::LazyInstance<cc::SurfaceManager> g_surface_manager = |
| 140 LAZY_INSTANCE_INITIALIZER; | 140 LAZY_INSTANCE_INITIALIZER; |
| 141 | 141 |
| 142 | 142 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 "trigger", trigger, | 293 "trigger", trigger, |
| 294 "delay", delay.InMillisecondsF()); | 294 "delay", delay.InMillisecondsF()); |
| 295 | 295 |
| 296 DCHECK(composite_on_vsync_trigger_ == DO_NOT_COMPOSITE); | 296 DCHECK(composite_on_vsync_trigger_ == DO_NOT_COMPOSITE); |
| 297 if (current_composite_task_) | 297 if (current_composite_task_) |
| 298 current_composite_task_->Cancel(); | 298 current_composite_task_->Cancel(); |
| 299 | 299 |
| 300 // Unretained because we cancel the task on shutdown. | 300 // Unretained because we cancel the task on shutdown. |
| 301 current_composite_task_.reset(new base::CancelableClosure( | 301 current_composite_task_.reset(new base::CancelableClosure( |
| 302 base::Bind(&CompositorImpl::Composite, base::Unretained(this), trigger))); | 302 base::Bind(&CompositorImpl::Composite, base::Unretained(this), trigger))); |
| 303 base::MessageLoop::current()->PostDelayedTask( | 303 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 304 FROM_HERE, current_composite_task_->callback(), delay); | 304 FROM_HERE, current_composite_task_->callback(), delay); |
| 305 } | 305 } |
| 306 | 306 |
| 307 void CompositorImpl::Composite(CompositingTrigger trigger) { | 307 void CompositorImpl::Composite(CompositingTrigger trigger) { |
| 308 if (trigger == COMPOSITE_IMMEDIATELY) | 308 if (trigger == COMPOSITE_IMMEDIATELY) |
| 309 will_composite_immediately_ = false; | 309 will_composite_immediately_ = false; |
| 310 | 310 |
| 311 DCHECK(host_); | 311 DCHECK(host_); |
| 312 DCHECK(trigger == COMPOSITE_IMMEDIATELY || trigger == COMPOSITE_EVENTUALLY); | 312 DCHECK(trigger == COMPOSITE_IMMEDIATELY || trigger == COMPOSITE_EVENTUALLY); |
| 313 DCHECK(needs_composite_); | 313 DCHECK(needs_composite_); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 scoped_ptr<cc::OutputSurface> real_output_surface( | 639 scoped_ptr<cc::OutputSurface> real_output_surface( |
| 640 new OutputSurfaceWithoutParent(context_provider, | 640 new OutputSurfaceWithoutParent(context_provider, |
| 641 weak_factory_.GetWeakPtr())); | 641 weak_factory_.GetWeakPtr())); |
| 642 | 642 |
| 643 cc::SurfaceManager* manager = GetSurfaceManager(); | 643 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 644 if (manager) { | 644 if (manager) { |
| 645 display_client_.reset(new cc::OnscreenDisplayClient( | 645 display_client_.reset(new cc::OnscreenDisplayClient( |
| 646 real_output_surface.Pass(), manager, HostSharedBitmapManager::current(), | 646 real_output_surface.Pass(), manager, HostSharedBitmapManager::current(), |
| 647 BrowserGpuMemoryBufferManager::current(), | 647 BrowserGpuMemoryBufferManager::current(), |
| 648 host_->settings().renderer_settings, | 648 host_->settings().renderer_settings, |
| 649 base::MessageLoopProxy::current())); | 649 base::ThreadTaskRunnerHandle::Get())); |
| 650 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 650 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
| 651 new cc::SurfaceDisplayOutputSurface( | 651 new cc::SurfaceDisplayOutputSurface( |
| 652 manager, surface_id_allocator_.get(), context_provider)); | 652 manager, surface_id_allocator_.get(), context_provider)); |
| 653 | 653 |
| 654 display_client_->set_surface_output_surface(surface_output_surface.get()); | 654 display_client_->set_surface_output_surface(surface_output_surface.get()); |
| 655 surface_output_surface->set_display_client(display_client_.get()); | 655 surface_output_surface->set_display_client(display_client_.get()); |
| 656 display_client_->display()->Resize(size_); | 656 display_client_->display()->Resize(size_); |
| 657 host_->SetOutputSurface(surface_output_surface.Pass()); | 657 host_->SetOutputSurface(surface_output_surface.Pass()); |
| 658 } else { | 658 } else { |
| 659 host_->SetOutputSurface(real_output_surface.Pass()); | 659 host_->SetOutputSurface(real_output_surface.Pass()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 | 750 |
| 751 void CompositorImpl::SetNeedsAnimate() { | 751 void CompositorImpl::SetNeedsAnimate() { |
| 752 needs_animate_ = true; | 752 needs_animate_ = true; |
| 753 if (!host_) | 753 if (!host_) |
| 754 return; | 754 return; |
| 755 | 755 |
| 756 host_->SetNeedsAnimate(); | 756 host_->SetNeedsAnimate(); |
| 757 } | 757 } |
| 758 | 758 |
| 759 } // namespace content | 759 } // namespace content |
| OLD | NEW |