1 group JSWGlue; 2 3 glue(effectName,peerName,interfaceDecl, 4 usercode,samplers,cleanup,srcRects,constants, 5 pixInitY,pixInitX,posDecls,posInitY,posIncrY,posInitX,posIncrX, 6 body) ::= << 7 /* 8 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. 9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10 * 11 * This code is free software; you can redistribute it and/or modify it 12 * under the terms of the GNU General Public License version 2 only, as 13 * published by the Free Software Foundation. Oracle designates this 14 * particular file as subject to the "Classpath" exception as provided 15 * by Oracle in the LICENSE file that accompanied this code. 16 * 17 * This code is distributed in the hope that it will be useful, but WITHOUT 18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 * version 2 for more details (a copy is included in the LICENSE file that 21 * accompanied this code). 22 * 23 * You should have received a copy of the GNU General Public License version 24 * 2 along with this work; if not, write to the Free Software Foundation, 25 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26 * 27 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 28 * or visit www.oracle.com if you need additional information or have any 29 * questions. 30 */ 31 32 /* 33 * This file was generated by JSLC -- DO NOT EDIT MANUALLY! 34 */ 35 36 package com.sun.scenario.effect.impl.sw.java; 37 38 import java.nio.FloatBuffer; 39 import java.nio.IntBuffer; 40 import com.sun.scenario.effect.Effect; 41 import com.sun.scenario.effect.FilterContext; 42 import com.sun.scenario.effect.FloatMap; 43 import com.sun.scenario.effect.ImageData; 44 import com.sun.scenario.effect.$effectName$; 45 import com.sun.scenario.effect.impl.BufferUtil; 46 import com.sun.scenario.effect.impl.HeapImage; 47 import com.sun.scenario.effect.impl.Renderer; 48 import com.sun.scenario.effect.impl.state.*; 49 import com.sun.javafx.geom.Rectangle; 50 import com.sun.javafx.geom.transform.BaseTransform; 51 52 public class JSW$peerName$Peer extends JSWEffectPeer $interfaceDecl$ { 53 54 public JSW$peerName$Peer(FilterContext fctx, Renderer r, String uniqueName) { 55 super(fctx, r, uniqueName); 56 } 57 58 @Override 59 protected final $effectName$ getEffect() { 60 return ($effectName$)super.getEffect(); 61 } 62 63 $usercode$ 64 65 @Override 66 public ImageData filter(Effect effect, 67 BaseTransform transform, 68 Rectangle outputClip, 69 ImageData... inputs) 70 { 71 setEffect(effect); 72 Rectangle dstBounds = getResultBounds(transform, outputClip, inputs); 73 setDestBounds(dstBounds); 74 75 // TODO: for now, all input images must be TYPE_INT_ARGB_PRE 76 $samplers$ 77 78 $srcRects$ 79 80 final int dstx = 0; 81 final int dsty = 0; 82 final int dstw = dstBounds.width; 83 final int dsth = dstBounds.height; 84 85 HeapImage dst = (HeapImage)getRenderer().getCompatibleImage(dstw, dsth); 86 setDestNativeBounds(dst.getPhysicalWidth(), dst.getPhysicalHeight()); 87 int dstscan = dst.getScanlineStride(); 88 int[] dstPixels = dst.getPixelArray(); 89 90 int dyi; 91 float color_x, color_y, color_z, color_w; 92 93 $constants$ 94 95 $posDecls$ 96 97 $posInitY$ 98 for (int dy = dsty; dy < dsty+dsth; dy++) { 99 $pixInitY$ 100 dyi = dy*dstscan; 101 102 $posInitX$ 103 for (int dx = dstx; dx < dstx+dstw; dx++) { 104 $pixInitX$ 105 106 $body$ 107 108 if (color_w < 0f) color_w = 0f; else if (color_w > 1f) color_w = 1f; 109 if (color_x < 0f) color_x = 0f; else if (color_x > color_w) color_x = color_w; 110 if (color_y < 0f) color_y = 0f; else if (color_y > color_w) color_y = color_w; 111 if (color_z < 0f) color_z = 0f; else if (color_z > color_w) color_z = color_w; 112 dstPixels[dyi+dx] = 113 ((int)(color_x * 0xff) << 16) | 114 ((int)(color_y * 0xff) << 8) | 115 ((int)(color_z * 0xff) << 0) | 116 ((int)(color_w * 0xff) << 24); 117 118 $posIncrX$ 119 } 120 121 $posIncrY$ 122 } 123 124 $cleanup$ 125 126 return new ImageData(getFilterContext(), dst, dstBounds); 127 } 128 } 129 130 >>