Bug 1751217 Part 3: Make HDR-capable macOS screens report 30 pixelDepth. r=mstange
[gecko.git] / widget / gtk / WindowSurfaceX11.cpp
bloba32cc12e18950ea78fb4b4983b7ee4eb2d0e083c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "WindowSurfaceX11.h"
8 #include "gfxPlatform.h"
9 #include "X11UndefineNone.h"
11 namespace mozilla {
12 namespace widget {
14 WindowSurfaceX11::WindowSurfaceX11(Display* aDisplay, Window aWindow,
15 Visual* aVisual, unsigned int aDepth)
16 : mDisplay(aDisplay),
17 mWindow(aWindow),
18 mVisual(aVisual),
19 mDepth(aDepth),
20 mFormat(GetVisualFormat(aVisual, aDepth)) {}
22 /* static */
23 gfx::SurfaceFormat WindowSurfaceX11::GetVisualFormat(const Visual* aVisual,
24 unsigned int aDepth) {
25 switch (aDepth) {
26 case 32:
27 if (aVisual->red_mask == 0xff0000 && aVisual->green_mask == 0xff00 &&
28 aVisual->blue_mask == 0xff) {
29 return gfx::SurfaceFormat::B8G8R8A8;
31 break;
32 case 24:
33 if (aVisual->red_mask == 0xff0000 && aVisual->green_mask == 0xff00 &&
34 aVisual->blue_mask == 0xff) {
35 return gfx::SurfaceFormat::B8G8R8X8;
37 break;
38 case 16:
39 if (aVisual->red_mask == 0xf800 && aVisual->green_mask == 0x07e0 &&
40 aVisual->blue_mask == 0x1f) {
41 return gfx::SurfaceFormat::R5G6B5_UINT16;
43 break;
46 return gfx::SurfaceFormat::UNKNOWN;
49 } // namespace widget
50 } // namespace mozilla