| 1 | /* |
| 2 | * Copyright (C) 2006-2018 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #pragma once |
| 27 | |
| 28 | #if USE(GLIB) |
| 29 | #include <wtf/Function.h> |
| 30 | #endif |
| 31 | |
| 32 | #if PLATFORM(MAC) |
| 33 | #include <wtf/HashMap.h> |
| 34 | |
| 35 | OBJC_CLASS NSScreen; |
| 36 | OBJC_CLASS NSWindow; |
| 37 | #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES |
| 38 | typedef struct CGRect NSRect; |
| 39 | typedef struct CGPoint NSPoint; |
| 40 | #else |
| 41 | typedef struct _NSRect NSRect; |
| 42 | typedef struct _NSPoint NSPoint; |
| 43 | #endif |
| 44 | #endif |
| 45 | |
| 46 | #if PLATFORM(IOS_FAMILY) |
| 47 | OBJC_CLASS UIScreen; |
| 48 | #endif |
| 49 | |
| 50 | #if USE(CG) |
| 51 | typedef struct CGColorSpace *CGColorSpaceRef; |
| 52 | #endif |
| 53 | |
| 54 | namespace WebCore { |
| 55 | |
| 56 | class FloatRect; |
| 57 | class FloatSize; |
| 58 | class Widget; |
| 59 | |
| 60 | using PlatformDisplayID = uint32_t; |
| 61 | using IORegistryGPUID = int64_t; // Global IOKit I/O registryID that can match a GPU across process boundaries. |
| 62 | |
| 63 | int screenDepth(Widget*); |
| 64 | int screenDepthPerComponent(Widget*); |
| 65 | bool screenIsMonochrome(Widget*); |
| 66 | |
| 67 | bool screenHasInvertedColors(); |
| 68 | #if USE(GLIB) |
| 69 | double screenDPI(); |
| 70 | void setScreenDPIObserverHandler(Function<void()>&&, void*); |
| 71 | #endif |
| 72 | |
| 73 | FloatRect screenRect(Widget*); |
| 74 | FloatRect screenAvailableRect(Widget*); |
| 75 | |
| 76 | WEBCORE_EXPORT bool screenSupportsExtendedColor(Widget* = nullptr); |
| 77 | |
| 78 | #if USE(CG) |
| 79 | WEBCORE_EXPORT CGColorSpaceRef screenColorSpace(Widget* = nullptr); |
| 80 | #endif |
| 81 | |
| 82 | #if PLATFORM(MAC) |
| 83 | struct ScreenProperties; |
| 84 | |
| 85 | WEBCORE_EXPORT PlatformDisplayID displayID(NSScreen *); |
| 86 | |
| 87 | WEBCORE_EXPORT NSScreen *screen(NSWindow *); |
| 88 | NSScreen *screen(PlatformDisplayID); |
| 89 | |
| 90 | FloatRect screenRectForDisplay(PlatformDisplayID); |
| 91 | WEBCORE_EXPORT FloatRect screenRectForPrimaryScreen(); |
| 92 | |
| 93 | WEBCORE_EXPORT FloatRect toUserSpace(const NSRect&, NSWindow *destination); |
| 94 | FloatRect toUserSpaceForPrimaryScreen(const NSRect&); |
| 95 | WEBCORE_EXPORT NSRect toDeviceSpace(const FloatRect&, NSWindow *source); |
| 96 | |
| 97 | NSPoint flipScreenPoint(const NSPoint&, NSScreen *); |
| 98 | |
| 99 | WEBCORE_EXPORT ScreenProperties collectScreenProperties(); |
| 100 | WEBCORE_EXPORT void setScreenProperties(const ScreenProperties&); |
| 101 | |
| 102 | WEBCORE_EXPORT PlatformDisplayID primaryScreenDisplayID(); |
| 103 | |
| 104 | uint32_t primaryOpenGLDisplayMask(); |
| 105 | uint32_t displayMaskForDisplay(PlatformDisplayID); |
| 106 | |
| 107 | #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 |
| 108 | IORegistryGPUID primaryGPUID(); |
| 109 | IORegistryGPUID gpuIDForDisplay(PlatformDisplayID); |
| 110 | IORegistryGPUID gpuIDForDisplayMask(uint32_t); |
| 111 | #endif |
| 112 | |
| 113 | #endif // !PLATFORM(MAC) |
| 114 | |
| 115 | #if PLATFORM(IOS_FAMILY) |
| 116 | |
| 117 | float screenPPIFactor(); |
| 118 | WEBCORE_EXPORT FloatSize screenSize(); |
| 119 | WEBCORE_EXPORT FloatSize availableScreenSize(); |
| 120 | WEBCORE_EXPORT FloatSize overrideScreenSize(); |
| 121 | WEBCORE_EXPORT float screenScaleFactor(UIScreen * = nullptr); |
| 122 | |
| 123 | #endif |
| 124 | |
| 125 | } // namespace WebCore |
| 126 | |