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_X11TEXTURESOURCEOGL__H
7 : #define MOZILLA_GFX_X11TEXTURESOURCEOGL__H
8 :
9 : #ifdef GL_PROVIDER_GLX
10 :
11 : #include "mozilla/layers/CompositorOGL.h"
12 : #include "mozilla/layers/TextureHostOGL.h"
13 : #include "mozilla/layers/X11TextureHost.h"
14 : #include "mozilla/gfx/2D.h"
15 :
16 : namespace mozilla {
17 : namespace layers {
18 :
19 : // TextureSource for Xlib-backed surfaces.
20 : class X11TextureSourceOGL
21 : : public TextureSourceOGL
22 : , public X11TextureSource
23 : {
24 : public:
25 : X11TextureSourceOGL(CompositorOGL* aCompositor, gfxXlibSurface* aSurface);
26 : ~X11TextureSourceOGL();
27 :
28 0 : virtual X11TextureSourceOGL* AsSourceOGL() override { return this; }
29 :
30 0 : virtual bool IsValid() const override { return !!gl(); } ;
31 :
32 : virtual void BindTexture(GLenum aTextureUnit, gfx::SamplingFilter aSamplingFilter) override;
33 :
34 : virtual gfx::IntSize GetSize() const override;
35 :
36 0 : virtual GLenum GetTextureTarget() const override { return LOCAL_GL_TEXTURE_2D; }
37 :
38 : virtual gfx::SurfaceFormat GetFormat() const override;
39 :
40 0 : virtual GLenum GetWrapMode() const override { return LOCAL_GL_CLAMP_TO_EDGE; }
41 :
42 : virtual void DeallocateDeviceData() override;
43 :
44 : virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
45 :
46 0 : virtual void Updated() override { mUpdated = true; }
47 :
48 0 : gl::GLContext* gl() const {
49 0 : return mGL;
50 : }
51 :
52 : static gfx::SurfaceFormat ContentTypeToSurfaceFormat(gfxContentType aType);
53 :
54 : protected:
55 : RefPtr<gl::GLContext> mGL;
56 : RefPtr<gfxXlibSurface> mSurface;
57 : RefPtr<gfx::SourceSurface> mSourceSurface;
58 : GLuint mTexture;
59 : bool mUpdated;
60 : };
61 :
62 : } // namespace layers
63 : } // namespace mozilla
64 :
65 : #endif
66 :
67 : #endif // MOZILLA_GFX_X11TEXTURESOURCEOGL__H
|