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_X11TEXTUREHOST__H
7 : #define MOZILLA_GFX_X11TEXTUREHOST__H
8 :
9 : #include "mozilla/layers/TextureHost.h"
10 : #include "mozilla/layers/LayersSurfaces.h"
11 : #include "mozilla/gfx/Types.h"
12 :
13 : #include "gfxXlibSurface.h"
14 :
15 : namespace mozilla {
16 : namespace layers {
17 :
18 0 : class X11TextureSource : public TextureSource
19 : {
20 : public:
21 : // Called when the underlying X surface has been changed.
22 : // Useful for determining whether to rebind a GLXPixmap to a texture.
23 : virtual void Updated() = 0;
24 :
25 0 : virtual const char* Name() const override { return "X11TextureSource"; }
26 : };
27 :
28 : // TextureHost for Xlib-backed TextureSources.
29 0 : class X11TextureHost : public TextureHost
30 : {
31 : public:
32 : X11TextureHost(TextureFlags aFlags,
33 : const SurfaceDescriptorX11& aDescriptor);
34 :
35 : virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
36 :
37 : virtual bool Lock() override;
38 :
39 : virtual gfx::SurfaceFormat GetFormat() const override;
40 :
41 : virtual gfx::IntSize GetSize() const override;
42 :
43 0 : virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
44 : {
45 0 : aTexture = mTextureSource;
46 0 : return !!aTexture;
47 : }
48 :
49 : virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
50 :
51 : #ifdef MOZ_LAYERS_HAVE_LOG
52 0 : virtual const char* Name() override { return "X11TextureHost"; }
53 : #endif
54 :
55 : protected:
56 0 : virtual void UpdatedInternal(const nsIntRegion*) override
57 : {
58 0 : if (mTextureSource)
59 0 : mTextureSource->Updated();
60 0 : }
61 :
62 : RefPtr<Compositor> mCompositor;
63 : RefPtr<X11TextureSource> mTextureSource;
64 : RefPtr<gfxXlibSurface> mSurface;
65 : };
66 :
67 : } // namespace layers
68 : } // namespace mozilla
69 :
70 : #endif // MOZILLA_GFX_X11TEXTUREHOST__H
|