Package icyllis.arc3d.granite
Class GraniteSurface
java.lang.Object
icyllis.arc3d.core.RefCnt
icyllis.arc3d.core.Surface
icyllis.arc3d.granite.GraniteSurface
- All Implemented Interfaces:
RefCounted
The surface that is backed by GPU.
-
Field Summary
Fields inherited from class icyllis.arc3d.core.Surface
kDiscard_ContentChangeMode, kPreserve_ContentChangeMode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Override this method to invoke de-allocation of the underlying resource.void
flush()
Returns an ImageInfo describing the Surface.static @SharedPtr GraniteSurface
make
(RecordingContext rc, ImageInfo info, boolean budgeted, boolean mipmapped, boolean approxFit, int surfaceOrigin, String label) makeImageCopy
(Rect2ic subset, boolean mipmapped) static @SharedPtr GraniteSurface
makeRenderTarget
(RecordingContext rc, ImageInfo info, boolean mipmapped, int surfaceOrigin, String label) While clients hold a ref on a Surface, the backing gpu object does not count against the budget.protected boolean
onCopyOnWrite
(int changeMode) If the surface is about to change, we call this so that our subclass can optionally fork their backend (copy-on-write) in case it was being shared with the cachedImage.protected RecordingContext
protected Canvas
Allocate a canvas that will draw into this surface.protected Image
onNewImageSnapshot
(Rect2ic subset) Allocate an Image that represents the current contents of the surface.Methods inherited from class icyllis.arc3d.core.Surface
getCachedCanvas, getCachedImage, getCanvas, getGenerationID, getHeight, getRecordingContext, getWidth, hasCachedImage, makeFromBackendTexture, makeImageSnapshot, makeImageSnapshot, makeRenderTarget, notifyWillChange, onDiscard, onRestoreBackingMutability
-
Constructor Details
-
GraniteSurface
-
-
Method Details
-
make
@Nullable @SharedPtr public static @SharedPtr GraniteSurface make(RecordingContext rc, ImageInfo info, boolean budgeted, boolean mipmapped, boolean approxFit, int surfaceOrigin, String label) -
makeRenderTarget
@Nullable @SharedPtr public static @SharedPtr GraniteSurface makeRenderTarget(RecordingContext rc, @Nonnull ImageInfo info, boolean mipmapped, int surfaceOrigin, @Nullable String label) While clients hold a ref on a Surface, the backing gpu object does not count against the budget. Once a Surface is freed, the backing gpu object may or may not become a scratch (i.e., reusable) resource but, if it does, it will be counted against the budget. -
deallocate
protected void deallocate()Description copied from class:RefCnt
Override this method to invoke de-allocation of the underlying resource.- Overrides:
deallocate
in classSurface
-
flush
public void flush() -
getImageInfo
Description copied from class:Surface
Returns an ImageInfo describing the Surface.- Specified by:
getImageInfo
in classSurface
-
onNewCanvas
Description copied from class:Surface
Allocate a canvas that will draw into this surface. We will cache this canvas, to return the same object to the caller multiple times. We take ownership, and will call unref() on the canvas when we go out of scope.- Specified by:
onNewCanvas
in classSurface
-
onNewImageSnapshot
Description copied from class:Surface
Allocate an Image that represents the current contents of the surface. This needs to be able to outlive the surface itself (if need be), and must faithfully represent the current contents, even if the surface is changed after this called (e.g. it is drawn to via its canvas).If a subset is specified, the impl must make a copy, rather than try to wait on copy-on-write.
- Specified by:
onNewImageSnapshot
in classSurface
-
onCopyOnWrite
protected boolean onCopyOnWrite(int changeMode) Description copied from class:Surface
If the surface is about to change, we call this so that our subclass can optionally fork their backend (copy-on-write) in case it was being shared with the cachedImage.Returns false if the backing cannot be un-shared.
- Specified by:
onCopyOnWrite
in classSurface
-
makeImageCopy
@Nullable @SharedPtr public @SharedPtr GraniteImage makeImageCopy(@Nullable Rect2ic subset, boolean mipmapped) -
onGetRecordingContext
- Overrides:
onGetRecordingContext
in classSurface
-