| 1 |
/* |
| 2 |
* Copyright 2024 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef MacWindowInfo_DEFINED |
| 9 |
#define MacWindowInfo_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkTypes.h" |
| 12 |
|
| 13 |
#if defined(SK_BUILD_FOR_IOS) |
| 14 |
#error "This is Mac-only code" |
| 15 |
#endif |
| 16 |
|
| 17 |
#include <Cocoa/Cocoa.h> |
| 18 |
|
| 19 |
namespace skwindow { |
| 20 |
|
| 21 |
struct MacWindowInfo { |
| 22 |
NSView* fMainView; |
| 23 |
}; |
| 24 |
|
| 25 |
static inline CGFloat GetBackingScaleFactor(NSView* view) { |
| 26 |
NSScreen* screen = view.window.screen ?: [NSScreen mainScreen]; |
| 27 |
return screen.backingScaleFactor; |
| 28 |
} |
| 29 |
|
| 30 |
} // namespace skwindow |
| 31 |
|
| 32 |
#endif |