1 /*
2 * Copyright (c) 2011, 2015, 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
31 import java.awt.GraphicsEnvironment;
32 import java.awt.Image;
33 import java.awt.Rectangle;
34 import java.awt.image.ColorModel;
35
36 import sun.java2d.SunGraphics2D;
37 import sun.java2d.SurfaceData;
38
39 import sun.lwawt.macosx.CPlatformView;
40
41 public abstract class CGLSurfaceData extends OGLSurfaceData {
42
43 protected final int scale;
44 protected final int width;
45 protected final int height;
46 protected CPlatformView pView;
47 private CGLGraphicsConfig graphicsConfig;
48
49 native void validate(int xoff, int yoff, int width, int height, boolean isOpaque);
50
51 private native void initOps(long pConfigInfo, long pPeerData, long layerPtr,
52 int xoff, int yoff, boolean isOpaque);
53
54 protected CGLSurfaceData(CGLGraphicsConfig gc, ColorModel cm, int type,
55 int width, int height) {
56 super(gc, cm, type);
57 // TEXTURE shouldn't be scaled, it is used for managed BufferedImages.
58 scale = type == TEXTURE ? 1 : gc.getDevice().getScaleFactor();
59 this.width = width * scale;
60 this.height = height * scale;
61 }
62
63 protected CGLSurfaceData(CPlatformView pView, CGLGraphicsConfig gc,
64 ColorModel cm, int type,int width, int height)
65 {
66 this(gc, cm, type, width, height);
67 this.pView = pView;
68 this.graphicsConfig = gc;
69
70 long pConfigInfo = gc.getNativeConfigInfo();
71 long pPeerData = 0L;
72 boolean isOpaque = true;
73 if (pView != null) {
74 pPeerData = pView.getAWTView();
75 isOpaque = pView.isOpaque();
76 }
77 initOps(pConfigInfo, pPeerData, 0, 0, 0, isOpaque);
78 }
79
80 protected CGLSurfaceData(CGLLayer layer, CGLGraphicsConfig gc,
81 ColorModel cm, int type,int width, int height)
82 {
83 this(gc, cm, type, width, height);
84 this.graphicsConfig = gc;
85
86 long pConfigInfo = gc.getNativeConfigInfo();
87 long layerPtr = 0L;
88 boolean isOpaque = true;
89 if (layer != null) {
90 layerPtr = layer.getPointer();
91 isOpaque = layer.isOpaque();
92 }
93 initOps(pConfigInfo, 0, layerPtr, 0, 0, isOpaque);
94 }
95
96 @Override //SurfaceData
97 public GraphicsConfiguration getDeviceConfiguration() {
98 return graphicsConfig;
99 }
100
101 /**
102 * Creates a SurfaceData object representing the primary (front) buffer of
103 * an on-screen Window.
104 */
105 public static CGLWindowSurfaceData createData(CPlatformView pView) {
106 CGLGraphicsConfig gc = getGC(pView);
107 return new CGLWindowSurfaceData(pView, gc);
108 }
109
110 /**
111 * Creates a SurfaceData object representing the intermediate buffer
112 * between the Java2D flusher thread and the AppKit thread.
113 */
|
1 /*
2 * Copyright (c) 2011, 2019, 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
31 import java.awt.GraphicsEnvironment;
32 import java.awt.Image;
33 import java.awt.Rectangle;
34 import java.awt.image.ColorModel;
35
36 import sun.java2d.SunGraphics2D;
37 import sun.java2d.SurfaceData;
38
39 import sun.lwawt.macosx.CPlatformView;
40
41 public abstract class CGLSurfaceData extends OGLSurfaceData {
42
43 protected final int scale;
44 protected final int width;
45 protected final int height;
46 protected CPlatformView pView;
47 private CGLGraphicsConfig graphicsConfig;
48
49 native void validate(int xoff, int yoff, int width, int height, boolean isOpaque);
50
51 private native void initOps(OGLGraphicsConfig gc, long pConfigInfo,
52 long pPeerData, long layerPtr, int xoff,
53 int yoff, boolean isOpaque);
54
55 protected CGLSurfaceData(CGLGraphicsConfig gc, ColorModel cm, int type,
56 int width, int height) {
57 super(gc, cm, type);
58 // TEXTURE shouldn't be scaled, it is used for managed BufferedImages.
59 scale = type == TEXTURE ? 1 : gc.getDevice().getScaleFactor();
60 this.width = width * scale;
61 this.height = height * scale;
62 }
63
64 protected CGLSurfaceData(CPlatformView pView, CGLGraphicsConfig gc,
65 ColorModel cm, int type,int width, int height)
66 {
67 this(gc, cm, type, width, height);
68 this.pView = pView;
69 this.graphicsConfig = gc;
70
71 long pConfigInfo = gc.getNativeConfigInfo();
72 long pPeerData = 0L;
73 boolean isOpaque = true;
74 if (pView != null) {
75 pPeerData = pView.getAWTView();
76 isOpaque = pView.isOpaque();
77 }
78 initOps(gc, pConfigInfo, pPeerData, 0, 0, 0, isOpaque);
79 }
80
81 protected CGLSurfaceData(CGLLayer layer, CGLGraphicsConfig gc,
82 ColorModel cm, int type,int width, int height)
83 {
84 this(gc, cm, type, width, height);
85 this.graphicsConfig = gc;
86
87 long pConfigInfo = gc.getNativeConfigInfo();
88 long layerPtr = 0L;
89 boolean isOpaque = true;
90 if (layer != null) {
91 layerPtr = layer.getPointer();
92 isOpaque = layer.isOpaque();
93 }
94 initOps(gc, pConfigInfo, 0, layerPtr, 0, 0, isOpaque);
95 }
96
97 @Override //SurfaceData
98 public GraphicsConfiguration getDeviceConfiguration() {
99 return graphicsConfig;
100 }
101
102 /**
103 * Creates a SurfaceData object representing the primary (front) buffer of
104 * an on-screen Window.
105 */
106 public static CGLWindowSurfaceData createData(CPlatformView pView) {
107 CGLGraphicsConfig gc = getGC(pView);
108 return new CGLWindowSurfaceData(pView, gc);
109 }
110
111 /**
112 * Creates a SurfaceData object representing the intermediate buffer
113 * between the Java2D flusher thread and the AppKit thread.
114 */
|