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

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

Issue 2299613003: New Compositor and tab content
Patch Set: more clean up Created 4 years, 3 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 overlay_candidate_validator_( 225 overlay_candidate_validator_(
226 new display_compositor:: 226 new display_compositor::
227 CompositorOverlayCandidateValidatorAndroid()) { 227 CompositorOverlayCandidateValidatorAndroid()) {
228 capabilities_.adjust_deadline_for_parent = false; 228 capabilities_.adjust_deadline_for_parent = false;
229 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers; 229 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers;
230 } 230 }
231 231
232 ~OutputSurfaceWithoutParent() override = default; 232 ~OutputSurfaceWithoutParent() override = default;
233 233
234 void SwapBuffers(cc::CompositorFrame frame) override { 234 void SwapBuffers(cc::CompositorFrame frame) override {
235 LOG(ERROR) << "bshe "
236 << "===out put surface with parent swap buffers";
235 GetCommandBufferProxy()->SetLatencyInfo(frame.metadata.latency_info); 237 GetCommandBufferProxy()->SetLatencyInfo(frame.metadata.latency_info);
236 if (frame.gl_frame_data->sub_buffer_rect.IsEmpty()) { 238 if (frame.gl_frame_data->sub_buffer_rect.IsEmpty()) {
237 context_provider_->ContextSupport()->CommitOverlayPlanes(); 239 context_provider_->ContextSupport()->CommitOverlayPlanes();
238 } else { 240 } else {
239 DCHECK(frame.gl_frame_data->sub_buffer_rect == 241 DCHECK(frame.gl_frame_data->sub_buffer_rect ==
240 gfx::Rect(frame.gl_frame_data->size)); 242 gfx::Rect(frame.gl_frame_data->size));
241 context_provider_->ContextSupport()->Swap(); 243 context_provider_->ContextSupport()->Swap();
242 } 244 }
243 } 245 }
244 246
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 pending_swapbuffers_(0U), 398 pending_swapbuffers_(0U),
397 num_successive_context_creation_failures_(0), 399 num_successive_context_creation_failures_(0),
398 output_surface_request_pending_(false), 400 output_surface_request_pending_(false),
399 needs_begin_frames_(false), 401 needs_begin_frames_(false),
400 weak_factory_(this) { 402 weak_factory_(this) {
401 ui::ContextProviderFactory::GetInstance() 403 ui::ContextProviderFactory::GetInstance()
402 ->GetSurfaceManager() 404 ->GetSurfaceManager()
403 ->RegisterSurfaceClientId(surface_id_allocator_->client_id()); 405 ->RegisterSurfaceClientId(surface_id_allocator_->client_id());
404 DCHECK(client); 406 DCHECK(client);
405 DCHECK(root_window); 407 DCHECK(root_window);
406 DCHECK(root_window->GetLayer() == nullptr); 408 // DCHECK(root_window->GetLayer() == nullptr);
407 root_window->SetLayer(cc::Layer::Create()); 409 root_window->SetLayer(cc::Layer::Create());
408 readback_layer_tree_ = cc::Layer::Create(); 410 readback_layer_tree_ = cc::Layer::Create();
409 readback_layer_tree_->SetHideLayerAndSubtree(true); 411 readback_layer_tree_->SetHideLayerAndSubtree(true);
410 root_window->GetLayer()->AddChild(readback_layer_tree_); 412 root_window->GetLayer()->AddChild(readback_layer_tree_);
411 root_window->AttachCompositor(this); 413 root_window->AttachCompositor(this);
412 CreateLayerTreeHost(); 414 CreateLayerTreeHost();
413 resource_manager_.Init(host_.get()); 415 resource_manager_.Init(host_.get());
414 } 416 }
415 417
416 CompositorImpl::~CompositorImpl() { 418 CompositorImpl::~CompositorImpl() {
(...skipping 13 matching lines...) Expand all
430 ui::ResourceManager& CompositorImpl::GetResourceManager() { 432 ui::ResourceManager& CompositorImpl::GetResourceManager() {
431 return resource_manager_; 433 return resource_manager_;
432 } 434 }
433 435
434 void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) { 436 void CompositorImpl::SetRootLayer(scoped_refptr<cc::Layer> root_layer) {
435 if (subroot_layer_.get()) { 437 if (subroot_layer_.get()) {
436 subroot_layer_->RemoveFromParent(); 438 subroot_layer_->RemoveFromParent();
437 subroot_layer_ = NULL; 439 subroot_layer_ = NULL;
438 } 440 }
439 if (root_window_->GetLayer()) { 441 if (root_window_->GetLayer()) {
442 LOG(ERROR) << "bshe "
443 << "set root layer success====";
440 subroot_layer_ = root_window_->GetLayer(); 444 subroot_layer_ = root_window_->GetLayer();
441 root_window_->GetLayer()->AddChild(root_layer); 445 root_window_->GetLayer()->AddChild(root_layer);
442 } 446 }
443 } 447 }
444 448
445 void CompositorImpl::SetSurface(jobject surface) { 449 void CompositorImpl::SetSurface(jobject surface) {
446 JNIEnv* env = base::android::AttachCurrentThread(); 450 JNIEnv* env = base::android::AttachCurrentThread();
447 base::android::ScopedJavaLocalRef<jobject> j_surface(env, surface); 451 base::android::ScopedJavaLocalRef<jobject> j_surface(env, surface);
448 452
449 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); 453 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get();
450 454
455 LOG(ERROR) << "bshe "
456 << "expect set Surface correctly====";
451 if (window_) { 457 if (window_) {
452 // Shut down GL context before unregistering surface. 458 // Shut down GL context before unregistering surface.
453 SetVisible(false); 459 SetVisible(false);
454 tracker->RemoveSurface(surface_handle_); 460 tracker->RemoveSurface(surface_handle_);
455 ANativeWindow_release(window_); 461 ANativeWindow_release(window_);
456 window_ = NULL; 462 window_ = NULL;
457 UnregisterViewSurface(surface_handle_); 463 UnregisterViewSurface(surface_handle_);
458 surface_handle_ = gpu::kNullSurfaceHandle; 464 surface_handle_ = gpu::kNullSurfaceHandle;
459 } 465 }
460 466
461 ANativeWindow* window = NULL; 467 ANativeWindow* window = NULL;
462 if (surface) { 468 if (surface) {
463 // Note: This ensures that any local references used by 469 // Note: This ensures that any local references used by
464 // ANativeWindow_fromSurface are released immediately. This is needed as a 470 // ANativeWindow_fromSurface are released immediately. This is needed as a
465 // workaround for https://code.google.com/p/android/issues/detail?id=68174 471 // workaround for https://code.google.com/p/android/issues/detail?id=68174
466 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); 472 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
467 window = ANativeWindow_fromSurface(env, surface); 473 window = ANativeWindow_fromSurface(env, surface);
468 } 474 }
469 475
470 if (window) { 476 if (window) {
471 window_ = window; 477 window_ = window;
472 ANativeWindow_acquire(window); 478 ANativeWindow_acquire(window);
473 surface_handle_ = tracker->AddSurfaceForNativeWidget(window); 479 surface_handle_ = tracker->AddSurfaceForNativeWidget(window);
474 // Register first, SetVisible() might create an OutputSurface. 480 // Register first, SetVisible() might create an OutputSurface.
475 RegisterViewSurface(surface_handle_, j_surface.obj()); 481 RegisterViewSurface(surface_handle_, j_surface.obj());
476 SetVisible(true); 482 SetVisible(true);
483 LOG(ERROR) << "bshe "
484 << "set Surface correctly====";
477 ANativeWindow_release(window); 485 ANativeWindow_release(window);
478 } 486 }
479 } 487 }
480 488
481 void CompositorImpl::CreateLayerTreeHost() { 489 void CompositorImpl::CreateLayerTreeHost() {
482 DCHECK(!host_); 490 DCHECK(!host_);
483 491
484 cc::LayerTreeSettings settings; 492 cc::LayerTreeSettings settings;
485 settings.renderer_settings.refresh_rate = 60.0; 493 settings.renderer_settings.refresh_rate = 60.0;
486 settings.renderer_settings.allow_antialiasing = false; 494 settings.renderer_settings.allow_antialiasing = false;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 void CompositorImpl::DidPostSwapBuffers() { 747 void CompositorImpl::DidPostSwapBuffers() {
740 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers"); 748 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers");
741 pending_swapbuffers_++; 749 pending_swapbuffers_++;
742 } 750 }
743 751
744 void CompositorImpl::DidCompleteSwapBuffers() { 752 void CompositorImpl::DidCompleteSwapBuffers() {
745 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers"); 753 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers");
746 DCHECK_GT(pending_swapbuffers_, 0U); 754 DCHECK_GT(pending_swapbuffers_, 0U);
747 pending_swapbuffers_--; 755 pending_swapbuffers_--;
748 client_->OnSwapBuffersCompleted(pending_swapbuffers_); 756 client_->OnSwapBuffersCompleted(pending_swapbuffers_);
757 LOG(ERROR) << "bshe===="
758 << "swap buffer complelet";
749 } 759 }
750 760
751 void CompositorImpl::DidAbortSwapBuffers() { 761 void CompositorImpl::DidAbortSwapBuffers() {
752 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); 762 TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers");
753 // This really gets called only once from 763 // This really gets called only once from
754 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the 764 // SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the
755 // context was lost. 765 // context was lost.
756 if (host_->visible()) 766 if (host_->visible())
757 host_->SetNeedsCommit(); 767 host_->SetNeedsCommit();
758 client_->OnSwapBuffersCompleted(0); 768 client_->OnSwapBuffersCompleted(0);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 805
796 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); 806 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate");
797 host_->SetNeedsAnimate(); 807 host_->SetNeedsAnimate();
798 } 808 }
799 809
800 bool CompositorImpl::HavePendingReadbacks() { 810 bool CompositorImpl::HavePendingReadbacks() {
801 return !readback_layer_tree_->children().empty(); 811 return !readback_layer_tree_->children().empty();
802 } 812 }
803 813
804 } // namespace content 814 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.cc ('k') | content/browser/renderer_host/render_widget_host_view_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698