1 /*
2 * Copyright (c) 2011, 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
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 native boolean initPbuffer(long pData, long pConfigInfo,
55 boolean isOpaque, int width, int height);
56
57 protected CGLSurfaceData(CGLGraphicsConfig gc, ColorModel cm, int type,
58 int width, int height) {
59 super(gc, cm, type);
60 // TEXTURE shouldn't be scaled, it is used for managed BufferedImages.
61 scale = type == TEXTURE ? 1 : gc.getDevice().getScaleFactor();
62 this.width = width * scale;
63 this.height = height * scale;
64 }
65
66 protected CGLSurfaceData(CPlatformView pView, CGLGraphicsConfig gc,
67 ColorModel cm, int type,int width, int height)
68 {
69 this(gc, cm, type, width, height);
70 this.pView = pView;
71 this.graphicsConfig = gc;
72
73 long pConfigInfo = gc.getNativeConfigInfo();
74 long pPeerData = 0L;
75 boolean isOpaque = true;
76 if (pView != null) {
|
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
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) {
|