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

Unified Diff: media/base/android/android_overlay_proxy.cc

Issue 2178973004: DialogSurfaceManager implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup 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 side-by-side diff with in-line comments
Download patch
Index: media/base/android/android_overlay_proxy.cc
diff --git a/media/base/android/android_overlay_proxy.cc b/media/base/android/android_overlay_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1c8504f829a40fa8d27d37d2dda65217b5f0dca5
--- /dev/null
+++ b/media/base/android/android_overlay_proxy.cc
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/android/android_overlay_proxy.h"
+
+#include "base/android/jni_android.h"
+#include "base/bind.h"
+#include "jni/AndroidOverlayProxy_jni.h"
+#include "media/base/android/android_overlay_callback.h"
+
+using base::android::AttachCurrentThread;
+using base::android::JavaRef;
+using base::android::ScopedJavaLocalRef;
+
+namespace media {
+
+AndroidOverlayProxy::AndroidOverlayProxy(
+ const JavaRef<jobject>& unwrapped_holder,
+ std::unique_ptr<AndroidOverlayCallback> wrapped_callback)
+ : wrapped_callback_(std::move(wrapped_callback)) {
+ JNIEnv* env = AttachCurrentThread();
+
+ // Set the callback that we'll use to get the java surface.
+ wrapped_callback_->SetAndroidSurfaceCB(base::Bind(
+ &AndroidOverlayProxy::OnAndroidSurface, base::Unretained(this)));
+
+ j_wrapped_surface_.Reset(
+ env, Java_AndroidOverlayProxy_wrap(env, unwrapped_holder).obj());
+}
+
+AndroidOverlayProxy::~AndroidOverlayProxy() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ wrapped_callback_->SetAndroidSurfaceCB(
+ AndroidOverlayCallback::AndroidSurfaceCB());
+
+ JNIEnv* env = AttachCurrentThread();
+ if (j_wrapped_surface_.obj())
+ Java_AndroidOverlayProxy_release(env, j_wrapped_surface_.obj());
+}
+
+void AndroidOverlayProxy::ScheduleLayout(const Config& config) {
+ DCHECK(CalledOnValidThread());
+ JNIEnv* env = AttachCurrentThread();
+ Java_AndroidOverlayProxy_scheduleLayoutSurface(
+ env, j_wrapped_surface_.obj(), config.rect.x(), config.rect.y(),
+ config.rect.width(), config.rect.height());
+}
+
+bool AndroidOverlayProxy::CalledOnValidThread() const {
+ return thread_checker_.CalledOnValidThread();
+}
+
+void AndroidOverlayProxy::OnAndroidSurface(
+ const base::android::JavaRef<jobject>& jsurface) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ android_surface_ =
+ gl::ScopedJavaSurface::AcquireExternalSurface(jsurface.obj());
+}
+
+gl::ScopedJavaSurface& AndroidOverlayProxy::GetAndroidSurface() {
+ return android_surface_;
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698