gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,103 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H
    1.10 +#define MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H
    1.11 +
    1.12 +#include "mozilla/layers/TextureHostOGL.h"
    1.13 +
    1.14 +class MacIOSurface;
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace layers {
    1.18 +
    1.19 +/**
    1.20 + * A texture source meant for use with MacIOSurfaceTextureHostOGL.
    1.21 + *
    1.22 + * It does not own any GL texture, and attaches its shared handle to one of
    1.23 + * the compositor's temporary textures when binding.
    1.24 + */
    1.25 +class MacIOSurfaceTextureSourceOGL : public NewTextureSource
    1.26 +                                   , public TextureSourceOGL
    1.27 +{
    1.28 +public:
    1.29 +  MacIOSurfaceTextureSourceOGL(CompositorOGL* aCompositor,
    1.30 +                               MacIOSurface* aSurface);
    1.31 +  virtual ~MacIOSurfaceTextureSourceOGL();
    1.32 +
    1.33 +  virtual TextureSourceOGL* AsSourceOGL() { return this; }
    1.34 +
    1.35 +  virtual void BindTexture(GLenum activetex, gfx::Filter aFilter) MOZ_OVERRIDE;
    1.36 +
    1.37 +  virtual bool IsValid() const MOZ_OVERRIDE { return !!gl(); }
    1.38 +
    1.39 +  virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
    1.40 +
    1.41 +  virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
    1.42 +
    1.43 +  virtual GLenum GetTextureTarget() const { return LOCAL_GL_TEXTURE_RECTANGLE_ARB; }
    1.44 +
    1.45 +  virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; }
    1.46 +
    1.47 +  // MacIOSurfaceTextureSourceOGL doesn't own any gl texture
    1.48 +  virtual void DeallocateDeviceData() {}
    1.49 +
    1.50 +  virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
    1.51 +
    1.52 +  gl::GLContext* gl() const;
    1.53 +
    1.54 +protected:
    1.55 +  CompositorOGL* mCompositor;
    1.56 +  RefPtr<MacIOSurface> mSurface;
    1.57 +};
    1.58 +
    1.59 +/**
    1.60 + * A TextureHost for shared MacIOSurface
    1.61 + *
    1.62 + * Most of the logic actually happens in MacIOSurfaceTextureSourceOGL.
    1.63 + */
    1.64 +class MacIOSurfaceTextureHostOGL : public TextureHost
    1.65 +{
    1.66 +public:
    1.67 +  MacIOSurfaceTextureHostOGL(TextureFlags aFlags,
    1.68 +                             const SurfaceDescriptorMacIOSurface& aDescriptor);
    1.69 +
    1.70 +  // SharedTextureHostOGL doesn't own any GL texture
    1.71 +  virtual void DeallocateDeviceData() MOZ_OVERRIDE {}
    1.72 +
    1.73 +  virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
    1.74 +
    1.75 +  virtual bool Lock() MOZ_OVERRIDE;
    1.76 +
    1.77 +  virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
    1.78 +
    1.79 +  virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
    1.80 +  {
    1.81 +    return mTextureSource;
    1.82 +  }
    1.83 +
    1.84 +  virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
    1.85 +  {
    1.86 +    return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
    1.87 +  }
    1.88 +
    1.89 +  gl::GLContext* gl() const;
    1.90 +
    1.91 +  virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
    1.92 +
    1.93 +#ifdef MOZ_LAYERS_HAVE_LOG
    1.94 +  virtual const char* Name() { return "MacIOSurfaceTextureHostOGL"; }
    1.95 +#endif
    1.96 +
    1.97 +protected:
    1.98 +  CompositorOGL* mCompositor;
    1.99 +  RefPtr<MacIOSurfaceTextureSourceOGL> mTextureSource;
   1.100 +  RefPtr<MacIOSurface> mSurface;
   1.101 +};
   1.102 +
   1.103 +}
   1.104 +}
   1.105 +
   1.106 +#endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H

mercurial