modules/graphics/src/main/java/com/sun/scenario/effect/impl/sw/sse/SSEBoxBlurPeer.java

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * This file was originally generated by JSLC
  28  * and then hand edited for performance.
  29  */
  30 
  31 package com.sun.scenario.effect.impl.sw.sse;
  32 
  33 import com.sun.scenario.effect.Effect;
  34 import com.sun.scenario.effect.FilterContext;
  35 import com.sun.scenario.effect.ImageData;
  36 import com.sun.scenario.effect.BoxBlur;
  37 import com.sun.scenario.effect.impl.HeapImage;
  38 import com.sun.scenario.effect.impl.Renderer;
  39 import com.sun.javafx.geom.Rectangle;
  40 import com.sun.javafx.geom.transform.BaseTransform;

  41 
  42 public class SSEBoxBlurPeer extends SSEEffectPeer {
  43 
  44     public SSEBoxBlurPeer(FilterContext fctx, Renderer r, String uniqueName) {
  45         super(fctx, r, uniqueName);
  46     }
  47 
  48     @Override
  49     protected final BoxBlur getEffect() {
  50         return (BoxBlur)super.getEffect();
  51     }
  52 
  53     @Override
  54     public ImageData filter(Effect effect,

  55                             BaseTransform transform,
  56                             Rectangle outputClip,
  57                             ImageData... inputs)
  58     {
  59         setEffect(effect);
  60 
  61         // NOTE: for now, all input images must be TYPE_INT_ARGB_PRE
  62 
  63         boolean horizontal = (getPass() == 0);
  64 
  65         // Calculate the amount the image grows on each iteration (size-1)
  66         int hinc = horizontal ? getEffect().getHorizontalSize() - 1 : 0;
  67         int vinc = horizontal ? 0 : getEffect().getVerticalSize() - 1;
  68         int iterations = getEffect().getPasses();
  69         if (iterations < 1 || (hinc < 1 && vinc < 1)) {
  70             inputs[0].addref();
  71             return inputs[0];
  72         }
  73         // Calculate the amount the image will grow through the full operation
  74         // Always upgrade to the next even amount of growth
  75         int growx = (hinc * iterations + 1) & (~0x1);
  76         int growy = (vinc * iterations + 1) & (~0x1);
  77 
  78         // Assert: ((FilterEffect) effect).operatesInUserSpace()...
  79         // NOTE: We could still have a transformed ImageData for other reasons...
  80         HeapImage src = (HeapImage)inputs[0].getUntransformedImage();
  81         Rectangle srcr = inputs[0].getUntransformedBounds();
  82 
  83         HeapImage cur = src;
  84         int curw = srcr.width;
  85         int curh = srcr.height;
  86         int curscan = cur.getScanlineStride();
  87         int[] curPixels = cur.getPixelArray();
  88 
  89         int finalw = curw + growx;
  90         int finalh = curh + growy;
  91         while (curw < finalw || curh < finalh) {
  92             int neww = curw + hinc;
  93             int newh = curh + vinc;
  94             if (neww > finalw) neww = finalw;
  95             if (newh > finalh) newh = finalh;
  96             HeapImage dst = (HeapImage)getRenderer().getCompatibleImage(neww, newh);
  97             int newscan = dst.getScanlineStride();
  98             int[] newPixels = dst.getPixelArray();




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * This file was originally generated by JSLC
  28  * and then hand edited for performance.
  29  */
  30 
  31 package com.sun.scenario.effect.impl.sw.sse;
  32 
  33 import com.sun.scenario.effect.Effect;
  34 import com.sun.scenario.effect.FilterContext;
  35 import com.sun.scenario.effect.ImageData;

  36 import com.sun.scenario.effect.impl.HeapImage;
  37 import com.sun.scenario.effect.impl.Renderer;
  38 import com.sun.javafx.geom.Rectangle;
  39 import com.sun.javafx.geom.transform.BaseTransform;
  40 import com.sun.scenario.effect.impl.state.BoxRenderState;
  41 
  42 public class SSEBoxBlurPeer extends SSEEffectPeer<BoxRenderState> {
  43 
  44     public SSEBoxBlurPeer(FilterContext fctx, Renderer r, String uniqueName) {
  45         super(fctx, r, uniqueName);
  46     }
  47 
  48     @Override





  49     public ImageData filter(Effect effect,
  50                             BoxRenderState brstate,
  51                             BaseTransform transform,
  52                             Rectangle outputClip,
  53                             ImageData... inputs)
  54     {
  55         setRenderState(brstate);

  56         // NOTE: for now, all input images must be TYPE_INT_ARGB_PRE
  57 
  58         boolean horizontal = (getPass() == 0);
  59 
  60         // Calculate the amount the image grows on each iteration (size-1)
  61         int hinc = horizontal ? brstate.getBoxPixelSize(0) - 1 : 0;
  62         int vinc = horizontal ? 0 : brstate.getBoxPixelSize(1) - 1;
  63         int iterations = brstate.getBlurPasses();
  64         if (iterations < 1 || (hinc < 1 && vinc < 1)) {
  65             inputs[0].addref();
  66             return inputs[0];
  67         }
  68         // Calculate the amount the image will grow through the full operation
  69         // Always upgrade to the next even amount of growth
  70         int growx = (hinc * iterations + 1) & (~0x1);
  71         int growy = (vinc * iterations + 1) & (~0x1);
  72 
  73         // Assert: rstate.getEffectTransformSpace() == UserSpace
  74         // NOTE: We could still have a transformed ImageData for other reasons...
  75         HeapImage src = (HeapImage)inputs[0].getUntransformedImage();
  76         Rectangle srcr = inputs[0].getUntransformedBounds();
  77 
  78         HeapImage cur = src;
  79         int curw = srcr.width;
  80         int curh = srcr.height;
  81         int curscan = cur.getScanlineStride();
  82         int[] curPixels = cur.getPixelArray();
  83 
  84         int finalw = curw + growx;
  85         int finalh = curh + growy;
  86         while (curw < finalw || curh < finalh) {
  87             int neww = curw + hinc;
  88             int newh = curh + vinc;
  89             if (neww > finalw) neww = finalw;
  90             if (newh > finalh) newh = finalh;
  91             HeapImage dst = (HeapImage)getRenderer().getCompatibleImage(neww, newh);
  92             int newscan = dst.getScanlineStride();
  93             int[] newPixels = dst.getPixelArray();