102f4aeb0Sopenharmony_ciName
202f4aeb0Sopenharmony_ci
302f4aeb0Sopenharmony_ci    ANDROID_presentation_time
402f4aeb0Sopenharmony_ci
502f4aeb0Sopenharmony_ciName Strings
602f4aeb0Sopenharmony_ci
702f4aeb0Sopenharmony_ci    EGL_ANDROID_presentation_time
802f4aeb0Sopenharmony_ci
902f4aeb0Sopenharmony_ciContributors
1002f4aeb0Sopenharmony_ci
1102f4aeb0Sopenharmony_ci    Jamie Gennis
1202f4aeb0Sopenharmony_ci    Andy McFadden
1302f4aeb0Sopenharmony_ci    Jesse Hall
1402f4aeb0Sopenharmony_ci
1502f4aeb0Sopenharmony_ciContact
1602f4aeb0Sopenharmony_ci
1702f4aeb0Sopenharmony_ci    Jamie Gennis, Google Inc. (jgennis 'at' google.com)
1802f4aeb0Sopenharmony_ci
1902f4aeb0Sopenharmony_ciStatus
2002f4aeb0Sopenharmony_ci
2102f4aeb0Sopenharmony_ci    Draft
2202f4aeb0Sopenharmony_ci
2302f4aeb0Sopenharmony_ciVersion
2402f4aeb0Sopenharmony_ci
2502f4aeb0Sopenharmony_ci    Version 4, June 6, 2016
2602f4aeb0Sopenharmony_ci
2702f4aeb0Sopenharmony_ciNumber
2802f4aeb0Sopenharmony_ci
2902f4aeb0Sopenharmony_ci    EGL Extension #98
3002f4aeb0Sopenharmony_ci
3102f4aeb0Sopenharmony_ciDependencies
3202f4aeb0Sopenharmony_ci
3302f4aeb0Sopenharmony_ci    Requires EGL 1.1
3402f4aeb0Sopenharmony_ci
3502f4aeb0Sopenharmony_ci    This extension is written against the wording of the EGL 1.4 Specification
3602f4aeb0Sopenharmony_ci
3702f4aeb0Sopenharmony_ciOverview
3802f4aeb0Sopenharmony_ci
3902f4aeb0Sopenharmony_ci    Often when rendering a sequence of images, there is some time at which each
4002f4aeb0Sopenharmony_ci    image is intended to be presented to the viewer.  This extension allows
4102f4aeb0Sopenharmony_ci    this desired presentation time to be specified for each frame rendered to
4202f4aeb0Sopenharmony_ci    an EGLSurface, allowing the native window system to use it.
4302f4aeb0Sopenharmony_ci
4402f4aeb0Sopenharmony_ciNew Types
4502f4aeb0Sopenharmony_ci
4602f4aeb0Sopenharmony_ci    /*
4702f4aeb0Sopenharmony_ci     * EGLnsecsANDROID is a signed integer type for representing a time in
4802f4aeb0Sopenharmony_ci     * nanoseconds.
4902f4aeb0Sopenharmony_ci     */
5002f4aeb0Sopenharmony_ci    #include <khrplatform.h>
5102f4aeb0Sopenharmony_ci    typedef khronos_stime_nanoseconds_t EGLnsecsANDROID;
5202f4aeb0Sopenharmony_ci
5302f4aeb0Sopenharmony_ci
5402f4aeb0Sopenharmony_ciNew Procedures and Functions
5502f4aeb0Sopenharmony_ci
5602f4aeb0Sopenharmony_ci    EGLBoolean eglPresentationTimeANDROID(
5702f4aeb0Sopenharmony_ci                        EGLDisplay dpy,
5802f4aeb0Sopenharmony_ci                        EGLSurface surface,
5902f4aeb0Sopenharmony_ci                        EGLnsecsANDROID time);
6002f4aeb0Sopenharmony_ci
6102f4aeb0Sopenharmony_ciNew Tokens
6202f4aeb0Sopenharmony_ci
6302f4aeb0Sopenharmony_ci    None.
6402f4aeb0Sopenharmony_ci
6502f4aeb0Sopenharmony_ciChanges to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors)
6602f4aeb0Sopenharmony_ci
6702f4aeb0Sopenharmony_ci    Add a new subsection before Section 3.9.4, page 53 (Posting Errors)
6802f4aeb0Sopenharmony_ci
6902f4aeb0Sopenharmony_ci    "3.9.4 Presentation Time
7002f4aeb0Sopenharmony_ci
7102f4aeb0Sopenharmony_ci    The function
7202f4aeb0Sopenharmony_ci
7302f4aeb0Sopenharmony_ci        EGLBoolean eglPresentationTimeANDROID(EGLDisplay dpy, EGLSurface
7402f4aeb0Sopenharmony_ci            surface, EGLnsecsANDROID time);
7502f4aeb0Sopenharmony_ci
7602f4aeb0Sopenharmony_ci    specifies the time at which the current color buffer of <surface> should be
7702f4aeb0Sopenharmony_ci    presented to the viewer.  The <time> parameter should be a time in
7802f4aeb0Sopenharmony_ci    nanoseconds, but the exact meaning of the time depends on the native
7902f4aeb0Sopenharmony_ci    window system's use of the presentation time.  In situations where
8002f4aeb0Sopenharmony_ci    an absolute time is needed such as displaying the color buffer on a
8102f4aeb0Sopenharmony_ci    display device, the time should correspond to the system monotonic up-time
8202f4aeb0Sopenharmony_ci    clock.  For situations in which an absolute time is not needed such as
8302f4aeb0Sopenharmony_ci    using the color buffer for video encoding, the presentation time of the
8402f4aeb0Sopenharmony_ci    first frame may be arbitrarily chosen and those of subsequent frames
8502f4aeb0Sopenharmony_ci    chosen relative to that of the first frame.
8602f4aeb0Sopenharmony_ci
8702f4aeb0Sopenharmony_ci    The presentation time may be set multiple times, with each call to
8802f4aeb0Sopenharmony_ci    eglPresentationTimeANDROID overriding prior calls.  Setting the
8902f4aeb0Sopenharmony_ci    presentation time alone does not cause the color buffer to be made
9002f4aeb0Sopenharmony_ci    visible, but if the color buffer is subsequently posted to a native window
9102f4aeb0Sopenharmony_ci    or copied to a native pixmap then the presentation time of the surface at
9202f4aeb0Sopenharmony_ci    that time may be passed along for the native window system to use.
9302f4aeb0Sopenharmony_ci
9402f4aeb0Sopenharmony_ci    If the surface presentation time is successfully set, EGL_TRUE is
9502f4aeb0Sopenharmony_ci    returned.  Otherwise EGL_FALSE is returned and an appropriate error is
9602f4aeb0Sopenharmony_ci    set.  If <dpy> is not the name of a valid, initialized EGLDisplay, an
9702f4aeb0Sopenharmony_ci    EGL_BAD_DISPLAY error is generated.  If <surface> is not a valid EGLSurface
9802f4aeb0Sopenharmony_ci    then an EGL_BAD_SURFACE error is generated.
9902f4aeb0Sopenharmony_ci
10002f4aeb0Sopenharmony_ciIssues
10102f4aeb0Sopenharmony_ci
10202f4aeb0Sopenharmony_ci    1. How is the presentation time used?
10302f4aeb0Sopenharmony_ci
10402f4aeb0Sopenharmony_ci    RESOLVED: The uses of the presentation time are intentionally not specified
10502f4aeb0Sopenharmony_ci    in this extension.  Some possible uses include Audio/Video synchronization,
10602f4aeb0Sopenharmony_ci    video frame timestamps for video encoding, display latency metrics, and
10702f4aeb0Sopenharmony_ci    display latency control.
10802f4aeb0Sopenharmony_ci
10902f4aeb0Sopenharmony_ci    2. How can the current value of the clock that should be used for the
11002f4aeb0Sopenharmony_ci    presentation time when an absolute time is needed be queried on Android?
11102f4aeb0Sopenharmony_ci
11202f4aeb0Sopenharmony_ci    RESOLVED: The current clock value can be queried from the Java
11302f4aeb0Sopenharmony_ci    System.nanoTime() method, or from the native clock_gettime function by
11402f4aeb0Sopenharmony_ci    passing CLOCK_MONOTONIC as the clock identifier.
11502f4aeb0Sopenharmony_ci
11602f4aeb0Sopenharmony_ci    3. Should the presentation time be state which is used by eglSwapBuffers,
11702f4aeb0Sopenharmony_ci    or should it be a new parameter to an extended variant of eglSwapBuffers?
11802f4aeb0Sopenharmony_ci
11902f4aeb0Sopenharmony_ci    RESOLVED: The presentation time should be new state which is used by
12002f4aeb0Sopenharmony_ci    the existing eglSwapBuffers call. Adding new state composes better with
12102f4aeb0Sopenharmony_ci    other (hypothetical) extensions that also modify the behavior of
12202f4aeb0Sopenharmony_ci    eglSwapBuffers.
12302f4aeb0Sopenharmony_ci
12402f4aeb0Sopenharmony_ciRevision History
12502f4aeb0Sopenharmony_ci
12602f4aeb0Sopenharmony_ci#4 (Jon Leech, June 6, 2016)
12702f4aeb0Sopenharmony_ci    - Clean up for publication. Make prototype parameter name 'surface'
12802f4aeb0Sopenharmony_ci      match the spec body.
12902f4aeb0Sopenharmony_ci
13002f4aeb0Sopenharmony_ci#3 (Jesse Hall, June 26, 2013)
13102f4aeb0Sopenharmony_ci    - Enumerated errors generated by eglPresentationTimeANDROID.
13202f4aeb0Sopenharmony_ci    - Added Issue #3 with resolution.
13302f4aeb0Sopenharmony_ci
13402f4aeb0Sopenharmony_ci#2 (Jamie Gennis, April 1, 2013)
13502f4aeb0Sopenharmony_ci    - Clarified how uses that either do or do not need an absolute time should
13602f4aeb0Sopenharmony_ci      be handled.
13702f4aeb0Sopenharmony_ci    - Specified the eglPresentationTimeANDROID return value.
13802f4aeb0Sopenharmony_ci
13902f4aeb0Sopenharmony_ci#1 (Jamie Gennis, January 8, 2013)
14002f4aeb0Sopenharmony_ci    - Initial draft.
141