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`

public final class GraniteSurface extends Surface
The surface that is backed by GPU.

- ## Field Summary

  ### Fields inherited from class icyllis.arc3d.core.Surface

  `kDiscard_ContentChangeMode, kPreserve_ContentChangeMode`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GraniteSurface(@SharedPtr GraniteDevice device)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `deallocate()`
  Override this method to invoke de-allocation of the underlying resource.
  `void`
  `flush()`
  `ImageInfo`
  `getImageInfo()`
  Returns an ImageInfo describing the Surface.
  `static @SharedPtr GraniteSurface`
  `make(RecordingContext rc, ImageInfo info, boolean budgeted, boolean mipmapped, boolean approxFit, int surfaceOrigin, String label)`
  `@SharedPtr GraniteImage`
  `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`
  `onGetRecordingContext()`
  `protected Canvas`
  `onNewCanvas()`
  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`

  ### Methods inherited from class icyllis.arc3d.core.RefCnt

  `create, create, getRefCnt, getRefCntAcquire, getRefCntVolatile, move, move, ref, unique, unref`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### GraniteSurface

    public GraniteSurface(@SharedPtr @SharedPtr GraniteDevice device)

- ## 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 class `Surface`

  - ### flush

    public void flush()

  - ### getImageInfo

    @Nonnull public ImageInfo getImageInfo()
    Description copied from class: `Surface`
    Returns an ImageInfo describing the Surface.
    Specified by:
      `getImageInfo` in class `Surface`

  - ### onNewCanvas

    protected Canvas 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 class `Surface`

  - ### onNewImageSnapshot

    @Nullable protected Image onNewImageSnapshot(@Nullable Rect2ic subset)
    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 class `Surface`

  - ### 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 class `Surface`

  - ### makeImageCopy

    @Nullable @SharedPtr public @SharedPtr GraniteImage makeImageCopy(@Nullable Rect2ic subset, boolean mipmapped)

  - ### onGetRecordingContext

    protected RecordingContext onGetRecordingContext()
    Overrides:
      `onGetRecordingContext` in class `Surface`