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/. */
7 #ifndef MOZILLA_GFX_TEXTURECLIENT_SHAREDSURFACE_H
8 #define MOZILLA_GFX_TEXTURECLIENT_SHAREDSURFACE_H
10 #include <cstddef> // for size_t
11 #include <stdint.h> // for uint32_t, uint8_t, uint64_t
12 #include "GLContextTypes.h" // for GLContext (ptr only), etc
13 #include "TextureClient.h"
14 #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
15 #include "mozilla/RefPtr.h" // for RefPtr, RefCounted
16 #include "mozilla/gfx/Point.h" // for IntSize
17 #include "mozilla/gfx/Types.h" // for SurfaceFormat
18 #include "mozilla/layers/CompositorTypes.h" // for TextureFlags, etc
19 #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
30 class SharedSurfaceTextureClient
;
32 class SharedSurfaceTextureData
: public TextureData
{
34 const UniquePtr
<gl::SharedSurface
> mSurf
;
36 friend class SharedSurfaceTextureClient
;
38 explicit SharedSurfaceTextureData(UniquePtr
<gl::SharedSurface
> surf
);
41 virtual ~SharedSurfaceTextureData();
43 bool Lock(OpenMode
) override
{ return false; }
45 void Unlock() override
{}
47 void FillInfo(TextureData::Info
& aInfo
) const override
;
49 bool Serialize(SurfaceDescriptor
& aOutDescriptor
) override
;
51 void Deallocate(LayersIPCChannel
*) override
;
53 gl::SharedSurface
* Surf() const { return mSurf
.get(); }
56 class SharedSurfaceTextureClient
: public TextureClient
{
58 SharedSurfaceTextureClient(SharedSurfaceTextureData
* aData
,
59 TextureFlags aFlags
, LayersIPCChannel
* aAllocator
);
61 ~SharedSurfaceTextureClient();
63 static already_AddRefed
<SharedSurfaceTextureClient
> Create(
64 UniquePtr
<gl::SharedSurface
> surf
, gl::SurfaceFactory
* factory
,
65 LayersIPCChannel
* aAllocator
, TextureFlags aFlags
);
67 gl::SharedSurface
* Surf() const {
68 return static_cast<const SharedSurfaceTextureData
*>(GetInternalData())
74 } // namespace mozilla
76 #endif // MOZILLA_GFX_TEXTURECLIENT_SHAREDSURFACE_H