summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2012-01-04 15:03:39 -0800
committerJesse Hall <jessehall@google.com>2012-01-04 15:03:39 -0800
commita4fb8a60b1070ced3108a024f0ce462c94bbd9a0 (patch)
treecca7493496df250202a4792d4e8c8f98849e25c9 /tools
parent9fe60c34a49c0be4d5014fb0e056959b4683304e (diff)
downloadandroid_development-a4fb8a60b1070ced3108a024f0ce462c94bbd9a0.tar.gz
android_development-a4fb8a60b1070ced3108a024f0ce462c94bbd9a0.tar.bz2
android_development-a4fb8a60b1070ced3108a024f0ce462c94bbd9a0.zip
EmuGL: fix GL view position in window on OS X
The code that creates the GL-accelerated screen view wasn't converting the upper-left-relative coordinates used within the emulator to the lower-left coordinates used by the Cocoa APIs on OS X. Since most skins have the screen view centered vertically this often just happened to work. Bug: 5782118 Change-Id: I2f96ee181e850df5676d10a82d86c94421149b40
Diffstat (limited to 'tools')
-rw-r--r--tools/emulator/opengl/host/libs/libOpenglRender/NativeMacSubWindow.m12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/NativeMacSubWindow.m b/tools/emulator/opengl/host/libs/libOpenglRender/NativeMacSubWindow.m
index 2ac39e809..f57f661fb 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/NativeMacSubWindow.m
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/NativeMacSubWindow.m
@@ -36,10 +36,18 @@
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
EGLNativeDisplayType* display_out,
int x, int y,int width, int height){
- NSRect contentRect = NSMakeRect(x, y, width, height);
+ NSWindow *win = (NSWindow *)p_window;
+ if (!win) {
+ return NULL;
+ }
+
+ /* (x,y) assume an upper-left origin, but Cocoa uses a lower-left origin */
+ NSRect content_rect = [win contentRectForFrameRect:[win frame]];
+ int cocoa_y = (int)content_rect.size.height - (y + height);
+ NSRect contentRect = NSMakeRect(x, cocoa_y, width, height);
+
NSView *glView = [[EmuGLView alloc] initWithFrame:contentRect];
if (glView) {
- NSWindow *win = (NSWindow *)p_window;
[[win contentView] addSubview:glView];
[win makeKeyAndOrderFront:nil];
}