Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 2732213008: Revert of android: Add draw completion for CompositorView (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <unordered_set> 10 #include <unordered_set>
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 attributes.red_size = 5; 179 attributes.red_size = 5;
180 attributes.green_size = 6; 180 attributes.green_size = 6;
181 attributes.blue_size = 5; 181 attributes.blue_size = 5;
182 } 182 }
183 183
184 return attributes; 184 return attributes;
185 } 185 }
186 186
187 class AndroidOutputSurface : public cc::OutputSurface { 187 class AndroidOutputSurface : public cc::OutputSurface {
188 public: 188 public:
189 AndroidOutputSurface( 189 explicit AndroidOutputSurface(
190 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider, 190 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider)
191 base::Closure swap_buffers_callback)
192 : cc::OutputSurface(std::move(context_provider)), 191 : cc::OutputSurface(std::move(context_provider)),
193 swap_buffers_callback_(std::move(swap_buffers_callback)),
194 overlay_candidate_validator_( 192 overlay_candidate_validator_(
195 new display_compositor:: 193 new display_compositor::
196 CompositorOverlayCandidateValidatorAndroid()), 194 CompositorOverlayCandidateValidatorAndroid()),
197 weak_ptr_factory_(this) { 195 weak_ptr_factory_(this) {
198 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers; 196 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers;
199 } 197 }
200 198
201 ~AndroidOutputSurface() override = default; 199 ~AndroidOutputSurface() override = default;
202 200
203 void SwapBuffers(cc::OutputSurfaceFrame frame) override { 201 void SwapBuffers(cc::OutputSurfaceFrame frame) override {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 DCHECK(command_buffer_proxy); 261 DCHECK(command_buffer_proxy);
264 return command_buffer_proxy; 262 return command_buffer_proxy;
265 } 263 }
266 264
267 void OnSwapBuffersCompleted( 265 void OnSwapBuffersCompleted(
268 const std::vector<ui::LatencyInfo>& latency_info, 266 const std::vector<ui::LatencyInfo>& latency_info,
269 gfx::SwapResult result, 267 gfx::SwapResult result,
270 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { 268 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
271 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); 269 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
272 client_->DidReceiveSwapBuffersAck(); 270 client_->DidReceiveSwapBuffersAck();
273 swap_buffers_callback_.Run();
274 } 271 }
275 272
276 private: 273 private:
277 cc::OutputSurfaceClient* client_ = nullptr; 274 cc::OutputSurfaceClient* client_ = nullptr;
278 base::Closure swap_buffers_callback_;
279 std::unique_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator_; 275 std::unique_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator_;
280 base::WeakPtrFactory<AndroidOutputSurface> weak_ptr_factory_; 276 base::WeakPtrFactory<AndroidOutputSurface> weak_ptr_factory_;
281 }; 277 };
282 278
283 #if defined(ENABLE_VULKAN) 279 #if defined(ENABLE_VULKAN)
284 class VulkanOutputSurface : public cc::OutputSurface { 280 class VulkanOutputSurface : public cc::OutputSurface {
285 public: 281 public:
286 explicit VulkanOutputSurface( 282 explicit VulkanOutputSurface(
287 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, 283 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider,
288 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 284 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 GetCompositorContextAttributes(has_transparent_background_), 675 GetCompositorContextAttributes(has_transparent_background_),
680 shared_context, 676 shared_context,
681 ui::command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); 677 ui::command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT);
682 if (!context_provider->BindToCurrentThread()) { 678 if (!context_provider->BindToCurrentThread()) {
683 LOG(ERROR) << "Failed to init ContextProvider for compositor."; 679 LOG(ERROR) << "Failed to init ContextProvider for compositor.";
684 LOG_IF(FATAL, ++num_successive_context_creation_failures_ >= 2) 680 LOG_IF(FATAL, ++num_successive_context_creation_failures_ >= 2)
685 << "Too many context creation failures. Giving up... "; 681 << "Too many context creation failures. Giving up... ";
686 HandlePendingCompositorFrameSinkRequest(); 682 HandlePendingCompositorFrameSinkRequest();
687 } 683 }
688 684
689 // Unretained is safe this owns cc::Display which owns OutputSurface. 685 auto display_output_surface =
690 InitializeDisplay( 686 base::MakeUnique<AndroidOutputSurface>(context_provider);
691 base::MakeUnique<AndroidOutputSurface>( 687 InitializeDisplay(std::move(display_output_surface), nullptr,
692 context_provider, 688 std::move(context_provider));
693 base::Bind(&CompositorImpl::DidSwapBuffers, base::Unretained(this))),
694 nullptr, std::move(context_provider));
695 } 689 }
696 690
697 void CompositorImpl::InitializeDisplay( 691 void CompositorImpl::InitializeDisplay(
698 std::unique_ptr<cc::OutputSurface> display_output_surface, 692 std::unique_ptr<cc::OutputSurface> display_output_surface,
699 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, 693 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider,
700 scoped_refptr<cc::ContextProvider> context_provider) { 694 scoped_refptr<cc::ContextProvider> context_provider) {
701 DCHECK(compositor_frame_sink_request_pending_); 695 DCHECK(compositor_frame_sink_request_pending_);
702 696
703 pending_frames_ = 0; 697 pending_frames_ = 0;
704 num_successive_context_creation_failures_ = 0; 698 num_successive_context_creation_failures_ = 0;
(...skipping 25 matching lines...) Expand all
730 : base::MakeUnique<cc::DirectCompositorFrameSink>( 724 : base::MakeUnique<cc::DirectCompositorFrameSink>(
731 frame_sink_id_, manager, display_.get(), context_provider, 725 frame_sink_id_, manager, display_.get(), context_provider,
732 nullptr, BrowserGpuMemoryBufferManager::current(), 726 nullptr, BrowserGpuMemoryBufferManager::current(),
733 HostSharedBitmapManager::current()); 727 HostSharedBitmapManager::current());
734 728
735 display_->SetVisible(true); 729 display_->SetVisible(true);
736 display_->Resize(size_); 730 display_->Resize(size_);
737 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); 731 host_->SetCompositorFrameSink(std::move(compositor_frame_sink));
738 } 732 }
739 733
740 void CompositorImpl::DidSwapBuffers() {
741 client_->DidSwapBuffers();
742 }
743
744 cc::UIResourceId CompositorImpl::CreateUIResource( 734 cc::UIResourceId CompositorImpl::CreateUIResource(
745 cc::UIResourceClient* client) { 735 cc::UIResourceClient* client) {
746 TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource"); 736 TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource");
747 return host_->GetUIResourceManager()->CreateUIResource(client); 737 return host_->GetUIResourceManager()->CreateUIResource(client);
748 } 738 }
749 739
750 void CompositorImpl::DeleteUIResource(cc::UIResourceId resource_id) { 740 void CompositorImpl::DeleteUIResource(cc::UIResourceId resource_id) {
751 TRACE_EVENT0("compositor", "CompositorImpl::DeleteUIResource"); 741 TRACE_EVENT0("compositor", "CompositorImpl::DeleteUIResource");
752 host_->GetUIResourceManager()->DeleteUIResource(resource_id); 742 host_->GetUIResourceManager()->DeleteUIResource(resource_id);
753 } 743 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 } 808 }
819 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, 809 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_,
820 frame_sink_id); 810 frame_sink_id);
821 } 811 }
822 812
823 bool CompositorImpl::HavePendingReadbacks() { 813 bool CompositorImpl::HavePendingReadbacks() {
824 return !readback_layer_tree_->children().empty(); 814 return !readback_layer_tree_->children().empty();
825 } 815 }
826 816
827 } // namespace content 817 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | content/public/browser/android/compositor_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698