Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +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/. */
|
|
|
|
|
|
|
|
#include "mozilla/layers/TextureClient.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stdint.h> // for uint8_t, uint32_t, etc
|
|
|
|
#include "Layers.h" // for Layer, etc
|
2013-12-20 20:46:29 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxContext.h" // for gfxContext, etc
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
|
|
|
#include "gfxPoint.h" // for gfxIntSize, gfxSize
|
|
|
|
#include "gfxReusableSurfaceWrapper.h" // for gfxReusableSurfaceWrapper
|
|
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
|
|
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
|
|
|
|
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
|
|
|
|
#include "mozilla/layers/CompositableForwarder.h"
|
|
|
|
#include "mozilla/layers/ISurfaceAllocator.h"
|
|
|
|
#include "mozilla/layers/ImageDataSerializer.h"
|
|
|
|
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
|
2013-05-23 11:17:10 +04:00
|
|
|
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
|
2014-02-27 01:36:35 +04:00
|
|
|
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
2013-10-02 04:57:50 +04:00
|
|
|
#include "ImageContainer.h" // for PlanarYCbCrImage, etc
|
2013-10-16 05:00:30 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-03-08 01:34:04 +04:00
|
|
|
#include "mozilla/layers/TextureClientOGL.h"
|
2014-04-28 15:29:13 +04:00
|
|
|
#include "mozilla/layers/PTextureChild.h"
|
2014-03-08 01:34:04 +04:00
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
#include "mozilla/layers/TextureD3D9.h"
|
|
|
|
#include "mozilla/layers/TextureD3D11.h"
|
|
|
|
#include "gfxWindowsPlatform.h"
|
|
|
|
#include "gfx2DGlue.h"
|
|
|
|
#endif
|
|
|
|
#ifdef MOZ_X11
|
|
|
|
#include "mozilla/layers/TextureClientX11.h"
|
|
|
|
#ifdef GL_PROVIDER_GLX
|
|
|
|
#include "GLXLibrary.h"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
#include <cutils/properties.h>
|
|
|
|
#include "mozilla/layers/GrallocTextureClient.h"
|
|
|
|
#endif
|
2013-08-12 06:21:17 +04:00
|
|
|
|
2013-08-19 17:59:27 +04:00
|
|
|
#ifdef MOZ_ANDROID_OMTC
|
|
|
|
# include "gfxReusableImageSurfaceWrapper.h"
|
|
|
|
#else
|
|
|
|
# include "gfxReusableSharedImageSurfaceWrapper.h"
|
|
|
|
# include "gfxSharedImageSurface.h"
|
|
|
|
#endif
|
|
|
|
|
2014-03-10 22:34:57 +04:00
|
|
|
#if 0
|
|
|
|
#define RECYCLE_LOG(...) printf_stderr(__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define RECYCLE_LOG(...) do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
using namespace mozilla::gl;
|
2013-10-16 05:00:30 +04:00
|
|
|
using namespace mozilla::gfx;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-12-12 05:44:45 +04:00
|
|
|
/**
|
|
|
|
* TextureChild is the content-side incarnation of the PTexture IPDL actor.
|
|
|
|
*
|
|
|
|
* TextureChild is used to synchronize a texture client and its corresponding
|
|
|
|
* TextureHost if needed (a TextureClient that is not shared with the compositor
|
|
|
|
* does not have a TextureChild)
|
|
|
|
*
|
|
|
|
* During the deallocation phase, a TextureChild may hold its recently destroyed
|
|
|
|
* TextureClient's data until the compositor side confirmed that it is safe to
|
|
|
|
* deallocte or recycle the it.
|
|
|
|
*/
|
2014-04-14 23:04:25 +04:00
|
|
|
class TextureChild MOZ_FINAL : public PTextureChild
|
2013-12-12 05:44:44 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-04-14 23:04:25 +04:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TextureChild)
|
|
|
|
|
2013-12-12 05:44:45 +04:00
|
|
|
TextureChild()
|
|
|
|
: mForwarder(nullptr)
|
|
|
|
, mTextureData(nullptr)
|
2013-12-12 05:44:55 +04:00
|
|
|
, mTextureClient(nullptr)
|
2013-12-21 01:44:30 +04:00
|
|
|
, mIPCOpen(false)
|
2013-12-12 05:44:45 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Recv__delete__() MOZ_OVERRIDE;
|
|
|
|
|
2014-05-06 05:56:40 +04:00
|
|
|
bool RecvCompositorRecycle()
|
2014-03-10 22:34:57 +04:00
|
|
|
{
|
|
|
|
RECYCLE_LOG("Receive recycle %p (%p)\n", mTextureClient, mWaitForRecycle.get());
|
|
|
|
mWaitForRecycle = nullptr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitForCompositorRecycle()
|
|
|
|
{
|
|
|
|
mWaitForRecycle = mTextureClient;
|
|
|
|
RECYCLE_LOG("Wait for recycle %p\n", mWaitForRecycle.get());
|
|
|
|
SendClientRecycle();
|
|
|
|
}
|
|
|
|
|
2013-12-12 05:44:45 +04:00
|
|
|
/**
|
|
|
|
* Only used during the deallocation phase iff we need synchronization between
|
|
|
|
* the client and host side for deallocation (that is, when the data is going
|
|
|
|
* to be deallocated or recycled on the client side).
|
|
|
|
*/
|
|
|
|
void SetTextureData(TextureClientData* aData)
|
|
|
|
{
|
|
|
|
mTextureData = aData;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeleteTextureData();
|
|
|
|
|
|
|
|
CompositableForwarder* GetForwarder() { return mForwarder; }
|
|
|
|
|
|
|
|
ISurfaceAllocator* GetAllocator() { return mForwarder; }
|
|
|
|
|
2013-12-12 05:44:55 +04:00
|
|
|
void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
|
|
|
|
2013-12-21 01:44:30 +04:00
|
|
|
bool IPCOpen() const { return mIPCOpen; }
|
|
|
|
|
2013-12-12 05:44:55 +04:00
|
|
|
private:
|
|
|
|
|
2013-12-21 01:44:30 +04:00
|
|
|
// AddIPDLReference and ReleaseIPDLReference are only to be called by CreateIPDLActor
|
|
|
|
// and DestroyIPDLActor, respectively. We intentionally make them private to prevent misuse.
|
|
|
|
// The purpose of these methods is to be aware of when the IPC system around this
|
|
|
|
// actor goes down: mIPCOpen is then set to false.
|
|
|
|
void AddIPDLReference() {
|
|
|
|
MOZ_ASSERT(mIPCOpen == false);
|
|
|
|
mIPCOpen = true;
|
|
|
|
AddRef();
|
|
|
|
}
|
|
|
|
void ReleaseIPDLReference() {
|
|
|
|
MOZ_ASSERT(mIPCOpen == true);
|
|
|
|
mIPCOpen = false;
|
|
|
|
Release();
|
|
|
|
}
|
|
|
|
|
2014-02-27 01:23:51 +04:00
|
|
|
RefPtr<CompositableForwarder> mForwarder;
|
2014-03-10 22:34:57 +04:00
|
|
|
RefPtr<TextureClient> mWaitForRecycle;
|
2013-12-12 05:44:45 +04:00
|
|
|
TextureClientData* mTextureData;
|
2013-12-12 05:44:55 +04:00
|
|
|
TextureClient* mTextureClient;
|
2013-12-21 01:44:30 +04:00
|
|
|
bool mIPCOpen;
|
2013-12-12 05:44:44 +04:00
|
|
|
|
2013-12-12 05:44:55 +04:00
|
|
|
friend class TextureClient;
|
2013-12-12 05:44:44 +04:00
|
|
|
};
|
|
|
|
|
2013-12-12 05:44:45 +04:00
|
|
|
void
|
|
|
|
TextureChild::DeleteTextureData()
|
|
|
|
{
|
2014-03-10 22:34:57 +04:00
|
|
|
mWaitForRecycle = nullptr;
|
2013-12-12 05:44:45 +04:00
|
|
|
if (mTextureData) {
|
|
|
|
mTextureData->DeallocateSharedData(GetAllocator());
|
|
|
|
delete mTextureData;
|
|
|
|
mTextureData = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TextureChild::Recv__delete__()
|
|
|
|
{
|
|
|
|
DeleteTextureData();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-12 05:44:55 +04:00
|
|
|
void
|
|
|
|
TextureChild::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
if (mTextureClient) {
|
|
|
|
mTextureClient->mActor = nullptr;
|
|
|
|
}
|
2014-03-10 22:34:57 +04:00
|
|
|
mWaitForRecycle = nullptr;
|
2013-12-12 05:44:55 +04:00
|
|
|
}
|
|
|
|
|
2013-12-12 05:44:44 +04:00
|
|
|
// static
|
|
|
|
PTextureChild*
|
|
|
|
TextureClient::CreateIPDLActor()
|
|
|
|
{
|
2013-12-21 01:44:30 +04:00
|
|
|
TextureChild* c = new TextureChild();
|
|
|
|
c->AddIPDLReference();
|
|
|
|
return c;
|
2013-12-12 05:44:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
bool
|
|
|
|
TextureClient::DestroyIPDLActor(PTextureChild* actor)
|
|
|
|
{
|
2013-12-21 01:44:30 +04:00
|
|
|
static_cast<TextureChild*>(actor)->ReleaseIPDLReference();
|
2013-12-12 05:44:44 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-25 08:23:41 +04:00
|
|
|
// static
|
|
|
|
TextureClient*
|
|
|
|
TextureClient::AsTextureClient(PTextureChild* actor)
|
|
|
|
{
|
2014-03-10 22:34:57 +04:00
|
|
|
return actor ? static_cast<TextureChild*>(actor)->mTextureClient : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextureClient::WaitForCompositorRecycle()
|
|
|
|
{
|
|
|
|
mActor->WaitForCompositorRecycle();
|
2014-02-25 08:23:41 +04:00
|
|
|
}
|
|
|
|
|
2013-12-12 05:44:44 +04:00
|
|
|
bool
|
|
|
|
TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
|
|
|
|
{
|
2013-12-12 05:44:53 +04:00
|
|
|
MOZ_ASSERT(aForwarder);
|
2014-02-10 06:24:27 +04:00
|
|
|
if (mActor && mActor->GetForwarder() == aForwarder) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(!mActor, "Cannot use a texture on several IPC channels.");
|
2013-12-12 05:44:53 +04:00
|
|
|
|
2013-12-12 05:44:44 +04:00
|
|
|
SurfaceDescriptor desc;
|
|
|
|
if (!ToSurfaceDescriptor(desc)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-22 02:06:18 +04:00
|
|
|
mActor = static_cast<TextureChild*>(aForwarder->CreateTexture(desc, GetFlags()));
|
|
|
|
MOZ_ASSERT(mActor);
|
2013-12-12 05:44:45 +04:00
|
|
|
mActor->mForwarder = aForwarder;
|
2013-12-12 05:44:55 +04:00
|
|
|
mActor->mTextureClient = this;
|
2013-12-12 05:44:44 +04:00
|
|
|
mShared = true;
|
2014-01-22 02:06:18 +04:00
|
|
|
return mActor->IPCOpen();
|
2013-12-12 05:44:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PTextureChild*
|
|
|
|
TextureClient::GetIPDLActor()
|
|
|
|
{
|
|
|
|
return mActor;
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
static bool
|
2014-03-28 18:35:21 +04:00
|
|
|
DisableGralloc(SurfaceFormat aFormat, const gfx::IntSize& aSizeHint)
|
2014-03-08 01:34:04 +04:00
|
|
|
{
|
|
|
|
if (aFormat == gfx::SurfaceFormat::A8) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-28 18:35:21 +04:00
|
|
|
#if ANDROID_VERSION <= 15
|
|
|
|
// Adreno 200 has a problem of drawing gralloc buffer width less than 64 and
|
|
|
|
// drawing gralloc buffer with a height 9px-16px.
|
|
|
|
// See Bug 983971.
|
|
|
|
if (aSizeHint.width < 64 || aSizeHint.height < 32) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// static
|
|
|
|
TemporaryRef<TextureClient>
|
|
|
|
TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
|
|
|
|
SurfaceFormat aFormat,
|
2014-03-12 16:16:37 +04:00
|
|
|
TextureFlags aTextureFlags,
|
2014-03-18 01:35:20 +04:00
|
|
|
gfx::BackendType aMoz2DBackend,
|
2014-03-12 16:16:37 +04:00
|
|
|
const gfx::IntSize& aSizeHint)
|
2014-03-08 01:34:04 +04:00
|
|
|
{
|
2014-03-18 01:35:20 +04:00
|
|
|
if (aMoz2DBackend == gfx::BackendType::NONE) {
|
|
|
|
aMoz2DBackend = gfxPlatform::GetPlatform()->GetContentBackend();
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
RefPtr<TextureClient> result;
|
|
|
|
|
2014-04-08 16:50:49 +04:00
|
|
|
#if defined(MOZ_WIDGET_GONK) || defined(XP_WIN)
|
|
|
|
int32_t maxTextureSize = aAllocator->GetMaxTextureSize();
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
LayersBackend parentBackend = aAllocator->GetCompositorBackendType();
|
2014-03-18 01:35:20 +04:00
|
|
|
if (parentBackend == LayersBackend::LAYERS_D3D11 &&
|
|
|
|
(aMoz2DBackend == gfx::BackendType::DIRECT2D ||
|
|
|
|
aMoz2DBackend == gfx::BackendType::DIRECT2D1_1) &&
|
|
|
|
gfxWindowsPlatform::GetPlatform()->GetD2DDevice() &&
|
2014-04-08 16:50:49 +04:00
|
|
|
aSizeHint.width <= maxTextureSize &&
|
|
|
|
aSizeHint.height <= maxTextureSize &&
|
2014-04-26 06:34:05 +04:00
|
|
|
!(aTextureFlags & TextureFlags::ALLOC_FALLBACK)) {
|
2014-03-31 22:31:52 +04:00
|
|
|
result = new TextureClientD3D11(aFormat, aTextureFlags);
|
2014-03-08 01:34:04 +04:00
|
|
|
}
|
|
|
|
if (parentBackend == LayersBackend::LAYERS_D3D9 &&
|
2014-03-18 01:35:20 +04:00
|
|
|
aMoz2DBackend == gfx::BackendType::CAIRO &&
|
2014-03-08 01:34:04 +04:00
|
|
|
aAllocator->IsSameProcess() &&
|
2014-04-08 16:50:49 +04:00
|
|
|
aSizeHint.width <= maxTextureSize &&
|
|
|
|
aSizeHint.height <= maxTextureSize &&
|
2014-04-26 06:34:05 +04:00
|
|
|
!(aTextureFlags & TextureFlags::ALLOC_FALLBACK)) {
|
2014-03-08 01:34:04 +04:00
|
|
|
if (!gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
|
|
|
|
result = new DIBTextureClientD3D9(aFormat, aTextureFlags);
|
|
|
|
} else {
|
|
|
|
result = new CairoTextureClientD3D9(aFormat, aTextureFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_X11
|
|
|
|
LayersBackend parentBackend = aAllocator->GetCompositorBackendType();
|
|
|
|
gfxSurfaceType type =
|
|
|
|
gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType();
|
|
|
|
|
|
|
|
if (parentBackend == LayersBackend::LAYERS_BASIC &&
|
2014-03-18 01:35:20 +04:00
|
|
|
aMoz2DBackend == gfx::BackendType::CAIRO &&
|
2014-03-08 01:34:04 +04:00
|
|
|
type == gfxSurfaceType::Xlib &&
|
2014-04-26 06:34:05 +04:00
|
|
|
!(aTextureFlags & TextureFlags::ALLOC_FALLBACK))
|
2014-03-08 01:34:04 +04:00
|
|
|
{
|
|
|
|
result = new TextureClientX11(aFormat, aTextureFlags);
|
|
|
|
}
|
|
|
|
#ifdef GL_PROVIDER_GLX
|
|
|
|
if (parentBackend == LayersBackend::LAYERS_OPENGL &&
|
|
|
|
type == gfxSurfaceType::Xlib &&
|
2014-04-26 06:34:05 +04:00
|
|
|
!(aTextureFlags & TextureFlags::ALLOC_FALLBACK) &&
|
2014-03-08 01:34:04 +04:00
|
|
|
aFormat != SurfaceFormat::A8 &&
|
|
|
|
gl::sGLXLibrary.UseTextureFromPixmap())
|
|
|
|
{
|
|
|
|
result = new TextureClientX11(aFormat, aTextureFlags);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2014-03-28 18:35:21 +04:00
|
|
|
if (!DisableGralloc(aFormat, aSizeHint)) {
|
2014-03-12 16:16:37 +04:00
|
|
|
// Don't allow Gralloc texture clients to exceed the maximum texture size.
|
|
|
|
// BufferTextureClients have code to handle tiling the surface client-side.
|
|
|
|
if (aSizeHint.width <= maxTextureSize && aSizeHint.height <= maxTextureSize) {
|
2014-03-18 01:35:20 +04:00
|
|
|
result = new GrallocTextureClientOGL(aAllocator, aFormat, aMoz2DBackend,
|
|
|
|
aTextureFlags);
|
2014-03-12 16:16:37 +04:00
|
|
|
}
|
2014-03-08 01:34:04 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Can't do any better than a buffer texture client.
|
|
|
|
if (!result) {
|
2014-03-18 01:35:20 +04:00
|
|
|
result = CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, aMoz2DBackend);
|
2014-03-08 01:34:04 +04:00
|
|
|
}
|
|
|
|
|
2014-04-10 12:14:28 +04:00
|
|
|
MOZ_ASSERT(!result || result->CanExposeDrawTarget(), "texture cannot expose a DrawTarget?");
|
2014-03-08 01:34:04 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
TemporaryRef<BufferTextureClient>
|
|
|
|
TextureClient::CreateBufferTextureClient(ISurfaceAllocator* aAllocator,
|
|
|
|
SurfaceFormat aFormat,
|
2014-03-18 01:35:20 +04:00
|
|
|
TextureFlags aTextureFlags,
|
|
|
|
gfx::BackendType aMoz2DBackend)
|
2014-03-08 01:34:04 +04:00
|
|
|
{
|
|
|
|
if (gfxPlatform::GetPlatform()->PreferMemoryOverShmem()) {
|
|
|
|
RefPtr<BufferTextureClient> result = new MemoryTextureClient(aAllocator, aFormat,
|
2014-03-18 01:35:20 +04:00
|
|
|
aMoz2DBackend,
|
2014-03-08 01:34:04 +04:00
|
|
|
aTextureFlags);
|
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
RefPtr<BufferTextureClient> result = new ShmemTextureClient(aAllocator, aFormat,
|
2014-03-18 01:35:20 +04:00
|
|
|
aMoz2DBackend,
|
2014-03-08 01:34:04 +04:00
|
|
|
aTextureFlags);
|
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-12 18:50:28 +04:00
|
|
|
class ShmemTextureClientData : public TextureClientData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShmemTextureClientData(ipc::Shmem& aShmem)
|
|
|
|
: mShmem(aShmem)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ShmemTextureClientData);
|
|
|
|
}
|
|
|
|
|
|
|
|
~ShmemTextureClientData()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ShmemTextureClientData);
|
|
|
|
}
|
|
|
|
|
2013-09-28 00:12:28 +04:00
|
|
|
virtual void DeallocateSharedData(ISurfaceAllocator* allocator)
|
2013-09-12 18:50:28 +04:00
|
|
|
{
|
|
|
|
allocator->DeallocShmem(mShmem);
|
|
|
|
mShmem = ipc::Shmem();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ipc::Shmem mShmem;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MemoryTextureClientData : public TextureClientData
|
|
|
|
{
|
|
|
|
public:
|
2013-09-28 00:12:28 +04:00
|
|
|
MemoryTextureClientData(uint8_t* aBuffer)
|
2013-09-12 18:50:28 +04:00
|
|
|
: mBuffer(aBuffer)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(MemoryTextureClientData);
|
|
|
|
}
|
|
|
|
|
|
|
|
~MemoryTextureClientData()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mBuffer, "Forgot to deallocate the shared texture data?");
|
2014-02-11 06:46:27 +04:00
|
|
|
MOZ_COUNT_DTOR(MemoryTextureClientData);
|
2013-09-12 18:50:28 +04:00
|
|
|
}
|
|
|
|
|
2013-09-28 00:12:28 +04:00
|
|
|
virtual void DeallocateSharedData(ISurfaceAllocator*)
|
2013-09-12 18:50:28 +04:00
|
|
|
{
|
|
|
|
delete[] mBuffer;
|
2013-12-12 05:44:45 +04:00
|
|
|
mBuffer = nullptr;
|
2013-09-12 18:50:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t* mBuffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
TextureClientData*
|
|
|
|
MemoryTextureClient::DropTextureData()
|
|
|
|
{
|
|
|
|
if (!mBuffer) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-09-28 00:12:28 +04:00
|
|
|
TextureClientData* result = new MemoryTextureClientData(mBuffer);
|
2013-09-12 18:50:28 +04:00
|
|
|
MarkInvalid();
|
|
|
|
mBuffer = nullptr;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureClientData*
|
|
|
|
ShmemTextureClient::DropTextureData()
|
|
|
|
{
|
|
|
|
if (!mShmem.IsReadable()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
TextureClientData* result = new ShmemTextureClientData(mShmem);
|
|
|
|
MarkInvalid();
|
|
|
|
mShmem = ipc::Shmem();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
TextureClient::TextureClient(TextureFlags aFlags)
|
2013-12-21 01:44:30 +04:00
|
|
|
: mFlags(aFlags)
|
2013-08-28 00:16:03 +04:00
|
|
|
, mShared(false)
|
2013-09-06 13:04:50 +04:00
|
|
|
, mValid(true)
|
2013-07-30 13:59:51 +04:00
|
|
|
{}
|
|
|
|
|
|
|
|
TextureClient::~TextureClient()
|
2013-12-12 05:44:45 +04:00
|
|
|
{
|
|
|
|
// All the destruction code that may lead to virtual method calls must
|
|
|
|
// be in Finalize() which is called just before the destructor.
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextureClient::ForceRemove()
|
|
|
|
{
|
|
|
|
if (mValid && mActor) {
|
2014-04-26 06:34:05 +04:00
|
|
|
if (GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
|
2013-12-12 05:44:45 +04:00
|
|
|
mActor->SetTextureData(DropTextureData());
|
2013-12-21 01:44:30 +04:00
|
|
|
if (mActor->IPCOpen()) {
|
|
|
|
mActor->SendRemoveTextureSync();
|
|
|
|
}
|
2013-12-12 05:44:45 +04:00
|
|
|
mActor->DeleteTextureData();
|
|
|
|
} else {
|
2013-12-21 01:44:30 +04:00
|
|
|
if (mActor->IPCOpen()) {
|
|
|
|
mActor->SendRemoveTexture();
|
|
|
|
}
|
2013-12-12 05:44:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
MarkInvalid();
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
bool TextureClient::CopyToTextureClient(TextureClient* aTarget,
|
|
|
|
const gfx::IntRect* aRect,
|
|
|
|
const gfx::IntPoint* aPoint)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsLocked());
|
|
|
|
MOZ_ASSERT(aTarget->IsLocked());
|
|
|
|
|
2014-04-10 12:14:28 +04:00
|
|
|
if (!aTarget->CanExposeDrawTarget() || !CanExposeDrawTarget()) {
|
2014-03-08 01:34:04 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-04-10 12:14:28 +04:00
|
|
|
RefPtr<DrawTarget> destinationTarget = aTarget->GetAsDrawTarget();
|
|
|
|
RefPtr<DrawTarget> sourceTarget = GetAsDrawTarget();
|
2014-03-08 01:34:04 +04:00
|
|
|
RefPtr<gfx::SourceSurface> source = sourceTarget->Snapshot();
|
|
|
|
destinationTarget->CopySurface(source,
|
|
|
|
aRect ? *aRect : gfx::IntRect(gfx::IntPoint(0, 0), GetSize()),
|
|
|
|
aPoint ? *aPoint : gfx::IntPoint(0, 0));
|
|
|
|
destinationTarget = nullptr;
|
|
|
|
source = nullptr;
|
|
|
|
sourceTarget = nullptr;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-12 05:44:45 +04:00
|
|
|
void
|
|
|
|
TextureClient::Finalize()
|
|
|
|
{
|
2014-03-21 21:03:20 +04:00
|
|
|
MOZ_ASSERT(!IsLocked());
|
2014-01-03 02:54:13 +04:00
|
|
|
// Always make a temporary strong reference to the actor before we use it,
|
|
|
|
// in case TextureChild::ActorDestroy might null mActor concurrently.
|
|
|
|
RefPtr<TextureChild> actor = mActor;
|
|
|
|
|
|
|
|
if (actor) {
|
2014-04-07 06:02:31 +04:00
|
|
|
// The actor has a raw pointer to us, actor->mTextureClient.
|
|
|
|
// Null it before RemoveTexture calls to avoid invalid actor->mTextureClient
|
|
|
|
// when calling TextureChild::ActorDestroy()
|
|
|
|
actor->mTextureClient = nullptr;
|
2013-12-12 05:44:45 +04:00
|
|
|
// this will call ForceRemove in the right thread, using a sync proxy if needed
|
2014-02-27 01:34:41 +04:00
|
|
|
if (actor->GetForwarder()) {
|
|
|
|
actor->GetForwarder()->RemoveTexture(this);
|
|
|
|
}
|
2013-12-12 05:44:45 +04:00
|
|
|
}
|
|
|
|
}
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
bool
|
|
|
|
TextureClient::ShouldDeallocateInDestructor() const
|
|
|
|
{
|
2013-08-28 00:16:03 +04:00
|
|
|
if (!IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we're meant to be deallocated by the host,
|
|
|
|
// but we haven't been shared yet, then we should
|
|
|
|
// deallocate on the client instead.
|
2013-09-12 18:50:28 +04:00
|
|
|
return !IsSharedWithCompositor();
|
2013-07-30 13:59:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ShmemTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor)
|
|
|
|
{
|
2013-09-06 13:04:50 +04:00
|
|
|
MOZ_ASSERT(IsValid());
|
2014-01-10 23:06:16 +04:00
|
|
|
if (!IsAllocated() || GetFormat() == gfx::SurfaceFormat::UNKNOWN) {
|
2013-07-30 13:59:51 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
aDescriptor = SurfaceDescriptorShmem(mShmem, GetFormat());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ShmemTextureClient::Allocate(uint32_t aSize)
|
|
|
|
{
|
2014-01-07 20:20:11 +04:00
|
|
|
MOZ_ASSERT(mValid);
|
2013-07-30 13:59:51 +04:00
|
|
|
ipc::SharedMemory::SharedMemoryType memType = OptimalShmemType();
|
|
|
|
mAllocated = GetAllocator()->AllocUnsafeShmem(aSize, memType, &mShmem);
|
|
|
|
return mAllocated;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t*
|
|
|
|
ShmemTextureClient::GetBuffer() const
|
|
|
|
{
|
2013-09-06 13:04:50 +04:00
|
|
|
MOZ_ASSERT(IsValid());
|
2013-07-30 13:59:51 +04:00
|
|
|
if (mAllocated) {
|
|
|
|
return mShmem.get<uint8_t>();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ShmemTextureClient::GetBufferSize() const
|
|
|
|
{
|
2013-09-06 13:04:50 +04:00
|
|
|
MOZ_ASSERT(IsValid());
|
2013-07-30 13:59:51 +04:00
|
|
|
return mShmem.Size<uint8_t>();
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
ShmemTextureClient::ShmemTextureClient(ISurfaceAllocator* aAllocator,
|
2013-08-03 21:30:28 +04:00
|
|
|
gfx::SurfaceFormat aFormat,
|
2014-03-18 01:35:20 +04:00
|
|
|
gfx::BackendType aMoz2DBackend,
|
2013-08-03 21:30:28 +04:00
|
|
|
TextureFlags aFlags)
|
2014-03-18 01:35:20 +04:00
|
|
|
: BufferTextureClient(aAllocator, aFormat, aMoz2DBackend, aFlags)
|
2013-07-30 13:59:51 +04:00
|
|
|
, mAllocated(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ShmemTextureClient);
|
|
|
|
}
|
|
|
|
|
|
|
|
ShmemTextureClient::~ShmemTextureClient()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ShmemTextureClient);
|
2013-09-28 00:12:28 +04:00
|
|
|
if (ShouldDeallocateInDestructor()) {
|
2013-07-30 13:59:51 +04:00
|
|
|
// if the buffer has never been shared we must deallocate it or ir would
|
|
|
|
// leak.
|
2014-03-08 01:34:04 +04:00
|
|
|
GetAllocator()->DeallocShmem(mShmem);
|
2013-07-30 13:59:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MemoryTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor)
|
|
|
|
{
|
2013-09-06 13:04:50 +04:00
|
|
|
MOZ_ASSERT(IsValid());
|
2014-01-10 23:06:16 +04:00
|
|
|
if (!IsAllocated() || GetFormat() == gfx::SurfaceFormat::UNKNOWN) {
|
2013-07-30 13:59:51 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aDescriptor = SurfaceDescriptorMemory(reinterpret_cast<uintptr_t>(mBuffer),
|
|
|
|
GetFormat());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MemoryTextureClient::Allocate(uint32_t aSize)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mBuffer);
|
2013-12-06 19:30:50 +04:00
|
|
|
static const fallible_t fallible = fallible_t();
|
|
|
|
mBuffer = new(fallible) uint8_t[aSize];
|
|
|
|
if (!mBuffer) {
|
|
|
|
NS_WARNING("Failed to allocate buffer");
|
|
|
|
return false;
|
|
|
|
}
|
2013-11-15 01:54:25 +04:00
|
|
|
GfxMemoryImageReporter::DidAlloc(mBuffer);
|
2013-07-30 13:59:51 +04:00
|
|
|
mBufSize = aSize;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
MemoryTextureClient::MemoryTextureClient(ISurfaceAllocator* aAllocator,
|
2013-08-03 21:30:28 +04:00
|
|
|
gfx::SurfaceFormat aFormat,
|
2014-03-18 01:35:20 +04:00
|
|
|
gfx::BackendType aMoz2DBackend,
|
2013-08-03 21:30:28 +04:00
|
|
|
TextureFlags aFlags)
|
2014-03-18 01:35:20 +04:00
|
|
|
: BufferTextureClient(aAllocator, aFormat, aMoz2DBackend, aFlags)
|
2013-07-30 13:59:51 +04:00
|
|
|
, mBuffer(nullptr)
|
|
|
|
, mBufSize(0)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(MemoryTextureClient);
|
|
|
|
}
|
|
|
|
|
|
|
|
MemoryTextureClient::~MemoryTextureClient()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(MemoryTextureClient);
|
2013-12-12 05:44:51 +04:00
|
|
|
if (mBuffer && ShouldDeallocateInDestructor()) {
|
|
|
|
// if the buffer has never been shared we must deallocate it or it would
|
2013-07-30 13:59:51 +04:00
|
|
|
// leak.
|
2013-11-15 01:54:25 +04:00
|
|
|
GfxMemoryImageReporter::WillFree(mBuffer);
|
2014-03-20 04:28:41 +04:00
|
|
|
delete [] mBuffer;
|
2013-07-30 13:59:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
BufferTextureClient::BufferTextureClient(ISurfaceAllocator* aAllocator,
|
2013-08-03 21:30:28 +04:00
|
|
|
gfx::SurfaceFormat aFormat,
|
2014-03-18 01:35:20 +04:00
|
|
|
gfx::BackendType aMoz2DBackend,
|
2013-08-03 21:30:28 +04:00
|
|
|
TextureFlags aFlags)
|
|
|
|
: TextureClient(aFlags)
|
2014-03-08 01:34:04 +04:00
|
|
|
, mAllocator(aAllocator)
|
2013-07-30 13:59:51 +04:00
|
|
|
, mFormat(aFormat)
|
2014-03-18 01:35:20 +04:00
|
|
|
, mBackend(aMoz2DBackend)
|
2014-04-26 06:34:06 +04:00
|
|
|
, mOpenMode(OpenMode::OPEN_NONE)
|
2014-01-07 20:20:11 +04:00
|
|
|
, mLocked(false)
|
2013-07-30 13:59:51 +04:00
|
|
|
{}
|
|
|
|
|
|
|
|
BufferTextureClient::~BufferTextureClient()
|
|
|
|
{}
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
ISurfaceAllocator*
|
|
|
|
BufferTextureClient::GetAllocator() const
|
|
|
|
{
|
|
|
|
return mAllocator;
|
|
|
|
}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
bool
|
2013-12-05 22:39:22 +04:00
|
|
|
BufferTextureClient::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2013-09-06 13:04:50 +04:00
|
|
|
MOZ_ASSERT(IsValid());
|
2014-01-10 23:06:16 +04:00
|
|
|
MOZ_ASSERT(mFormat != gfx::SurfaceFormat::YUV, "This textureClient cannot use YCbCr data");
|
2014-01-07 20:20:11 +04:00
|
|
|
MOZ_ASSERT(aSize.width * aSize.height);
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
int bufSize
|
|
|
|
= ImageDataSerializer::ComputeMinBufferSize(aSize, mFormat);
|
|
|
|
if (!Allocate(bufSize)) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
|
|
|
|
if (aFlags & ALLOC_CLEAR_BUFFER) {
|
|
|
|
memset(GetBuffer(), 0, bufSize);
|
|
|
|
}
|
|
|
|
|
2014-02-21 01:04:11 +04:00
|
|
|
ImageDataSerializer serializer(GetBuffer(), GetBufferSize());
|
2013-07-30 13:59:51 +04:00
|
|
|
serializer.InitializeBufferInfo(aSize, mFormat);
|
2013-08-03 21:29:18 +04:00
|
|
|
mSize = aSize;
|
2013-07-30 13:59:51 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
TemporaryRef<gfx::DrawTarget>
|
|
|
|
BufferTextureClient::GetAsDrawTarget()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsValid());
|
2014-03-21 21:03:20 +04:00
|
|
|
MOZ_ASSERT(mLocked, "GetAsDrawTarget should be called on locked textures only");
|
2014-01-07 20:20:11 +04:00
|
|
|
|
|
|
|
if (mDrawTarget) {
|
|
|
|
return mDrawTarget;
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2014-02-21 01:04:11 +04:00
|
|
|
ImageDataSerializer serializer(GetBuffer(), GetBufferSize());
|
2013-12-05 22:39:22 +04:00
|
|
|
if (!serializer.IsValid()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-03-18 01:35:20 +04:00
|
|
|
mDrawTarget = serializer.GetAsDrawTarget(mBackend);
|
2014-01-07 20:20:11 +04:00
|
|
|
if (mDrawTarget) {
|
|
|
|
return mDrawTarget;
|
|
|
|
}
|
|
|
|
|
2014-04-30 00:33:10 +04:00
|
|
|
mDrawTarget = serializer.GetAsDrawTarget(BackendType::CAIRO);
|
2014-01-07 20:20:11 +04:00
|
|
|
|
|
|
|
return mDrawTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BufferTextureClient::Lock(OpenMode aMode)
|
|
|
|
{
|
2014-03-21 21:03:20 +04:00
|
|
|
MOZ_ASSERT(!mLocked, "The TextureClient is already Locked!");
|
2014-01-07 20:20:11 +04:00
|
|
|
mOpenMode = aMode;
|
2014-02-14 13:20:41 +04:00
|
|
|
mLocked = IsValid() && IsAllocated();;
|
|
|
|
return mLocked;
|
2014-01-07 20:20:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BufferTextureClient::Unlock()
|
|
|
|
{
|
2014-03-21 21:03:20 +04:00
|
|
|
MOZ_ASSERT(mLocked, "The TextureClient is already Unlocked!");
|
2014-01-07 20:20:11 +04:00
|
|
|
mLocked = false;
|
|
|
|
if (!mDrawTarget) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-10 12:14:28 +04:00
|
|
|
// see the comment on TextureClient::GetAsDrawTarget.
|
2014-03-21 21:03:20 +04:00
|
|
|
// This DrawTarget is internal to the TextureClient and is only exposed to the
|
|
|
|
// outside world between Lock() and Unlock(). This assertion checks that no outside
|
|
|
|
// reference remains by the time Unlock() is called.
|
|
|
|
MOZ_ASSERT(mDrawTarget->refCount() == 1);
|
|
|
|
|
2014-01-07 20:20:11 +04:00
|
|
|
mDrawTarget->Flush();
|
|
|
|
mDrawTarget = nullptr;
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
bool
|
2013-10-02 04:57:50 +04:00
|
|
|
BufferTextureClient::UpdateYCbCr(const PlanarYCbCrData& aData)
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2014-03-21 21:03:20 +04:00
|
|
|
MOZ_ASSERT(mLocked);
|
2014-01-10 23:06:16 +04:00
|
|
|
MOZ_ASSERT(mFormat == gfx::SurfaceFormat::YUV, "This textureClient can only use YCbCr data");
|
2013-07-30 13:59:51 +04:00
|
|
|
MOZ_ASSERT(!IsImmutable());
|
2013-09-06 13:04:50 +04:00
|
|
|
MOZ_ASSERT(IsValid());
|
2013-07-30 13:59:51 +04:00
|
|
|
MOZ_ASSERT(aData.mCbSkip == aData.mCrSkip);
|
|
|
|
|
2014-02-21 01:04:13 +04:00
|
|
|
YCbCrImageDataSerializer serializer(GetBuffer(), GetBufferSize());
|
2013-07-30 13:59:51 +04:00
|
|
|
MOZ_ASSERT(serializer.IsValid());
|
|
|
|
if (!serializer.CopyData(aData.mYChannel, aData.mCbChannel, aData.mCrChannel,
|
2013-12-31 13:06:12 +04:00
|
|
|
aData.mYSize, aData.mYStride,
|
|
|
|
aData.mCbCrSize, aData.mCbCrStride,
|
2013-07-30 13:59:51 +04:00
|
|
|
aData.mYSkip, aData.mCbSkip)) {
|
|
|
|
NS_WARNING("Failed to copy image data!");
|
|
|
|
return false;
|
|
|
|
}
|
2013-08-03 21:30:28 +04:00
|
|
|
|
|
|
|
if (TextureRequiresLocking(mFlags)) {
|
|
|
|
// We don't have support for proper locking yet, so we'll
|
|
|
|
// have to be immutable instead.
|
|
|
|
MarkImmutable();
|
|
|
|
}
|
2013-07-30 13:59:51 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-08-04 11:46:17 +04:00
|
|
|
BufferTextureClient::AllocateForYCbCr(gfx::IntSize aYSize,
|
|
|
|
gfx::IntSize aCbCrSize,
|
|
|
|
StereoMode aStereoMode)
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2013-09-06 13:04:50 +04:00
|
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
size_t bufSize = YCbCrImageDataSerializer::ComputeMinBufferSize(aYSize,
|
|
|
|
aCbCrSize);
|
|
|
|
if (!Allocate(bufSize)) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-02-21 01:04:13 +04:00
|
|
|
YCbCrImageDataSerializer serializer(GetBuffer(), GetBufferSize());
|
2013-07-30 13:59:51 +04:00
|
|
|
serializer.InitializeBufferInfo(aYSize,
|
2013-08-04 11:46:17 +04:00
|
|
|
aCbCrSize,
|
|
|
|
aStereoMode);
|
2013-08-03 21:29:18 +04:00
|
|
|
mSize = aYSize;
|
2013-07-30 13:59:51 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
}
|