Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef MOZILLA_GFX_TEXTURECLIENT_SHAREDSURFACE_H
7 : #define MOZILLA_GFX_TEXTURECLIENT_SHAREDSURFACE_H
8 :
9 : #include <cstddef> // for size_t
10 : #include <stdint.h> // for uint32_t, uint8_t, uint64_t
11 : #include "GLContextTypes.h" // for GLContext (ptr only), etc
12 : #include "TextureClient.h"
13 : #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
14 : #include "mozilla/RefPtr.h" // for RefPtr, RefCounted
15 : #include "mozilla/gfx/Point.h" // for IntSize
16 : #include "mozilla/gfx/Types.h" // for SurfaceFormat
17 : #include "mozilla/layers/CompositorTypes.h" // for TextureFlags, etc
18 : #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
19 :
20 : namespace mozilla {
21 : namespace gl {
22 : class GLContext;
23 : class SharedSurface;
24 : class SurfaceFactory;
25 : } // namespace gl
26 :
27 : namespace layers {
28 :
29 : class SharedSurfaceTextureClient;
30 :
31 : class SharedSurfaceTextureData : public TextureData
32 : {
33 : protected:
34 : const UniquePtr<gl::SharedSurface> mSurf;
35 :
36 : friend class SharedSurfaceTextureClient;
37 :
38 : explicit SharedSurfaceTextureData(UniquePtr<gl::SharedSurface> surf);
39 : public:
40 :
41 : ~SharedSurfaceTextureData();
42 :
43 0 : virtual bool Lock(OpenMode) override { return false; }
44 :
45 0 : virtual void Unlock() override {}
46 :
47 : virtual void FillInfo(TextureData::Info& aInfo) const override;
48 :
49 : virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
50 :
51 : virtual void Deallocate(LayersIPCChannel*) override;
52 :
53 0 : gl::SharedSurface* Surf() const { return mSurf.get(); }
54 : };
55 :
56 : class SharedSurfaceTextureClient : public TextureClient
57 : {
58 : public:
59 : SharedSurfaceTextureClient(SharedSurfaceTextureData* aData,
60 : TextureFlags aFlags,
61 : LayersIPCChannel* aAllocator);
62 :
63 : ~SharedSurfaceTextureClient();
64 :
65 : static already_AddRefed<SharedSurfaceTextureClient>
66 : Create(UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
67 : LayersIPCChannel* aAllocator, TextureFlags aFlags);
68 :
69 0 : gl::SharedSurface* Surf() const {
70 0 : return static_cast<const SharedSurfaceTextureData*>(GetInternalData())->Surf();
71 : }
72 : };
73 :
74 : } // namespace layers
75 : } // namespace mozilla
76 :
77 : #endif // MOZILLA_GFX_TEXTURECLIENT_SHAREDSURFACE_H
|