Class AbstractCompositeContext

  • All Implemented Interfaces:
    java.awt.CompositeContext

    public abstract class AbstractCompositeContext
    extends java.lang.Object
    implements java.awt.CompositeContext
    This abstract implementation of CompositeContext 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 the VALUE_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 of compose 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • alpha

        protected final float alpha
      • srcColorModel

        protected final java.awt.image.ColorModel srcColorModel
      • dstColorModel

        protected final java.awt.image.ColorModel dstColorModel
      • renderingHints

        protected final java.awt.RenderingHints renderingHints
      • fast

        protected final boolean fast
    • Constructor Detail

      • AbstractCompositeContext

        public AbstractCompositeContext​(float alpha,
                                        java.awt.image.ColorModel srcColorModel,
                                        java.awt.image.ColorModel dstColorModel,
                                        java.awt.RenderingHints hints)
    • 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 interface java.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 data
        dst - the destination data
        sBands - the number of source bands
        dBands - 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 to compose( src, dst, sBands, dBands, aFactor )
        Parameters:
        src - the source data to mix
        dst - 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 to composeF44( src, dst, aFactor )
        Parameters:
        src - the source data to mix
        dst - 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 to compose( src, dst, 4, 4, aFactor )
        Parameters:
        src - the source data to mix
        dst - the destination to be mixed into
      • dispose

        public void dispose()
        Specified by:
        dispose in interface java.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)