Class AbstractCompositeContext
- java.lang.Object
-
- ca.cgjennings.graphics.composites.AbstractCompositeContext
-
- All Implemented Interfaces:
java.awt.CompositeContext
public abstract class AbstractCompositeContext extends java.lang.Object implements java.awt.CompositeContext
This abstract implementation ofCompositeContext
is designed to handle RGB/ARGB data. Subclasses must implement the abstract general case method, and may optionally override other methods to provide special case code for use when theVALUE_ALPHA_INTERPOLATION_SPEED
hint is set and/or the source and destination both have 4 bands (ARGB). The context will transparently make use of multiple CPUs to increase compositing performance, so subclasses must ensure that their implementations ofcompose
methods can be called concurrently from multiple threads.- Author:
- Chris Jennings
-
-
Field Summary
Fields Modifier and Type Field Description protected float
alpha
protected java.awt.image.ColorModel
dstColorModel
protected boolean
fast
protected java.awt.RenderingHints
renderingHints
protected java.awt.image.ColorModel
srcColorModel
-
Constructor Summary
Constructors Constructor Description AbstractCompositeContext(float alpha, java.awt.image.ColorModel srcColorModel, java.awt.image.ColorModel dstColorModel, java.awt.RenderingHints hints)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static int
clamp(int a)
protected abstract void
compose(int[] src, int[] dst, int sBands, int dBands, int aFactor)
Subclasses must override this to perform general case compositing.void
compose(java.awt.image.Raster top, java.awt.image.Raster bottom, java.awt.image.WritableRaster dest)
protected void
compose44(int[] src, int[] dst, int aFactor)
This method can be overidden to provide fast special case code for images with 4 bands (A+RGB) in both source and destination.protected void
composeF44(int[] src, int[] dst, int aFactor)
This method can be overidden to provide fast special case code for images with 4 bands (A+RGB) in both source and destination when the alpha interpolation rendering hint is set for speed.protected void
composeFxx(int[] src, int[] dst, int sBands, int dBands, int aFactor)
This method can be overidden to provide fast special case code for images with variable bands in both source and destination when the alpha interpolation rendering hint is set for speed.void
dispose()
protected static int
div(int a, int b)
protected static int
fmix(int aFactor, int b)
protected static int
mix(int aFactor, int b)
protected static int
mul(int a, int b)
-
-
-
Method Detail
-
compose
public void compose(java.awt.image.Raster top, java.awt.image.Raster bottom, java.awt.image.WritableRaster dest)
- Specified by:
compose
in interfacejava.awt.CompositeContext
-
compose
protected abstract void compose(int[] src, int[] dst, int sBands, int dBands, int aFactor)
Subclasses must override this to perform general case compositing.- Parameters:
src
- the source datadst
- the destination datasBands
- the number of source bandsdBands
- the number of destination bands
-
composeFxx
protected void composeFxx(int[] src, int[] dst, int sBands, int dBands, int aFactor)
This method can be overidden to provide fast special case code for images with variable bands in both source and destination when the alpha interpolation rendering hint is set for speed. The default implementation forwards tocompose( src, dst, sBands, dBands, aFactor )
- Parameters:
src
- the source data to mixdst
- the destination to be mixed into
-
compose44
protected void compose44(int[] src, int[] dst, int aFactor)
This method can be overidden to provide fast special case code for images with 4 bands (A+RGB) in both source and destination. The default implementation forwards tocomposeF44( src, dst, aFactor )
- Parameters:
src
- the source data to mixdst
- the destination to be mixed into
-
composeF44
protected void composeF44(int[] src, int[] dst, int aFactor)
This method can be overidden to provide fast special case code for images with 4 bands (A+RGB) in both source and destination when the alpha interpolation rendering hint is set for speed. The default implementation forwards tocompose( src, dst, 4, 4, aFactor )
- Parameters:
src
- the source data to mixdst
- the destination to be mixed into
-
dispose
public void dispose()
- Specified by:
dispose
in interfacejava.awt.CompositeContext
-
clamp
protected static int clamp(int a)
-
mul
protected static int mul(int a, int b)
-
div
protected static int div(int a, int b)
-
mix
protected static int mix(int aFactor, int b)
-
fmix
protected static int fmix(int aFactor, int b)
-
-