Class GraniteSurface

All Implemented Interfaces:
RefCounted

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

  • 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