@@ -76,6 +76,8 @@ __BEGIN_DECLS
7676struct APerformanceHintManager ;
7777struct APerformanceHintSession ;
7878struct AWorkDuration ;
79+ struct ANativeWindow ;
80+ struct ASurfaceControl ;
7981
8082/* *
8183 * {@link AWorkDuration} is an opaque type that represents the breakdown of the
@@ -353,6 +355,39 @@ int APerformanceHint_notifyWorkloadReset(
353355 APerformanceHintSession* _Nonnull session,
354356 bool cpu, bool gpu, const char * _Nonnull debugName) __INTRODUCED_IN(36 );
355357
358+ /* *
359+ * Associates a session with any {@link ASurfaceControl} or {@link ANativeWindow}
360+ * instances managed by this session.
361+ *
362+ * This method is primarily intended for sessions that manage the timing of an entire
363+ * graphics pipeline end-to-end, such as those using the
364+ * {@link ASessionCreationConfig_setGraphicsPipeline} API. However, any session directly
365+ * or indirectly managing a graphics pipeline should still associate themselves with
366+ * directly relevant ASurfaceControl or ANativeWindow instances for better optimization.
367+ *
368+ * To see any benefit from this method, the client must make sure they are updating the framerate
369+ * of attached surfaces using methods such as {@link ANativeWindow_setFrameRate}, or by updating
370+ * any associated ASurfaceControls with transactions that have {ASurfaceTransaction_setFrameRate}.
371+ *
372+ * @param session The {@link APerformanceHintSession} instance to update.
373+ * @param nativeWindows A pointer to a list of ANativeWindows associated with this session.
374+ * nullptr can be passed to indicate there are no associated ANativeWindows.
375+ * @param nativeWindowsSize The number of ANativeWindows in the list.
376+ * @param surfaceControls A pointer to a list of ASurfaceControls associated with this session.
377+ * nullptr can be passed to indicate there are no associated ASurfaceControls.
378+ * @param surfaceControlsSize The number of ASurfaceControls in the list.
379+ *
380+ * @return 0 on success.
381+ * EPIPE if communication has failed.
382+ * ENOTSUP if unsupported.
383+ * EINVAL if invalid or empty arguments passed.
384+ */
385+
386+ int APerformanceHint_setNativeSurfaces (APerformanceHintSession* _Nonnull session,
387+ ANativeWindow* _Nonnull* _Nullable nativeWindows, int nativeWindowsSize,
388+ ASurfaceControl* _Nonnull* _Nullable surfaceControls, int surfaceControlsSize)
389+ __INTRODUCED_IN(36 );
390+
356391/* *
357392 * Creates a new AWorkDuration. When the client finishes using {@link AWorkDuration}, it should
358393 * call {@link AWorkDuration_release()} to destroy {@link AWorkDuration} and release all resources
@@ -520,6 +555,63 @@ int ASessionCreationConfig_setPreferPowerEfficiency(
520555int ASessionCreationConfig_setGraphicsPipeline (
521556 ASessionCreationConfig* _Nonnull config, bool enabled) __INTRODUCED_IN(36 );
522557
558+ /* *
559+ * Associates a session with any {@link ASurfaceControl} or {@link ANativeWindow}
560+ * instances managed by this session. See {@link APerformanceHint_setNativeSurfaces}
561+ * for more details.
562+ *
563+ * @param config The {@link ASessionCreationConfig}
564+ * created by calling {@link ASessionCreationConfig_create()}.
565+ * @param nativeWindows A pointer to a list of ANativeWindows associated with this session.
566+ * nullptr can be passed to indicate there are no associated ANativeWindows.
567+ * @param nativeWindowsSize The number of ANativeWindows in the list.
568+ * @param surfaceControls A pointer to a list of ASurfaceControls associated with this session.
569+ * nullptr can be passed to indicate there are no associated ASurfaceControls.
570+ * @param surfaceControlsSize The number of ASurfaceControls in the list.
571+ *
572+ * @return 0 on success.
573+ * ENOTSUP if unsupported.
574+ * EINVAL if invalid or empty arguments passed.
575+ */
576+ int ASessionCreationConfig_setNativeSurfaces (
577+ ASessionCreationConfig* _Nonnull config,
578+ ANativeWindow* _Nonnull* _Nullable nativeWindows, int nativeWindowsSize,
579+ ASurfaceControl* _Nonnull* _Nullable surfaceControls, int surfaceControlsSize)
580+ __INTRODUCED_IN(36 );
581+
582+ /* *
583+ * Enable automatic timing mode for sessions using the GRAPHICS_PIPELINE API with an attached
584+ * surface. In this mode, sessions do not need to report actual durations and only need
585+ * to keep their thread list up-to-date, set a native surface, call
586+ * {@link ASessionCreationConfig_setGraphicsPipeline()} to signal that the session is in
587+ * "graphics pipeline" mode, and then set whether automatic timing is desired for the
588+ * CPU, GPU, or both, using this method.
589+ *
590+ * It is still be beneficial to set an accurate target time, as this may help determine
591+ * timing information for some workloads where there is less information available from
592+ * the framework, such as games. Additionally, reported CPU durations will be ignored
593+ * while automatic CPU timing is enabled, and similarly GPU durations will be ignored
594+ * when automatic GPU timing is enabled. When both are enabled, the entire
595+ * reportActualWorkDuration call will be ignored, and the session will be managed
596+ * completely automatically.
597+ *
598+ * This mode will not work unless the client makes sure they are updating the framerate
599+ * of attached surfaces with methods such as {@link ANativeWindow_setFrameRate}, or updating
600+ * any associated ASurfaceControls with transactions that have {ASurfaceTransaction_setFrameRate}.
601+ *
602+ * @param config The {@link ASessionCreationConfig}
603+ * created by calling {@link ASessionCreationConfig_create()}.
604+ * @param cpu Whether to enable automatic timing for the CPU for this session.
605+ * @param gpu Whether to enable automatic timing for the GPU for this session.
606+ *
607+ * @return 0 on success.
608+ * ENOTSUP if unsupported.
609+ */
610+ int ASessionCreationConfig_setUseAutoTiming (
611+ ASessionCreationConfig* _Nonnull config,
612+ bool cpu, bool gpu)
613+ __INTRODUCED_IN(36 );
614+
523615__END_DECLS
524616
525617#endif // ANDROID_NATIVE_PERFORMANCE_HINT_H
0 commit comments