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 java.nio.FloatBuffer; 34 import com.sun.scenario.effect.FilterContext; 35 import com.sun.scenario.effect.ImageData; 36 import com.sun.scenario.effect.Effect; 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 import com.sun.scenario.effect.impl.state.AccessHelper; 42 import com.sun.scenario.effect.impl.state.LinearConvolveKernel; 43 import com.sun.scenario.effect.impl.state.LinearConvolveKernel.PassType; 44 import com.sun.scenario.effect.impl.state.LinearConvolvePeer; 45 46 public class SSELinearConvolvePeer extends SSEEffectPeer implements LinearConvolvePeer { 47 48 public SSELinearConvolvePeer(FilterContext fctx, Renderer r, String uniqueName) { 49 super(fctx, r, uniqueName); 50 } 51 52 @Override 53 protected final Effect getEffect() { 54 return (Effect)super.getEffect(); 55 } 56 57 protected LinearConvolveKernel getKernel() { 58 return (LinearConvolveKernel) AccessHelper.getState(getEffect()); 59 } 60 61 public int getPow2ScaleX(LinearConvolveKernel kernel) { 62 return kernel.getPow2ScaleX(); 63 } 64 65 public int getPow2ScaleY(LinearConvolveKernel kernel) { 66 return kernel.getPow2ScaleY(); 67 } 68 69 @Override 70 public Rectangle getResultBounds(BaseTransform transform, 71 Rectangle outputClip, 72 ImageData... inputDatas) 73 { 74 return getKernel().getScaledResultBounds(inputDatas[0].getTransformedBounds(outputClip), getPass()); 75 } 76 77 private int getCount() { 78 return getKernel().getScaledKernelSize(getPass()); 79 } 80 81 private float[] getOffset() { 82 return getKernel().getVector(getInputNativeBounds(0), 83 getInputTransform(0), 84 getPass()); 85 } 86 87 private FloatBuffer getWeights() { 88 return getKernel().getWeights(getPass()); 89 } 90 91 @Override 92 public ImageData filter(Effect effect, 93 BaseTransform transform, 94 Rectangle outputClip, 95 ImageData... inputs) 96 { 97 setEffect(effect); 98 Rectangle dstRawBounds = getResultBounds(transform, null, inputs); 99 Rectangle dstBounds = new Rectangle(dstRawBounds); 100 dstBounds.intersectWith(outputClip); 101 setDestBounds(dstBounds); 102 int dstw = dstBounds.width; 103 int dsth = dstBounds.height; 104 105 // NOTE: for now, all input images must be TYPE_INT_ARGB_PRE 106 HeapImage src = (HeapImage)inputs[0].getUntransformedImage(); 107 int srcw = src.getPhysicalWidth(); 108 int srch = src.getPhysicalHeight(); 109 int srcscan = src.getScanlineStride(); 110 int[] srcPixels = src.getPixelArray(); 111 112 Rectangle src0Bounds = inputs[0].getUntransformedBounds(); 113 BaseTransform src0Transform = inputs[0].getTransform(); 114 Rectangle src0NativeBounds = new Rectangle(0, 0, srcw, srch); 115 // Assert: ((FilterEffect) effect).operatesInUserSpace()... 116 setInputBounds(0, src0Bounds); 117 setInputTransform(0, src0Transform); 118 setInputNativeBounds(0, src0NativeBounds); 119 120 HeapImage dst = (HeapImage)getRenderer().getCompatibleImage(dstw, dsth); 121 setDestNativeBounds(dst.getPhysicalWidth(), dst.getPhysicalHeight()); 122 int dstscan = dst.getScanlineStride(); 123 int[] dstPixels = dst.getPixelArray(); 124 125 int count = getCount(); 126 FloatBuffer weights_buf = getWeights(); 127 128 PassType type = getKernel().getPassType(getPass()); 129 if (!src0Transform.isIdentity() || 130 !dstBounds.contains(dstRawBounds.x, dstRawBounds.y)) 131 { 132 // RT-27406 133 // TODO: Fix the optimized loops to deal with non-zero srcxy0 134 // and transforms... 135 type = PassType.GENERAL_VECTOR; 136 } 137 if (type == PassType.HORIZONTAL_CENTERED) { 138 float[] weights_arr = new float[count * 2]; 139 weights_buf.get(weights_arr, 0, count); 140 weights_buf.rewind(); 141 weights_buf.get(weights_arr, count, count); 142 filterHV(dstPixels, dstw, dsth, 1, dstscan, 143 srcPixels, srcw, srch, 1, srcscan, 144 weights_arr); 145 } else if (type == PassType.VERTICAL_CENTERED) { 146 float[] weights_arr = new float[count * 2]; 147 weights_buf.get(weights_arr, 0, count); 148 weights_buf.rewind(); 158 int nCoords = getTextureCoordinates(0, srcRect, 159 src0Bounds.x, src0Bounds.y, 160 src0NativeBounds.width, 161 src0NativeBounds.height, 162 dstBounds, src0Transform); 163 float srcx0 = srcRect[0] * srcw; 164 float srcy0 = srcRect[1] * srch; 165 float dxcol, dycol, dxrow, dyrow; 166 if (nCoords < 8) { 167 dxcol = (srcRect[2] - srcRect[0]) * srcw / dstBounds.width; 168 dycol = 0f; 169 dxrow = 0f; 170 dyrow = (srcRect[3] - srcRect[1]) * srch / dstBounds.height; 171 } else { 172 dxcol = (srcRect[4] - srcRect[0]) * srcw / dstBounds.width; 173 dycol = (srcRect[5] - srcRect[1]) * srch / dstBounds.height; 174 dxrow = (srcRect[6] - srcRect[0]) * srcw / dstBounds.width; 175 dyrow = (srcRect[7] - srcRect[1]) * srch / dstBounds.height; 176 } 177 178 float[] offset_arr = getOffset(); 179 float deltax = offset_arr[0] * srcw; 180 float deltay = offset_arr[1] * srch; 181 float offsetx = offset_arr[2] * srcw; 182 float offsety = offset_arr[3] * srch; 183 184 filterVector(dstPixels, dstw, dsth, dstscan, 185 srcPixels, srcw, srch, srcscan, 186 weights_arr, count, 187 srcx0, srcy0, 188 offsetx, offsety, 189 deltax, deltay, 190 dxcol, dycol, dxrow, dyrow); 191 } 192 193 return new ImageData(getFilterContext(), dst, dstBounds); 194 } 195 196 protected native void 197 filterVector(int dstPixels[], int dstw, int dsth, int dstscan, 198 int srcPixels[], int srcw, int srch, int srcscan, 199 float weights[], int count, 200 float srcx0, float srcy0, 201 float offsetx, float offsety, 202 float deltax, float deltay, 203 float dxcol, float dycol, float dxrow, float dyrow); 204 205 /** 206 * In the nomenclature of the argument list for this method, "row" refers 207 * to the coordinate which increments once for each new stream of single 208 * axis data that we are blurring in a single pass. And "col" refers to 209 * the other coordinate that increments along the row. 210 * Rows are horizontal in the first pass and vertical in the second pass. 211 * Cols are vice versa. 212 */ 213 protected native void 214 filterHV(int dstPixels[], int dstcols, int dstrows, int dcolinc, int drowinc, 215 int srcPixels[], int srccols, int srcrows, int scolinc, int srowinc, 216 float weights[]); 217 } | 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 java.nio.FloatBuffer; 34 import com.sun.scenario.effect.FilterContext; 35 import com.sun.scenario.effect.ImageData; 36 import com.sun.scenario.effect.Effect; 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 import com.sun.scenario.effect.impl.state.LinearConvolveRenderState; 42 import com.sun.scenario.effect.impl.state.LinearConvolveRenderState.PassType; 43 44 public class SSELinearConvolvePeer extends SSEEffectPeer<LinearConvolveRenderState> { 45 46 public SSELinearConvolvePeer(FilterContext fctx, Renderer r, String uniqueName) { 47 super(fctx, r, uniqueName); 48 } 49 50 @Override 51 public ImageData filter(Effect effect, 52 LinearConvolveRenderState lcrstate, 53 BaseTransform transform, 54 Rectangle outputClip, 55 ImageData... inputs) 56 { 57 setRenderState(lcrstate); 58 Rectangle dstRawBounds = inputs[0].getTransformedBounds(null); 59 dstRawBounds = lcrstate.getPassResultBounds(dstRawBounds); 60 Rectangle dstBounds = new Rectangle(dstRawBounds); 61 dstBounds.intersectWith(outputClip); 62 setDestBounds(dstBounds); 63 int dstw = dstBounds.width; 64 int dsth = dstBounds.height; 65 66 // NOTE: for now, all input images must be TYPE_INT_ARGB_PRE 67 HeapImage src = (HeapImage)inputs[0].getUntransformedImage(); 68 int srcw = src.getPhysicalWidth(); 69 int srch = src.getPhysicalHeight(); 70 int srcscan = src.getScanlineStride(); 71 int[] srcPixels = src.getPixelArray(); 72 73 Rectangle src0Bounds = inputs[0].getUntransformedBounds(); 74 BaseTransform src0Transform = inputs[0].getTransform(); 75 Rectangle src0NativeBounds = new Rectangle(0, 0, srcw, srch); 76 // Assert: rstate.getEffectTransformSpace() == UserSpace 77 setInputBounds(0, src0Bounds); 78 setInputTransform(0, src0Transform); 79 setInputNativeBounds(0, src0NativeBounds); 80 81 HeapImage dst = (HeapImage)getRenderer().getCompatibleImage(dstw, dsth); 82 setDestNativeBounds(dst.getPhysicalWidth(), dst.getPhysicalHeight()); 83 int dstscan = dst.getScanlineStride(); 84 int[] dstPixels = dst.getPixelArray(); 85 86 int count = lcrstate.getPassKernelSize(); 87 FloatBuffer weights_buf = lcrstate.getPassWeights(); 88 89 PassType type = lcrstate.getPassType(); 90 if (!src0Transform.isIdentity() || 91 !dstBounds.contains(dstRawBounds.x, dstRawBounds.y)) 92 { 93 // RT-27406 94 // TODO: Fix the optimized loops to deal with non-zero srcxy0 95 // and transforms... 96 type = PassType.GENERAL_VECTOR; 97 } 98 if (type == PassType.HORIZONTAL_CENTERED) { 99 float[] weights_arr = new float[count * 2]; 100 weights_buf.get(weights_arr, 0, count); 101 weights_buf.rewind(); 102 weights_buf.get(weights_arr, count, count); 103 filterHV(dstPixels, dstw, dsth, 1, dstscan, 104 srcPixels, srcw, srch, 1, srcscan, 105 weights_arr); 106 } else if (type == PassType.VERTICAL_CENTERED) { 107 float[] weights_arr = new float[count * 2]; 108 weights_buf.get(weights_arr, 0, count); 109 weights_buf.rewind(); 119 int nCoords = getTextureCoordinates(0, srcRect, 120 src0Bounds.x, src0Bounds.y, 121 src0NativeBounds.width, 122 src0NativeBounds.height, 123 dstBounds, src0Transform); 124 float srcx0 = srcRect[0] * srcw; 125 float srcy0 = srcRect[1] * srch; 126 float dxcol, dycol, dxrow, dyrow; 127 if (nCoords < 8) { 128 dxcol = (srcRect[2] - srcRect[0]) * srcw / dstBounds.width; 129 dycol = 0f; 130 dxrow = 0f; 131 dyrow = (srcRect[3] - srcRect[1]) * srch / dstBounds.height; 132 } else { 133 dxcol = (srcRect[4] - srcRect[0]) * srcw / dstBounds.width; 134 dycol = (srcRect[5] - srcRect[1]) * srch / dstBounds.height; 135 dxrow = (srcRect[6] - srcRect[0]) * srcw / dstBounds.width; 136 dyrow = (srcRect[7] - srcRect[1]) * srch / dstBounds.height; 137 } 138 139 float[] offset_arr = lcrstate.getPassVector(); 140 float deltax = offset_arr[0] * srcw; 141 float deltay = offset_arr[1] * srch; 142 float offsetx = offset_arr[2] * srcw; 143 float offsety = offset_arr[3] * srch; 144 145 filterVector(dstPixels, dstw, dsth, dstscan, 146 srcPixels, srcw, srch, srcscan, 147 weights_arr, count, 148 srcx0, srcy0, 149 offsetx, offsety, 150 deltax, deltay, 151 dxcol, dycol, dxrow, dyrow); 152 } 153 154 return new ImageData(getFilterContext(), dst, dstBounds); 155 } 156 157 protected native void 158 filterVector(int dstPixels[], int dstw, int dsth, int dstscan, 159 int srcPixels[], int srcw, int srch, int srcscan, 160 float weights[], int count, 161 float srcx0, float srcy0, 162 float offsetx, float offsety, 163 float deltax, float deltay, 164 float dxcol, float dycol, float dxrow, float dyrow); 165 166 /* 167 * In the nomenclature of the argument list for this method, "row" refers 168 * to the coordinate which increments once for each new stream of single 169 * axis data that we are blurring in a single pass. And "col" refers to 170 * the other coordinate that increments along the row. 171 * Rows are horizontal in the first pass and vertical in the second pass. 172 * Cols are vice versa. 173 */ 174 protected native void 175 filterHV(int dstPixels[], int dstcols, int dstrows, int dcolinc, int drowinc, 176 int srcPixels[], int srccols, int srcrows, int scolinc, int srowinc, 177 float weights[]); 178 } |