Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proof of Concept] MacOS Platform Layer #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jceipek
Copy link

@jceipek jceipek commented Aug 15, 2021

This is a rough pass at a MacOS platform layer for the Palanteer viewer application (note that I have not touched the instrumentation or scripting layer yet, and I haven't tested the networked recording, just loading trace files).

@dfeneyrou Huge props for making a really great profiling tool and writing it in such a way that porting to a new platform is feasible in a tractable amount of time. Please let me know if having a MacOS platform layer in the codebase is something you'd be interested in. I don't mind either way; this is mostly a learning project for me.

This is not really in a mergeable state yet, but I wanted to open it up for feedback and discussion on the approach. I've never written a shippable platform layer before and don't have a lot of experience with native MacOS APIs.

From a usability perspective, the two biggest outstanding problems are

Also:

  • the MacOS menus are not interactive while the main window has focus. I have no idea why yet.
  • the cmake changes are not well considered. I don't really know how to use cmake and would love suggestions on how to structure them better.
  • this still uses OpenGL, which is deprecated on MacOS. A Metal rendering backend would be faster and more likely to stay usable into the future, but I wouldn't know where to start since the existing platform layer is OpenGL only and doesn't have any hooks for other APIs like Vulkan or DirectX.

Comment on lines +573 to +592
if (clipboardData != nil) {
NSUInteger byteCount = [clipboardData lengthOfBytesUsingEncoding:NSUTF16StringEncoding];
uint16_t* chars = (uint16_t*)malloc(byteCount);
if (chars) {
[clipboardData
getBytes:chars
maxLength:byteCount
usedLength:NULL
encoding:NSUTF16StringEncoding
options:0
range:NSMakeRange(0, [clipboardData length])
remainingRange:NULL];
uint16_t* ptr = chars;
while (byteCount) {
gClip.reqData.push_back(*ptr++);
byteCount -= 2; // Since we're going 2 bytes at a time
}
free(chars);
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect there's a much easier way to do this, but I wasn't sure how.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant