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

Side by Side 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, 4 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.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/DialogSurfaceWrapper_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 DialogSurface::DialogSurface(
40 const JavaRef<jobject>& unwrapped_surface,
41 std::unique_ptr<DialogSurfaceCallback>&& wrapped_callback)
42 : wrapped_callback_(std::move(wrapped_callback)) {
43 JNIEnv* env = AttachCurrentThread();
44 CHECK(env);
45 j_wrapped_surface_.Reset(
46 env, Java_DialogSurfaceWrapper_wrap(env, unwrapped_surface.obj()).obj());
47 }
48
49 DialogSurface::~DialogSurface() {
50 DCHECK(thread_checker_.CalledOnValidThread());
51
52 JNIEnv* env = AttachCurrentThread();
53 CHECK(env);
54 if (j_wrapped_surface_.obj())
55 Java_DialogSurfaceWrapper_release(env, j_wrapped_surface_.obj());
56 }
57
58 void DialogSurface::ScheduleLayout(const Config& config) {
59 DCHECK(CalledOnValidThread());
60 JNIEnv* env = AttachCurrentThread();
61 CHECK(env);
62 Java_DialogSurfaceWrapper_scheduleLayoutSurface(
63 env, j_wrapped_surface_.obj(), config.position.x(), config.position.y(),
64 config.size.width(), config.size.height());
65 }
66
67 gl::ScopedJavaSurface DialogSurface::GetSurface() {
68 DCHECK(CalledOnValidThread());
69 JNIEnv* env = AttachCurrentThread();
70 CHECK(env);
71 ScopedJavaLocalRef<jobject> surface(
72 Java_DialogSurfaceWrapper_getSurface(env, j_wrapped_surface_.obj()));
73 if (surface.obj() == nullptr)
74 return gl::ScopedJavaSurface();
75
76 return gl::ScopedJavaSurface::AcquireExternalSurface(surface.obj());
77 }
78
79 bool DialogSurface::CalledOnValidThread() const {
80 return thread_checker_.CalledOnValidThread();
81 }
82
83 bool DialogSurface::RegisterDialogSurface(JNIEnv* env) {
84 return RegisterNativesImpl(env);
85 }
86
87 } // namespace media
OLDNEW
« 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