OLD | NEW |
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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 void CompositorImpl::SetSurface(jobject surface) { | 473 void CompositorImpl::SetSurface(jobject surface) { |
474 JNIEnv* env = base::android::AttachCurrentThread(); | 474 JNIEnv* env = base::android::AttachCurrentThread(); |
475 gpu::GpuSurfaceTracker* tracker = gpu::GpuSurfaceTracker::Get(); | 475 gpu::GpuSurfaceTracker* tracker = gpu::GpuSurfaceTracker::Get(); |
476 | 476 |
477 if (window_) { | 477 if (window_) { |
478 // Shut down GL context before unregistering surface. | 478 // Shut down GL context before unregistering surface. |
479 SetVisible(false); | 479 SetVisible(false); |
480 tracker->RemoveSurface(surface_handle_); | 480 tracker->RemoveSurface(surface_handle_); |
481 ANativeWindow_release(window_); | 481 ANativeWindow_release(window_); |
482 window_ = NULL; | 482 window_ = NULL; |
483 | |
484 tracker->UnregisterViewSurface(surface_handle_); | |
485 surface_handle_ = gpu::kNullSurfaceHandle; | 483 surface_handle_ = gpu::kNullSurfaceHandle; |
486 } | 484 } |
487 | 485 |
488 ANativeWindow* window = NULL; | 486 ANativeWindow* window = NULL; |
489 if (surface) { | 487 if (surface) { |
490 // Note: This ensures that any local references used by | 488 // Note: This ensures that any local references used by |
491 // ANativeWindow_fromSurface are released immediately. This is needed as a | 489 // ANativeWindow_fromSurface are released immediately. This is needed as a |
492 // workaround for https://code.google.com/p/android/issues/detail?id=68174 | 490 // workaround for https://code.google.com/p/android/issues/detail?id=68174 |
493 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); | 491 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); |
494 window = ANativeWindow_fromSurface(env, surface); | 492 window = ANativeWindow_fromSurface(env, surface); |
495 } | 493 } |
496 | 494 |
497 if (window) { | 495 if (window) { |
498 window_ = window; | 496 window_ = window; |
499 ANativeWindow_acquire(window); | 497 ANativeWindow_acquire(window); |
500 surface_handle_ = tracker->AddSurfaceForNativeWidget(window); | |
501 // Register first, SetVisible() might create a CompositorFrameSink. | 498 // Register first, SetVisible() might create a CompositorFrameSink. |
502 tracker->RegisterViewSurface(surface_handle_, surface); | 499 surface_handle_ = tracker->AddSurfaceForNativeWidget( |
| 500 gpu::GpuSurfaceTracker::SurfaceRecord(window, surface)); |
503 SetVisible(true); | 501 SetVisible(true); |
504 ANativeWindow_release(window); | 502 ANativeWindow_release(window); |
505 } | 503 } |
506 } | 504 } |
507 | 505 |
508 void CompositorImpl::CreateLayerTreeHost() { | 506 void CompositorImpl::CreateLayerTreeHost() { |
509 DCHECK(!host_); | 507 DCHECK(!host_); |
510 | 508 |
511 cc::LayerTreeSettings settings; | 509 cc::LayerTreeSettings settings; |
512 settings.renderer_settings.refresh_rate = 60.0; | 510 settings.renderer_settings.refresh_rate = 60.0; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 } | 867 } |
870 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, | 868 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, |
871 frame_sink_id); | 869 frame_sink_id); |
872 } | 870 } |
873 | 871 |
874 bool CompositorImpl::HavePendingReadbacks() { | 872 bool CompositorImpl::HavePendingReadbacks() { |
875 return !readback_layer_tree_->children().empty(); | 873 return !readback_layer_tree_->children().empty(); |
876 } | 874 } |
877 | 875 |
878 } // namespace content | 876 } // namespace content |
OLD | NEW |