1 /*
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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
214
215 return (XRSurfaceData) srcData;
216 }
217
218 @Override
219 boolean isPaintValid(SunGraphics2D sg2d) {
220 TexturePaint paint = (TexturePaint) sg2d.paint;
221 BufferedImage bi = paint.getImage();
222 XRSurfaceData dstData = (XRSurfaceData) sg2d.getDestSurface();
223
224 return getAccSrcSurface(dstData, bi) != null;
225 }
226
227 @Override
228 void setXRPaint(SunGraphics2D sg2d, Paint pt) {
229 TexturePaint paint = (TexturePaint) pt;
230 BufferedImage bi = paint.getImage();
231 Rectangle2D anchor = paint.getAnchorRect();
232
233 XRSurfaceData dstData = (XRSurfaceData) sg2d.surfaceData;
234 XRSurfaceData srcData = (XRSurfaceData) getAccSrcSurface(dstData, bi);
235
236 AffineTransform at = new AffineTransform();
237 at.translate(anchor.getX(), anchor.getY());
238 at.scale(anchor.getWidth() / ((double) bi.getWidth()), anchor.getHeight() / ((double) bi.getHeight()));
239
240 try {
241 at.invert();
242 } catch (NoninvertibleTransformException ex) {
243 at.setToIdentity();
244 }
245 srcData.setStaticSrcTx(at);
246
247 srcData.validateAsSource(at, XRUtils.RepeatNormal, XRUtils.ATransOpToXRQuality(sg2d.interpolationType));
248 xrCompMan.setTexturePaint(srcData);
249 }
250 }
251
252 public int[] convertToIntArgbPixels(Color[] colors) {
253 int[] pixels = new int[colors.length];
254 for (int i = 0; i < colors.length; i++) {
255 pixels[i] = colorToIntArgbPixel(colors[i]);
256 }
257 return pixels;
258 }
259
260 public int colorToIntArgbPixel(Color c) {
261 int rgb = c.getRGB();
262 int a = (int) Math.round(xrCompMan.getExtraAlpha() * (rgb >>> 24));
263 return ((a << 24) | (rgb & 0x00FFFFFF));
264 }
265 }
|
1 /*
2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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
214
215 return (XRSurfaceData) srcData;
216 }
217
218 @Override
219 boolean isPaintValid(SunGraphics2D sg2d) {
220 TexturePaint paint = (TexturePaint) sg2d.paint;
221 BufferedImage bi = paint.getImage();
222 XRSurfaceData dstData = (XRSurfaceData) sg2d.getDestSurface();
223
224 return getAccSrcSurface(dstData, bi) != null;
225 }
226
227 @Override
228 void setXRPaint(SunGraphics2D sg2d, Paint pt) {
229 TexturePaint paint = (TexturePaint) pt;
230 BufferedImage bi = paint.getImage();
231 Rectangle2D anchor = paint.getAnchorRect();
232
233 XRSurfaceData dstData = (XRSurfaceData) sg2d.surfaceData;
234 XRSurfaceData srcData = getAccSrcSurface(dstData, bi);
235
236 AffineTransform at = new AffineTransform();
237 at.translate(anchor.getX(), anchor.getY());
238 at.scale(anchor.getWidth() / ((double) bi.getWidth()), anchor.getHeight() / ((double) bi.getHeight()));
239
240 try {
241 at.invert();
242 } catch (NoninvertibleTransformException ex) {
243 at.setToIdentity();
244 }
245 srcData.setStaticSrcTx(at);
246
247 srcData.validateAsSource(at, XRUtils.RepeatNormal, XRUtils.ATransOpToXRQuality(sg2d.interpolationType));
248 xrCompMan.setTexturePaint(srcData);
249 }
250 }
251
252 public int[] convertToIntArgbPixels(Color[] colors) {
253 int[] pixels = new int[colors.length];
254 for (int i = 0; i < colors.length; i++) {
255 pixels[i] = colorToIntArgbPixel(colors[i]);
256 }
257 return pixels;
258 }
259
260 public int colorToIntArgbPixel(Color c) {
261 int rgb = c.getRGB();
262 int a = Math.round(xrCompMan.getExtraAlpha() * (rgb >>> 24));
263 return ((a << 24) | (rgb & 0x00FFFFFF));
264 }
265 }
|