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 package com.sun.scenario.effect.impl.prism; 27 28 import com.sun.javafx.geom.Rectangle; 29 import com.sun.javafx.geom.transform.BaseTransform; 30 import com.sun.prism.Graphics; 31 import com.sun.scenario.effect.Effect; 32 import com.sun.scenario.effect.FilterContext; 33 import com.sun.scenario.effect.ImageData; 34 import com.sun.scenario.effect.impl.EffectPeer; 35 import com.sun.scenario.effect.impl.Renderer; 36 37 public class PrCropPeer extends EffectPeer { 38 39 public PrCropPeer(FilterContext fctx, Renderer r, String uniqueName) { 40 super(fctx, r, uniqueName); 41 } 42 43 @Override 44 public ImageData filter(Effect effect, 45 BaseTransform transform, 46 Rectangle outputClip, 47 ImageData... inputs) 48 { 49 FilterContext fctx = getFilterContext(); 50 ImageData srcData = inputs[0]; 51 Rectangle srcBounds = srcData.getTransformedBounds(null); 52 if (outputClip.contains(srcBounds)) { 53 srcData.addref(); 54 return srcData; 55 } 56 57 Rectangle dstBounds = new Rectangle(srcBounds); 58 dstBounds.intersectWith(outputClip); 59 int w = dstBounds.width; 60 int h = dstBounds.height; 61 PrDrawable dst = (PrDrawable)getRenderer().getCompatibleImage(w, h); 62 63 if (!srcData.validate(fctx) || dst == null) { 64 dst = null; | 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 package com.sun.scenario.effect.impl.prism; 27 28 import com.sun.javafx.geom.Rectangle; 29 import com.sun.javafx.geom.transform.BaseTransform; 30 import com.sun.prism.Graphics; 31 import com.sun.scenario.effect.Effect; 32 import com.sun.scenario.effect.FilterContext; 33 import com.sun.scenario.effect.ImageData; 34 import com.sun.scenario.effect.impl.EffectPeer; 35 import com.sun.scenario.effect.impl.Renderer; 36 import com.sun.scenario.effect.impl.state.RenderState; 37 38 public class PrCropPeer extends EffectPeer { 39 40 public PrCropPeer(FilterContext fctx, Renderer r, String uniqueName) { 41 super(fctx, r, uniqueName); 42 } 43 44 @Override 45 public ImageData filter(Effect effect, 46 RenderState rstate, 47 BaseTransform transform, 48 Rectangle outputClip, 49 ImageData... inputs) 50 { 51 FilterContext fctx = getFilterContext(); 52 ImageData srcData = inputs[0]; 53 Rectangle srcBounds = srcData.getTransformedBounds(null); 54 if (outputClip.contains(srcBounds)) { 55 srcData.addref(); 56 return srcData; 57 } 58 59 Rectangle dstBounds = new Rectangle(srcBounds); 60 dstBounds.intersectWith(outputClip); 61 int w = dstBounds.width; 62 int h = dstBounds.height; 63 PrDrawable dst = (PrDrawable)getRenderer().getCompatibleImage(w, h); 64 65 if (!srcData.validate(fctx) || dst == null) { 66 dst = null; |