JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
com.jogamp.opengl.util.packrect.RectanglePacker Class Reference

Packs rectangles supplied by the user (typically representing image regions) into a larger backing store rectangle (typically representing a large texture). More...

Collaboration diagram for com.jogamp.opengl.util.packrect.RectanglePacker:

Classes

class  RectHComparator
 

Public Member Functions

 RectanglePacker (final BackingStoreManager manager, final int initialWidth, final int initialHeight)
 
Object getBackingStore ()
 
void setMaxSize (final int maxWidth, final int maxHeight)
 Sets up a maximum width and height for the backing store. More...
 
void add (final Rect rect) throws RuntimeException
 Decides upon an (x, y) position for the given rectangle (leaving its width and height unchanged) and places it on the backing store. More...
 
void remove (final Rect rect)
 Removes the given rectangle from this RectanglePacker. More...
 
void visit (final RectVisitor visitor)
 Visits all Rects contained in this RectanglePacker. More...
 
float verticalFragmentationRatio ()
 Returns the vertical fragmentation ratio of this RectanglePacker. More...
 
void compact ()
 Forces a compaction cycle, which typically results in allocating a new backing store and copying all entries to it. More...
 
void clear ()
 Clears all Rects contained in this RectanglePacker. More...
 
void dispose ()
 Disposes the backing store allocated by the BackingStoreManager. More...
 

Detailed Description

Packs rectangles supplied by the user (typically representing image regions) into a larger backing store rectangle (typically representing a large texture).

Supports automatic compaction of the space on the backing store, and automatic expansion of the backing store, when necessary.

Definition at line 50 of file RectanglePacker.java.

Constructor & Destructor Documentation

◆ RectanglePacker()

com.jogamp.opengl.util.packrect.RectanglePacker.RectanglePacker ( final BackingStoreManager  manager,
final int  initialWidth,
final int  initialHeight 
)

Definition at line 76 of file RectanglePacker.java.

Member Function Documentation

◆ add()

void com.jogamp.opengl.util.packrect.RectanglePacker.add ( final Rect  rect) throws RuntimeException

Decides upon an (x, y) position for the given rectangle (leaving its width and height unchanged) and places it on the backing store.

May provoke re-layout of other Rects already added. If the BackingStoreManager does not support compaction, and BackingStoreManager.preExpand does not clear enough space for the incoming rectangle, then this method will throw a RuntimeException.

Definition at line 110 of file RectanglePacker.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void com.jogamp.opengl.util.packrect.RectanglePacker.clear ( )

Clears all Rects contained in this RectanglePacker.

Definition at line 293 of file RectanglePacker.java.

Here is the call graph for this function:

◆ compact()

void com.jogamp.opengl.util.packrect.RectanglePacker.compact ( )

Forces a compaction cycle, which typically results in allocating a new backing store and copying all entries to it.

Definition at line 166 of file RectanglePacker.java.

◆ dispose()

void com.jogamp.opengl.util.packrect.RectanglePacker.dispose ( )

Disposes the backing store allocated by the BackingStoreManager.

This RectanglePacker may no longer be used after calling this method.

Definition at line 300 of file RectanglePacker.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBackingStore()

Object com.jogamp.opengl.util.packrect.RectanglePacker.getBackingStore ( )

Definition at line 85 of file RectanglePacker.java.

Here is the call graph for this function:

◆ remove()

void com.jogamp.opengl.util.packrect.RectanglePacker.remove ( final Rect  rect)

Removes the given rectangle from this RectanglePacker.

Definition at line 146 of file RectanglePacker.java.

Here is the call graph for this function:

◆ setMaxSize()

void com.jogamp.opengl.util.packrect.RectanglePacker.setMaxSize ( final int  maxWidth,
final int  maxHeight 
)

Sets up a maximum width and height for the backing store.

These are optional and if not specified the backing store will grow as necessary. Setting up a maximum width and height introduces the possibility that additions will fail; these are handled with the BackingStoreManager's allocationFailed notification.

Definition at line 98 of file RectanglePacker.java.

◆ verticalFragmentationRatio()

float com.jogamp.opengl.util.packrect.RectanglePacker.verticalFragmentationRatio ( )

Returns the vertical fragmentation ratio of this RectanglePacker.

This is defined as the ratio of the sum of the heights of all completely empty Levels divided by the overall used height of the LevelSet. A high vertical fragmentation ratio indicates that it may be profitable to perform a compaction.

Definition at line 160 of file RectanglePacker.java.

Here is the call graph for this function:

◆ visit()

void com.jogamp.opengl.util.packrect.RectanglePacker.visit ( final RectVisitor  visitor)

Visits all Rects contained in this RectanglePacker.

Definition at line 151 of file RectanglePacker.java.

Here is the call graph for this function:

The documentation for this class was generated from the following file: