1 /*
2 * Copyright (c) 2007, 2013, 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
115 D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
116 BufferedImage bi = paint.getImage();
117
118 // verify that the texture image dimensions are pow2
119 D3DGraphicsDevice gd =
120 (D3DGraphicsDevice)dstData.getDeviceConfiguration().getDevice();
121 int imgw = bi.getWidth();
122 int imgh = bi.getHeight();
123 if (!gd.isCapPresent(CAPS_TEXNONPOW2)) {
124 if ((imgw & (imgw - 1)) != 0 || (imgh & (imgh - 1)) != 0) {
125 return false;
126 }
127 }
128 // verify that the texture image is square if it has to be
129 if (!gd.isCapPresent(CAPS_TEXNONSQUARE) && imgw != imgh)
130 {
131 return false;
132 }
133
134 SurfaceData srcData =
135 dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
136 CompositeType.SrcOver, null);
137 if (!(srcData instanceof D3DSurfaceData)) {
138 // REMIND: this is a hack that attempts to cache the system
139 // memory image from the TexturePaint instance into a
140 // D3D texture...
141 srcData =
142 dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
143 CompositeType.SrcOver, null);
144 if (!(srcData instanceof D3DSurfaceData)) {
145 return false;
146 }
147 }
148
149 // verify that the source surface is actually a texture
150 D3DSurfaceData d3dData = (D3DSurfaceData)srcData;
151 if (d3dData.getType() != D3DSurfaceData.TEXTURE) {
152 return false;
153 }
154
155 return true;
156 }
157 }
158
159 /****************** Shared MultipleGradientPaint support ********************/
160
161 private static abstract class MultiGradient extends D3DPaints {
162
|
1 /*
2 * Copyright (c) 2007, 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
115 D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
116 BufferedImage bi = paint.getImage();
117
118 // verify that the texture image dimensions are pow2
119 D3DGraphicsDevice gd =
120 (D3DGraphicsDevice)dstData.getDeviceConfiguration().getDevice();
121 int imgw = bi.getWidth();
122 int imgh = bi.getHeight();
123 if (!gd.isCapPresent(CAPS_TEXNONPOW2)) {
124 if ((imgw & (imgw - 1)) != 0 || (imgh & (imgh - 1)) != 0) {
125 return false;
126 }
127 }
128 // verify that the texture image is square if it has to be
129 if (!gd.isCapPresent(CAPS_TEXNONSQUARE) && imgw != imgh)
130 {
131 return false;
132 }
133
134 SurfaceData srcData =
135 dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT,
136 CompositeType.SrcOver, null);
137 if (!(srcData instanceof D3DSurfaceData)) {
138 // REMIND: this is a hack that attempts to cache the system
139 // memory image from the TexturePaint instance into a
140 // D3D texture...
141 srcData =
142 dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT,
143 CompositeType.SrcOver, null);
144 if (!(srcData instanceof D3DSurfaceData)) {
145 return false;
146 }
147 }
148
149 // verify that the source surface is actually a texture
150 D3DSurfaceData d3dData = (D3DSurfaceData)srcData;
151 if (d3dData.getType() != D3DSurfaceData.TEXTURE) {
152 return false;
153 }
154
155 return true;
156 }
157 }
158
159 /****************** Shared MultipleGradientPaint support ********************/
160
161 private static abstract class MultiGradient extends D3DPaints {
162
|