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