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

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

Issue 2661523003: cc: Merge LayerTree into the LayerTreeHost. (Closed)
Patch Set: auto Created 3 years, 10 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 animation_host_ = cc::AnimationHost::CreateMainInstance(); 436 animation_host_ = cc::AnimationHost::CreateMainInstance();
437 437
438 cc::LayerTreeHost::InitParams params; 438 cc::LayerTreeHost::InitParams params;
439 params.client = this; 439 params.client = this;
440 params.task_graph_runner = g_task_graph_runner.Pointer(); 440 params.task_graph_runner = g_task_graph_runner.Pointer();
441 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); 441 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
442 params.settings = &settings; 442 params.settings = &settings;
443 params.mutator_host = animation_host_.get(); 443 params.mutator_host = animation_host_.get();
444 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params); 444 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params);
445 DCHECK(!host_->IsVisible()); 445 DCHECK(!host_->IsVisible());
446 host_->GetLayerTree()->SetRootLayer(root_window_->GetLayer()); 446 host_->SetRootLayer(root_window_->GetLayer());
447 host_->SetFrameSinkId(frame_sink_id_); 447 host_->SetFrameSinkId(frame_sink_id_);
448 host_->GetLayerTree()->SetViewportSize(size_); 448 host_->SetViewportSize(size_);
449 SetHasTransparentBackground(false); 449 SetHasTransparentBackground(false);
450 host_->GetLayerTree()->SetDeviceScaleFactor(1); 450 host_->SetDeviceScaleFactor(1);
451 451
452 if (needs_animate_) 452 if (needs_animate_)
453 host_->SetNeedsAnimate(); 453 host_->SetNeedsAnimate();
454 } 454 }
455 455
456 void CompositorImpl::SetVisible(bool visible) { 456 void CompositorImpl::SetVisible(bool visible) {
457 TRACE_EVENT1("cc", "CompositorImpl::SetVisible", "visible", visible); 457 TRACE_EVENT1("cc", "CompositorImpl::SetVisible", "visible", visible);
458 if (!visible) { 458 if (!visible) {
459 DCHECK(host_->IsVisible()); 459 DCHECK(host_->IsVisible());
460 460
(...skipping 13 matching lines...) Expand all
474 HandlePendingCompositorFrameSinkRequest(); 474 HandlePendingCompositorFrameSinkRequest();
475 } 475 }
476 } 476 }
477 477
478 void CompositorImpl::SetWindowBounds(const gfx::Size& size) { 478 void CompositorImpl::SetWindowBounds(const gfx::Size& size) {
479 if (size_ == size) 479 if (size_ == size)
480 return; 480 return;
481 481
482 size_ = size; 482 size_ = size;
483 if (host_) 483 if (host_)
484 host_->GetLayerTree()->SetViewportSize(size); 484 host_->SetViewportSize(size);
485 if (display_) 485 if (display_)
486 display_->Resize(size); 486 display_->Resize(size);
487 root_window_->GetLayer()->SetBounds(size); 487 root_window_->GetLayer()->SetBounds(size);
488 } 488 }
489 489
490 void CompositorImpl::SetHasTransparentBackground(bool transparent) { 490 void CompositorImpl::SetHasTransparentBackground(bool transparent) {
491 has_transparent_background_ = transparent; 491 has_transparent_background_ = transparent;
492 if (host_) { 492 if (host_) {
493 host_->GetLayerTree()->set_has_transparent_background(transparent); 493 host_->set_has_transparent_background(transparent);
494 494
495 // Give a delay in setting the background color to avoid the color for 495 // Give a delay in setting the background color to avoid the color for
496 // the normal mode (white) affecting the UI transition. 496 // the normal mode (white) affecting the UI transition.
497 base::ThreadTaskRunnerHandle::Get().get()->PostDelayedTask( 497 base::ThreadTaskRunnerHandle::Get().get()->PostDelayedTask(
498 FROM_HERE, 498 FROM_HERE,
499 base::Bind(&CompositorImpl::SetBackgroundColor, 499 base::Bind(&CompositorImpl::SetBackgroundColor,
500 weak_factory_.GetWeakPtr(), 500 weak_factory_.GetWeakPtr(),
501 transparent ? SK_ColorBLACK : SK_ColorWHITE), 501 transparent ? SK_ColorBLACK : SK_ColorWHITE),
502 base::TimeDelta::FromMilliseconds(500)); 502 base::TimeDelta::FromMilliseconds(500));
503 } 503 }
504 } 504 }
505 505
506 void CompositorImpl::SetBackgroundColor(int color) { 506 void CompositorImpl::SetBackgroundColor(int color) {
507 host_->GetLayerTree()->set_background_color(color); 507 host_->set_background_color(color);
508 } 508 }
509 509
510 void CompositorImpl::SetNeedsComposite() { 510 void CompositorImpl::SetNeedsComposite() {
511 if (!host_->IsVisible()) 511 if (!host_->IsVisible())
512 return; 512 return;
513 TRACE_EVENT0("compositor", "Compositor::SetNeedsComposite"); 513 TRACE_EVENT0("compositor", "Compositor::SetNeedsComposite");
514 host_->SetNeedsAnimate(); 514 host_->SetNeedsAnimate();
515 } 515 }
516 516
517 void CompositorImpl::UpdateLayerTreeHost() { 517 void CompositorImpl::UpdateLayerTreeHost() {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 733
734 cc::FrameSinkId CompositorImpl::GetFrameSinkId() { 734 cc::FrameSinkId CompositorImpl::GetFrameSinkId() {
735 return frame_sink_id_; 735 return frame_sink_id_;
736 } 736 }
737 737
738 bool CompositorImpl::HavePendingReadbacks() { 738 bool CompositorImpl::HavePendingReadbacks() {
739 return !readback_layer_tree_->children().empty(); 739 return !readback_layer_tree_->children().empty();
740 } 740 }
741 741
742 } // namespace content 742 } // namespace content
OLDNEW
« no previous file with comments | « cc/trees/tree_synchronizer_unittest.cc ('k') | content/renderer/gpu/gpu_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698