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

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

Issue 1967553002: DO NOT COMMIT - DialogSurface initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 years, 5 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
« no previous file with comments | « media/base/android/dialog_surface.h ('k') | media/base/android/dialog_surface_callback.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/dialog_surface.cc
diff --git a/media/base/android/dialog_surface.cc b/media/base/android/dialog_surface.cc
new file mode 100644
index 0000000000000000000000000000000000000000..49b06eb6f895cdc6852c248152fdd3dc6581c8ad
--- /dev/null
+++ b/media/base/android/dialog_surface.cc
@@ -0,0 +1,87 @@
+// 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.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/DialogSurfaceWrapper_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 {
+
+DialogSurface::DialogSurface(
+ const JavaRef<jobject>& unwrapped_surface,
+ std::unique_ptr<DialogSurfaceCallback>&& wrapped_callback)
+ : wrapped_callback_(std::move(wrapped_callback)) {
+ JNIEnv* env = AttachCurrentThread();
+ CHECK(env);
+ j_wrapped_surface_.Reset(
+ env, Java_DialogSurfaceWrapper_wrap(env, unwrapped_surface.obj()).obj());
+}
+
+DialogSurface::~DialogSurface() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ JNIEnv* env = AttachCurrentThread();
+ CHECK(env);
+ if (j_wrapped_surface_.obj())
+ Java_DialogSurfaceWrapper_release(env, j_wrapped_surface_.obj());
+}
+
+void DialogSurface::ScheduleLayout(const Config& config) {
+ DCHECK(CalledOnValidThread());
+ JNIEnv* env = AttachCurrentThread();
+ CHECK(env);
+ Java_DialogSurfaceWrapper_scheduleLayoutSurface(
+ env, j_wrapped_surface_.obj(), config.position.x(), config.position.y(),
+ config.size.width(), config.size.height());
+}
+
+gl::ScopedJavaSurface DialogSurface::GetSurface() {
+ DCHECK(CalledOnValidThread());
+ JNIEnv* env = AttachCurrentThread();
+ CHECK(env);
+ ScopedJavaLocalRef<jobject> surface(
+ Java_DialogSurfaceWrapper_getSurface(env, j_wrapped_surface_.obj()));
+ if (surface.obj() == nullptr)
+ return gl::ScopedJavaSurface();
+
+ return gl::ScopedJavaSurface::AcquireExternalSurface(surface.obj());
+}
+
+bool DialogSurface::CalledOnValidThread() const {
+ return thread_checker_.CalledOnValidThread();
+}
+
+bool DialogSurface::RegisterDialogSurface(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace media
« no previous file with comments | « media/base/android/dialog_surface.h ('k') | media/base/android/dialog_surface_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698