d063e8b6f1
Windowing and events: * Use a NSTrackingArea to only capture mouse events within the view. * Use ViewDelegate to track events rather than pulling them out of the event pump. * Sets up the autoreleasepool correctly to clear out old events Context creation: * Don't use a subview for OpenGL (it's not necessary). * For Metal, use a CAMetalLayer rather than MTKView. * Add vsync support to Metal. Bug: skia:8737 Change-Id: I8ea5cc865df65f8dc2fef47082bf6a4d1657cf03 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/213672 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
63 lines
1.2 KiB
Objective-C
63 lines
1.2 KiB
Objective-C
/*
|
|
* Copyright 2016 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef Window_mac_DEFINED
|
|
#define Window_mac_DEFINED
|
|
|
|
#include "src/core/SkTDynamicHash.h"
|
|
#include "tools/sk_app/Window.h"
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
namespace sk_app {
|
|
|
|
class Window_mac : public Window {
|
|
public:
|
|
Window_mac()
|
|
: INHERITED()
|
|
, fWindow(nil)
|
|
, fMSAASampleCount(1) {}
|
|
~Window_mac() override {
|
|
this->closeWindow();
|
|
}
|
|
|
|
bool initWindow();
|
|
|
|
void setTitle(const char*) override;
|
|
void show() override;
|
|
|
|
bool attach(BackendType) override;
|
|
|
|
void onInval() override {}
|
|
|
|
static void PaintWindows();
|
|
|
|
static const NSInteger& GetKey(const Window_mac& w) {
|
|
return w.fWindowNumber;
|
|
}
|
|
|
|
static uint32_t Hash(const NSInteger& windowNumber) {
|
|
return windowNumber;
|
|
}
|
|
|
|
NSWindow* window() { return fWindow; }
|
|
void closeWindow();
|
|
|
|
private:
|
|
NSWindow* fWindow;
|
|
NSInteger fWindowNumber;
|
|
int fMSAASampleCount;
|
|
|
|
static SkTDynamicHash<Window_mac, NSInteger> gWindowMap;
|
|
|
|
typedef Window INHERITED;
|
|
};
|
|
|
|
} // namespace sk_app
|
|
|
|
#endif
|