gfx/layers/basic/MacIOSurfaceTextureHostBasic.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/layers/basic/MacIOSurfaceTextureHostBasic.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,91 @@
     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_MACIOSURFACETEXTUREHOST_BASIC_H
    1.10 +#define MOZILLA_GFX_MACIOSURFACETEXTUREHOST_BASIC_H
    1.11 +
    1.12 +#include "mozilla/layers/TextureHostBasic.h"
    1.13 +
    1.14 +class MacIOSurface;
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace layers {
    1.18 +
    1.19 +class BasicCompositor;
    1.20 +
    1.21 +/**
    1.22 + * A texture source meant for use with BasicCompositor.
    1.23 + *
    1.24 + * It does not own any GL texture, and attaches its shared handle to one of
    1.25 + * the compositor's temporary textures when binding.
    1.26 + */
    1.27 +class MacIOSurfaceTextureSourceBasic
    1.28 +  : public TextureSourceBasic,
    1.29 +    public NewTextureSource
    1.30 +{
    1.31 +public:
    1.32 +  MacIOSurfaceTextureSourceBasic(BasicCompositor* aCompositor,
    1.33 +                                 MacIOSurface* aSurface);
    1.34 +  virtual ~MacIOSurfaceTextureSourceBasic();
    1.35 +
    1.36 +  virtual TextureSourceBasic* AsSourceBasic() MOZ_OVERRIDE { return this; }
    1.37 +
    1.38 +  virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
    1.39 +  virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
    1.40 +  virtual gfx::SourceSurface* GetSurface(gfx::DrawTarget* aTarget) MOZ_OVERRIDE;
    1.41 +
    1.42 +  virtual void DeallocateDeviceData() MOZ_OVERRIDE { }
    1.43 +
    1.44 +  virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
    1.45 +
    1.46 +protected:
    1.47 +  BasicCompositor* mCompositor;
    1.48 +  RefPtr<MacIOSurface> mSurface;
    1.49 +  RefPtr<gfx::SourceSurface> mSourceSurface;
    1.50 +};
    1.51 +
    1.52 +/**
    1.53 + * A TextureHost for shared MacIOSurface
    1.54 + *
    1.55 + * Most of the logic actually happens in MacIOSurfaceTextureSourceBasic.
    1.56 + */
    1.57 +class MacIOSurfaceTextureHostBasic : public TextureHost
    1.58 +{
    1.59 +public:
    1.60 +  MacIOSurfaceTextureHostBasic(TextureFlags aFlags,
    1.61 +                               const SurfaceDescriptorMacIOSurface& aDescriptor);
    1.62 +
    1.63 +  virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
    1.64 +
    1.65 +  virtual bool Lock() MOZ_OVERRIDE;
    1.66 +
    1.67 +  virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
    1.68 +
    1.69 +  virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
    1.70 +  {
    1.71 +    return mTextureSource;
    1.72 +  }
    1.73 +
    1.74 +  virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
    1.75 +  {
    1.76 +    return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
    1.77 +  }
    1.78 +
    1.79 +  virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
    1.80 +
    1.81 +#ifdef MOZ_LAYERS_HAVE_LOG
    1.82 +  virtual const char* Name() { return "MacIOSurfaceTextureHostBasic"; }
    1.83 +#endif
    1.84 +
    1.85 +protected:
    1.86 +  BasicCompositor* mCompositor;
    1.87 +  RefPtr<MacIOSurfaceTextureSourceBasic> mTextureSource;
    1.88 +  RefPtr<MacIOSurface> mSurface;
    1.89 +};
    1.90 +
    1.91 +}
    1.92 +}
    1.93 +
    1.94 +#endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_BASIC_H

mercurial