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 #include "WindowSurfaceX11SHM.h"
8 
9 namespace mozilla::widget {
10 
WindowSurfaceX11SHM(Display * aDisplay,Drawable aWindow,Visual * aVisual,unsigned int aDepth)11 WindowSurfaceX11SHM::WindowSurfaceX11SHM(Display* aDisplay, Drawable aWindow,
12                                          Visual* aVisual, unsigned int aDepth) {
13   mFrontImage = new nsShmImage(aDisplay, aWindow, aVisual, aDepth);
14   mBackImage = new nsShmImage(aDisplay, aWindow, aVisual, aDepth);
15 }
16 
Lock(const LayoutDeviceIntRegion & aRegion)17 already_AddRefed<gfx::DrawTarget> WindowSurfaceX11SHM::Lock(
18     const LayoutDeviceIntRegion& aRegion) {
19   mBackImage.swap(mFrontImage);
20   return mBackImage->CreateDrawTarget(aRegion);
21 }
22 
Commit(const LayoutDeviceIntRegion & aInvalidRegion)23 void WindowSurfaceX11SHM::Commit(const LayoutDeviceIntRegion& aInvalidRegion) {
24   mBackImage->Put(aInvalidRegion);
25 }
26 
27 }  // namespace mozilla::widget
28