| 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 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 12 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/auto_reset.h" | 14 #include "base/auto_reset.h" |
| 14 #include "base/bind.h" | 15 #include "base/bind.h" |
| 15 #include "base/cancelable_callback.h" | 16 #include "base/cancelable_callback.h" |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/containers/hash_tables.h" | 18 #include "base/containers/hash_tables.h" |
| 18 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
| 19 #include "base/logging.h" | 20 #include "base/logging.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return g_surface_manager.Pointer(); | 217 return g_surface_manager.Pointer(); |
| 217 } | 218 } |
| 218 | 219 |
| 219 // static | 220 // static |
| 220 scoped_ptr<cc::SurfaceIdAllocator> CompositorImpl::CreateSurfaceIdAllocator() { | 221 scoped_ptr<cc::SurfaceIdAllocator> CompositorImpl::CreateSurfaceIdAllocator() { |
| 221 scoped_ptr<cc::SurfaceIdAllocator> allocator( | 222 scoped_ptr<cc::SurfaceIdAllocator> allocator( |
| 222 new cc::SurfaceIdAllocator(++g_surface_id_namespace)); | 223 new cc::SurfaceIdAllocator(++g_surface_id_namespace)); |
| 223 cc::SurfaceManager* manager = GetSurfaceManager(); | 224 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 224 DCHECK(manager); | 225 DCHECK(manager); |
| 225 allocator->RegisterSurfaceIdNamespace(manager); | 226 allocator->RegisterSurfaceIdNamespace(manager); |
| 226 return allocator.Pass(); | 227 return allocator; |
| 227 } | 228 } |
| 228 | 229 |
| 229 CompositorImpl::CompositorImpl(CompositorClient* client, | 230 CompositorImpl::CompositorImpl(CompositorClient* client, |
| 230 gfx::NativeWindow root_window) | 231 gfx::NativeWindow root_window) |
| 231 : root_layer_(cc::Layer::Create(Compositor::LayerSettings())), | 232 : root_layer_(cc::Layer::Create(Compositor::LayerSettings())), |
| 232 resource_manager_(root_window), | 233 resource_manager_(root_window), |
| 233 surface_id_allocator_(GetSurfaceManager() ? CreateSurfaceIdAllocator() | 234 surface_id_allocator_(GetSurfaceManager() ? CreateSurfaceIdAllocator() |
| 234 : nullptr), | 235 : nullptr), |
| 235 has_transparent_background_(false), | 236 has_transparent_background_(false), |
| 236 device_scale_factor_(1), | 237 device_scale_factor_(1), |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 DCHECK(context_provider.get()); | 657 DCHECK(context_provider.get()); |
| 657 | 658 |
| 658 scoped_ptr<cc::OutputSurface> real_output_surface( | 659 scoped_ptr<cc::OutputSurface> real_output_surface( |
| 659 new OutputSurfaceWithoutParent( | 660 new OutputSurfaceWithoutParent( |
| 660 this, context_provider, | 661 this, context_provider, |
| 661 base::Bind(&CompositorImpl::PopulateGpuCapabilities, | 662 base::Bind(&CompositorImpl::PopulateGpuCapabilities, |
| 662 base::Unretained(this)))); | 663 base::Unretained(this)))); |
| 663 | 664 |
| 664 cc::SurfaceManager* manager = GetSurfaceManager(); | 665 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 665 if (manager) { | 666 if (manager) { |
| 666 display_client_.reset(new cc::OnscreenDisplayClient( | 667 display_client_.reset( |
| 667 real_output_surface.Pass(), manager, HostSharedBitmapManager::current(), | 668 new cc::OnscreenDisplayClient(std::move(real_output_surface), manager, |
| 668 BrowserGpuMemoryBufferManager::current(), | 669 HostSharedBitmapManager::current(), |
| 669 host_->settings().renderer_settings, | 670 BrowserGpuMemoryBufferManager::current(), |
| 670 base::ThreadTaskRunnerHandle::Get())); | 671 host_->settings().renderer_settings, |
| 672 base::ThreadTaskRunnerHandle::Get())); |
| 671 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 673 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
| 672 new cc::SurfaceDisplayOutputSurface( | 674 new cc::SurfaceDisplayOutputSurface( |
| 673 manager, surface_id_allocator_.get(), context_provider, nullptr)); | 675 manager, surface_id_allocator_.get(), context_provider, nullptr)); |
| 674 | 676 |
| 675 display_client_->set_surface_output_surface(surface_output_surface.get()); | 677 display_client_->set_surface_output_surface(surface_output_surface.get()); |
| 676 surface_output_surface->set_display_client(display_client_.get()); | 678 surface_output_surface->set_display_client(display_client_.get()); |
| 677 display_client_->display()->Resize(size_); | 679 display_client_->display()->Resize(size_); |
| 678 host_->SetOutputSurface(surface_output_surface.Pass()); | 680 host_->SetOutputSurface(std::move(surface_output_surface)); |
| 679 } else { | 681 } else { |
| 680 host_->SetOutputSurface(real_output_surface.Pass()); | 682 host_->SetOutputSurface(std::move(real_output_surface)); |
| 681 } | 683 } |
| 682 } | 684 } |
| 683 | 685 |
| 684 void CompositorImpl::PopulateGpuCapabilities( | 686 void CompositorImpl::PopulateGpuCapabilities( |
| 685 gpu::Capabilities gpu_capabilities) { | 687 gpu::Capabilities gpu_capabilities) { |
| 686 gpu_capabilities_ = gpu_capabilities; | 688 gpu_capabilities_ = gpu_capabilities; |
| 687 } | 689 } |
| 688 | 690 |
| 689 void CompositorImpl::AddObserver(VSyncObserver* observer) { | 691 void CompositorImpl::AddObserver(VSyncObserver* observer) { |
| 690 observer_list_.AddObserver(observer); | 692 observer_list_.AddObserver(observer); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 void CompositorImpl::DidCommit() { | 762 void CompositorImpl::DidCommit() { |
| 761 root_window_->OnCompositingDidCommit(); | 763 root_window_->OnCompositingDidCommit(); |
| 762 } | 764 } |
| 763 | 765 |
| 764 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { | 766 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { |
| 765 root_layer_->AddChild(layer); | 767 root_layer_->AddChild(layer); |
| 766 } | 768 } |
| 767 | 769 |
| 768 void CompositorImpl::RequestCopyOfOutputOnRootLayer( | 770 void CompositorImpl::RequestCopyOfOutputOnRootLayer( |
| 769 scoped_ptr<cc::CopyOutputRequest> request) { | 771 scoped_ptr<cc::CopyOutputRequest> request) { |
| 770 root_layer_->RequestCopyOfOutput(request.Pass()); | 772 root_layer_->RequestCopyOfOutput(std::move(request)); |
| 771 } | 773 } |
| 772 | 774 |
| 773 void CompositorImpl::OnVSync(base::TimeTicks frame_time, | 775 void CompositorImpl::OnVSync(base::TimeTicks frame_time, |
| 774 base::TimeDelta vsync_period) { | 776 base::TimeDelta vsync_period) { |
| 775 vsync_period_ = vsync_period; | 777 vsync_period_ = vsync_period; |
| 776 last_vsync_ = frame_time; | 778 last_vsync_ = frame_time; |
| 777 | 779 |
| 778 if (WillCompositeThisFrame()) { | 780 if (WillCompositeThisFrame()) { |
| 779 // We somehow missed the last vsync interval, so reschedule for deadline. | 781 // We somehow missed the last vsync interval, so reschedule for deadline. |
| 780 // We cannot schedule immediately, or will get us out-of-phase with new | 782 // We cannot schedule immediately, or will get us out-of-phase with new |
| (...skipping 17 matching lines...) Expand all Loading... |
| 798 | 800 |
| 799 void CompositorImpl::SetNeedsAnimate() { | 801 void CompositorImpl::SetNeedsAnimate() { |
| 800 needs_animate_ = true; | 802 needs_animate_ = true; |
| 801 if (!host_->visible()) | 803 if (!host_->visible()) |
| 802 return; | 804 return; |
| 803 | 805 |
| 804 host_->SetNeedsAnimate(); | 806 host_->SetNeedsAnimate(); |
| 805 } | 807 } |
| 806 | 808 |
| 807 } // namespace content | 809 } // namespace content |
| OLD | NEW |