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
)
18 mFormat(GetVisualFormat(aVisual
, aDepth
)) {}
21 gfx::SurfaceFormat
WindowSurfaceX11::GetVisualFormat(const Visual
* aVisual
,
22 unsigned int aDepth
) {
25 if (aVisual
->red_mask
== 0xff0000 && aVisual
->green_mask
== 0xff00 &&
26 aVisual
->blue_mask
== 0xff) {
27 return gfx::SurfaceFormat::B8G8R8A8
;
31 if (aVisual
->red_mask
== 0xff0000 && aVisual
->green_mask
== 0xff00 &&
32 aVisual
->blue_mask
== 0xff) {
33 return gfx::SurfaceFormat::B8G8R8X8
;
37 if (aVisual
->red_mask
== 0xf800 && aVisual
->green_mask
== 0x07e0 &&
38 aVisual
->blue_mask
== 0x1f) {
39 return gfx::SurfaceFormat::R5G6B5_UINT16
;
44 return gfx::SurfaceFormat::UNKNOWN
;
47 } // namespace mozilla::widget