Class DisplayHelper
- java.lang.Object
-
- com.google.android.filament.android.DisplayHelper
-
public class DisplayHelper extends java.lang.ObjectDisplayHelper is here to help managing a Display, for instance being notified when its resolution or refresh rate changes.
-
-
Constructor Summary
Constructors Constructor Description DisplayHelper(android.content.Context context)Creates a DisplayHelper which helps managing aDisplay.DisplayHelper(android.content.Context context, android.os.Handler handler)Creates a DisplayHelper which helps manage aDisplayand provides a Handler where callbacks can execute filament code.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattach(Renderer renderer, android.view.Display display)Sets the filamentRendererassociated to theDisplay, from this point on,Renderer.DisplayInfowill be automatically updated when theDisplayproperties change.voiddetach()Disconnect the previously setRendererfromDisplayThis is typically called fromUiHelper.RendererCallback.onDetachedFromSurface().protected voidfinalize()static longgetAppVsyncOffsetNanos(android.view.Display display)android.view.DisplaygetDisplay()Returns theDisplaycurrently monitoredstatic Renderer.DisplayInfogetDisplayInfo(android.view.Display display, Renderer.DisplayInfo info)Populate aRenderer.DisplayInfowith properties from the givenDisplaystatic longgetPresentationDeadlineNanos(android.view.Display display)static longgetRefreshPeriodNanos(android.view.Display display)Returns aDisplay's refresh period in nanosecondsstatic floatgetRefreshRate(android.view.Display display)
-
-
-
Constructor Detail
-
DisplayHelper
public DisplayHelper(@NonNull android.content.Context context)Creates a DisplayHelper which helps managing aDisplay. TheDisplayto manage is specified withattach(com.google.android.filament.Renderer, android.view.Display)- Parameters:
context- aContextto used to retrieve theDisplayManager
-
DisplayHelper
public DisplayHelper(@NonNull android.content.Context context, @NonNull android.os.Handler handler)Creates a DisplayHelper which helps manage aDisplayand provides a Handler where callbacks can execute filament code. Use this method if filament is executing on another thread.- Parameters:
context- aContextto used to retrieve tehDisplayManagerhandler- aHandlerused to run callbacks accessing filament
-
-
Method Detail
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
attach
public void attach(@NonNull Renderer renderer, @NonNull android.view.Display display)Sets the filamentRendererassociated to theDisplay, from this point on,Renderer.DisplayInfowill be automatically updated when theDisplayproperties change. This is typically called fromUiHelper.RendererCallback.onNativeWindowChanged(android.view.Surface).
-
detach
public void detach()
Disconnect the previously setRendererfromDisplayThis is typically called fromUiHelper.RendererCallback.onDetachedFromSurface().
-
getDisplay
public android.view.Display getDisplay()
Returns theDisplaycurrently monitored- Returns:
- the
Displayset inattach(com.google.android.filament.Renderer, android.view.Display)or null
-
getDisplayInfo
@NonNull public static Renderer.DisplayInfo getDisplayInfo(@NonNull android.view.Display display, @Nullable Renderer.DisplayInfo info)
Populate aRenderer.DisplayInfowith properties from the givenDisplay- Parameters:
display-Displayto getRenderer.DisplayInfofrominfo- an instance ofRenderer.DisplayInfoor null- Returns:
- an populated instance of
Renderer.DisplayInfo
-
getAppVsyncOffsetNanos
public static long getAppVsyncOffsetNanos(@NonNull android.view.Display display)- Returns:
- the
Displayapplication vsync offset 0 if not supported - See Also:
Display.getAppVsyncOffsetNanos()
-
getPresentationDeadlineNanos
public static long getPresentationDeadlineNanos(@NonNull android.view.Display display)- Returns:
- the
Displaypresentation deadline before the h/w vsync event in nanoseconds - See Also:
Display.getPresentationDeadlineNanos()
-
getRefreshRate
public static float getRefreshRate(@NonNull android.view.Display display)- Returns:
- the
Displayrefresh rate in Hz - See Also:
Display.getRefreshRate()
-
getRefreshPeriodNanos
public static long getRefreshPeriodNanos(@NonNull android.view.Display display)Returns aDisplay's refresh period in nanoseconds- Parameters:
display- theDisplayto get the refresh period from- Returns:
- the
Displayrefresh period in nanoseconds
-
-