gecko-dev/gfx/layers/client/CompositableClient.cpp

129 строки
3.5 KiB
C++
Исходник Обычный вид История

/* -*- 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 "mozilla/layers/CompositableClient.h"
#include <stdint.h> // for uint64_t, uint32_t
#include "gfxPlatform.h" // for gfxPlatform
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
#include "mozilla/layers/TextureClientOGL.h"
#include "mozilla/mozalloc.h" // for operator delete, etc
#ifdef XP_WIN
#include "gfxWindowsPlatform.h" // for gfxWindowsPlatform
#include "mozilla/layers/TextureD3D11.h"
#include "mozilla/layers/TextureD3D9.h"
#endif
using namespace mozilla::gfx;
namespace mozilla {
namespace layers {
CompositableClient::CompositableClient(CompositableForwarder* aForwarder,
TextureFlags aTextureFlags)
: mCompositableChild(nullptr)
, mForwarder(aForwarder)
, mTextureFlags(aTextureFlags)
{
MOZ_COUNT_CTOR(CompositableClient);
}
CompositableClient::~CompositableClient()
{
MOZ_COUNT_DTOR(CompositableClient);
Destroy();
}
LayersBackend
CompositableClient::GetCompositorBackendType() const
{
return mForwarder->GetCompositorBackendType();
}
void
CompositableClient::SetIPDLActor(CompositableChild* aChild)
{
mCompositableChild = aChild;
}
CompositableChild*
CompositableClient::GetIPDLActor() const
{
return mCompositableChild;
}
bool
CompositableClient::Connect()
{
if (!GetForwarder() || GetIPDLActor()) {
return false;
}
GetForwarder()->Connect(this);
return true;
}
void
CompositableClient::Destroy()
{
if (!mCompositableChild) {
return;
}
mCompositableChild->SetClient(nullptr);
mCompositableChild->Destroy();
mCompositableChild = nullptr;
}
uint64_t
CompositableClient::GetAsyncID() const
{
if (mCompositableChild) {
return mCompositableChild->GetAsyncID();
}
return 0; // zero is always an invalid async ID
}
void
CompositableChild::Destroy()
{
Send__delete__(this);
}
TemporaryRef<BufferTextureClient>
CompositableClient::CreateBufferTextureClient(SurfaceFormat aFormat,
TextureFlags aTextureFlags,
gfx::BackendType aMoz2DBackend)
{
return TextureClient::CreateBufferTextureClient(GetForwarder(), aFormat,
aTextureFlags | mTextureFlags,
aMoz2DBackend);
}
TemporaryRef<TextureClient>
CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
TextureFlags aTextureFlags,
gfx::BackendType aMoz2DBackend,
const IntSize& aSizeHint)
{
return TextureClient::CreateTextureClientForDrawing(GetForwarder(), aFormat,
aTextureFlags | mTextureFlags,
aMoz2DBackend,
aSizeHint);
}
bool
CompositableClient::AddTextureClient(TextureClient* aClient)
{
return aClient->InitIPDLActor(mForwarder);
}
void
CompositableClient::OnTransaction()
{
}
} // namespace layers
} // namespace mozilla