2016-09-21 12:24:44 +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 "GPUVideoTextureHost.h"
|
2016-09-21 12:25:33 +03:00
|
|
|
#include "mozilla/dom/VideoDecoderManagerParent.h"
|
2016-09-21 12:24:44 +03:00
|
|
|
#include "ImageContainer.h"
|
2016-09-23 00:44:26 +03:00
|
|
|
#include "mozilla/layers/VideoBridgeParent.h"
|
2016-09-21 12:24:44 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
GPUVideoTextureHost::GPUVideoTextureHost(TextureFlags aFlags,
|
|
|
|
const SurfaceDescriptorGPUVideo& aDescriptor)
|
|
|
|
: TextureHost(aFlags)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(GPUVideoTextureHost);
|
2016-09-23 00:44:26 +03:00
|
|
|
mWrappedTextureHost = VideoBridgeParent::GetSingleton()->LookupTexture(aDescriptor.handle());
|
2016-09-21 12:24:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
GPUVideoTextureHost::~GPUVideoTextureHost()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(GPUVideoTextureHost);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GPUVideoTextureHost::Lock()
|
|
|
|
{
|
2016-09-23 00:44:26 +03:00
|
|
|
if (!mWrappedTextureHost) {
|
2016-09-21 12:24:44 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-09-23 00:44:26 +03:00
|
|
|
return mWrappedTextureHost->Lock();
|
|
|
|
}
|
2016-09-21 12:24:44 +03:00
|
|
|
|
2017-01-23 23:34:59 +03:00
|
|
|
void
|
|
|
|
GPUVideoTextureHost::Unlock()
|
|
|
|
{
|
|
|
|
if (!mWrappedTextureHost) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mWrappedTextureHost->Unlock();
|
|
|
|
}
|
|
|
|
|
2016-09-23 00:44:26 +03:00
|
|
|
bool
|
|
|
|
GPUVideoTextureHost::BindTextureSource(CompositableTextureSourceRef& aTexture)
|
|
|
|
{
|
|
|
|
if (!mWrappedTextureHost) {
|
|
|
|
return false;
|
2016-09-21 12:24:44 +03:00
|
|
|
}
|
2016-09-23 00:44:26 +03:00
|
|
|
return mWrappedTextureHost->BindTextureSource(aTexture);
|
|
|
|
}
|
2016-09-21 12:24:44 +03:00
|
|
|
|
2017-06-20 11:17:17 +03:00
|
|
|
bool
|
|
|
|
GPUVideoTextureHost::AcquireTextureSource(CompositableTextureSourceRef& aTexture)
|
|
|
|
{
|
|
|
|
if (!mWrappedTextureHost) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return mWrappedTextureHost->AcquireTextureSource(aTexture);
|
|
|
|
}
|
|
|
|
|
2016-09-21 12:24:44 +03:00
|
|
|
void
|
2017-03-22 06:32:54 +03:00
|
|
|
GPUVideoTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
2016-09-21 12:24:44 +03:00
|
|
|
{
|
2016-09-23 00:44:26 +03:00
|
|
|
if (mWrappedTextureHost) {
|
2017-03-22 06:32:54 +03:00
|
|
|
mWrappedTextureHost->SetTextureSourceProvider(aProvider);
|
2016-09-21 12:24:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-02 23:55:07 +03:00
|
|
|
YUVColorSpace
|
|
|
|
GPUVideoTextureHost::GetYUVColorSpace() const
|
|
|
|
{
|
|
|
|
if (mWrappedTextureHost) {
|
|
|
|
return mWrappedTextureHost->GetYUVColorSpace();
|
|
|
|
}
|
|
|
|
return YUVColorSpace::UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2016-09-21 12:24:44 +03:00
|
|
|
gfx::IntSize
|
|
|
|
GPUVideoTextureHost::GetSize() const
|
|
|
|
{
|
2016-09-23 00:44:26 +03:00
|
|
|
if (!mWrappedTextureHost) {
|
2016-09-21 12:24:44 +03:00
|
|
|
return gfx::IntSize();
|
|
|
|
}
|
2016-09-23 00:44:26 +03:00
|
|
|
return mWrappedTextureHost->GetSize();
|
2016-09-21 12:24:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx::SurfaceFormat
|
|
|
|
GPUVideoTextureHost::GetFormat() const
|
|
|
|
{
|
2016-09-23 00:44:26 +03:00
|
|
|
if (!mWrappedTextureHost) {
|
|
|
|
return gfx::SurfaceFormat::UNKNOWN;
|
|
|
|
}
|
|
|
|
return mWrappedTextureHost->GetFormat();
|
2016-09-21 12:24:44 +03:00
|
|
|
}
|
|
|
|
|
2017-06-15 12:07:46 +03:00
|
|
|
bool
|
|
|
|
GPUVideoTextureHost::HasIntermediateBuffer() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWrappedTextureHost);
|
|
|
|
|
|
|
|
return mWrappedTextureHost->HasIntermediateBuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GPUVideoTextureHost::CreateRenderTexture(const wr::ExternalImageId& aExternalImageId)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWrappedTextureHost);
|
|
|
|
|
|
|
|
mWrappedTextureHost->CreateRenderTexture(aExternalImageId);
|
|
|
|
}
|
|
|
|
|
2017-09-26 16:30:46 +03:00
|
|
|
uint32_t
|
|
|
|
GPUVideoTextureHost::NumSubTextures() const
|
2017-06-15 12:07:46 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWrappedTextureHost);
|
2017-09-26 16:30:46 +03:00
|
|
|
return mWrappedTextureHost->NumSubTextures();
|
2017-06-15 12:07:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-04 14:59:42 +03:00
|
|
|
GPUVideoTextureHost::AddWRImage(wr::ResourceUpdateQueue& aResources,
|
2017-06-15 12:07:46 +03:00
|
|
|
Range<const wr::ImageKey>& aImageKeys,
|
|
|
|
const wr::ExternalImageId& aExtID)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWrappedTextureHost);
|
|
|
|
|
2017-09-04 14:59:42 +03:00
|
|
|
mWrappedTextureHost->AddWRImage(aResources, aImageKeys, aExtID);
|
2017-06-15 12:07:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GPUVideoTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-06-15 12:07:46 +03:00
|
|
|
wr::ImageRendering aFilter,
|
|
|
|
Range<const wr::ImageKey>& aImageKeys)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWrappedTextureHost);
|
|
|
|
MOZ_ASSERT(aImageKeys.length() > 0);
|
|
|
|
|
|
|
|
mWrappedTextureHost->PushExternalImage(aBuilder,
|
|
|
|
aBounds,
|
|
|
|
aClip,
|
|
|
|
aFilter,
|
|
|
|
aImageKeys);
|
|
|
|
}
|
|
|
|
|
2016-09-21 12:24:44 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|