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
23 * questions.
24 */
25 package com.sun.glass.ui.mac;
26
27 import com.sun.glass.ui.Pixels;
28 import com.sun.glass.ui.View;
29 import java.nio.Buffer;
30 import java.nio.ByteBuffer;
31 import java.nio.IntBuffer;
32 import java.util.Map;
33 import java.util.TreeSet;
34
35 /**
36 * MacOSX platform implementation class for View.
37 */
38 final class MacView extends View {
39
40 private native static void _initIDs();
41 static {
42 _initIDs();
43 multiClickTime = _getMultiClickTime_impl();
44 multiClickMaxX = _getMultiClickMaxX_impl();
45 multiClickMaxY = _getMultiClickMaxY_impl();
46 }
47
48 // Constants
64 static int getMultiClickMaxY_impl() {
65 return multiClickMaxY;
66 }
67
68 @Override native protected int _getNativeFrameBuffer(long ptr);
69 @Override native protected long _create(Map caps);
70 @Override native protected int _getX(long ptr);
71 @Override native protected int _getY(long ptr);
72 @Override native protected void _setParent(long ptr, long parentPtr);
73 @Override native protected boolean _close(long ptr);
74 @Override native protected void _scheduleRepaint(long ptr);
75 @Override native protected void _begin(long ptr);
76 @Override native protected void _end(long ptr);
77 @Override native protected boolean _enterFullscreen(long ptr, boolean animate, boolean keepRatio, boolean hideCursor);
78 @Override native protected void _exitFullscreen(long ptr, boolean animate);
79 @Override native protected void _enableInputMethodEvents(long ptr, boolean enable);
80
81 @Override protected void _uploadPixels(long ptr, Pixels pixels) {
82 Buffer data = pixels.getPixels();
83 if (data.isDirect() == true) {
84 _uploadPixelsDirect(ptr, data, pixels.getWidth(), pixels.getHeight(), pixels.getScale());
85 } else if (data.hasArray() == true) {
86 if (pixels.getBytesPerComponent() == 1) {
87 ByteBuffer bytes = (ByteBuffer)data;
88 _uploadPixelsByteArray(ptr, bytes.array(), bytes.arrayOffset(),
89 pixels.getWidth(), pixels.getHeight(), pixels.getScale());
90 } else {
91 IntBuffer ints = (IntBuffer)data;
92 _uploadPixelsIntArray(ptr, ints.array(), ints.arrayOffset(),
93 pixels.getWidth(), pixels.getHeight(), pixels.getScale());
94 }
95 } else {
96 // gznote: what are the circumstances under which this can happen?
97 _uploadPixelsDirect(ptr, pixels.asByteBuffer(),
98 pixels.getWidth(), pixels.getHeight(), pixels.getScale());
99 }
100 }
101 native void _uploadPixelsDirect(long viewPtr, Buffer pixels, int width, int height, float scale);
102 native void _uploadPixelsByteArray(long viewPtr, byte[] pixels, int offset, int width, int height, float scale);
103 native void _uploadPixelsIntArray(long viewPtr, int[] pixels, int offset, int width, int height, float scale);
104
105 @Override protected long _getNativeView(long ptr) {
106 return ptr;
107 }
108
109 native protected long _getNativeLayer(long ptr);
110 public long getNativeLayer() {
111 return _getNativeLayer(getNativeView());
112 }
113
114 native protected int _getNativeRemoteLayerId(long ptr, String serverName);
115 @Override public int getNativeRemoteLayerId(String serverName) {
116 // used when run inside plugin
117 return _getNativeRemoteLayerId(getNativeLayer(), serverName);
118 }
119
120 native protected void _hostRemoteLayerId(long ptr, int nativeLayerId);
121 public void hostRemoteLayerId(int nativeLayerId) {
122 // used when run inside plugin
123 _hostRemoteLayerId(getNativeLayer(), nativeLayerId);
|
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
23 * questions.
24 */
25 package com.sun.glass.ui.mac;
26
27 import com.sun.glass.ui.Pixels;
28 import com.sun.glass.ui.View;
29 import com.sun.glass.ui.Window;
30 import java.nio.Buffer;
31 import java.nio.ByteBuffer;
32 import java.nio.IntBuffer;
33 import java.util.Map;
34 import java.util.TreeSet;
35
36 /**
37 * MacOSX platform implementation class for View.
38 */
39 final class MacView extends View {
40
41 private native static void _initIDs();
42 static {
43 _initIDs();
44 multiClickTime = _getMultiClickTime_impl();
45 multiClickMaxX = _getMultiClickMaxX_impl();
46 multiClickMaxY = _getMultiClickMaxY_impl();
47 }
48
49 // Constants
65 static int getMultiClickMaxY_impl() {
66 return multiClickMaxY;
67 }
68
69 @Override native protected int _getNativeFrameBuffer(long ptr);
70 @Override native protected long _create(Map caps);
71 @Override native protected int _getX(long ptr);
72 @Override native protected int _getY(long ptr);
73 @Override native protected void _setParent(long ptr, long parentPtr);
74 @Override native protected boolean _close(long ptr);
75 @Override native protected void _scheduleRepaint(long ptr);
76 @Override native protected void _begin(long ptr);
77 @Override native protected void _end(long ptr);
78 @Override native protected boolean _enterFullscreen(long ptr, boolean animate, boolean keepRatio, boolean hideCursor);
79 @Override native protected void _exitFullscreen(long ptr, boolean animate);
80 @Override native protected void _enableInputMethodEvents(long ptr, boolean enable);
81
82 @Override protected void _uploadPixels(long ptr, Pixels pixels) {
83 Buffer data = pixels.getPixels();
84 if (data.isDirect() == true) {
85 _uploadPixelsDirect(ptr, data, pixels.getWidth(), pixels.getHeight(), pixels.getScaleX(), pixels.getScaleY());
86 } else if (data.hasArray() == true) {
87 if (pixels.getBytesPerComponent() == 1) {
88 ByteBuffer bytes = (ByteBuffer)data;
89 _uploadPixelsByteArray(ptr, bytes.array(), bytes.arrayOffset(),
90 pixels.getWidth(), pixels.getHeight(), pixels.getScaleX(), pixels.getScaleY());
91 } else {
92 IntBuffer ints = (IntBuffer)data;
93 _uploadPixelsIntArray(ptr, ints.array(), ints.arrayOffset(),
94 pixels.getWidth(), pixels.getHeight(), pixels.getScaleX(), pixels.getScaleY());
95 }
96 } else {
97 // gznote: what are the circumstances under which this can happen?
98 _uploadPixelsDirect(ptr, pixels.asByteBuffer(),
99 pixels.getWidth(), pixels.getHeight(), pixels.getScaleX(), pixels.getScaleY());
100 }
101 }
102 native void _uploadPixelsDirect(long viewPtr, Buffer pixels, int width, int height, float scaleX, float scaleY);
103 native void _uploadPixelsByteArray(long viewPtr, byte[] pixels, int offset, int width, int height, float scaleX, float scaleY);
104 native void _uploadPixelsIntArray(long viewPtr, int[] pixels, int offset, int width, int height, float scaleX, float scaleY);
105
106 @Override
107 protected void notifyResize(int width, int height) {
108 Window w = getWindow();
109 float sx = (w == null) ? 1.0f : w.getPlatformScaleX();
110 float sy = (w == null) ? 1.0f : w.getPlatformScaleY();
111 width = Math.round(width * sx);
112 height = Math.round(height * sy);
113 super.notifyResize(width, height);
114 }
115
116 @Override
117 protected void notifyMouse(int type, int button, int x, int y, int xAbs,
118 int yAbs, int modifiers, boolean isPopupTrigger,
119 boolean isSynthesized) {
120 Window w = getWindow();
121 float sx = (w == null) ? 1.0f : w.getPlatformScaleX();
122 float sy = (w == null) ? 1.0f : w.getPlatformScaleY();
123 x = Math.round(x * sx);
124 y = Math.round(y * sy);
125 xAbs = Math.round(xAbs * sx);
126 yAbs = Math.round(yAbs * sy);
127 super.notifyMouse(type, button, x, y, xAbs, yAbs, modifiers,
128 isPopupTrigger, isSynthesized);
129 }
130
131 @Override protected long _getNativeView(long ptr) {
132 return ptr;
133 }
134
135 native protected long _getNativeLayer(long ptr);
136 public long getNativeLayer() {
137 return _getNativeLayer(getNativeView());
138 }
139
140 native protected int _getNativeRemoteLayerId(long ptr, String serverName);
141 @Override public int getNativeRemoteLayerId(String serverName) {
142 // used when run inside plugin
143 return _getNativeRemoteLayerId(getNativeLayer(), serverName);
144 }
145
146 native protected void _hostRemoteLayerId(long ptr, int nativeLayerId);
147 public void hostRemoteLayerId(int nativeLayerId) {
148 // used when run inside plugin
149 _hostRemoteLayerId(getNativeLayer(), nativeLayerId);
|