skia2/tools/sk_app/mac/Window_mac.h
Ben Wagner fa8b5e4502 Add support for retina displays to sk_app.
The macOS view system is in "big pixel" units, so translate these
into "physical pixel" units.

To compensate, add sk_app::Window::scaleFactor() which returns the
scale factor. The viewer app is modified to apply the inverse of
this scale factor to the current zoom level.

Change-Id: I4fac066a230c87793fc5a0e5a582d60d25e46e7b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361558
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-01-29 17:33:48 +00:00

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) {}
~Window_mac() override {
this->closeWindow();
}
bool initWindow();
void setTitle(const char*) override;
void show() override;
bool attach(BackendType) override;
void onInval() override {}
float scaleFactor() const 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;
static SkTDynamicHash<Window_mac, NSInteger> gWindowMap;
using INHERITED = Window;
};
} // namespace sk_app
#endif