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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/base/android/android_overlay.h
diff --git a/media/base/android/android_overlay.h b/media/base/android/android_overlay.h
new file mode 100644
index 0000000000000000000000000000000000000000..1b67c4c85d224a7fda289558bfae35040758b0b1
--- /dev/null
+++ b/media/base/android/android_overlay.h
@@ -0,0 +1,72 @@
+// Copyright 2017 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.
+
+#ifndef MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_
+#define MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_
+
+#include "base/android/scoped_java_ref.h"
+#include "base/callback.h"
+#include "base/macros.h"
+#include "media/base/media_export.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gl/android/scoped_java_surface.h"
+
+namespace media {
+
+// Client interface to an AndroidOverlay. Once constructed, you can expect to
+// receive zero or one ReadyCallbacks, and one DestroyedCallback.
+// Upon receiving ReadyCallback, you will have an Android Surface that you may
+// use until DestroyedCallback. You may also move the surface (ScheduleLayout).
+// When SurfaceDestroyed arrives, you should stop using the Android Surface and
+// delete the AndroidOverlay instance. Note that these calls are synchronous
+// in Android, so you should delete the AndroidOverlay surface as soon as
+// possible. Other overlays might be blocked waiting.
+class MEDIA_EXPORT AndroidOverlay {
+ public:
+ // Called when the overlay is ready for use. Use |j_surface()| to get it.
+ using ReadyCallback = base::Callback<void()>;
+
+ // Called when the overlay has been destroyed. This may be called before
+ // ReadyCallback. It will be the last callback for the overlay.
+ using DestroyedCallback = base::Callback<void()>;
+
+ // Configuration used to create an overlay.
+ struct Config {
+ public:
+ Config();
+ Config(const Config&);
+ ~Config();
+
+ gfx::Rect rect;
+ // TODO(liberato): add format, etc. here.
+
+ ReadyCallback ready_cb;
+ DestroyedCallback destroyed_cb;
+ };
+
+ virtual ~AndroidOverlay();
+
+ // Schedule a relayout of this overlay. If called before the client is
+ // notified that the surface is created, then the call will be ignored.
+ virtual void ScheduleLayout(const gfx::Rect& rect) = 0;
+
+ // Return the Java Surface object.
+ const base::android::JavaRef<jobject>& j_surface() const {
+ return surface_.j_surface();
+ }
+
+ protected:
+ AndroidOverlay();
+
+ // Set the java surface that we'll provide. Subclasses should provide this
+ // before sending ReadyCallback.
+ void SetJavaSurface(gl::ScopedJavaSurface);
+
+ gl::ScopedJavaSurface surface_;
+ DISALLOW_COPY_AND_ASSIGN(AndroidOverlay);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_

Powered by Google App Engine
This is Rietveld 408576698