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

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

Issue 1967553002: DO NOT COMMIT - DialogSurface initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added check for gpu process for dialog surface manager. Created 4 years, 6 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/dialog_surface_controller.cc
diff --git a/media/base/android/dialog_surface_controller.cc b/media/base/android/dialog_surface_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0165e4500a1ee977b1017ca2df5e87055cd156f5
--- /dev/null
+++ b/media/base/android/dialog_surface_controller.cc
@@ -0,0 +1,93 @@
+// 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/dialog_surface_controller.h"
+
+#include <algorithm>
+#include <limits>
+#include <map>
+#include <memory>
+#include <utility>
+
+#include "base/android/build_info.h"
+#include "base/android/jni_android.h"
+#include "base/android/jni_array.h"
+#include "base/android/jni_string.h"
+#include "base/lazy_instance.h"
+#include "base/logging.h"
+#include "base/numerics/safe_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/synchronization/lock.h"
+#include "base/synchronization/waitable_event.h"
+#include "jni/DialogSurfaceControllerWrapper_jni.h"
+#include "media/base/android/dialog_surface_callback.h"
+#include "media/base/android/dialog_surface_manager.h"
+#include "media/base/bind_to_current_loop.h"
+#include "media/base/bit_reader.h"
+#include "media/base/decrypt_config.h"
+
+using base::android::AttachCurrentThread;
+using base::android::ConvertJavaStringToUTF8;
+using base::android::ConvertUTF8ToJavaString;
+using base::android::JavaIntArrayToIntVector;
+using base::android::JavaRef;
+using base::android::ScopedJavaLocalRef;
+
+namespace media {
+
+DialogSurfaceController::DialogSurfaceController(
+ const JavaRef<jobject>& unwrapped_controller,
+ std::unique_ptr<DialogSurfaceCallback>&& wrapped_callback)
+ : wrapped_callback_(std::move(wrapped_callback)) {
+ JNIEnv* env = AttachCurrentThread();
+ CHECK(env);
+ j_wrapped_controller_.Reset(env, Java_DialogSurfaceControllerWrapper_wrap(
+ env, unwrapped_controller.obj())
+ .obj());
+}
+
+DialogSurfaceController::~DialogSurfaceController() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ JNIEnv* env = AttachCurrentThread();
+ CHECK(env);
+ if (j_wrapped_controller_.obj())
+ Java_DialogSurfaceControllerWrapper_release(env,
+ j_wrapped_controller_.obj());
+}
+
+void DialogSurfaceController::ScheduleLayout(const Config& config) {
+ DCHECK(CalledOnValidThread());
+ JNIEnv* env = AttachCurrentThread();
+ CHECK(env);
+ Java_DialogSurfaceControllerWrapper_scheduleLayoutSurface(
+ env, j_wrapped_controller_.obj(), config.position.x(),
+ config.position.y(), config.size.width(), config.size.height());
+}
+
+gl::ScopedJavaSurface DialogSurfaceController::GetSurface() {
+ DCHECK(CalledOnValidThread());
+ // TODO(liberato): should we tell ScopedJavaSurface not to release the
+ // surface when it is destroyed? i think so.
+ JNIEnv* env = AttachCurrentThread();
+ CHECK(env);
+ ScopedJavaLocalRef<jobject> surface(
+ Java_DialogSurfaceControllerWrapper_getSurface(
+ env, j_wrapped_controller_.obj()));
+ if (surface.obj() == nullptr)
+ return gl::ScopedJavaSurface();
+
+ // TODO(liberato): does this work if the surface is null?
+ return gl::ScopedJavaSurface::AcquireExternalSurface(surface.obj());
+}
+
+bool DialogSurfaceController::CalledOnValidThread() const {
+ return thread_checker_.CalledOnValidThread();
+}
+
+bool DialogSurfaceController::RegisterDialogSurfaceController(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698