| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | |
| 3 * Copyright (C) 2009 Torch Mobile, Inc. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions | |
| 7 * are met: | |
| 8 * 1. Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 * notice, this list of conditions and the following disclaimer in the | |
| 12 * documentation and/or other materials provided with the distribution. | |
| 13 * | |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 25 */ | |
| 26 | |
| 27 #include "config.h" | |
| 28 #include "PlatformScreen.h" | |
| 29 | |
| 30 #include "FloatRect.h" | |
| 31 #include "Frame.h" | |
| 32 #include "FrameView.h" | |
| 33 #include "HostWindow.h" | |
| 34 #include "IntRect.h" | |
| 35 #include "NotImplemented.h" | |
| 36 #include "Page.h" | |
| 37 #include <windows.h> | |
| 38 | |
| 39 namespace WebCore { | |
| 40 | |
| 41 // Returns info for the default monitor if widget is NULL | |
| 42 static MONITORINFOEX monitorInfoForWidget(Widget* widget) | |
| 43 { | |
| 44 HWND window = widget ? widget->root()->hostWindow()->platformPageClient() :
0; | |
| 45 HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY); | |
| 46 | |
| 47 MONITORINFOEX monitorInfo; | |
| 48 monitorInfo.cbSize = sizeof(MONITORINFOEX); | |
| 49 GetMonitorInfo(monitor, &monitorInfo); | |
| 50 return monitorInfo; | |
| 51 } | |
| 52 | |
| 53 static DEVMODE deviceInfoForWidget(Widget* widget) | |
| 54 { | |
| 55 DEVMODE deviceInfo; | |
| 56 deviceInfo.dmSize = sizeof(DEVMODE); | |
| 57 deviceInfo.dmDriverExtra = 0; | |
| 58 #if OS(WINCE) | |
| 59 if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &deviceInfo)) | |
| 60 deviceInfo.dmBitsPerPel = 16; | |
| 61 #else | |
| 62 MONITORINFOEX monitorInfo = monitorInfoForWidget(widget); | |
| 63 EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &deviceInfo
); | |
| 64 #endif | |
| 65 | |
| 66 return deviceInfo; | |
| 67 } | |
| 68 | |
| 69 int screenDepth(Widget* widget) | |
| 70 { | |
| 71 DEVMODE deviceInfo = deviceInfoForWidget(widget); | |
| 72 if (deviceInfo.dmBitsPerPel == 32) { | |
| 73 // Some video drivers return 32, but this function is supposed to ignore
the alpha | |
| 74 // component. See <http://webkit.org/b/42972>. | |
| 75 return 24; | |
| 76 } | |
| 77 return deviceInfo.dmBitsPerPel; | |
| 78 } | |
| 79 | |
| 80 int screenDepthPerComponent(Widget* widget) | |
| 81 { | |
| 82 // FIXME: Assumes RGB -- not sure if this is right. | |
| 83 return screenDepth(widget) / 3; | |
| 84 } | |
| 85 | |
| 86 bool screenIsMonochrome(Widget* widget) | |
| 87 { | |
| 88 #if OS(WINCE) | |
| 89 // EnumDisplaySettings doesn't set dmColor in DEVMODE. | |
| 90 return false; | |
| 91 #else | |
| 92 DEVMODE deviceInfo = deviceInfoForWidget(widget); | |
| 93 return deviceInfo.dmColor == DMCOLOR_MONOCHROME; | |
| 94 #endif | |
| 95 } | |
| 96 | |
| 97 FloatRect screenRect(Widget* widget) | |
| 98 { | |
| 99 MONITORINFOEX monitorInfo = monitorInfoForWidget(widget); | |
| 100 return monitorInfo.rcMonitor; | |
| 101 } | |
| 102 | |
| 103 FloatRect screenAvailableRect(Widget* widget) | |
| 104 { | |
| 105 MONITORINFOEX monitorInfo = monitorInfoForWidget(widget); | |
| 106 return monitorInfo.rcWork; | |
| 107 } | |
| 108 | |
| 109 void screenColorProfile(ColorProfile&) | |
| 110 { | |
| 111 notImplemented(); | |
| 112 } | |
| 113 | |
| 114 } // namespace WebCore | |
| OLD | NEW |