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

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

Issue 2791723003: Update GpuSurfaceTracker to include Android surfaces. (Closed)
Patch Set: made one-arg constructor implicit Created 3 years, 8 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 void CompositorImpl::SetSurface(jobject surface) { 466 void CompositorImpl::SetSurface(jobject surface) {
467 JNIEnv* env = base::android::AttachCurrentThread(); 467 JNIEnv* env = base::android::AttachCurrentThread();
468 gpu::GpuSurfaceTracker* tracker = gpu::GpuSurfaceTracker::Get(); 468 gpu::GpuSurfaceTracker* tracker = gpu::GpuSurfaceTracker::Get();
469 469
470 if (window_) { 470 if (window_) {
471 // Shut down GL context before unregistering surface. 471 // Shut down GL context before unregistering surface.
472 SetVisible(false); 472 SetVisible(false);
473 tracker->RemoveSurface(surface_handle_); 473 tracker->RemoveSurface(surface_handle_);
474 ANativeWindow_release(window_); 474 ANativeWindow_release(window_);
475 window_ = NULL; 475 window_ = NULL;
476
477 tracker->UnregisterViewSurface(surface_handle_);
478 surface_handle_ = gpu::kNullSurfaceHandle; 476 surface_handle_ = gpu::kNullSurfaceHandle;
479 } 477 }
480 478
481 ANativeWindow* window = NULL; 479 ANativeWindow* window = NULL;
482 if (surface) { 480 if (surface) {
483 // Note: This ensures that any local references used by 481 // Note: This ensures that any local references used by
484 // ANativeWindow_fromSurface are released immediately. This is needed as a 482 // ANativeWindow_fromSurface are released immediately. This is needed as a
485 // workaround for https://code.google.com/p/android/issues/detail?id=68174 483 // workaround for https://code.google.com/p/android/issues/detail?id=68174
486 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); 484 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
487 window = ANativeWindow_fromSurface(env, surface); 485 window = ANativeWindow_fromSurface(env, surface);
488 } 486 }
489 487
490 if (window) { 488 if (window) {
491 window_ = window; 489 window_ = window;
492 ANativeWindow_acquire(window); 490 ANativeWindow_acquire(window);
493 surface_handle_ = tracker->AddSurfaceForNativeWidget(window);
494 // Register first, SetVisible() might create a CompositorFrameSink. 491 // Register first, SetVisible() might create a CompositorFrameSink.
495 tracker->RegisterViewSurface(surface_handle_, surface); 492 surface_handle_ = tracker->AddSurfaceForNativeWidget(
493 gpu::GpuSurfaceTracker::Record(window, surface));
496 SetVisible(true); 494 SetVisible(true);
497 ANativeWindow_release(window); 495 ANativeWindow_release(window);
498 } 496 }
499 } 497 }
500 498
501 void CompositorImpl::CreateLayerTreeHost() { 499 void CompositorImpl::CreateLayerTreeHost() {
502 DCHECK(!host_); 500 DCHECK(!host_);
503 501
504 cc::LayerTreeSettings settings; 502 cc::LayerTreeSettings settings;
505 settings.renderer_settings.refresh_rate = 60.0; 503 settings.renderer_settings.refresh_rate = 60.0;
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 } 860 }
863 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, 861 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_,
864 frame_sink_id); 862 frame_sink_id);
865 } 863 }
866 864
867 bool CompositorImpl::HavePendingReadbacks() { 865 bool CompositorImpl::HavePendingReadbacks() {
868 return !readback_layer_tree_->children().empty(); 866 return !readback_layer_tree_->children().empty();
869 } 867 }
870 868
871 } // namespace content 869 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698