Line data Source code
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 : #ifndef _MOZILLA_WIDGET_GTK_WINDOW_SURFACE_PROVIDER_H
8 : #define _MOZILLA_WIDGET_GTK_WINDOW_SURFACE_PROVIDER_H
9 :
10 : #include "mozilla/widget/WindowSurface.h"
11 : #include "mozilla/gfx/Types.h"
12 : #include "mozilla/gfx/2D.h"
13 : #include "Units.h"
14 :
15 : #include <X11/Xlib.h> // for Window, Display, Visual, etc.
16 :
17 : namespace mozilla {
18 : namespace widget {
19 :
20 : /*
21 : * Holds the logic for creating WindowSurface's for a GTK nsWindow.
22 : * The main purpose of this class is to allow sharing of logic between
23 : * nsWindow and X11CompositorWidget, for when OMTC is enabled or disabled.
24 : */
25 0 : class WindowSurfaceProvider final
26 : {
27 : public:
28 : WindowSurfaceProvider();
29 :
30 : /**
31 : * Initializes the WindowSurfaceProvider by giving it the window
32 : * handle and display to attach to. WindowSurfaceProvider doesn't
33 : * own the Display, Window, etc, and they must continue to exist
34 : * while WindowSurfaceProvider is used.
35 : */
36 : void Initialize(
37 : Display* aDisplay,
38 : Window aWindow,
39 : Visual* aVisual,
40 : int aDepth);
41 :
42 : /**
43 : * Releases any surfaces created by this provider.
44 : * This is used by X11CompositorWidget to get rid
45 : * of resources before we close the display connection.
46 : */
47 : void CleanupResources();
48 :
49 : already_AddRefed<gfx::DrawTarget>
50 : StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
51 : layers::BufferMode* aBufferMode);
52 : void EndRemoteDrawingInRegion(gfx::DrawTarget* aDrawTarget,
53 : LayoutDeviceIntRegion& aInvalidRegion);
54 :
55 : private:
56 : UniquePtr<WindowSurface> CreateWindowSurface();
57 :
58 : Display* mXDisplay;
59 : Window mXWindow;
60 : Visual* mXVisual;
61 : int mXDepth;
62 :
63 : UniquePtr<WindowSurface> mWindowSurface;
64 : };
65 :
66 : } // namespace widget
67 : } // namespace mozilla
68 :
69 : #endif // _MOZILLA_WIDGET_GTK_WINDOW_SURFACE_PROVIDER_H
|