Loading include/android/surface_control.h +67 −41 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ typedef struct ASurfaceControl ASurfaceControl; /** * Creates an ASurfaceControl with either ANativeWindow or an ASurfaceControl as its parent. * |debug_name| is a debug name associated with this surface. It can be used to * \a debug_name is a debug name associated with this surface. It can be used to * identify this surface in the SurfaceFlinger's layer tree. It must not be * null. * Loading @@ -69,7 +69,7 @@ ASurfaceControl* ASurfaceControl_create(ASurfaceControl* parent, const char* deb __INTRODUCED_IN(29); /** * Releases the |surface_control| object. After releasing the ASurfaceControl the caller no longer * Releases the \a surface_control object. After releasing the ASurfaceControl the caller no longer * has ownership of the AsurfaceControl. The surface and it's children may remain on display as long * as their parent remains on display. * Loading @@ -87,21 +87,21 @@ typedef struct ASurfaceTransaction ASurfaceTransaction; /** * The caller takes ownership of the transaction and must release it using * ASurfaceControl_delete below. * ASurfaceTransaction_delete() below. * * Available since API level 29. */ ASurfaceTransaction* ASurfaceTransaction_create() __INTRODUCED_IN(29); /** * Destroys the |transaction| object. * Destroys the \a transaction object. * * Available since API level 29. */ void ASurfaceTransaction_delete(ASurfaceTransaction* transaction) __INTRODUCED_IN(29); /** * Applies the updates accumulated in |transaction|. * Applies the updates accumulated in \a transaction. * * Note that the transaction is guaranteed to be applied atomically. The * transactions which are applied on the same thread are also guaranteed to be Loading @@ -123,10 +123,10 @@ typedef struct ASurfaceTransactionStats ASurfaceTransactionStats; * ASurfaceTransaction_OnComplete callback can be used to be notified when a frame * including the updates in a transaction was presented. * * |context| is the optional context provided by the client that is passed into * \param context Optional context provided by the client that is passed into * the callback. * * |stats| is an opaque handle that can be passed to ASurfaceTransactionStats functions to query * \param stats Opaque handle that can be passed to ASurfaceTransactionStats functions to query * information about the transaction. The handle is only valid during the callback. * * THREADING Loading Loading @@ -157,14 +157,14 @@ int ASurfaceTransactionStats_getPresentFenceFd(ASurfaceTransactionStats* surface __INTRODUCED_IN(29); /** * |outASurfaceControls| returns an array of ASurfaceControl pointers that were updated during the * \a outASurfaceControls returns an array of ASurfaceControl pointers that were updated during the * transaction. Stats for the surfaces can be queried through ASurfaceTransactionStats functions. * When the client is done using the array, it must release it by calling * ASurfaceTransactionStats_releaseASurfaceControls. * * Available since API level 29. * * |outASurfaceControlsSize| returns the size of the ASurfaceControls array. * \a outASurfaceControlsSize returns the size of the ASurfaceControls array. */ void ASurfaceTransactionStats_getASurfaceControls(ASurfaceTransactionStats* surface_transaction_stats, ASurfaceControl*** outASurfaceControls, Loading @@ -172,7 +172,7 @@ void ASurfaceTransactionStats_getASurfaceControls(ASurfaceTransactionStats* surf __INTRODUCED_IN(29); /** * Releases the array of ASurfaceControls that were returned by * ASurfaceTransactionStats_getASurfaceControls. * ASurfaceTransactionStats_getASurfaceControls(). * * Available since API level 29. */ Loading @@ -197,8 +197,8 @@ int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* surfac * buffer is already released. The recipient of the callback takes ownership of the * previousReleaseFenceFd and is responsible for closing it. * * Each time a buffer is set through ASurfaceTransaction_setBuffer()/_setCachedBuffer() on a * transaction which is applied, the framework takes a ref on this buffer. The framework treats the * Each time a buffer is set through ASurfaceTransaction_setBuffer() on a transaction * which is applied, the framework takes a ref on this buffer. The framework treats the * addition of a buffer to a particular surface as a unique ref. When a transaction updates or * removes a buffer from a surface, or removes the surface itself from the tree, this ref is * guaranteed to be released in the OnComplete callback for this transaction. The Loading Loading @@ -226,10 +226,10 @@ void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* transaction, void* c ASurfaceTransaction_OnComplete func) __INTRODUCED_IN(29); /** * Reparents the |surface_control| from its old parent to the |new_parent| surface control. * Any children of the* reparented |surface_control| will remain children of the |surface_control|. * Reparents the \a surface_control from its old parent to the \a new_parent surface control. * Any children of the reparented \a surface_control will remain children of the \a surface_control. * * The |new_parent| can be null. Surface controls with a null parent do not appear on the display. * The \a new_parent can be null. Surface controls with a null parent do not appear on the display. * * Available since API level 29. */ Loading @@ -237,14 +237,16 @@ void ASurfaceTransaction_reparent(ASurfaceTransaction* transaction, ASurfaceControl* surface_control, ASurfaceControl* new_parent) __INTRODUCED_IN(29); /* Parameter for ASurfaceTransaction_setVisibility */ /** * Parameter for ASurfaceTransaction_setVisibility(). */ enum { ASURFACE_TRANSACTION_VISIBILITY_HIDE = 0, ASURFACE_TRANSACTION_VISIBILITY_SHOW = 1, }; /** * Updates the visibility of |surface_control|. If show is set to * ASURFACE_TRANSACTION_VISIBILITY_HIDE, the |surface_control| and all surfaces in its subtree will * Updates the visibility of \a surface_control. If show is set to * ASURFACE_TRANSACTION_VISIBILITY_HIDE, the \a surface_control and all surfaces in its subtree will * be hidden. * * Available since API level 29. Loading @@ -254,7 +256,7 @@ void ASurfaceTransaction_setVisibility(ASurfaceTransaction* transaction, __INTRODUCED_IN(29); /** * Updates the z order index for |surface_control|. Note that the z order for a surface * Updates the z order index for \a surface_control. Note that the z order for a surface * is relative to other surfaces which are siblings of this surface. The behavior of sibilings with * the same z order is undefined. * Loading @@ -267,11 +269,11 @@ void ASurfaceTransaction_setZOrder(ASurfaceTransaction* transaction, __INTRODUCED_IN(29); /** * Updates the AHardwareBuffer displayed for |surface_control|. If not -1, the * Updates the AHardwareBuffer displayed for \a surface_control. If not -1, the * acquire_fence_fd should be a file descriptor that is signaled when all pending work * for the buffer is complete and the buffer can be safely read. * * The frameworks takes ownership of the |acquire_fence_fd| passed and is responsible * The frameworks takes ownership of the \a acquire_fence_fd passed and is responsible * for closing it. * * Available since API level 29. Loading @@ -281,9 +283,9 @@ void ASurfaceTransaction_setBuffer(ASurfaceTransaction* transaction, int acquire_fence_fd = -1) __INTRODUCED_IN(29); /** * Updates the color for |surface_control|. This will make the background color for the * ASurfaceControl visible in transparent regions of the surface. Colors |r|, |g|, * and |b| must be within the range that is valid for |dataspace|. |dataspace| and |alpha| * Updates the color for \a surface_control. This will make the background color for the * ASurfaceControl visible in transparent regions of the surface. Colors \a r, \a g, * and \a b must be within the range that is valid for \a dataspace. \a dataspace and \a alpha * will be the dataspace and alpha set for the background color layer. * * Available since API level 29. Loading @@ -294,15 +296,15 @@ void ASurfaceTransaction_setColor(ASurfaceTransaction* transaction, __INTRODUCED_IN(29); /** * |source| the sub-rect within the buffer's content to be rendered inside the surface's area * \param source The sub-rect within the buffer's content to be rendered inside the surface's area * The surface's source rect is clipped by the bounds of its current buffer. The source rect's width * and height must be > 0. * * |destination| specifies the rect in the parent's space where this surface will be drawn. The post * \param destination Specifies the rect in the parent's space where this surface will be drawn. The post * source rect bounds are scaled to fit the destination rect. The surface's destination rect is * clipped by the bounds of its parent. The destination rect's width and height must be > 0. * * |transform| the transform applied after the source rect is applied to the buffer. This parameter * \param transform The transform applied after the source rect is applied to the buffer. This parameter * should be set to 0 for no transform. To specify a transfrom use the NATIVE_WINDOW_TRANSFORM_* * enum. * Loading @@ -314,7 +316,9 @@ void ASurfaceTransaction_setGeometry(ASurfaceTransaction* transaction, __INTRODUCED_IN(29); /* Parameter for ASurfaceTransaction_setBufferTransparency */ /** * Parameter for ASurfaceTransaction_setBufferTransparency(). */ enum { ASURFACE_TRANSACTION_TRANSPARENCY_TRANSPARENT = 0, ASURFACE_TRANSACTION_TRANSPARENCY_TRANSLUCENT = 1, Loading Loading @@ -360,7 +364,7 @@ void ASurfaceTransaction_setDesiredPresentTime(ASurfaceTransaction* transaction, /** * Sets the alpha for the buffer. It uses a premultiplied blending. * * The |alpha| must be between 0.0 and 1.0. * The \a alpha must be between 0.0 and 1.0. * * Available since API level 29. */ Loading @@ -379,10 +383,10 @@ void ASurfaceTransaction_setBufferDataSpace(ASurfaceTransaction* transaction, ASurfaceControl* surface_control, ADataSpace data_space) __INTRODUCED_IN(29); /* /** * SMPTE ST 2086 "Mastering Display Color Volume" static metadata * * When |metadata| is set to null, the framework does not use any smpte2086 metadata when rendering * When \a metadata is set to null, the framework does not use any smpte2086 metadata when rendering * the surface's buffer. * * Available since API level 29. Loading @@ -392,10 +396,10 @@ void ASurfaceTransaction_setHdrMetadata_smpte2086(ASurfaceTransaction* transacti struct AHdrMetadata_smpte2086* metadata) __INTRODUCED_IN(29); /* /** * Sets the CTA 861.3 "HDR Static Metadata Extension" static metadata on a surface. * * When |metadata| is set to null, the framework does not use any cta861.3 metadata when rendering * When \a metadata is set to null, the framework does not use any cta861.3 metadata when rendering * the surface's buffer. * * Available since API level 29. Loading @@ -410,7 +414,23 @@ void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* transactio #if __ANDROID_API__ >= 30 /** * Sets the intended frame rate for |surface_control|. * Same as ASurfaceTransaction_setFrameRateWithSeamlessness(transaction, surface_control, * frameRate, compatibility, true). * * See ASurfaceTransaction_setFrameRateWithSeamlessness(). * * Available since API level 30. */ void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* transaction, ASurfaceControl* surface_control, float frameRate, int8_t compatibility) __INTRODUCED_IN(30); #endif // __ANDROID_API__ >= 30 #if __ANDROID_API__ >= 31 /** * Sets the intended frame rate for \a surface_control. * * On devices that are capable of running the display at different refresh rates, the system may * choose a display refresh rate to better match this surface's frame rate. Usage of this API won't Loading @@ -419,24 +439,30 @@ void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* transactio * callback timings, and changes to the time interval at which the system releases buffers back to * the application. * * |frameRate| is the intended frame rate of this surface, in frames per second. 0 is a special * \param frameRate is the intended frame rate of this surface, in frames per second. 0 is a special * value that indicates the app will accept the system's choice for the display frame rate, which is * the default behavior if this function isn't called. The frameRate param does <em>not</em> need to * be a valid refresh rate for this device's display - e.g., it's fine to pass 30fps to a device * that can only run the display at 60fps. * * |compatibility| The frame rate compatibility of this surface. The compatibility value may * \param compatibility The frame rate compatibility of this surface. The compatibility value may * influence the system's choice of display frame rate. To specify a compatibility use the * ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* enum. * * Available since API level 30. * \param shouldBeSeamless Whether display refresh rate transitions should be seamless. A * seamless transition is one that doesn't have any visual interruptions, such as a black * screen for a second or two. True indicates that any frame rate changes caused by this * request should be seamless. False indicates that non-seamless refresh rates are also * acceptable. * * Available since API level 31. */ void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* transaction, void ASurfaceTransaction_setFrameRateWithSeamlessness(ASurfaceTransaction* transaction, ASurfaceControl* surface_control, float frameRate, int8_t compatibility) __INTRODUCED_IN(30); #endif // __ANDROID_API__ >= 30 int8_t compatibility, bool shouldBeSeamless) __INTRODUCED_IN(31); #endif // __ANDROID_API__ >= 31 __END_DECLS #endif // ANDROID_SURFACE_CONTROL_H libs/gui/BLASTBufferQueue.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -378,11 +378,11 @@ public: }).detach(); } status_t setFrameRate(float frameRate, int8_t compatibility) override { status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless) override { if (!ValidateFrameRate(frameRate, compatibility, "BBQSurface::setFrameRate")) { return BAD_VALUE; } return mBbq->setFrameRate(frameRate, compatibility); return mBbq->setFrameRate(frameRate, compatibility, shouldBeSeamless); } status_t setFrameTimelineVsync(int64_t frameTimelineVsyncId) override { Loading @@ -392,12 +392,12 @@ public: // TODO: Can we coalesce this with frame updates? Need to confirm // no timing issues. status_t BLASTBufferQueue::setFrameRate(float frameRate, int8_t compatibility) { status_t BLASTBufferQueue::setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless) { std::unique_lock _lock{mMutex}; SurfaceComposerClient::Transaction t; return t.setFrameRate(mSurfaceControl, frameRate, compatibility) .apply(); return t.setFrameRate(mSurfaceControl, frameRate, compatibility, shouldBeSeamless).apply(); } status_t BLASTBufferQueue::setFrameTimelineVsync(int64_t frameTimelineVsyncId) { Loading libs/gui/ISurfaceComposer.cpp +14 −2 Original line number Diff line number Diff line Loading @@ -1114,7 +1114,7 @@ public: } virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate, int8_t compatibility) { int8_t compatibility, bool shouldBeSeamless) { Parcel data, reply; status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); if (err != NO_ERROR) { Loading @@ -1140,6 +1140,12 @@ public: return err; } err = data.writeBool(shouldBeSeamless); if (err != NO_ERROR) { ALOGE("setFrameRate: failed writing bool: %s (%d)", strerror(-err), -err); return err; } err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply); if (err != NO_ERROR) { ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err); Loading Loading @@ -2033,7 +2039,13 @@ status_t BnSurfaceComposer::onTransact( ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err); return err; } status_t result = setFrameRate(surface, frameRate, compatibility); bool shouldBeSeamless; err = data.readBool(&shouldBeSeamless); if (err != NO_ERROR) { ALOGE("setFrameRate: failed to read bool: %s (%d)", strerror(-err), -err); return err; } status_t result = setFrameRate(surface, frameRate, compatibility, shouldBeSeamless); reply->writeInt32(result); return NO_ERROR; } Loading libs/gui/LayerState.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ layer_state_t::layer_state_t() frameRateSelectionPriority(-1), frameRate(0.0f), frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT), shouldBeSeamless(true), fixedTransformHint(ui::Transform::ROT_INVALID), frameNumber(0) { matrix.dsdx = matrix.dtdy = 1.0f; Loading Loading @@ -144,6 +145,7 @@ status_t layer_state_t::write(Parcel& output) const SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority); SAFE_PARCEL(output.writeFloat, frameRate); SAFE_PARCEL(output.writeByte, frameRateCompatibility); SAFE_PARCEL(output.writeBool, shouldBeSeamless); SAFE_PARCEL(output.writeUint32, fixedTransformHint); SAFE_PARCEL(output.writeUint64, frameNumber); SAFE_PARCEL(output.writeInt64, frameTimelineVsyncId); Loading Loading @@ -262,6 +264,7 @@ status_t layer_state_t::read(const Parcel& input) SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority); SAFE_PARCEL(input.readFloat, &frameRate); SAFE_PARCEL(input.readByte, &frameRateCompatibility); SAFE_PARCEL(input.readBool, &shouldBeSeamless); SAFE_PARCEL(input.readUint32, &tmpUint32); fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32); SAFE_PARCEL(input.readUint64, &frameNumber); Loading Loading @@ -521,6 +524,7 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eFrameRateChanged; frameRate = other.frameRate; frameRateCompatibility = other.frameRateCompatibility; shouldBeSeamless = other.shouldBeSeamless; } if (other.what & eFixedTransformHintChanged) { what |= eFixedTransformHintChanged; Loading libs/gui/Surface.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -1443,7 +1443,8 @@ int Surface::dispatchGetLastQueueDuration(va_list args) { int Surface::dispatchSetFrameRate(va_list args) { float frameRate = static_cast<float>(va_arg(args, double)); int8_t compatibility = static_cast<int8_t>(va_arg(args, int)); return setFrameRate(frameRate, compatibility); bool shouldBeSeamless = static_cast<bool>(va_arg(args, int)); return setFrameRate(frameRate, compatibility, shouldBeSeamless); } int Surface::dispatchAddCancelInterceptor(va_list args) { Loading Loading @@ -2279,7 +2280,7 @@ void Surface::ProducerListenerProxy::onBuffersDiscarded(const std::vector<int32_ mSurfaceListener->onBuffersDiscarded(discardedBufs); } status_t Surface::setFrameRate(float frameRate, int8_t compatibility) { status_t Surface::setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless) { ATRACE_CALL(); ALOGV("Surface::setFrameRate"); Loading @@ -2287,7 +2288,8 @@ status_t Surface::setFrameRate(float frameRate, int8_t compatibility) { return BAD_VALUE; } return composerService()->setFrameRate(mGraphicBufferProducer, frameRate, compatibility); return composerService()->setFrameRate(mGraphicBufferProducer, frameRate, compatibility, shouldBeSeamless); } status_t Surface::setFrameTimelineVsync(int64_t frameTimelineVsyncId) { Loading Loading
include/android/surface_control.h +67 −41 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ typedef struct ASurfaceControl ASurfaceControl; /** * Creates an ASurfaceControl with either ANativeWindow or an ASurfaceControl as its parent. * |debug_name| is a debug name associated with this surface. It can be used to * \a debug_name is a debug name associated with this surface. It can be used to * identify this surface in the SurfaceFlinger's layer tree. It must not be * null. * Loading @@ -69,7 +69,7 @@ ASurfaceControl* ASurfaceControl_create(ASurfaceControl* parent, const char* deb __INTRODUCED_IN(29); /** * Releases the |surface_control| object. After releasing the ASurfaceControl the caller no longer * Releases the \a surface_control object. After releasing the ASurfaceControl the caller no longer * has ownership of the AsurfaceControl. The surface and it's children may remain on display as long * as their parent remains on display. * Loading @@ -87,21 +87,21 @@ typedef struct ASurfaceTransaction ASurfaceTransaction; /** * The caller takes ownership of the transaction and must release it using * ASurfaceControl_delete below. * ASurfaceTransaction_delete() below. * * Available since API level 29. */ ASurfaceTransaction* ASurfaceTransaction_create() __INTRODUCED_IN(29); /** * Destroys the |transaction| object. * Destroys the \a transaction object. * * Available since API level 29. */ void ASurfaceTransaction_delete(ASurfaceTransaction* transaction) __INTRODUCED_IN(29); /** * Applies the updates accumulated in |transaction|. * Applies the updates accumulated in \a transaction. * * Note that the transaction is guaranteed to be applied atomically. The * transactions which are applied on the same thread are also guaranteed to be Loading @@ -123,10 +123,10 @@ typedef struct ASurfaceTransactionStats ASurfaceTransactionStats; * ASurfaceTransaction_OnComplete callback can be used to be notified when a frame * including the updates in a transaction was presented. * * |context| is the optional context provided by the client that is passed into * \param context Optional context provided by the client that is passed into * the callback. * * |stats| is an opaque handle that can be passed to ASurfaceTransactionStats functions to query * \param stats Opaque handle that can be passed to ASurfaceTransactionStats functions to query * information about the transaction. The handle is only valid during the callback. * * THREADING Loading Loading @@ -157,14 +157,14 @@ int ASurfaceTransactionStats_getPresentFenceFd(ASurfaceTransactionStats* surface __INTRODUCED_IN(29); /** * |outASurfaceControls| returns an array of ASurfaceControl pointers that were updated during the * \a outASurfaceControls returns an array of ASurfaceControl pointers that were updated during the * transaction. Stats for the surfaces can be queried through ASurfaceTransactionStats functions. * When the client is done using the array, it must release it by calling * ASurfaceTransactionStats_releaseASurfaceControls. * * Available since API level 29. * * |outASurfaceControlsSize| returns the size of the ASurfaceControls array. * \a outASurfaceControlsSize returns the size of the ASurfaceControls array. */ void ASurfaceTransactionStats_getASurfaceControls(ASurfaceTransactionStats* surface_transaction_stats, ASurfaceControl*** outASurfaceControls, Loading @@ -172,7 +172,7 @@ void ASurfaceTransactionStats_getASurfaceControls(ASurfaceTransactionStats* surf __INTRODUCED_IN(29); /** * Releases the array of ASurfaceControls that were returned by * ASurfaceTransactionStats_getASurfaceControls. * ASurfaceTransactionStats_getASurfaceControls(). * * Available since API level 29. */ Loading @@ -197,8 +197,8 @@ int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* surfac * buffer is already released. The recipient of the callback takes ownership of the * previousReleaseFenceFd and is responsible for closing it. * * Each time a buffer is set through ASurfaceTransaction_setBuffer()/_setCachedBuffer() on a * transaction which is applied, the framework takes a ref on this buffer. The framework treats the * Each time a buffer is set through ASurfaceTransaction_setBuffer() on a transaction * which is applied, the framework takes a ref on this buffer. The framework treats the * addition of a buffer to a particular surface as a unique ref. When a transaction updates or * removes a buffer from a surface, or removes the surface itself from the tree, this ref is * guaranteed to be released in the OnComplete callback for this transaction. The Loading Loading @@ -226,10 +226,10 @@ void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* transaction, void* c ASurfaceTransaction_OnComplete func) __INTRODUCED_IN(29); /** * Reparents the |surface_control| from its old parent to the |new_parent| surface control. * Any children of the* reparented |surface_control| will remain children of the |surface_control|. * Reparents the \a surface_control from its old parent to the \a new_parent surface control. * Any children of the reparented \a surface_control will remain children of the \a surface_control. * * The |new_parent| can be null. Surface controls with a null parent do not appear on the display. * The \a new_parent can be null. Surface controls with a null parent do not appear on the display. * * Available since API level 29. */ Loading @@ -237,14 +237,16 @@ void ASurfaceTransaction_reparent(ASurfaceTransaction* transaction, ASurfaceControl* surface_control, ASurfaceControl* new_parent) __INTRODUCED_IN(29); /* Parameter for ASurfaceTransaction_setVisibility */ /** * Parameter for ASurfaceTransaction_setVisibility(). */ enum { ASURFACE_TRANSACTION_VISIBILITY_HIDE = 0, ASURFACE_TRANSACTION_VISIBILITY_SHOW = 1, }; /** * Updates the visibility of |surface_control|. If show is set to * ASURFACE_TRANSACTION_VISIBILITY_HIDE, the |surface_control| and all surfaces in its subtree will * Updates the visibility of \a surface_control. If show is set to * ASURFACE_TRANSACTION_VISIBILITY_HIDE, the \a surface_control and all surfaces in its subtree will * be hidden. * * Available since API level 29. Loading @@ -254,7 +256,7 @@ void ASurfaceTransaction_setVisibility(ASurfaceTransaction* transaction, __INTRODUCED_IN(29); /** * Updates the z order index for |surface_control|. Note that the z order for a surface * Updates the z order index for \a surface_control. Note that the z order for a surface * is relative to other surfaces which are siblings of this surface. The behavior of sibilings with * the same z order is undefined. * Loading @@ -267,11 +269,11 @@ void ASurfaceTransaction_setZOrder(ASurfaceTransaction* transaction, __INTRODUCED_IN(29); /** * Updates the AHardwareBuffer displayed for |surface_control|. If not -1, the * Updates the AHardwareBuffer displayed for \a surface_control. If not -1, the * acquire_fence_fd should be a file descriptor that is signaled when all pending work * for the buffer is complete and the buffer can be safely read. * * The frameworks takes ownership of the |acquire_fence_fd| passed and is responsible * The frameworks takes ownership of the \a acquire_fence_fd passed and is responsible * for closing it. * * Available since API level 29. Loading @@ -281,9 +283,9 @@ void ASurfaceTransaction_setBuffer(ASurfaceTransaction* transaction, int acquire_fence_fd = -1) __INTRODUCED_IN(29); /** * Updates the color for |surface_control|. This will make the background color for the * ASurfaceControl visible in transparent regions of the surface. Colors |r|, |g|, * and |b| must be within the range that is valid for |dataspace|. |dataspace| and |alpha| * Updates the color for \a surface_control. This will make the background color for the * ASurfaceControl visible in transparent regions of the surface. Colors \a r, \a g, * and \a b must be within the range that is valid for \a dataspace. \a dataspace and \a alpha * will be the dataspace and alpha set for the background color layer. * * Available since API level 29. Loading @@ -294,15 +296,15 @@ void ASurfaceTransaction_setColor(ASurfaceTransaction* transaction, __INTRODUCED_IN(29); /** * |source| the sub-rect within the buffer's content to be rendered inside the surface's area * \param source The sub-rect within the buffer's content to be rendered inside the surface's area * The surface's source rect is clipped by the bounds of its current buffer. The source rect's width * and height must be > 0. * * |destination| specifies the rect in the parent's space where this surface will be drawn. The post * \param destination Specifies the rect in the parent's space where this surface will be drawn. The post * source rect bounds are scaled to fit the destination rect. The surface's destination rect is * clipped by the bounds of its parent. The destination rect's width and height must be > 0. * * |transform| the transform applied after the source rect is applied to the buffer. This parameter * \param transform The transform applied after the source rect is applied to the buffer. This parameter * should be set to 0 for no transform. To specify a transfrom use the NATIVE_WINDOW_TRANSFORM_* * enum. * Loading @@ -314,7 +316,9 @@ void ASurfaceTransaction_setGeometry(ASurfaceTransaction* transaction, __INTRODUCED_IN(29); /* Parameter for ASurfaceTransaction_setBufferTransparency */ /** * Parameter for ASurfaceTransaction_setBufferTransparency(). */ enum { ASURFACE_TRANSACTION_TRANSPARENCY_TRANSPARENT = 0, ASURFACE_TRANSACTION_TRANSPARENCY_TRANSLUCENT = 1, Loading Loading @@ -360,7 +364,7 @@ void ASurfaceTransaction_setDesiredPresentTime(ASurfaceTransaction* transaction, /** * Sets the alpha for the buffer. It uses a premultiplied blending. * * The |alpha| must be between 0.0 and 1.0. * The \a alpha must be between 0.0 and 1.0. * * Available since API level 29. */ Loading @@ -379,10 +383,10 @@ void ASurfaceTransaction_setBufferDataSpace(ASurfaceTransaction* transaction, ASurfaceControl* surface_control, ADataSpace data_space) __INTRODUCED_IN(29); /* /** * SMPTE ST 2086 "Mastering Display Color Volume" static metadata * * When |metadata| is set to null, the framework does not use any smpte2086 metadata when rendering * When \a metadata is set to null, the framework does not use any smpte2086 metadata when rendering * the surface's buffer. * * Available since API level 29. Loading @@ -392,10 +396,10 @@ void ASurfaceTransaction_setHdrMetadata_smpte2086(ASurfaceTransaction* transacti struct AHdrMetadata_smpte2086* metadata) __INTRODUCED_IN(29); /* /** * Sets the CTA 861.3 "HDR Static Metadata Extension" static metadata on a surface. * * When |metadata| is set to null, the framework does not use any cta861.3 metadata when rendering * When \a metadata is set to null, the framework does not use any cta861.3 metadata when rendering * the surface's buffer. * * Available since API level 29. Loading @@ -410,7 +414,23 @@ void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* transactio #if __ANDROID_API__ >= 30 /** * Sets the intended frame rate for |surface_control|. * Same as ASurfaceTransaction_setFrameRateWithSeamlessness(transaction, surface_control, * frameRate, compatibility, true). * * See ASurfaceTransaction_setFrameRateWithSeamlessness(). * * Available since API level 30. */ void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* transaction, ASurfaceControl* surface_control, float frameRate, int8_t compatibility) __INTRODUCED_IN(30); #endif // __ANDROID_API__ >= 30 #if __ANDROID_API__ >= 31 /** * Sets the intended frame rate for \a surface_control. * * On devices that are capable of running the display at different refresh rates, the system may * choose a display refresh rate to better match this surface's frame rate. Usage of this API won't Loading @@ -419,24 +439,30 @@ void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* transactio * callback timings, and changes to the time interval at which the system releases buffers back to * the application. * * |frameRate| is the intended frame rate of this surface, in frames per second. 0 is a special * \param frameRate is the intended frame rate of this surface, in frames per second. 0 is a special * value that indicates the app will accept the system's choice for the display frame rate, which is * the default behavior if this function isn't called. The frameRate param does <em>not</em> need to * be a valid refresh rate for this device's display - e.g., it's fine to pass 30fps to a device * that can only run the display at 60fps. * * |compatibility| The frame rate compatibility of this surface. The compatibility value may * \param compatibility The frame rate compatibility of this surface. The compatibility value may * influence the system's choice of display frame rate. To specify a compatibility use the * ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* enum. * * Available since API level 30. * \param shouldBeSeamless Whether display refresh rate transitions should be seamless. A * seamless transition is one that doesn't have any visual interruptions, such as a black * screen for a second or two. True indicates that any frame rate changes caused by this * request should be seamless. False indicates that non-seamless refresh rates are also * acceptable. * * Available since API level 31. */ void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* transaction, void ASurfaceTransaction_setFrameRateWithSeamlessness(ASurfaceTransaction* transaction, ASurfaceControl* surface_control, float frameRate, int8_t compatibility) __INTRODUCED_IN(30); #endif // __ANDROID_API__ >= 30 int8_t compatibility, bool shouldBeSeamless) __INTRODUCED_IN(31); #endif // __ANDROID_API__ >= 31 __END_DECLS #endif // ANDROID_SURFACE_CONTROL_H
libs/gui/BLASTBufferQueue.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -378,11 +378,11 @@ public: }).detach(); } status_t setFrameRate(float frameRate, int8_t compatibility) override { status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless) override { if (!ValidateFrameRate(frameRate, compatibility, "BBQSurface::setFrameRate")) { return BAD_VALUE; } return mBbq->setFrameRate(frameRate, compatibility); return mBbq->setFrameRate(frameRate, compatibility, shouldBeSeamless); } status_t setFrameTimelineVsync(int64_t frameTimelineVsyncId) override { Loading @@ -392,12 +392,12 @@ public: // TODO: Can we coalesce this with frame updates? Need to confirm // no timing issues. status_t BLASTBufferQueue::setFrameRate(float frameRate, int8_t compatibility) { status_t BLASTBufferQueue::setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless) { std::unique_lock _lock{mMutex}; SurfaceComposerClient::Transaction t; return t.setFrameRate(mSurfaceControl, frameRate, compatibility) .apply(); return t.setFrameRate(mSurfaceControl, frameRate, compatibility, shouldBeSeamless).apply(); } status_t BLASTBufferQueue::setFrameTimelineVsync(int64_t frameTimelineVsyncId) { Loading
libs/gui/ISurfaceComposer.cpp +14 −2 Original line number Diff line number Diff line Loading @@ -1114,7 +1114,7 @@ public: } virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate, int8_t compatibility) { int8_t compatibility, bool shouldBeSeamless) { Parcel data, reply; status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); if (err != NO_ERROR) { Loading @@ -1140,6 +1140,12 @@ public: return err; } err = data.writeBool(shouldBeSeamless); if (err != NO_ERROR) { ALOGE("setFrameRate: failed writing bool: %s (%d)", strerror(-err), -err); return err; } err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply); if (err != NO_ERROR) { ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err); Loading Loading @@ -2033,7 +2039,13 @@ status_t BnSurfaceComposer::onTransact( ALOGE("setFrameRate: failed to read byte: %s (%d)", strerror(-err), -err); return err; } status_t result = setFrameRate(surface, frameRate, compatibility); bool shouldBeSeamless; err = data.readBool(&shouldBeSeamless); if (err != NO_ERROR) { ALOGE("setFrameRate: failed to read bool: %s (%d)", strerror(-err), -err); return err; } status_t result = setFrameRate(surface, frameRate, compatibility, shouldBeSeamless); reply->writeInt32(result); return NO_ERROR; } Loading
libs/gui/LayerState.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ layer_state_t::layer_state_t() frameRateSelectionPriority(-1), frameRate(0.0f), frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT), shouldBeSeamless(true), fixedTransformHint(ui::Transform::ROT_INVALID), frameNumber(0) { matrix.dsdx = matrix.dtdy = 1.0f; Loading Loading @@ -144,6 +145,7 @@ status_t layer_state_t::write(Parcel& output) const SAFE_PARCEL(output.writeInt32, frameRateSelectionPriority); SAFE_PARCEL(output.writeFloat, frameRate); SAFE_PARCEL(output.writeByte, frameRateCompatibility); SAFE_PARCEL(output.writeBool, shouldBeSeamless); SAFE_PARCEL(output.writeUint32, fixedTransformHint); SAFE_PARCEL(output.writeUint64, frameNumber); SAFE_PARCEL(output.writeInt64, frameTimelineVsyncId); Loading Loading @@ -262,6 +264,7 @@ status_t layer_state_t::read(const Parcel& input) SAFE_PARCEL(input.readInt32, &frameRateSelectionPriority); SAFE_PARCEL(input.readFloat, &frameRate); SAFE_PARCEL(input.readByte, &frameRateCompatibility); SAFE_PARCEL(input.readBool, &shouldBeSeamless); SAFE_PARCEL(input.readUint32, &tmpUint32); fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32); SAFE_PARCEL(input.readUint64, &frameNumber); Loading Loading @@ -521,6 +524,7 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eFrameRateChanged; frameRate = other.frameRate; frameRateCompatibility = other.frameRateCompatibility; shouldBeSeamless = other.shouldBeSeamless; } if (other.what & eFixedTransformHintChanged) { what |= eFixedTransformHintChanged; Loading
libs/gui/Surface.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -1443,7 +1443,8 @@ int Surface::dispatchGetLastQueueDuration(va_list args) { int Surface::dispatchSetFrameRate(va_list args) { float frameRate = static_cast<float>(va_arg(args, double)); int8_t compatibility = static_cast<int8_t>(va_arg(args, int)); return setFrameRate(frameRate, compatibility); bool shouldBeSeamless = static_cast<bool>(va_arg(args, int)); return setFrameRate(frameRate, compatibility, shouldBeSeamless); } int Surface::dispatchAddCancelInterceptor(va_list args) { Loading Loading @@ -2279,7 +2280,7 @@ void Surface::ProducerListenerProxy::onBuffersDiscarded(const std::vector<int32_ mSurfaceListener->onBuffersDiscarded(discardedBufs); } status_t Surface::setFrameRate(float frameRate, int8_t compatibility) { status_t Surface::setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless) { ATRACE_CALL(); ALOGV("Surface::setFrameRate"); Loading @@ -2287,7 +2288,8 @@ status_t Surface::setFrameRate(float frameRate, int8_t compatibility) { return BAD_VALUE; } return composerService()->setFrameRate(mGraphicBufferProducer, frameRate, compatibility); return composerService()->setFrameRate(mGraphicBufferProducer, frameRate, compatibility, shouldBeSeamless); } status_t Surface::setFrameTimelineVsync(int64_t frameTimelineVsyncId) { Loading