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"
14 WindowSurfaceX11::WindowSurfaceX11(Display
* aDisplay
, Window aWindow
,
15 Visual
* aVisual
, unsigned int aDepth
)
20 mFormat(GetVisualFormat(aVisual
, aDepth
)) {}
23 gfx::SurfaceFormat
WindowSurfaceX11::GetVisualFormat(const Visual
* aVisual
,
24 unsigned int aDepth
) {
27 if (aVisual
->red_mask
== 0xff0000 && aVisual
->green_mask
== 0xff00 &&
28 aVisual
->blue_mask
== 0xff) {
29 return gfx::SurfaceFormat::B8G8R8A8
;
33 if (aVisual
->red_mask
== 0xff0000 && aVisual
->green_mask
== 0xff00 &&
34 aVisual
->blue_mask
== 0xff) {
35 return gfx::SurfaceFormat::B8G8R8X8
;
39 if (aVisual
->red_mask
== 0xf800 && aVisual
->green_mask
== 0x07e0 &&
40 aVisual
->blue_mask
== 0x1f) {
41 return gfx::SurfaceFormat::R5G6B5_UINT16
;
46 return gfx::SurfaceFormat::UNKNOWN
;
50 } // namespace mozilla