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_MACIOSURFACETEXTURECLIENTOGL_H
8 #define MOZILLA_GFX_MACIOSURFACETEXTURECLIENTOGL_H
9 
10 #include "mozilla/layers/TextureClientOGL.h"
11 
12 class DMABufSurface;
13 
14 namespace mozilla {
15 namespace layers {
16 
17 class DMABUFTextureData : public TextureData {
18  public:
19   static DMABUFTextureData* Create(const gfx::IntSize& aSize,
20                                    gfx::SurfaceFormat aFormat,
21                                    gfx::BackendType aBackend);
22 
Create(DMABufSurface * aSurface,gfx::BackendType aBackend)23   static DMABUFTextureData* Create(DMABufSurface* aSurface,
24                                    gfx::BackendType aBackend) {
25     return new DMABUFTextureData(aSurface, aBackend);
26   }
27 
28   ~DMABUFTextureData();
29 
30   virtual TextureData* CreateSimilar(
31       LayersIPCChannel* aAllocator, LayersBackend aLayersBackend,
32       TextureFlags aFlags = TextureFlags::DEFAULT,
33       TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
34 
35   void FillInfo(TextureData::Info& aInfo) const override;
36 
37   bool Lock(OpenMode) override;
38 
39   void Unlock() override;
40 
41   already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
42 
43   bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
44 
45   void Deallocate(LayersIPCChannel*) override;
46 
47   void Forget(LayersIPCChannel*) override;
48 
49   bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
50 
51   // For debugging purposes only.
52   already_AddRefed<gfx::DataSourceSurface> GetAsSurface();
53 
54  protected:
55   DMABUFTextureData(DMABufSurface* aSurface, gfx::BackendType aBackend);
56 
57   RefPtr<DMABufSurface> mSurface;
58   gfx::BackendType mBackend;
59 };
60 
61 }  // namespace layers
62 }  // namespace mozilla
63 
64 #endif  // MOZILLA_GFX_MACIOSURFACETEXTURECLIENTOGL_H
65