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
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
kMaxPages, kMaxPlots -
Constructor Summary
ConstructorsConstructorDescriptionPlot(int pageIndex, int plotIndex, DrawAtlas.AtlasGenerationCounter generationCounter, int plotX, int plotY, int width, int height, int colorType, int bpp) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddRect(int width, int height, DrawAtlas.AtlasLocator atlasLocator) To add data to the Plot, first call addRect to see if it's possible.voidclear()Reset the Plot.voidclose()voidcopySubImage(DrawAtlas.AtlasLocator atlasLocator, Object srcBase, long srcAddr) Copy sub-image, src data must be tightly packed.longdataAt(DrawAtlas.AtlasLocator atlasLocator) longTo manage the lifetime of a plot, we use last use token to determine when we can evict a plot from the cache, i.e.voidbooleanReturns true if there's dirty data.intlongprepareForUpload(Rect2i outRect) Returns aligned, read-only memory address to the image data to upload, as it will be copied into a staging buffer.voidvoidsetLastUseToken(long token) Methods inherited from class icyllis.arc3d.granite.DrawAtlas.PlotLocator
getGeneration, getPageIndex, getPlotIndex, isValid, setGeneration, setLocation, setLocation, toString
-
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:
closein interfaceAutoCloseable
-
addRect
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 viadataAt(AtlasLocator)and render to that location, or if you already have data usecopySubImage(AtlasLocator, Object, long). -
dataAt
-
copySubImage
Copy sub-image, src data must be tightly packed. This must be called and can only be called once afteraddRect(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
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.
-