1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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_GFX_TEXTURECLIENT_X11_H
8 #define MOZILLA_GFX_TEXTURECLIENT_X11_H
9 
10 #include "mozilla/layers/TextureClient.h"
11 #include "ISurfaceAllocator.h"  // For IsSurfaceDescriptorValid
12 
13 namespace mozilla {
14 namespace layers {
15 
16 class X11TextureData : public TextureData {
17  public:
18   static X11TextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
19                                 TextureFlags aFlags,
20                                 LayersIPCChannel* aAllocator);
21 
22   virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
23 
24   virtual bool Lock(OpenMode aMode) override;
25 
26   virtual void Unlock() override;
27 
28   virtual void FillInfo(TextureData::Info& aInfo) const override;
29 
30   virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
31 
32   virtual void Deallocate(LayersIPCChannel*) override;
33 
34   virtual TextureData* CreateSimilar(
35       LayersIPCChannel* aAllocator, LayersBackend aLayersBackend,
36       TextureFlags aFlags = TextureFlags::DEFAULT,
37       TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
38 
39   virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
40 
41  protected:
42   X11TextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
43                  bool aClientDeallocation, bool aIsCrossProcess,
44                  gfxXlibSurface* aSurface);
45 
46   gfx::IntSize mSize;
47   gfx::SurfaceFormat mFormat;
48   RefPtr<gfxXlibSurface> mSurface;
49   bool mClientDeallocation;
50   bool mIsCrossProcess;
51 };
52 
53 }  // namespace layers
54 }  // namespace mozilla
55 
56 #endif
57