summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/android/native_window_jni.h11
-rw-r--r--include/gui/ISurfaceComposerClient.h78
-rw-r--r--include/gui/Surface.h18
-rw-r--r--include/gui/SurfaceComposerClient.h3
-rw-r--r--include/gui/SurfaceControl.h2
5 files changed, 63 insertions, 49 deletions
diff --git a/include/android/native_window_jni.h b/include/android/native_window_jni.h
index 1ec2a67c3d..23b39aa41f 100644
--- a/include/android/native_window_jni.h
+++ b/include/android/native_window_jni.h
@@ -54,6 +54,17 @@ ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface);
ANativeWindow* ANativeWindow_fromSurfaceTexture(JNIEnv* env, jobject surfaceTexture);
#endif
+#if __ANDROID_API__ >= 26
+/**
+ * Return a Java Surface object derived from the ANativeWindow, for interacting
+ * with it through Java code. The returned Java object acquires a reference on
+ * the ANativeWindow; maintains it through general Java object's life cycle;
+ * and will automatically release the reference when the Java object gets garbage
+ * collected.
+ */
+jobject ANativeWindow_toSurface(JNIEnv* env, ANativeWindow* window);
+#endif
+
#ifdef __cplusplus
};
#endif
diff --git a/include/gui/ISurfaceComposerClient.h b/include/gui/ISurfaceComposerClient.h
index 1f4387d7c2..a680bc67c4 100644
--- a/include/gui/ISurfaceComposerClient.h
+++ b/include/gui/ISurfaceComposerClient.h
@@ -14,55 +14,52 @@
* limitations under the License.
*/
-#ifndef ANDROID_GUI_ISURFACE_COMPOSER_CLIENT_H
-#define ANDROID_GUI_ISURFACE_COMPOSER_CLIENT_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <utils/RefBase.h>
+#pragma once
#include <binder/IInterface.h>
-
-#include <ui/FrameStats.h>
+#include <binder/SafeInterface.h>
#include <ui/PixelFormat.h>
namespace android {
-// ----------------------------------------------------------------------------
+class FrameStats;
class IGraphicBufferProducer;
-class ISurfaceComposerClient : public IInterface
-{
+class ISurfaceComposerClient : public IInterface {
public:
DECLARE_META_INTERFACE(SurfaceComposerClient)
+ enum class Tag : uint32_t {
+ CreateSurface = IBinder::FIRST_CALL_TRANSACTION,
+ DestroySurface,
+ ClearLayerFrameStats,
+ GetLayerFrameStats,
+ Last,
+ };
+
// flags for createSurface()
enum { // (keep in sync with Surface.java)
- eHidden = 0x00000004,
- eDestroyBackbuffer = 0x00000020,
- eSecure = 0x00000080,
- eNonPremultiplied = 0x00000100,
- eOpaque = 0x00000400,
- eProtectedByApp = 0x00000800,
- eProtectedByDRM = 0x00001000,
- eCursorWindow = 0x00002000,
-
- eFXSurfaceNormal = 0x00000000,
- eFXSurfaceDim = 0x00020000,
- eFXSurfaceMask = 0x000F0000,
+ eHidden = 0x00000004,
+ eDestroyBackbuffer = 0x00000020,
+ eSecure = 0x00000080,
+ eNonPremultiplied = 0x00000100,
+ eOpaque = 0x00000400,
+ eProtectedByApp = 0x00000800,
+ eProtectedByDRM = 0x00001000,
+ eCursorWindow = 0x00002000,
+
+ eFXSurfaceNormal = 0x00000000,
+ eFXSurfaceDim = 0x00020000,
+ eFXSurfaceMask = 0x000F0000,
};
/*
* Requires ACCESS_SURFACE_FLINGER permission
*/
- virtual status_t createSurface(
- const String8& name, uint32_t w, uint32_t h,
- PixelFormat format, uint32_t flags,
- const sp<IBinder>& parent, uint32_t windowType, uint32_t ownerUid,
- sp<IBinder>* handle,
- sp<IGraphicBufferProducer>* gbp) = 0;
+ virtual status_t createSurface(const String8& name, uint32_t w, uint32_t h, PixelFormat format,
+ uint32_t flags, const sp<IBinder>& parent, uint32_t windowType,
+ uint32_t ownerUid, sp<IBinder>* handle,
+ sp<IGraphicBufferProducer>* gbp) = 0;
/*
* Requires ACCESS_SURFACE_FLINGER permission
@@ -78,21 +75,14 @@ public:
* Requires ACCESS_SURFACE_FLINGER permission
*/
virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const = 0;
-
- virtual status_t getTransformToDisplayInverse(const sp<IBinder>& handle,
- bool* outTransformToDisplayInverse) const = 0;
};
-// ----------------------------------------------------------------------------
-
-class BnSurfaceComposerClient: public BnInterface<ISurfaceComposerClient> {
+class BnSurfaceComposerClient : public SafeBnInterface<ISurfaceComposerClient> {
public:
- virtual status_t onTransact(uint32_t code, const Parcel& data,
- Parcel* reply, uint32_t flags = 0);
-};
+ BnSurfaceComposerClient()
+ : SafeBnInterface<ISurfaceComposerClient>("BnSurfaceComposerClient") {}
-// ----------------------------------------------------------------------------
-
-}; // namespace android
+ status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) override;
+};
-#endif // ANDROID_GUI_ISURFACE_COMPOSER_CLIENT_H
+} // namespace android
diff --git a/include/gui/Surface.h b/include/gui/Surface.h
index 62f6cadece..88ef010368 100644
--- a/include/gui/Surface.h
+++ b/include/gui/Surface.h
@@ -257,10 +257,25 @@ public:
virtual int query(int what, int* value) const;
virtual int connect(int api, const sp<IProducerListener>& listener);
+
+ // When reportBufferRemoval is true, clients must call getAndFlushRemovedBuffers to fetch
+ // GraphicBuffers removed from this surface after a dequeueBuffer, detachNextBuffer or
+ // attachBuffer call. This allows clients with their own buffer caches to free up buffers no
+ // longer in use by this surface.
+ virtual int connect(
+ int api, const sp<IProducerListener>& listener,
+ bool reportBufferRemoval);
virtual int detachNextBuffer(sp<GraphicBuffer>* outBuffer,
sp<Fence>* outFence);
virtual int attachBuffer(ANativeWindowBuffer*);
+ // When client connects to Surface with reportBufferRemoval set to true, any buffers removed
+ // from this Surface will be collected and returned here. Once this method returns, these
+ // buffers will no longer be referenced by this Surface unless they are attached to this
+ // Surface later. The list of removed buffers will only be stored until the next dequeueBuffer,
+ // detachNextBuffer, or attachBuffer call.
+ status_t getAndFlushRemovedBuffers(std::vector<sp<GraphicBuffer>>* out);
+
protected:
enum { NUM_BUFFER_SLOTS = BufferQueueDefs::NUM_BUFFER_SLOTS };
enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
@@ -414,6 +429,9 @@ protected:
// A cached copy of the FrameEventHistory maintained by the consumer.
bool mEnableFrameTimestamps = false;
std::unique_ptr<ProducerFrameEventHistory> mFrameEventHistory;
+
+ bool mReportRemovedBuffers = false;
+ std::vector<sp<GraphicBuffer>> mRemovedBuffers;
};
} // namespace android
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index 1e8cf76627..394425a328 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -169,9 +169,6 @@ public:
status_t clearLayerFrameStats(const sp<IBinder>& token) const;
status_t getLayerFrameStats(const sp<IBinder>& token, FrameStats* outStats) const;
- status_t getTransformToDisplayInverse(const sp<IBinder>& token,
- bool* outTransformToDisplayInverse) const;
-
static status_t clearAnimationFrameStats();
static status_t getAnimationFrameStats(FrameStats* outStats);
diff --git a/include/gui/SurfaceControl.h b/include/gui/SurfaceControl.h
index 8ee35bc495..3cff7df260 100644
--- a/include/gui/SurfaceControl.h
+++ b/include/gui/SurfaceControl.h
@@ -119,8 +119,6 @@ public:
status_t clearLayerFrameStats() const;
status_t getLayerFrameStats(FrameStats* outStats) const;
- status_t getTransformToDisplayInverse(bool* outTransformToDisplayInverse) const;
-
private:
// can't be copied
SurfaceControl& operator = (SurfaceControl& rhs);