1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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_X11_IMAGE_H
8 #define _MOZILLA_WIDGET_GTK_WINDOW_SURFACE_X11_IMAGE_H
9 
10 #ifdef MOZ_X11
11 
12 #  include <glib.h>
13 #  include "WindowSurfaceX11.h"
14 #  include "gfxXlibSurface.h"
15 #  include "gfxImageSurface.h"
16 
17 namespace mozilla {
18 namespace widget {
19 
20 class WindowSurfaceX11Image : public WindowSurfaceX11 {
21  public:
22   WindowSurfaceX11Image(Display* aDisplay, Window aWindow, Visual* aVisual,
23                         unsigned int aDepth, bool aIsShaped);
24   ~WindowSurfaceX11Image();
25 
26   already_AddRefed<gfx::DrawTarget> Lock(
27       const LayoutDeviceIntRegion& aRegion) override;
28   void Commit(const LayoutDeviceIntRegion& aInvalidRegion) override;
IsFallback()29   bool IsFallback() const override { return true; }
30 
31  private:
32   void ResizeTransparencyBitmap(int aWidth, int aHeight);
33   void ApplyTransparencyBitmap();
34 
35   RefPtr<gfxXlibSurface> mWindowSurface;
36   RefPtr<gfxImageSurface> mImageSurface;
37 
38   gchar* mTransparencyBitmap;
39   int32_t mTransparencyBitmapWidth;
40   int32_t mTransparencyBitmapHeight;
41   bool mIsShaped;
42 };
43 
44 }  // namespace widget
45 }  // namespace mozilla
46 
47 #endif  // MOZ_X11
48 #endif  // _MOZILLA_WIDGET_GTK_WINDOW_SURFACE_X11_IMAGE_H
49