The raster source provides the ability to supply arbitrary pixel data whilst rendering. The pixels are queried at the time of rasterisation by means of user callback functions, allowing for the ultimate flexibility. For example, in handling compressed image sources, you may keep a MRU cache of decompressed images and decompress sources on the fly and discard old ones to conserve memory.
For the raster source to be effective, you must at least specify the acquire and release callbacks which are used to retrieve the pixel data for the region of interest and demark when it can be freed afterwards. Other callbacks are provided for when the pattern is copied temporarily during rasterisation, or more permanently as a snapshot in order to keep the pixel data available for printing.
-
Constructor Summary
ConstructorDescriptionRasterSource
(MemorySegment address) Constructor used internally to instantiate a java RasterSource object for a nativecairo_pattern_t
instance -
Method Summary
Modifier and TypeMethodDescriptionstatic RasterSource
Creates a new user pattern for providing pixel data.Queries the current acquire callbackgetCopy()
Queries the current copy callback.Queries the current finish callback.Queries the current release callback.Queries the current snapshot callback.void
setAcquire
(RasterSourceAcquireFunc acquire, RasterSourceReleaseFunc release) Specifies the callbacks used to generate the image surface for a rendering operation (acquire) and the function used to cleanup that surface afterwards.void
setCopy
(RasterSourceCopyFunc copy) Updates the copy callback which is used whenever a temporary copy of the pattern is taken.void
setFinish
(RasterSourceFinishFunc finish) Updates the finish callback which is used whenever a pattern (or a copy thereof) will no longer be used.void
setSnapshot
(RasterSourceSnapshotFunc snapshot) Sets the callback that will be used whenever a snapshot is taken of the pattern, that is whenever the current contents of the pattern should be preserved for later use.Methods inherited from class org.freedesktop.cairo.Pattern
destroy, getDither, getExtend, getFilter, getMatrix, getPatternType, getType, getUserData, setDither, setExtend, setFilter, setMatrix, setUserData, status
-
Constructor Details
-
RasterSource
Constructor used internally to instantiate a java RasterSource object for a nativecairo_pattern_t
instance- Parameters:
address
- the memory address of the nativecairo_pattern_t
instance
-
-
Method Details
-
create
Creates a new user pattern for providing pixel data.Use the setter functions to associate callbacks with the returned pattern. The only mandatory callback is acquire.
- Parameters:
content
- content type for the pixel data that will be returned. Knowing the content type ahead of time is used for analysing the operation and picking the appropriate rendering path.width
- maximum size of the sample areaheight
- maximum size of the sample area- Returns:
- a newly created
Pattern
of typeRasterSource
- Since:
- 1.2
-
setAcquire
Specifies the callbacks used to generate the image surface for a rendering operation (acquire) and the function used to cleanup that surface afterwards.The
acquire
callback should create a surface (preferably an image surface created to match the target usingSurface.createSimilarImage(Surface, Format, int, int)
) that defines at least the region of interest specified by extents. The surface is allowed to be the entire sample area, but if it does contain a subsection of the sample area, the surface extents should be provided by setting the device offset (along with its width and height) usingSurface.setDeviceOffset(double, double)
.- Parameters:
acquire
- acquire callbackrelease
- release callback- Since:
- 1.12
-
getAcquire
Queries the current acquire callback- Returns:
- the current acquire callback
- Since:
- 1.2
-
getRelease
Queries the current release callback.- Returns:
- the current release callback
- Since:
- 1.2
-
setSnapshot
Sets the callback that will be used whenever a snapshot is taken of the pattern, that is whenever the current contents of the pattern should be preserved for later use. This is typically invoked whilst printing.- Parameters:
snapshot
- the pattern to update- Since:
- 1.12
-
getSnapshot
Queries the current snapshot callback.- Returns:
- the current snapshot callback
- Since:
- 1.12
-
setCopy
Updates the copy callback which is used whenever a temporary copy of the pattern is taken.- Parameters:
copy
- the copy callback- Since:
- 1.12
-
getCopy
Queries the current copy callback.- Returns:
- the current copy callback
- Since:
- 1.12
-
setFinish
Updates the finish callback which is used whenever a pattern (or a copy thereof) will no longer be used.- Parameters:
finish
- the finish callback- Since:
- 1.12
-
getFinish
Queries the current finish callback.- Returns:
- the current finish callback
- Since:
- 1.12
-