2015-06-05 03:15:38 +03: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/. */
|
|
|
|
|
|
|
|
#include "TextureClientSharedSurface.h"
|
|
|
|
|
|
|
|
#include "GLContext.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "mozilla/gfx/Logging.h" // for gfxDebug
|
|
|
|
#include "mozilla/layers/ISurfaceAllocator.h"
|
|
|
|
#include "mozilla/unused.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "SharedSurface.h"
|
|
|
|
|
2015-09-21 17:21:52 +03:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2015-10-27 08:43:07 +03:00
|
|
|
#include "mozilla/layers/GrallocTextureClient.h"
|
2015-09-21 17:21:52 +03:00
|
|
|
#include "SharedSurfaceGralloc.h"
|
|
|
|
#endif
|
|
|
|
|
2015-10-27 08:43:07 +03:00
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
2015-06-05 03:15:38 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2015-11-24 21:07:02 +03:00
|
|
|
SharedSurfaceTextureClient::SharedSurfaceTextureClient(ISurfaceAllocator* aAllocator,
|
|
|
|
TextureFlags aFlags,
|
|
|
|
UniquePtr<gl::SharedSurface> surf,
|
|
|
|
gl::SurfaceFactory* factory)
|
|
|
|
: TextureClient(aAllocator,
|
|
|
|
aFlags | TextureFlags::RECYCLE | surf->GetTextureFlags())
|
|
|
|
, mSurf(Move(surf))
|
2015-11-20 16:25:03 +03:00
|
|
|
{
|
|
|
|
}
|
2015-11-20 16:24:55 +03:00
|
|
|
|
2015-11-24 21:07:02 +03:00
|
|
|
SharedSurfaceTextureClient::~SharedSurfaceTextureClient()
|
2015-11-20 16:24:55 +03:00
|
|
|
{
|
2015-11-24 21:07:02 +03:00
|
|
|
// Free the ShSurf implicitly.
|
2015-11-20 16:24:55 +03:00
|
|
|
}
|
|
|
|
|
2015-11-24 21:07:02 +03:00
|
|
|
gfx::IntSize
|
|
|
|
SharedSurfaceTextureClient::GetSize() const
|
2015-11-20 16:25:03 +03:00
|
|
|
{
|
2015-11-24 21:07:02 +03:00
|
|
|
return mSurf->mSize;
|
2015-11-20 16:25:03 +03:00
|
|
|
}
|
2015-11-20 16:24:55 +03:00
|
|
|
|
2015-11-24 21:07:02 +03:00
|
|
|
bool
|
|
|
|
SharedSurfaceTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
2015-11-20 16:24:55 +03:00
|
|
|
{
|
2015-11-24 21:07:02 +03:00
|
|
|
return mSurf->ToSurfaceDescriptor(&aOutDescriptor);
|
2015-11-20 16:24:55 +03:00
|
|
|
}
|
|
|
|
|
2015-09-21 17:21:52 +03:00
|
|
|
void
|
|
|
|
SharedSurfaceTextureClient::SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2015-10-15 18:53:37 +03:00
|
|
|
gl::SharedSurface_Gralloc* surf = nullptr;
|
|
|
|
if (mSurf->mType == gl::SharedSurfaceType::Gralloc) {
|
|
|
|
surf = gl::SharedSurface_Gralloc::Cast(mSurf.get());
|
2015-09-21 17:21:52 +03:00
|
|
|
}
|
|
|
|
if (surf && surf->GetTextureClient()) {
|
|
|
|
surf->GetTextureClient()->SetReleaseFenceHandle(aReleaseFenceHandle);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
TextureClient::SetReleaseFenceHandle(aReleaseFenceHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
FenceHandle
|
|
|
|
SharedSurfaceTextureClient::GetAndResetReleaseFenceHandle()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2015-10-15 18:53:37 +03:00
|
|
|
gl::SharedSurface_Gralloc* surf = nullptr;
|
|
|
|
if (mSurf->mType == gl::SharedSurfaceType::Gralloc) {
|
|
|
|
surf = gl::SharedSurface_Gralloc::Cast(mSurf.get());
|
2015-09-21 17:21:52 +03:00
|
|
|
}
|
|
|
|
if (surf && surf->GetTextureClient()) {
|
|
|
|
return surf->GetTextureClient()->GetAndResetReleaseFenceHandle();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return TextureClient::GetAndResetReleaseFenceHandle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SharedSurfaceTextureClient::SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2015-10-15 18:53:37 +03:00
|
|
|
gl::SharedSurface_Gralloc* surf = nullptr;
|
|
|
|
if (mSurf->mType == gl::SharedSurfaceType::Gralloc) {
|
|
|
|
surf = gl::SharedSurface_Gralloc::Cast(mSurf.get());
|
2015-09-21 17:21:52 +03:00
|
|
|
}
|
|
|
|
if (surf && surf->GetTextureClient()) {
|
|
|
|
return surf->GetTextureClient()->SetAcquireFenceHandle(aAcquireFenceHandle);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
TextureClient::SetAcquireFenceHandle(aAcquireFenceHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
const FenceHandle&
|
|
|
|
SharedSurfaceTextureClient::GetAcquireFenceHandle() const
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2015-10-15 18:53:37 +03:00
|
|
|
gl::SharedSurface_Gralloc* surf = nullptr;
|
|
|
|
if (mSurf->mType == gl::SharedSurfaceType::Gralloc) {
|
|
|
|
surf = gl::SharedSurface_Gralloc::Cast(mSurf.get());
|
2015-09-21 17:21:52 +03:00
|
|
|
}
|
|
|
|
if (surf && surf->GetTextureClient()) {
|
|
|
|
return surf->GetTextureClient()->GetAcquireFenceHandle();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return TextureClient::GetAcquireFenceHandle();
|
|
|
|
}
|
|
|
|
|
2015-06-05 03:15:38 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|