Class GeckoDisplay
GeckoSession with a Surface
for displaying content. To ensure drawing only happens on a valid Surface, GeckoSession will only use the provided Surface after surfaceChanged(SurfaceInfo) is called and before surfaceDestroyed() returns.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface that allows Gecko the request a new Surface from the application.static final classBuilder to construct screenshot requests.static classWrapper class containing a Surface and associated information that the compositor should render in to. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGeckoDisplay(GeckoSession session) Protected constructor for GeckoDisplay. -
Method Summary
Modifier and TypeMethodDescriptionRequest aBitmapof the visible portion of the web page currently being rendered.voidsafeAreaInsetsChanged(int top, int right, int bottom, int left) Update the safe area insets of the surface on the screen.voidscreenOriginChanged(int left, int top) Update the position of the surface on the screen.Creates a new screenshot builder.voidsetDynamicToolbarMaxHeight(int height) Set the maximum height of the dynamic toolbar(s).voidsetVerticalClipping(int clippingHeight) Update the amount of vertical space that is clipped or visibly obscured in the bottom portion of the display.booleanReturn whether the display should be pinned on the screen.voidsurfaceChanged(GeckoDisplay.SurfaceInfo surfaceInfo) Sets a surface for the compositor render a surface.voidRemoves the current surface registered with the compositor.voidwindowInsetsChanged(androidx.core.view.WindowInsetsCompat insets) Called when the root window insets changed.
-
Constructor Details
-
GeckoDisplay
Protected constructor for GeckoDisplay.- Parameters:
session- The GeckoSession this display is associated with
-
-
Method Details
-
surfaceChanged
Sets a surface for the compositor render a surface.Required call. The display's Surface has been created or changed. Must be called on the application main thread. GeckoSession may block this call to ensure the Surface is valid while resuming drawing.
If rendering in to a
SurfaceViewon SDK level 29 or above, please ensure that the SurfaceControl field of theGeckoDisplay.SurfaceInfoobject is set.- Parameters:
surfaceInfo- Information about the new Surface.
-
surfaceDestroyed
@UiThread public void surfaceDestroyed()Removes the current surface registered with the compositor.Required call. The display's Surface has been destroyed. Must be called on the application main thread. GeckoSession may block this call to ensure the Surface is valid while pausing drawing.
-
screenOriginChanged
@UiThread public void screenOriginChanged(int left, int top) Update the position of the surface on the screen.Optional call. The display's coordinates on the screen has changed. Must be called on the application main thread.
- Parameters:
left- The X coordinate of the display on the screen, in screen pixels.top- The Y coordinate of the display on the screen, in screen pixels.
-
safeAreaInsetsChanged
@UiThread public void safeAreaInsetsChanged(int top, int right, int bottom, int left) Update the safe area insets of the surface on the screen.- Parameters:
left- left margin of safe areatop- top margin of safe arearight- right margin of safe areabottom- bottom margin of safe area
-
setDynamicToolbarMaxHeight
@UiThread public void setDynamicToolbarMaxHeight(int height) Set the maximum height of the dynamic toolbar(s).If the toolbar is dynamic, this function needs to be called with the maximum possible toolbar height so that Gecko can make the ICB static even during the dynamic toolbar height is being changed.
- Parameters:
height- The maximum height of the dynamic toolbar(s).
-
setVerticalClipping
@UiThread public void setVerticalClipping(int clippingHeight) Update the amount of vertical space that is clipped or visibly obscured in the bottom portion of the display. Tells gecko where to put bottom fixed elements so they are fully visible.Optional call. The display's visible vertical space has changed. Must be called on the application main thread.
- Parameters:
clippingHeight- The height of the bottom clipped space in screen pixels.
-
shouldPinOnScreen
@UiThread public boolean shouldPinOnScreen()Return whether the display should be pinned on the screen.When pinned, the display should not be moved on the screen due to animation, scrolling, etc. A common reason for the display being pinned is when the user is dragging a selection caret inside the display; normal user interaction would be disrupted in that case if the display was moved on screen.
- Returns:
- True if display should be pinned on the screen.
-
capturePixels
Request aBitmapof the visible portion of the web page currently being rendered.Returned
Bitmapwill have the same dimensions as theSurfacetheGeckoDisplayis currently using.If the
GeckoSession.isCompositorReady()is false theGeckoResultwill complete with anIllegalStateException.This function must be called on the UI thread.
- Returns:
- A
GeckoResultthat completes with aBitmapcontaining the pixels and size information of the currently visible rendered web page.
-
screenshot
Creates a new screenshot builder.- Returns:
- The new
GeckoDisplay.ScreenshotBuilder
-
windowInsetsChanged
@UiThread public void windowInsetsChanged(@NonNull androidx.core.view.WindowInsetsCompat insets) Called when the root window insets changed.- Parameters:
insets- the WindowInsetsCompat
-