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

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

Issue 782723002: Refactor part of CompositorImpl::SetVisible() into its own method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); 382 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
383 window = ANativeWindow_fromSurface(env, surface); 383 window = ANativeWindow_fromSurface(env, surface);
384 } 384 }
385 if (window) { 385 if (window) {
386 SetWindowSurface(window); 386 SetWindowSurface(window);
387 ANativeWindow_release(window); 387 ANativeWindow_release(window);
388 RegisterViewSurface(surface_id_, j_surface.obj()); 388 RegisterViewSurface(surface_id_, j_surface.obj());
389 } 389 }
390 } 390 }
391 391
392 void CompositorImpl::SetVisible(bool visible) { 392 void CompositorImpl::CreateLayerTreeHost() {
aelias_OOO_until_Jul13 2014/12/05 19:38:00 Please add "DCHECK(!host_);" at the beginning.
393 if (!visible) {
394 DCHECK(host_);
395 // Look for any layers that were attached to the root for readback
396 // and are waiting for Composite() to happen.
397 bool readback_pending = false;
398 for (size_t i = 0; i < root_layer_->children().size(); ++i) {
399 if (root_layer_->children()[i]->HasCopyRequest()) {
400 readback_pending = true;
401 break;
402 }
403 }
404 if (readback_pending) {
405 ignore_schedule_composite_ = true;
406 host_->Composite(base::TimeTicks::Now());
407 ignore_schedule_composite_ = false;
408 }
409 if (WillComposite())
410 CancelComposite();
411 ui_resource_provider_.SetLayerTreeHost(NULL);
412 host_.reset();
413 display_client_.reset();
414 if (current_composite_task_) {
415 current_composite_task_->Cancel();
416 current_composite_task_.reset();
417 }
418 } else if (!host_) {
419 DCHECK(!WillCompositeThisFrame()); 393 DCHECK(!WillCompositeThisFrame());
420 needs_composite_ = false; 394 needs_composite_ = false;
421 defer_composite_for_gpu_channel_ = false; 395 defer_composite_for_gpu_channel_ = false;
422 pending_swapbuffers_ = 0; 396 pending_swapbuffers_ = 0;
423 cc::LayerTreeSettings settings; 397 cc::LayerTreeSettings settings;
424 settings.renderer_settings.refresh_rate = 60.0; 398 settings.renderer_settings.refresh_rate = 60.0;
425 settings.renderer_settings.allow_antialiasing = false; 399 settings.renderer_settings.allow_antialiasing = false;
426 settings.renderer_settings.highp_threshold_min = 2048; 400 settings.renderer_settings.highp_threshold_min = 2048;
427 settings.impl_side_painting = false; 401 settings.impl_side_painting = false;
428 settings.calculate_top_controls_position = false; 402 settings.calculate_top_controls_position = false;
(...skipping 14 matching lines...) Expand all
443 settings, 417 settings,
444 base::MessageLoopProxy::current(), 418 base::MessageLoopProxy::current(),
445 nullptr); 419 nullptr);
446 host_->SetRootLayer(root_layer_); 420 host_->SetRootLayer(root_layer_);
447 421
448 host_->SetVisible(true); 422 host_->SetVisible(true);
449 host_->SetLayerTreeHostClientReady(); 423 host_->SetLayerTreeHostClientReady();
450 host_->SetViewportSize(size_); 424 host_->SetViewportSize(size_);
451 host_->set_has_transparent_background(has_transparent_background_); 425 host_->set_has_transparent_background(has_transparent_background_);
452 host_->SetDeviceScaleFactor(device_scale_factor_); 426 host_->SetDeviceScaleFactor(device_scale_factor_);
427 }
428
429 void CompositorImpl::SetVisible(bool visible) {
430 if (!visible) {
431 DCHECK(host_);
432 // Look for any layers that were attached to the root for readback
433 // and are waiting for Composite() to happen.
434 bool readback_pending = false;
435 for (size_t i = 0; i < root_layer_->children().size(); ++i) {
436 if (root_layer_->children()[i]->HasCopyRequest()) {
437 readback_pending = true;
438 break;
439 }
440 }
441 if (readback_pending) {
442 ignore_schedule_composite_ = true;
443 host_->Composite(base::TimeTicks::Now());
444 ignore_schedule_composite_ = false;
445 }
446 if (WillComposite())
447 CancelComposite();
448 ui_resource_provider_.SetLayerTreeHost(NULL);
449 host_.reset();
450 display_client_.reset();
451 if (current_composite_task_) {
452 current_composite_task_->Cancel();
453 current_composite_task_.reset();
454 }
455 } else if (!host_) {
456 CreateLayerTreeHost();
453 ui_resource_provider_.SetLayerTreeHost(host_.get()); 457 ui_resource_provider_.SetLayerTreeHost(host_.get());
454 } 458 }
455 } 459 }
456 460
457 void CompositorImpl::setDeviceScaleFactor(float factor) { 461 void CompositorImpl::setDeviceScaleFactor(float factor) {
458 device_scale_factor_ = factor; 462 device_scale_factor_ = factor;
459 if (host_) 463 if (host_)
460 host_->SetDeviceScaleFactor(factor); 464 host_->SetDeviceScaleFactor(factor);
461 } 465 }
462 466
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 } 679 }
676 680
677 void CompositorImpl::SetNeedsAnimate() { 681 void CompositorImpl::SetNeedsAnimate() {
678 if (!host_) 682 if (!host_)
679 return; 683 return;
680 684
681 host_->SetNeedsAnimate(); 685 host_->SetNeedsAnimate();
682 } 686 }
683 687
684 } // namespace content 688 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698