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 package sun.java2d.windows;
27
28 import java.awt.Rectangle;
29 import java.awt.GraphicsConfiguration;
30 import java.awt.color.ColorSpace;
31 import java.awt.image.ColorModel;
32 import java.awt.image.ComponentColorModel;
33 import java.awt.image.DirectColorModel;
34 import java.awt.image.IndexColorModel;
35 import java.awt.image.Raster;
36
37 import sun.awt.SunHints;
38 import sun.awt.Win32GraphicsConfig;
39 import sun.awt.Win32GraphicsDevice;
40 import sun.awt.windows.WComponentPeer;
41 import sun.java2d.ScreenUpdateManager;
42 import sun.java2d.SunGraphics2D;
43 import sun.java2d.SurfaceData;
44 import sun.java2d.SurfaceDataProxy;
45 import sun.java2d.pipe.Region;
46 import sun.java2d.pipe.PixelToShapeConverter;
47 import sun.java2d.loops.GraphicsPrimitive;
48 import sun.java2d.loops.SurfaceType;
49 import sun.java2d.loops.CompositeType;
50 import sun.java2d.loops.RenderLoops;
60 DESC_GDI = "GDI";
61
62 // Generic GDI surface type - used for registering all loops
63 public static final SurfaceType AnyGdi =
64 SurfaceType.IntRgb.deriveSubType(DESC_GDI);
65
66 public static final SurfaceType IntRgbGdi =
67 SurfaceType.IntRgb.deriveSubType(DESC_GDI);
68
69 public static final SurfaceType Ushort565RgbGdi =
70 SurfaceType.Ushort565Rgb.deriveSubType(DESC_GDI);
71
72 public static final SurfaceType Ushort555RgbGdi =
73 SurfaceType.Ushort555Rgb.deriveSubType(DESC_GDI);
74
75 public static final SurfaceType ThreeByteBgrGdi =
76 SurfaceType.ThreeByteBgr.deriveSubType(DESC_GDI);
77
78 private static native void initIDs(Class<?> xorComp);
79
80 static {
81 initIDs(XORComposite.class);
82 if (WindowsFlags.isGdiBlitEnabled()) {
83 // Register our gdi Blit loops
84 GDIBlitLoops.register();
85 }
86 }
87
88 public static SurfaceType getSurfaceType(ColorModel cm) {
89 switch (cm.getPixelSize()) {
90 case 32:
91 case 24:
92 if (cm instanceof DirectColorModel) {
93 if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
94 return IntRgbGdi;
95 } else {
96 return SurfaceType.IntRgbx;
97 }
98 } else {
99 return ThreeByteBgrGdi;
248 case 32:
249 case 24:
250 if (cm instanceof DirectColorModel) {
251 depth = 32;
252 } else {
253 depth = 24;
254 }
255 break;
256 default:
257 depth = cm.getPixelSize();
258 }
259 if (cm instanceof DirectColorModel) {
260 DirectColorModel dcm = (DirectColorModel)cm;
261 rMask = dcm.getRedMask();
262 gMask = dcm.getGreenMask();
263 bMask = dcm.getBlueMask();
264 }
265 this.graphicsConfig =
266 (Win32GraphicsConfig) peer.getGraphicsConfiguration();
267 this.solidloops = graphicsConfig.getSolidLoops(sType);
268
269 Win32GraphicsDevice gd =
270 (Win32GraphicsDevice)graphicsConfig.getDevice();
271 initOps(peer, depth, rMask, gMask, bMask, gd.getScreen());
272 setBlitProxyKey(graphicsConfig.getProxyKey());
273 }
274
275 /**
276 * {@inheritDoc}
277 *
278 * Overridden to use ScreenUpdateManager to obtain the replacement surface.
279 *
280 * @see sun.java2d.ScreenUpdateManager#getReplacementScreenSurface
281 */
282 @Override
283 public SurfaceData getReplacement() {
284 ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
285 return mgr.getReplacementScreenSurface(peer, this);
286 }
287
288 public Rectangle getBounds() {
289 Rectangle r = peer.getBounds();
290 r.x = r.y = 0;
291 return r;
292 }
293
294 public boolean copyArea(SunGraphics2D sg2d,
295 int x, int y, int w, int h, int dx, int dy)
296 {
297 CompositeType comptype = sg2d.imageComp;
298 if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
299 sg2d.clipState != SunGraphics2D.CLIP_SHAPE &&
300 (CompositeType.SrcOverNoEa.equals(comptype) ||
301 CompositeType.SrcNoEa.equals(comptype)))
302 {
303 x += sg2d.transX;
304 y += sg2d.transY;
305 int dstx1 = x + dx;
306 int dsty1 = y + dy;
307 int dstx2 = dstx1 + w;
308 int dsty2 = dsty1 + h;
309 Region clip = sg2d.getCompClip();
310 if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX();
|
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 package sun.java2d.windows;
27
28 import java.awt.Rectangle;
29 import java.awt.GraphicsConfiguration;
30 import java.awt.color.ColorSpace;
31 import java.awt.geom.AffineTransform;
32 import java.awt.image.ColorModel;
33 import java.awt.image.ComponentColorModel;
34 import java.awt.image.DirectColorModel;
35 import java.awt.image.IndexColorModel;
36 import java.awt.image.Raster;
37
38 import sun.awt.SunHints;
39 import sun.awt.Win32GraphicsConfig;
40 import sun.awt.Win32GraphicsDevice;
41 import sun.awt.windows.WComponentPeer;
42 import sun.java2d.ScreenUpdateManager;
43 import sun.java2d.SunGraphics2D;
44 import sun.java2d.SurfaceData;
45 import sun.java2d.SurfaceDataProxy;
46 import sun.java2d.pipe.Region;
47 import sun.java2d.pipe.PixelToShapeConverter;
48 import sun.java2d.loops.GraphicsPrimitive;
49 import sun.java2d.loops.SurfaceType;
50 import sun.java2d.loops.CompositeType;
51 import sun.java2d.loops.RenderLoops;
61 DESC_GDI = "GDI";
62
63 // Generic GDI surface type - used for registering all loops
64 public static final SurfaceType AnyGdi =
65 SurfaceType.IntRgb.deriveSubType(DESC_GDI);
66
67 public static final SurfaceType IntRgbGdi =
68 SurfaceType.IntRgb.deriveSubType(DESC_GDI);
69
70 public static final SurfaceType Ushort565RgbGdi =
71 SurfaceType.Ushort565Rgb.deriveSubType(DESC_GDI);
72
73 public static final SurfaceType Ushort555RgbGdi =
74 SurfaceType.Ushort555Rgb.deriveSubType(DESC_GDI);
75
76 public static final SurfaceType ThreeByteBgrGdi =
77 SurfaceType.ThreeByteBgr.deriveSubType(DESC_GDI);
78
79 private static native void initIDs(Class<?> xorComp);
80
81 private final double scaleX;
82 private final double scaleY;
83
84 static {
85 initIDs(XORComposite.class);
86 if (WindowsFlags.isGdiBlitEnabled()) {
87 // Register our gdi Blit loops
88 GDIBlitLoops.register();
89 }
90 }
91
92 public static SurfaceType getSurfaceType(ColorModel cm) {
93 switch (cm.getPixelSize()) {
94 case 32:
95 case 24:
96 if (cm instanceof DirectColorModel) {
97 if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
98 return IntRgbGdi;
99 } else {
100 return SurfaceType.IntRgbx;
101 }
102 } else {
103 return ThreeByteBgrGdi;
252 case 32:
253 case 24:
254 if (cm instanceof DirectColorModel) {
255 depth = 32;
256 } else {
257 depth = 24;
258 }
259 break;
260 default:
261 depth = cm.getPixelSize();
262 }
263 if (cm instanceof DirectColorModel) {
264 DirectColorModel dcm = (DirectColorModel)cm;
265 rMask = dcm.getRedMask();
266 gMask = dcm.getGreenMask();
267 bMask = dcm.getBlueMask();
268 }
269 this.graphicsConfig =
270 (Win32GraphicsConfig) peer.getGraphicsConfiguration();
271 this.solidloops = graphicsConfig.getSolidLoops(sType);
272 Win32GraphicsDevice gd = graphicsConfig.getDevice();
273 scaleX = gd.getDefaultScaleX();
274 scaleY = gd.getDefaultScaleY();
275 initOps(peer, depth, rMask, gMask, bMask, gd.getScreen());
276 setBlitProxyKey(graphicsConfig.getProxyKey());
277 }
278
279 @Override
280 public double getDefaultScaleX() {
281 return scaleX;
282 }
283
284 @Override
285 public double getDefaultScaleY() {
286 return scaleY;
287 }
288
289 /**
290 * {@inheritDoc}
291 *
292 * Overridden to use ScreenUpdateManager to obtain the replacement surface.
293 *
294 * @see sun.java2d.ScreenUpdateManager#getReplacementScreenSurface
295 */
296 @Override
297 public SurfaceData getReplacement() {
298 ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
299 return mgr.getReplacementScreenSurface(peer, this);
300 }
301
302 public Rectangle getBounds() {
303 Rectangle r = peer.getBounds();
304 r.x = r.y = 0;
305 r.width = (int) Math.ceil(r.width * scaleX);
306 r.height = (int) Math.ceil(r.height * scaleY);
307 return r;
308 }
309
310 public boolean copyArea(SunGraphics2D sg2d,
311 int x, int y, int w, int h, int dx, int dy)
312 {
313 CompositeType comptype = sg2d.imageComp;
314 if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
315 sg2d.clipState != SunGraphics2D.CLIP_SHAPE &&
316 (CompositeType.SrcOverNoEa.equals(comptype) ||
317 CompositeType.SrcNoEa.equals(comptype)))
318 {
319 x += sg2d.transX;
320 y += sg2d.transY;
321 int dstx1 = x + dx;
322 int dsty1 = y + dy;
323 int dstx2 = dstx1 + w;
324 int dsty2 = dsty1 + h;
325 Region clip = sg2d.getCompClip();
326 if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX();
|