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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/base/android/dialog_surface_controller.h"
6
7 #include <algorithm>
8 #include <limits>
9 #include <map>
10 #include <memory>
11 #include <utility>
12
13 #include "base/android/build_info.h"
14 #include "base/android/jni_android.h"
15 #include "base/android/jni_array.h"
16 #include "base/android/jni_string.h"
17 #include "base/lazy_instance.h"
18 #include "base/logging.h"
19 #include "base/numerics/safe_conversions.h"
20 #include "base/strings/string_util.h"
21 #include "base/synchronization/lock.h"
22 #include "base/synchronization/waitable_event.h"
23 #include "jni/DialogSurfaceControllerWrapper_jni.h"
24 #include "media/base/android/dialog_surface_callback.h"
25 #include "media/base/android/dialog_surface_manager.h"
26 #include "media/base/bind_to_current_loop.h"
27 #include "media/base/bit_reader.h"
28 #include "media/base/decrypt_config.h"
29
30 using base::android::AttachCurrentThread;
31 using base::android::ConvertJavaStringToUTF8;
32 using base::android::ConvertUTF8ToJavaString;
33 using base::android::JavaIntArrayToIntVector;
34 using base::android::JavaRef;
35 using base::android::ScopedJavaLocalRef;
36
37 namespace media {
38
39 DialogSurfaceController::DialogSurfaceController(
40 const JavaRef<jobject>& unwrapped_controller,
41 std::unique_ptr<DialogSurfaceCallback>&& wrapped_callback)
42 : wrapped_callback_(std::move(wrapped_callback)) {
43 JNIEnv* env = AttachCurrentThread();
44 CHECK(env);
45 j_wrapped_controller_.Reset(env, Java_DialogSurfaceControllerWrapper_wrap(
46 env, unwrapped_controller.obj())
47 .obj());
48 }
49
50 DialogSurfaceController::~DialogSurfaceController() {
51 DCHECK(thread_checker_.CalledOnValidThread());
52
53 JNIEnv* env = AttachCurrentThread();
54 CHECK(env);
55 if (j_wrapped_controller_.obj())
56 Java_DialogSurfaceControllerWrapper_release(env,
57 j_wrapped_controller_.obj());
58 }
59
60 void DialogSurfaceController::ScheduleLayout(const Config& config) {
61 DCHECK(CalledOnValidThread());
62 JNIEnv* env = AttachCurrentThread();
63 CHECK(env);
64 Java_DialogSurfaceControllerWrapper_scheduleLayoutSurface(
65 env, j_wrapped_controller_.obj(), config.position.x(),
66 config.position.y(), config.size.width(), config.size.height());
67 }
68
69 gl::ScopedJavaSurface DialogSurfaceController::GetSurface() {
70 DCHECK(CalledOnValidThread());
71 // TODO(liberato): should we tell ScopedJavaSurface not to release the
72 // surface when it is destroyed? i think so.
73 JNIEnv* env = AttachCurrentThread();
74 CHECK(env);
75 ScopedJavaLocalRef<jobject> surface(
76 Java_DialogSurfaceControllerWrapper_getSurface(
77 env, j_wrapped_controller_.obj()));
78 if (surface.obj() == nullptr)
79 return gl::ScopedJavaSurface();
80
81 // TODO(liberato): does this work if the surface is null?
82 return gl::ScopedJavaSurface::AcquireExternalSurface(surface.obj());
83 }
84
85 bool DialogSurfaceController::CalledOnValidThread() const {
86 return thread_checker_.CalledOnValidThread();
87 }
88
89 bool DialogSurfaceController::RegisterDialogSurfaceController(JNIEnv* env) {
90 return RegisterNativesImpl(env);
91 }
92
93 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698