Chromium Code Reviews| 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 |
|
watk
2017/02/17 22:40:36
The contract about what to do when SurfaceDestroye
liberato (no reviews please)
2017/03/07 21:30:25
Done.
|
| +// 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()>; |
|
watk
2017/02/17 22:40:36
Use the conventional "cb": ReadyCb?
liberato (no reviews please)
2017/03/07 21:30:25
done, though i used "CB" since it seems more commo
|
| + |
| + // 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. |
|
watk
2017/02/17 22:40:36
TODO doesn't seem necessary because we'll add thin
liberato (no reviews please)
2017/03/07 21:30:25
on a CL a while ago, an objection was raised that
|
| + |
| + ReadyCallback ready_cb; |
| + DestroyedCallback destroyed_cb; |
| + }; |
| + |
| + virtual ~AndroidOverlay(); |
| + |
| + // Schedule a relayout of this overlay. If called before the client is |
|
watk
2017/02/17 22:40:36
nit: here and elsewhere comments style is not in l
liberato (no reviews please)
2017/03/07 21:30:25
nit++ :) Done.
|
| + // 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. |
|
watk
2017/02/17 22:40:36
nit: Don't think it needs a comment
liberato (no reviews please)
2017/03/07 21:30:25
i agree that it adds no value as written. changed
|
| + 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); |
|
watk
2017/02/17 22:40:36
Doesn't seem necessary if subclasses can set surfa
liberato (no reviews please)
2017/03/07 21:30:25
true. i'll just make j_surface() abstract and mak
|
| + |
| + gl::ScopedJavaSurface surface_; |
| + DISALLOW_COPY_AND_ASSIGN(AndroidOverlay); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_BASE_ANDROID_ANDROID_OVERLAY_H_ |