2013-08-09 19:23:46 +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_GRALLOCTEXTUREHOST_H
|
|
|
|
#define MOZILLA_GFX_GRALLOCTEXTUREHOST_H
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
|
2014-10-16 17:48:29 +04:00
|
|
|
#include "mozilla/layers/CompositorOGL.h"
|
2013-08-09 19:23:46 +04:00
|
|
|
#include "mozilla/layers/TextureHostOGL.h"
|
|
|
|
#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
|
|
|
|
#include <ui/GraphicBuffer.h>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class GrallocTextureHostOGL : public TextureHost
|
|
|
|
{
|
|
|
|
friend class GrallocBufferActor;
|
|
|
|
public:
|
2013-12-12 05:44:47 +04:00
|
|
|
GrallocTextureHostOGL(TextureFlags aFlags,
|
2013-08-09 19:23:46 +04:00
|
|
|
const NewSurfaceDescriptorGralloc& aDescriptor);
|
|
|
|
|
|
|
|
virtual ~GrallocTextureHostOGL();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Lock() override;
|
2013-08-09 19:23:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Unlock() override;
|
2013-08-09 19:23:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetCompositor(Compositor* aCompositor) override;
|
2013-08-09 19:23:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateSharedData() override;
|
2013-08-09 19:23:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ForgetSharedData() override;
|
2013-12-12 05:44:45 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateDeviceData() override;
|
2013-08-09 19:23:46 +04:00
|
|
|
|
|
|
|
virtual gfx::SurfaceFormat GetFormat() const;
|
|
|
|
|
2015-07-20 02:02:51 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override { return mCropSize; }
|
2013-08-09 19:23:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual LayerRenderState GetRenderState() override;
|
2013-08-09 19:23:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void PrepareTextureSource(CompositableTextureSourceRef& aTextureSource) override;
|
2014-10-16 21:08:32 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool BindTextureSource(CompositableTextureSourceRef& aTextureSource) override;
|
2014-10-16 21:08:32 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void UnbindTextureSource() override;
|
2014-10-16 21:08:32 +04:00
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
|
2013-08-09 19:23:46 +04:00
|
|
|
|
2015-05-22 09:25:00 +03:00
|
|
|
virtual void WaitAcquireFenceHandleSyncComplete() override;
|
|
|
|
|
2015-07-20 02:03:10 +03:00
|
|
|
virtual void SetCropRect(nsIntRect aCropRect) override;
|
|
|
|
|
2013-08-30 18:24:05 +04:00
|
|
|
bool IsValid() const;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual const char* Name() override { return "GrallocTextureHostOGL"; }
|
2013-08-09 19:23:46 +04:00
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
gl::GLContext* GetGLContext() const { return mCompositor ? mCompositor->gl() : nullptr; }
|
|
|
|
|
2013-08-09 19:23:46 +04:00
|
|
|
private:
|
2014-10-16 21:08:32 +04:00
|
|
|
void DestroyEGLImage();
|
2014-10-24 22:25:25 +04:00
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
NewSurfaceDescriptorGralloc mGrallocHandle;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<GLTextureSource> mGLTextureSource;
|
|
|
|
RefPtr<CompositorOGL> mCompositor;
|
2014-10-16 21:08:32 +04:00
|
|
|
// Size reported by the GraphicBuffer
|
|
|
|
gfx::IntSize mSize;
|
|
|
|
// Size reported by TextureClient, can be different in some cases (video?),
|
|
|
|
// used by LayerRenderState.
|
2015-07-20 02:02:51 +03:00
|
|
|
gfx::IntSize mCropSize;
|
2014-10-16 21:08:32 +04:00
|
|
|
gfx::SurfaceFormat mFormat;
|
|
|
|
EGLImage mEGLImage;
|
2014-10-30 05:32:40 +03:00
|
|
|
bool mIsOpaque;
|
2013-08-09 19:23:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|