7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 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 private LinearConvolveKernel getKernel() { 28 return (LinearConvolveKernel) AccessHelper.getState(getEffect()); 29 } 30 31 public int getPow2ScaleX(LinearConvolveKernel kernel) { 32 return kernel.getPow2ScaleX(); 33 } 34 35 public int getPow2ScaleY(LinearConvolveKernel kernel) { 36 return kernel.getPow2ScaleY(); 37 } 38 39 public Rectangle getResultBounds(com.sun.javafx.geom.transform.BaseTransform transform, 40 com.sun.javafx.geom.Rectangle outputClip, 41 com.sun.scenario.effect.ImageData... inputDatas) 42 { 43 return getKernel().getScaledResultBounds(inputDatas[0].getTransformedBounds(outputClip), getPass()); 44 } 45 46 private int getCount() { 47 return (getKernel().getScaledKernelSize(getPass()) + 3) / 4; 48 } 49 50 private float[] getOffset() { 51 return getKernel().getVector(getInputNativeBounds(0), getInputTransform(0), getPass()); 52 } 53 54 private FloatBuffer getWeights() { 55 return getKernel().getWeights(getPass()); 56 } 57 58 private int getWeightsArrayLength() { 59 return getKernel().getWeightsArrayLength(getPass()); 60 } 61 62 private float[] getShadowColor() { 63 return getKernel().getShadowColorComponents(getPass()); 64 } 65 >> 66 67 param sampler img; 68 param int count; 69 // offset.x = dx offset between adjacent weighted convolution samples 70 // offset.y = dy offset between adjacent weighted convolution samples 71 // offset.z = dx offset to first weighted convolution sample 72 // offset.w = dy offset to first weighted convolution sample 73 param float4 offset; 74 param float4 shadowColor; 75 // value for each location in the offsets array: 76 // weights[i].x = weight for pos0 + offset + i*direction*4+0 77 // weights[i].y = weight for pos0 + offset + i*direction*4+1 78 // weights[i].z = weight for pos0 + offset + i*direction*4+2 79 // weights[i].w = weight for pos0 + offset + i*direction*4+3 80 param float4 weights[%d]; 81 82 void main() 83 { 84 int i; 85 float sum = 0.0; 86 float2 loc = pos0 + offset.zw; 87 unroll (%d, 0) for (i = 0; i < count; i++) { 88 sum += weights[i].x * sample(img, loc).a; 89 loc += offset.xy; 90 sum += weights[i].y * sample(img, loc).a; 91 loc += offset.xy; 92 sum += weights[i].z * sample(img, loc).a; 93 loc += offset.xy; 94 sum += weights[i].w * sample(img, loc).a; 95 loc += offset.xy; 96 } 97 sum = clamp(sum, 0.0, 1.0); 98 color = sum * shadowColor; 99 } | 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 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 public Rectangle getResultBounds(com.sun.javafx.geom.transform.BaseTransform transform, 28 com.sun.javafx.geom.Rectangle outputClip, 29 com.sun.scenario.effect.ImageData... inputDatas) 30 { 31 return getRenderState().getPassResultBounds(inputDatas[0].getTransformedBounds(outputClip)); 32 } 33 34 private int getCount() { 35 return (getRenderState().getPassKernelSize() + 3) / 4; 36 } 37 38 private float[] getOffset() { 39 return getRenderState().getPassVector(); 40 } 41 42 private FloatBuffer getWeights() { 43 return getRenderState().getPassWeights(); 44 } 45 46 private int getWeightsArrayLength() { 47 return getRenderState().getPassWeightsArrayLength(); 48 } 49 50 private float[] getShadowColor() { 51 return getRenderState().getPassShadowColorComponents(); 52 } 53 >> 54 55 param sampler img; 56 param int count; 57 // offset.x = dx offset between adjacent weighted convolution samples 58 // offset.y = dy offset between adjacent weighted convolution samples 59 // offset.z = dx offset to first weighted convolution sample 60 // offset.w = dy offset to first weighted convolution sample 61 param float4 offset; 62 param float4 shadowColor; 63 // value for each location in the offsets array: 64 // weights[i].x = weight for pos0 + offset.zw + (i*4+0)*offset.xy 65 // weights[i].y = weight for pos0 + offset.zw + (i*4+1)*offset.xy 66 // weights[i].z = weight for pos0 + offset.zw + (i*4+2)*offset.xy 67 // weights[i].w = weight for pos0 + offset.zw + (i*4+3)*offset.xy 68 param float4 weights[%d]; 69 70 void main() 71 { 72 int i; 73 float sum = 0.0; 74 float2 loc = pos0 + offset.zw; 75 unroll (%d, 0) for (i = 0; i < count; i++) { 76 sum += weights[i].x * sample(img, loc).a; 77 loc += offset.xy; 78 sum += weights[i].y * sample(img, loc).a; 79 loc += offset.xy; 80 sum += weights[i].z * sample(img, loc).a; 81 loc += offset.xy; 82 sum += weights[i].w * sample(img, loc).a; 83 loc += offset.xy; 84 } 85 sum = clamp(sum, 0.0, 1.0); 86 color = sum * shadowColor; 87 } |