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

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

Issue 2718903002: android: Rename SwapBuffers to SwapFrames (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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 CompositorImpl::CompositorImpl(CompositorClient* client, 327 CompositorImpl::CompositorImpl(CompositorClient* client,
328 gfx::NativeWindow root_window) 328 gfx::NativeWindow root_window)
329 : frame_sink_id_( 329 : frame_sink_id_(
330 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()), 330 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()),
331 resource_manager_(root_window), 331 resource_manager_(root_window),
332 window_(NULL), 332 window_(NULL),
333 surface_handle_(gpu::kNullSurfaceHandle), 333 surface_handle_(gpu::kNullSurfaceHandle),
334 client_(client), 334 client_(client),
335 root_window_(root_window), 335 root_window_(root_window),
336 needs_animate_(false), 336 needs_animate_(false),
337 pending_swapbuffers_(0U), 337 pending_frames_(0U),
338 num_successive_context_creation_failures_(0), 338 num_successive_context_creation_failures_(0),
339 compositor_frame_sink_request_pending_(false), 339 compositor_frame_sink_request_pending_(false),
340 weak_factory_(this) { 340 weak_factory_(this) {
341 ui::ContextProviderFactory::GetInstance() 341 ui::ContextProviderFactory::GetInstance()
342 ->GetSurfaceManager() 342 ->GetSurfaceManager()
343 ->RegisterFrameSinkId(frame_sink_id_); 343 ->RegisterFrameSinkId(frame_sink_id_);
344 DCHECK(client); 344 DCHECK(client);
345 DCHECK(root_window); 345 DCHECK(root_window);
346 DCHECK(root_window->GetLayer() == nullptr); 346 DCHECK(root_window->GetLayer() == nullptr);
347 root_window->SetLayer(cc::Layer::Create()); 347 root_window->SetLayer(cc::Layer::Create());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 460
461 // Make a best effort to try to complete pending readbacks. 461 // Make a best effort to try to complete pending readbacks.
462 // TODO(crbug.com/637035): Consider doing this in a better way, 462 // TODO(crbug.com/637035): Consider doing this in a better way,
463 // ideally with the guarantee of readbacks completing. 463 // ideally with the guarantee of readbacks completing.
464 if (display_.get() && HavePendingReadbacks()) 464 if (display_.get() && HavePendingReadbacks())
465 display_->ForceImmediateDrawAndSwapIfPossible(); 465 display_->ForceImmediateDrawAndSwapIfPossible();
466 466
467 host_->SetVisible(false); 467 host_->SetVisible(false);
468 host_->ReleaseCompositorFrameSink(); 468 host_->ReleaseCompositorFrameSink();
469 has_compositor_frame_sink_ = false; 469 has_compositor_frame_sink_ = false;
470 pending_swapbuffers_ = 0; 470 pending_frames_ = 0;
471 display_.reset(); 471 display_.reset();
472 } else { 472 } else {
473 host_->SetVisible(true); 473 host_->SetVisible(true);
474 if (compositor_frame_sink_request_pending_) 474 if (compositor_frame_sink_request_pending_)
475 HandlePendingCompositorFrameSinkRequest(); 475 HandlePendingCompositorFrameSinkRequest();
476 } 476 }
477 } 477 }
478 478
479 void CompositorImpl::SetWindowBounds(const gfx::Size& size) { 479 void CompositorImpl::SetWindowBounds(const gfx::Size& size) {
480 if (size_ == size) 480 if (size_ == size)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 break; 638 break;
639 } 639 }
640 } 640 }
641 641
642 void CompositorImpl::InitializeDisplay( 642 void CompositorImpl::InitializeDisplay(
643 std::unique_ptr<cc::OutputSurface> display_output_surface, 643 std::unique_ptr<cc::OutputSurface> display_output_surface,
644 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, 644 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider,
645 scoped_refptr<cc::ContextProvider> context_provider) { 645 scoped_refptr<cc::ContextProvider> context_provider) {
646 DCHECK(compositor_frame_sink_request_pending_); 646 DCHECK(compositor_frame_sink_request_pending_);
647 647
648 pending_swapbuffers_ = 0; 648 pending_frames_ = 0;
649 num_successive_context_creation_failures_ = 0; 649 num_successive_context_creation_failures_ = 0;
650 650
651 if (context_provider) { 651 if (context_provider) {
652 gpu_capabilities_ = context_provider->ContextCapabilities(); 652 gpu_capabilities_ = context_provider->ContextCapabilities();
653 } else { 653 } else {
654 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider. 654 // TODO(danakj): Populate gpu_capabilities_ for VulkanContextProvider.
655 } 655 }
656 656
657 cc::SurfaceManager* manager = 657 cc::SurfaceManager* manager =
658 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); 658 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 TRACE_EVENT0("compositor", "CompositorImpl::DeleteUIResource"); 693 TRACE_EVENT0("compositor", "CompositorImpl::DeleteUIResource");
694 host_->GetUIResourceManager()->DeleteUIResource(resource_id); 694 host_->GetUIResourceManager()->DeleteUIResource(resource_id);
695 } 695 }
696 696
697 bool CompositorImpl::SupportsETC1NonPowerOfTwo() const { 697 bool CompositorImpl::SupportsETC1NonPowerOfTwo() const {
698 return gpu_capabilities_.texture_format_etc1_npot; 698 return gpu_capabilities_.texture_format_etc1_npot;
699 } 699 }
700 700
701 void CompositorImpl::DidSubmitCompositorFrame() { 701 void CompositorImpl::DidSubmitCompositorFrame() {
702 TRACE_EVENT0("compositor", "CompositorImpl::DidSubmitCompositorFrame"); 702 TRACE_EVENT0("compositor", "CompositorImpl::DidSubmitCompositorFrame");
703 pending_swapbuffers_++; 703 pending_frames_++;
704 } 704 }
705 705
706 void CompositorImpl::DidReceiveCompositorFrameAck() { 706 void CompositorImpl::DidReceiveCompositorFrameAck() {
707 TRACE_EVENT0("compositor", "CompositorImpl::DidReceiveCompositorFrameAck"); 707 TRACE_EVENT0("compositor", "CompositorImpl::DidReceiveCompositorFrameAck");
708 DCHECK_GT(pending_swapbuffers_, 0U); 708 DCHECK_GT(pending_frames_, 0U);
709 pending_swapbuffers_--; 709 pending_frames_--;
710 client_->OnSwapBuffersCompleted(pending_swapbuffers_); 710 client_->DidSwapFrame(pending_frames_);
711 } 711 }
712 712
713 void CompositorImpl::DidLoseCompositorFrameSink() { 713 void CompositorImpl::DidLoseCompositorFrameSink() {
714 TRACE_EVENT0("compositor", "CompositorImpl::DidLoseCompositorFrameSink"); 714 TRACE_EVENT0("compositor", "CompositorImpl::DidLoseCompositorFrameSink");
715 has_compositor_frame_sink_ = false; 715 has_compositor_frame_sink_ = false;
716 client_->OnSwapBuffersCompleted(0); 716 client_->DidSwapFrame(0);
717 } 717 }
718 718
719 void CompositorImpl::DidCommit() { 719 void CompositorImpl::DidCommit() {
720 root_window_->OnCompositingDidCommit(); 720 root_window_->OnCompositingDidCommit();
721 } 721 }
722 722
723 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) { 723 void CompositorImpl::AttachLayerForReadback(scoped_refptr<cc::Layer> layer) {
724 readback_layer_tree_->AddChild(layer); 724 readback_layer_tree_->AddChild(layer);
725 } 725 }
726 726
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 ui::ContextProviderFactory::GetInstance() 762 ui::ContextProviderFactory::GetInstance()
763 ->GetSurfaceManager() 763 ->GetSurfaceManager()
764 ->UnregisterFrameSinkHierarchy(frame_sink_id_, frame_sink_id); 764 ->UnregisterFrameSinkHierarchy(frame_sink_id_, frame_sink_id);
765 } 765 }
766 766
767 bool CompositorImpl::HavePendingReadbacks() { 767 bool CompositorImpl::HavePendingReadbacks() {
768 return !readback_layer_tree_->children().empty(); 768 return !readback_layer_tree_->children().empty();
769 } 769 }
770 770
771 } // namespace content 771 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698