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.CompositeContextThis abstract implementation ofCompositeContextis 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_SPEEDhint 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 ofcomposemethods can be called concurrently from multiple threads.- Author:
- Chris Jennings
-
-
Field Summary
Fields Modifier and Type Field Description protected floatalphaprotected java.awt.image.ColorModeldstColorModelprotected booleanfastprotected java.awt.RenderingHintsrenderingHintsprotected java.awt.image.ColorModelsrcColorModel
-
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 intclamp(int a)protected abstract voidcompose(int[] src, int[] dst, int sBands, int dBands, int aFactor)Subclasses must override this to perform general case compositing.voidcompose(java.awt.image.Raster top, java.awt.image.Raster bottom, java.awt.image.WritableRaster dest)protected voidcompose44(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 voidcomposeF44(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 voidcomposeFxx(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.voiddispose()protected static intdiv(int a, int b)protected static intfmix(int aFactor, int b)protected static intmix(int aFactor, int b)protected static intmul(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:
composein 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:
disposein 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)
-
-