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

Side by Side Diff: media/base/android/dialog_surface.cc

Issue 2178973004: DialogSurfaceManager implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed IDialogSurfaceActivityMapper from common.aidl Created 4 years 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.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"
boliu 2017/01/04 01:48:43 there is somewhat of a tradition to call the nativ
liberato (no reviews please) 2017/01/11 22:17:56 i'll put out a separate PS with the renaming per o
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::JavaRef;
32 using base::android::ScopedJavaLocalRef;
33
34 namespace media {
35
36 DialogSurface::DialogSurface(
37 const JavaRef<jobject>& unwrapped_holder,
38 std::unique_ptr<DialogSurfaceCallback> wrapped_callback)
39 : wrapped_callback_(std::move(wrapped_callback)) {
40 JNIEnv* env = AttachCurrentThread();
41 CHECK(env);
boliu 2017/01/04 01:48:43 there aren't a lot of CHECK(env), or even DCHECKs
liberato (no reviews please) 2017/01/11 22:17:56 Done, and elsewhere.
42
43 // Set the callback that we'll use to get the java surface.
44 wrapped_callback_->SetAndroidSurfaceCB(
45 base::Bind(&DialogSurface::OnAndroidSurface, base::Unretained(this)));
46
47 j_wrapped_surface_.Reset(
48 env, Java_DialogSurfaceWrapper_wrap(env, unwrapped_holder.obj()).obj());
boliu 2017/01/04 01:48:43 are either .obj() here necessary? I'd hope everyth
liberato (no reviews please) 2017/01/11 22:17:56 turns out that the outer one is required, but the
49 }
50
51 DialogSurface::~DialogSurface() {
52 DCHECK(thread_checker_.CalledOnValidThread());
53
54 wrapped_callback_->SetAndroidSurfaceCB(
55 DialogSurfaceCallback::AndroidSurfaceCB());
56
57 JNIEnv* env = AttachCurrentThread();
58 CHECK(env);
59 if (j_wrapped_surface_.obj())
60 Java_DialogSurfaceWrapper_release(env, j_wrapped_surface_.obj());
61 }
62
63 void DialogSurface::ScheduleLayout(const Config& config) {
64 DCHECK(CalledOnValidThread());
65 JNIEnv* env = AttachCurrentThread();
66 CHECK(env);
67 Java_DialogSurfaceWrapper_scheduleLayoutSurface(
68 env, j_wrapped_surface_.obj(), config.rect.x(), config.rect.y(),
69 config.rect.width(), config.rect.height());
70 }
71
72 bool DialogSurface::CalledOnValidThread() const {
73 return thread_checker_.CalledOnValidThread();
74 }
75
76 void DialogSurface::OnAndroidSurface(
77 const base::android::JavaRef<jobject>& jsurface) {
78 android_surface_ =
boliu 2017/01/04 01:48:43 thread check here?
liberato (no reviews please) 2017/01/11 22:17:56 Done.
79 gl::ScopedJavaSurface::AcquireExternalSurface(jsurface.obj());
80 }
81
82 gl::ScopedJavaSurface& DialogSurface::GetAndroidSurface() {
83 return android_surface_;
84 }
85
86 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698