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

Side by Side Diff: media/base/android/android_overlay.h

Issue 2688193002: Mojo framework for AndroidOverlay. (Closed)
Patch Set: cl comments, refactored MojoAndroidOverlay to inherit from mojom:... Created 3 years, 10 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 2017 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 #ifndef MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_
6 #define MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_
7
8 #include "base/android/scoped_java_ref.h"
9 #include "base/callback.h"
10 #include "base/macros.h"
11 #include "media/base/media_export.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gl/android/scoped_java_surface.h"
14
15 namespace media {
16
17 // Client interface to an AndroidOverlay. Once constructed, you can expect to
18 // receive zero or one ReadyCallbacks, and one DestroyedCallback.
19 // Upon receiving ReadyCallback, you will have an Android Surface that you may
20 // use until DestroyedCallback. You may also move the surface (ScheduleLayout).
21 // When SurfaceDestroyed arrives, you should stop using the Android Surface and
22 // delete the AndroidOverlay instance. Note that these calls are synchronous
23 // in Android, so you should delete the AndroidOverlay surface as soon as
24 // possible. Other overlays might be blocked waiting.
25 class MEDIA_EXPORT AndroidOverlay {
26 public:
27 // Called when the overlay is ready for use. Use |j_surface()| to get it.
28 using ReadyCallback = base::Callback<void()>;
29
30 // Called when the overlay has been destroyed. This may be called before
31 // ReadyCallback. It will be the last callback for the overlay.
32 using DestroyedCallback = base::Callback<void()>;
33
34 // Configuration used to create an overlay.
35 struct Config {
36 public:
37 Config();
38 Config(const Config&);
39 ~Config();
40
41 gfx::Rect rect;
42 // TODO(liberato): add format, etc. here.
43
44 ReadyCallback ready_cb;
45 DestroyedCallback destroyed_cb;
46 };
47
48 virtual ~AndroidOverlay();
49
50 // Schedule a relayout of this overlay. If called before the client is
51 // notified that the surface is created, then the call will be ignored.
52 virtual void ScheduleLayout(const gfx::Rect& rect) = 0;
53
54 // Return the Java Surface object.
55 const base::android::JavaRef<jobject>& j_surface() const {
56 return surface_.j_surface();
57 }
58
59 protected:
60 AndroidOverlay();
61
62 // Set the java surface that we'll provide. Subclasses should provide this
63 // before sending ReadyCallback.
64 void SetJavaSurface(gl::ScopedJavaSurface);
65
66 gl::ScopedJavaSurface surface_;
67 DISALLOW_COPY_AND_ASSIGN(AndroidOverlay);
68 };
69
70 } // namespace media
71
72 #endif // MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698