2013-12-04 04:20:04 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_MACIOSURFACETEXTUREHOST_BASIC_H
|
|
|
|
#define MOZILLA_GFX_MACIOSURFACETEXTUREHOST_BASIC_H
|
|
|
|
|
2014-10-16 17:48:29 +04:00
|
|
|
#include "mozilla/layers/BasicCompositor.h"
|
2013-12-04 04:20:04 +04:00
|
|
|
#include "mozilla/layers/TextureHostBasic.h"
|
|
|
|
|
|
|
|
class MacIOSurface;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class BasicCompositor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A texture source meant for use with BasicCompositor.
|
|
|
|
*
|
|
|
|
* It does not own any GL texture, and attaches its shared handle to one of
|
|
|
|
* the compositor's temporary textures when binding.
|
|
|
|
*/
|
|
|
|
class MacIOSurfaceTextureSourceBasic
|
|
|
|
: public TextureSourceBasic,
|
2014-10-07 17:58:59 +04:00
|
|
|
public TextureSource
|
2013-12-04 04:20:04 +04:00
|
|
|
{
|
|
|
|
public:
|
2017-03-22 06:32:53 +03:00
|
|
|
explicit MacIOSurfaceTextureSourceBasic(MacIOSurface* aSurface);
|
2013-12-04 04:20:04 +04:00
|
|
|
virtual ~MacIOSurfaceTextureSourceBasic();
|
|
|
|
|
2016-02-08 13:57:00 +03:00
|
|
|
virtual const char* Name() const override { return "MacIOSurfaceTextureSourceBasic"; }
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual TextureSourceBasic* AsSourceBasic() override { return this; }
|
2013-12-04 04:20:04 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override;
|
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override;
|
|
|
|
virtual gfx::SourceSurface* GetSurface(gfx::DrawTarget* aTarget) override;
|
2013-12-04 04:20:04 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateDeviceData() override { }
|
2013-12-04 04:20:04 +04:00
|
|
|
|
|
|
|
protected:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MacIOSurface> mSurface;
|
|
|
|
RefPtr<gfx::SourceSurface> mSourceSurface;
|
2013-12-04 04:20:04 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A TextureHost for shared MacIOSurface
|
|
|
|
*
|
|
|
|
* Most of the logic actually happens in MacIOSurfaceTextureSourceBasic.
|
|
|
|
*/
|
|
|
|
class MacIOSurfaceTextureHostBasic : public TextureHost
|
|
|
|
{
|
|
|
|
public:
|
2013-12-12 05:44:47 +04:00
|
|
|
MacIOSurfaceTextureHostBasic(TextureFlags aFlags,
|
|
|
|
const SurfaceDescriptorMacIOSurface& aDescriptor);
|
2013-12-04 04:20:04 +04:00
|
|
|
|
2017-03-22 06:32:54 +03:00
|
|
|
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
2016-06-02 12:00:21 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Lock() override;
|
2013-12-04 04:20:04 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override;
|
2013-12-04 04:20:04 +04:00
|
|
|
|
2015-03-27 13:16:34 +03:00
|
|
|
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
|
2013-12-04 04:20:04 +04:00
|
|
|
{
|
2015-03-27 13:16:34 +03:00
|
|
|
aTexture = mTextureSource;
|
|
|
|
return !!aTexture;
|
2013-12-04 04:20:04 +04:00
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override
|
2013-12-04 04:20:04 +04:00
|
|
|
{
|
|
|
|
return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override;
|
2013-12-04 04:20:04 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_LAYERS_HAVE_LOG
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual const char* Name() override { return "MacIOSurfaceTextureHostBasic"; }
|
2013-12-04 04:20:04 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MacIOSurfaceTextureSourceBasic> mTextureSource;
|
|
|
|
RefPtr<MacIOSurface> mSurface;
|
2013-12-04 04:20:04 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2013-12-04 04:20:04 +04:00
|
|
|
|
|
|
|
#endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_BASIC_H
|