Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / gtk / WindowSurfaceX11.cpp
blob36b238a98b8e3bae17bb59b0f18acd02ead70a5c
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"
10 namespace mozilla::widget {
12 WindowSurfaceX11::WindowSurfaceX11(Display* aDisplay, Window aWindow,
13 Visual* aVisual, unsigned int aDepth)
14 : mDisplay(aDisplay),
15 mWindow(aWindow),
16 mVisual(aVisual),
17 mDepth(aDepth),
18 mFormat(GetVisualFormat(aVisual, aDepth)) {}
20 /* static */
21 gfx::SurfaceFormat WindowSurfaceX11::GetVisualFormat(const Visual* aVisual,
22 unsigned int aDepth) {
23 switch (aDepth) {
24 case 32:
25 if (aVisual->red_mask == 0xff0000 && aVisual->green_mask == 0xff00 &&
26 aVisual->blue_mask == 0xff) {
27 return gfx::SurfaceFormat::B8G8R8A8;
29 break;
30 case 24:
31 if (aVisual->red_mask == 0xff0000 && aVisual->green_mask == 0xff00 &&
32 aVisual->blue_mask == 0xff) {
33 return gfx::SurfaceFormat::B8G8R8X8;
35 break;
36 case 16:
37 if (aVisual->red_mask == 0xf800 && aVisual->green_mask == 0x07e0 &&
38 aVisual->blue_mask == 0x1f) {
39 return gfx::SurfaceFormat::R5G6B5_UINT16;
41 break;
44 return gfx::SurfaceFormat::UNKNOWN;
47 } // namespace mozilla::widget