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
Modifier and TypeClassDescriptionstatic interface
Interface that allows Gecko the request a new Surface from the application.static final class
Builder to construct screenshot requests.static class
Wrapper class containing a Surface and associated information that the compositor should render in to. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRequest aBitmap
of the visible portion of the web page currently being rendered.void
safeAreaInsetsChanged
(int top, int right, int bottom, int left) Update the safe area insets of the surface on the screen.void
screenOriginChanged
(int left, int top) Update the position of the surface on the screen.Creates a new screenshot builder.void
setDynamicToolbarMaxHeight
(int height) Set the maximum height of the dynamic toolbar(s).void
setVerticalClipping
(int clippingHeight) Update the amount of vertical space that is clipped or visibly obscured in the bottom portion of the display.boolean
Return whether the display should be pinned on the screen.void
surfaceChanged
(GeckoDisplay.SurfaceInfo surfaceInfo) Sets a surface for the compositor render a surface.void
Removes the current surface registered with the compositor.void
windowInsetsChanged
(androidx.core.view.WindowInsetsCompat insets) Called when the root window insets changed.
-
Constructor Details
-
GeckoDisplay
-
-
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
SurfaceView
on SDK level 29 or above, please ensure that the SurfaceControl field of theGeckoDisplay.SurfaceInfo
object 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 aBitmap
of the visible portion of the web page currently being rendered.Returned
Bitmap
will have the same dimensions as theSurface
theGeckoDisplay
is currently using.If the
GeckoSession.isCompositorReady()
is false theGeckoResult
will complete with anIllegalStateException
.This function must be called on the UI thread.
- Returns:
- A
GeckoResult
that completes with aBitmap
containing 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
-