/src/mozilla-central/widget/gtk/WindowSurfaceX11.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
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/. */ |
6 | | |
7 | | #include "WindowSurfaceX11.h" |
8 | | #include "gfxPlatform.h" |
9 | | #include "X11UndefineNone.h" |
10 | | |
11 | | namespace mozilla { |
12 | | namespace widget { |
13 | | |
14 | | WindowSurfaceX11::WindowSurfaceX11(Display* aDisplay, |
15 | | Window aWindow, |
16 | | Visual* aVisual, |
17 | | unsigned int aDepth) |
18 | | : mDisplay(aDisplay) |
19 | | , mWindow(aWindow) |
20 | | , mVisual(aVisual) |
21 | | , mDepth(aDepth) |
22 | | , mFormat(GetVisualFormat(aVisual, aDepth)) |
23 | 0 | { |
24 | 0 | } |
25 | | |
26 | | /* static */ |
27 | | gfx::SurfaceFormat |
28 | | WindowSurfaceX11::GetVisualFormat(const Visual* aVisual, unsigned int aDepth) |
29 | 0 | { |
30 | 0 | switch (aDepth) { |
31 | 0 | case 32: |
32 | 0 | if (aVisual->red_mask == 0xff0000 && |
33 | 0 | aVisual->green_mask == 0xff00 && |
34 | 0 | aVisual->blue_mask == 0xff) { |
35 | 0 | return gfx::SurfaceFormat::B8G8R8A8; |
36 | 0 | } |
37 | 0 | break; |
38 | 0 | case 24: |
39 | 0 | if (aVisual->red_mask == 0xff0000 && |
40 | 0 | aVisual->green_mask == 0xff00 && |
41 | 0 | aVisual->blue_mask == 0xff) { |
42 | 0 | return gfx::SurfaceFormat::B8G8R8X8; |
43 | 0 | } |
44 | 0 | break; |
45 | 0 | case 16: |
46 | 0 | if (aVisual->red_mask == 0xf800 && |
47 | 0 | aVisual->green_mask == 0x07e0 && |
48 | 0 | aVisual->blue_mask == 0x1f) { |
49 | 0 | return gfx::SurfaceFormat::R5G6B5_UINT16; |
50 | 0 | } |
51 | 0 | break; |
52 | 0 | } |
53 | 0 | |
54 | 0 | return gfx::SurfaceFormat::UNKNOWN; |
55 | 0 | } |
56 | | |
57 | | } // namespace widget |
58 | | } // namespace mozilla |