Package icyllis.arc3d.granite

# Class DrawAtlas.Plot

java.lang.Object
icyllis.arc3d.granite.DrawAtlas.PlotLocator
icyllis.arc3d.granite.DrawAtlas.Plot

All Implemented Interfaces:
  `AutoCloseable`

Enclosing class:
  `DrawAtlas`

public static class DrawAtlas.Plot extends DrawAtlas.PlotLocator implements AutoCloseable
The backing texture for an atlas is broken into a spatial grid of Plots. The Plots keep track of sub-image placement via their `RectanglePacker`.

- ## Field Summary

  ### Fields inherited from class icyllis.arc3d.granite.DrawAtlas.PlotLocator

  `MAX_PAGES, MAX_PLOTS`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Plot(int pageIndex, int plotIndex, DrawAtlas.AtlasGenerationCounter generationCounter, int plotX, int plotY, int width, int height, int colorType, int bpp)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `addRect(int width, int height, DrawAtlas.AtlasLocator atlasLocator)`
  To add data to the Plot, first call addRect to see if it's possible.
  `void`
  `clear()`
  Reset the Plot.
  `void`
  `close()`
  `void`
  `copySubImage(DrawAtlas.AtlasLocator atlasLocator, Object srcBase, long srcAddr)`
  Copy sub-image, src data must be tightly packed.
  `long`
  `dataAt(DrawAtlas.AtlasLocator atlasLocator)`
  `long`
  `getLastUseToken()`
  To manage the lifetime of a plot, we use last use token to determine when we can evict a plot from the cache, i.e.
  `void`
  `incFlushesSinceLastUsed()`
  `boolean`
  `needsUpload()`
  Returns true if there's dirty data.
  `int`
  `numFlushesSinceLastUsed()`
  `long`
  `prepareForUpload(Rect2i outRect)`
  Returns aligned, read-only memory address to the image data to upload, as it will be copied into a staging buffer.
  `void`
  `resetFlushesSinceLastUsed()`
  `void`
  `setLastUseToken(long token)`

  ### Methods inherited from class icyllis.arc3d.granite.DrawAtlas.PlotLocator

  `getGeneration, getPageIndex, getPlotIndex, isValid, setGeneration, setLocation, setLocation, toString`

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

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

- ## Constructor Details

  - ### Plot

    public Plot(int pageIndex, int plotIndex, DrawAtlas.AtlasGenerationCounter generationCounter, int plotX, int plotY, int width, int height, int colorType, int bpp)

- ## Method Details

  - ### close

    public void close()
    Specified by:
      `close` in interface `AutoCloseable`

  - ### addRect

    public boolean addRect(int width, int height, DrawAtlas.AtlasLocator atlasLocator)
    To add data to the Plot, first call addRect to see if it's possible. If successful, use the atlasLocator to get a pointer to the location in the atlas via `dataAt(AtlasLocator)` and render to that location, or if you already have data use `copySubImage(AtlasLocator, Object, long)`.

  - ### dataAt

    public long dataAt(DrawAtlas.AtlasLocator atlasLocator)

  - ### copySubImage

    public void copySubImage(DrawAtlas.AtlasLocator atlasLocator, Object srcBase, long srcAddr)
    Copy sub-image, src data must be tightly packed. This must be called and can only be called once after `addRect(int, int, AtlasLocator)`.

  - ### getLastUseToken

    public long getLastUseToken()
    To manage the lifetime of a plot, we use last use token to determine when we can evict a plot from the cache, i.e. if the last use has already flushed through the gpu then we can reuse the plot.

  - ### setLastUseToken

    public void setLastUseToken(long token)

  - ### numFlushesSinceLastUsed

    public int numFlushesSinceLastUsed()

  - ### incFlushesSinceLastUsed

    public void incFlushesSinceLastUsed()

  - ### resetFlushesSinceLastUsed

    public void resetFlushesSinceLastUsed()

  - ### needsUpload

    public boolean needsUpload()
    Returns true if there's dirty data.

  - ### prepareForUpload

    public long prepareForUpload(Rect2i outRect)
    Returns aligned, read-only memory address to the image data to upload, as it will be copied into a staging buffer. The sub-image region will be stored in outRect in integer texture coordinates.

  - ### clear

    public void clear()
    Reset the Plot.

    Zero out all the tracked data, `DrawAtlas.PlotLocator.getGeneration()` is incremented.