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/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_TEXTURECLIENT_H
|
|
|
|
#define MOZILLA_GFX_TEXTURECLIENT_H
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stddef.h> // for size_t
|
|
|
|
#include <stdint.h> // for uint32_t, uint8_t, uint64_t
|
|
|
|
#include "GLTextureImage.h" // for TextureImage
|
|
|
|
#include "ImageTypes.h" // for StereoMode
|
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
2015-03-21 19:28:04 +03:00
|
|
|
#include "mozilla/Attributes.h" // for override
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/RefPtr.h" // for RefPtr, RefCounted
|
|
|
|
#include "mozilla/gfx/2D.h" // for DrawTarget
|
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
|
|
|
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
2014-02-25 08:23:41 +04:00
|
|
|
#include "mozilla/layers/FenceUtils.h" // for FenceHandle
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/ipc/Shmem.h" // for Shmem
|
2014-01-21 22:53:48 +04:00
|
|
|
#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/CompositorTypes.h" // for TextureFlags, etc
|
2014-12-13 04:50:47 +03:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
|
|
|
#include "mozilla/mozalloc.h" // for operator delete
|
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
|
|
|
#include "nsISupportsImpl.h" // for TextureImage::AddRef, etc
|
2014-07-24 21:34:43 +04:00
|
|
|
#include "GfxTexturesReporter.h"
|
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
|
|
|
|
2013-09-25 00:45:14 +04:00
|
|
|
class gfxImageSurface;
|
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 {
|
2014-06-19 04:04:06 +04:00
|
|
|
|
2014-11-25 22:54:29 +03:00
|
|
|
// When defined, we track which pool the tile came from and test for
|
|
|
|
// any inconsistencies. This can be defined in release build as well.
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define GFX_DEBUG_TRACK_CLIENTS_IN_POOL 1
|
|
|
|
#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
|
|
|
namespace layers {
|
|
|
|
|
2014-05-24 20:14:45 +04:00
|
|
|
class AsyncTransactionTracker;
|
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
|
|
|
class CompositableForwarder;
|
2013-07-30 13:59:51 +04:00
|
|
|
class ISurfaceAllocator;
|
|
|
|
class CompositableClient;
|
2014-06-19 04:57:51 +04:00
|
|
|
struct PlanarYCbCrData;
|
2013-10-02 04:57:50 +04:00
|
|
|
class Image;
|
2013-12-12 05:44:44 +04:00
|
|
|
class PTextureChild;
|
|
|
|
class TextureChild;
|
2014-03-08 01:34:04 +04:00
|
|
|
class BufferTextureClient;
|
2014-04-10 11:24:59 +04:00
|
|
|
class TextureClient;
|
2014-11-25 22:54:29 +03:00
|
|
|
#ifdef GFX_DEBUG_TRACK_CLIENTS_IN_POOL
|
|
|
|
class TextureClientPool;
|
|
|
|
#endif
|
2014-07-22 19:49:05 +04:00
|
|
|
class KeepAlive;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TextureClient is the abstraction that allows us to share data between the
|
|
|
|
* content and the compositor side.
|
|
|
|
*/
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
enum TextureAllocationFlags {
|
|
|
|
ALLOC_DEFAULT = 0,
|
2014-06-18 02:55:31 +04:00
|
|
|
ALLOC_CLEAR_BUFFER = 1,
|
2014-12-16 18:11:48 +03:00
|
|
|
ALLOC_CLEAR_BUFFER_WHITE = 2,
|
|
|
|
ALLOC_DISALLOW_BUFFERTEXTURECLIENT = 4
|
2013-12-05 22:39:22 +04:00
|
|
|
};
|
|
|
|
|
2014-12-13 04:50:47 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
typedef void* SyncHandle;
|
|
|
|
#else
|
|
|
|
typedef uintptr_t SyncHandle;
|
|
|
|
#endif // XP_WIN
|
|
|
|
|
|
|
|
class SyncObject : public RefCounted<SyncObject>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObject)
|
|
|
|
virtual ~SyncObject() { }
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
static already_AddRefed<SyncObject> CreateSyncObject(SyncHandle aHandle);
|
2014-12-13 04:50:47 +03:00
|
|
|
|
2015-01-26 01:22:08 +03:00
|
|
|
enum class SyncType {
|
2014-12-13 04:50:47 +03:00
|
|
|
D3D11,
|
2015-01-26 01:22:08 +03:00
|
|
|
};
|
2014-12-13 04:50:47 +03:00
|
|
|
|
|
|
|
virtual SyncType GetSyncType() = 0;
|
|
|
|
virtual void FinalizeFrame() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SyncObject() { }
|
|
|
|
};
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Interface for TextureClients that can be updated using YCbCr data.
|
|
|
|
*/
|
|
|
|
class TextureClientYCbCr
|
|
|
|
{
|
|
|
|
public:
|
2014-02-05 00:32:02 +04:00
|
|
|
/**
|
|
|
|
* Copy aData into this texture client.
|
|
|
|
*
|
|
|
|
* This must never be called on a TextureClient that is not sucessfully locked.
|
|
|
|
*/
|
2013-10-02 04:57:50 +04:00
|
|
|
virtual bool UpdateYCbCr(const PlanarYCbCrData& aData) = 0;
|
2014-02-05 00:32:02 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates for a given surface size, taking into account the pixel format
|
|
|
|
* which is part of the state of the TextureClient.
|
|
|
|
*
|
|
|
|
* Does not clear the surface, since we consider that the surface
|
|
|
|
* be painted entirely with opaque content.
|
|
|
|
*/
|
2013-08-04 11:46:17 +04:00
|
|
|
virtual bool AllocateForYCbCr(gfx::IntSize aYSize,
|
|
|
|
gfx::IntSize aCbCrSize,
|
|
|
|
StereoMode aStereoMode) = 0;
|
2013-07-30 13:59:51 +04:00
|
|
|
};
|
|
|
|
|
2014-07-30 17:38:46 +04:00
|
|
|
/**
|
|
|
|
* This class may be used to asynchronously receive an update when the content
|
|
|
|
* drawn to this texture client is available for reading in CPU memory. This
|
|
|
|
* can only be used on texture clients that support draw target creation.
|
|
|
|
*/
|
|
|
|
class TextureReadbackSink
|
|
|
|
{
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TextureReadbackSink)
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Callback function to implement in order to receive a DataSourceSurface
|
|
|
|
* containing the data read back from the texture client. This will always
|
|
|
|
* be called on the main thread, and this may not hold on to the
|
|
|
|
* DataSourceSurface beyond the execution of this function.
|
|
|
|
*/
|
|
|
|
virtual void ProcessReadback(gfx::DataSourceSurface *aSourceSurface) = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~TextureReadbackSink() {}
|
|
|
|
};
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* TextureClient is a thin abstraction over texture data that need to be shared
|
|
|
|
* between the content process and the compositor process. It is the
|
|
|
|
* content-side half of a TextureClient/TextureHost pair. A corresponding
|
|
|
|
* TextureHost lives on the compositor-side.
|
|
|
|
*
|
|
|
|
* TextureClient's primary purpose is to present texture data in a way that is
|
|
|
|
* understood by the IPC system. There are two ways to use it:
|
|
|
|
* - Use it to serialize image data that is not IPC-friendly (most likely
|
|
|
|
* involving a copy into shared memory)
|
|
|
|
* - preallocate it and paint directly into it, which avoids copy but requires
|
2013-08-08 16:53:12 +04:00
|
|
|
* the painting code to be aware of TextureClient (or at least the underlying
|
|
|
|
* shared memory).
|
2013-07-30 13:59:51 +04:00
|
|
|
*
|
|
|
|
* There is always one and only one TextureClient per TextureHost, and the
|
|
|
|
* TextureClient/Host pair only owns one buffer of image data through its
|
2013-08-08 16:53:12 +04:00
|
|
|
* lifetime. This means that the lifetime of the underlying shared data
|
2013-07-30 13:59:51 +04:00
|
|
|
* matches the lifetime of the TextureClient/Host pair. It also means
|
|
|
|
* TextureClient/Host do not implement double buffering, which is the
|
|
|
|
* responsibility of the compositable (which would use two Texture pairs).
|
|
|
|
* In order to send several different buffers to the compositor side, use
|
|
|
|
* several TextureClients.
|
|
|
|
*/
|
2013-12-12 05:44:40 +04:00
|
|
|
class TextureClient
|
2013-12-12 05:45:11 +04:00
|
|
|
: public AtomicRefCountedWithFinalize<TextureClient>
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-12-22 11:49:00 +03:00
|
|
|
explicit TextureClient(ISurfaceAllocator* aAllocator,
|
|
|
|
TextureFlags aFlags = TextureFlags::DEFAULT);
|
2013-07-30 13:59:51 +04:00
|
|
|
virtual ~TextureClient();
|
|
|
|
|
2014-07-10 15:45:40 +04:00
|
|
|
// Creates and allocates a TextureClient usable with Moz2D.
|
2015-06-17 17:00:52 +03:00
|
|
|
static already_AddRefed<TextureClient>
|
2014-07-10 15:45:40 +04:00
|
|
|
CreateForDrawing(ISurfaceAllocator* aAllocator,
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
gfx::IntSize aSize,
|
|
|
|
gfx::BackendType aMoz2dBackend,
|
|
|
|
TextureFlags aTextureFlags,
|
|
|
|
TextureAllocationFlags flags = ALLOC_DEFAULT);
|
|
|
|
|
2014-07-10 15:48:29 +04:00
|
|
|
// Creates and allocates a BufferTextureClient supporting the YCbCr format.
|
2015-06-17 17:00:52 +03:00
|
|
|
static already_AddRefed<BufferTextureClient>
|
2014-07-10 15:48:29 +04:00
|
|
|
CreateForYCbCr(ISurfaceAllocator* aAllocator,
|
|
|
|
gfx::IntSize aYSize,
|
|
|
|
gfx::IntSize aCbCrSize,
|
|
|
|
StereoMode aStereoMode,
|
|
|
|
TextureFlags aTextureFlags);
|
|
|
|
|
2014-07-10 15:45:40 +04:00
|
|
|
// Creates and allocates a BufferTextureClient (can beaccessed through raw
|
|
|
|
// pointers).
|
2015-06-17 17:00:52 +03:00
|
|
|
static already_AddRefed<BufferTextureClient>
|
2014-07-10 15:45:40 +04:00
|
|
|
CreateForRawBufferAccess(ISurfaceAllocator* aAllocator,
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
gfx::IntSize aSize,
|
|
|
|
gfx::BackendType aMoz2dBackend,
|
|
|
|
TextureFlags aTextureFlags,
|
|
|
|
TextureAllocationFlags flags = ALLOC_DEFAULT);
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2014-07-22 16:17:31 +04:00
|
|
|
// Creates and allocates a BufferTextureClient (can beaccessed through raw
|
|
|
|
// pointers) with a certain buffer size. It's unfortunate that we need this.
|
|
|
|
// providing format and sizes could let us do more optimization.
|
2015-06-17 17:00:52 +03:00
|
|
|
static already_AddRefed<BufferTextureClient>
|
2014-07-22 16:17:31 +04:00
|
|
|
CreateWithBufferSize(ISurfaceAllocator* aAllocator,
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
size_t aSize,
|
|
|
|
TextureFlags aTextureFlags);
|
|
|
|
|
2014-07-25 13:24:46 +04:00
|
|
|
// Creates and allocates a TextureClient of the same type.
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<TextureClient>
|
2014-07-25 13:24:46 +04:00
|
|
|
CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT,
|
|
|
|
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates for a given surface size, taking into account the pixel format
|
|
|
|
* which is part of the state of the TextureClient.
|
|
|
|
*
|
|
|
|
* Does not clear the surface by default, clearing the surface can be done
|
|
|
|
* by passing the CLEAR_BUFFER flag.
|
|
|
|
*
|
|
|
|
* TextureClients that can expose a DrawTarget should override this method.
|
|
|
|
*/
|
|
|
|
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
|
|
|
TextureAllocationFlags flags = ALLOC_DEFAULT)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
virtual TextureClientYCbCr* AsTextureClientYCbCr() { return nullptr; }
|
|
|
|
|
2013-09-30 16:42:47 +04:00
|
|
|
/**
|
|
|
|
* Locks the shared data, allowing the caller to get access to it.
|
|
|
|
*
|
|
|
|
* Please always lock/unlock when accessing the shared data.
|
|
|
|
* If Lock() returns false, you should not attempt to access the shared data.
|
|
|
|
*/
|
|
|
|
virtual bool Lock(OpenMode aMode) { return IsValid(); }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
virtual void Unlock() {}
|
|
|
|
|
2014-01-24 18:25:04 +04:00
|
|
|
virtual bool IsLocked() const = 0;
|
|
|
|
|
2014-04-10 12:14:28 +04:00
|
|
|
virtual bool CanExposeDrawTarget() const { return false; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a DrawTarget to draw into the TextureClient.
|
|
|
|
*
|
|
|
|
* This must never be called on a TextureClient that is not sucessfully locked.
|
|
|
|
* When called several times within one Lock/Unlock pair, this method should
|
|
|
|
* return the same DrawTarget.
|
|
|
|
* The DrawTarget is automatically flushed by the TextureClient when the latter
|
|
|
|
* is unlocked, and the DrawTarget that will be returned within the next
|
|
|
|
* lock/unlock pair may or may not be the same object.
|
|
|
|
* Do not keep references to the DrawTarget outside of the lock/unlock pair.
|
|
|
|
*
|
|
|
|
* This is typically used as follows:
|
|
|
|
*
|
2014-04-26 06:34:06 +04:00
|
|
|
* if (!texture->Lock(OpenMode::OPEN_READ_WRITE)) {
|
2014-04-10 12:14:28 +04:00
|
|
|
* return false;
|
|
|
|
* }
|
|
|
|
* {
|
|
|
|
* // Restrict this code's scope to ensure all references to dt are gone
|
|
|
|
* // when Unlock is called.
|
2014-06-11 22:57:58 +04:00
|
|
|
* DrawTarget* dt = texture->BorrowDrawTarget();
|
2014-04-10 12:14:28 +04:00
|
|
|
* // use the draw target ...
|
|
|
|
* }
|
|
|
|
* texture->Unlock();
|
|
|
|
*
|
|
|
|
*/
|
2014-06-11 22:57:58 +04:00
|
|
|
virtual gfx::DrawTarget* BorrowDrawTarget() { return nullptr; }
|
2014-04-10 12:14:28 +04:00
|
|
|
|
|
|
|
// TextureClients that can expose a DrawTarget should override this method.
|
|
|
|
virtual gfx::SurfaceFormat GetFormat() const
|
|
|
|
{
|
|
|
|
return gfx::SurfaceFormat::UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2015-01-13 00:51:02 +03:00
|
|
|
/**
|
|
|
|
* This method is strictly for debugging. It causes locking and
|
|
|
|
* needless copies.
|
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() {
|
2015-01-13 00:51:02 +03:00
|
|
|
Lock(OpenMode::OPEN_READ);
|
|
|
|
RefPtr<gfx::SourceSurface> surf = BorrowDrawTarget()->Snapshot();
|
|
|
|
RefPtr<gfx::DataSourceSurface> data = surf->GetDataSurface();
|
|
|
|
Unlock();
|
2015-05-01 16:14:16 +03:00
|
|
|
return data.forget();
|
2015-01-13 00:51:02 +03:00
|
|
|
}
|
2014-12-18 21:32:45 +03:00
|
|
|
|
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
|
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
/**
|
|
|
|
* Copies a rectangle from this texture client to a position in aTarget.
|
|
|
|
* It is assumed that the necessary locks are in place; so this should at
|
|
|
|
* least have a read lock and aTarget should at least have a write lock.
|
|
|
|
*/
|
|
|
|
virtual bool CopyToTextureClient(TextureClient* aTarget,
|
|
|
|
const gfx::IntRect* aRect,
|
|
|
|
const gfx::IntPoint* aPoint);
|
|
|
|
|
2013-08-26 16:50:16 +04:00
|
|
|
/**
|
|
|
|
* Returns true if this texture has a lock/unlock mechanism.
|
|
|
|
* Textures that do not implement locking should be immutable or should
|
|
|
|
* use immediate uploads (see TextureFlags in CompositorTypes.h)
|
|
|
|
*/
|
2013-09-30 16:42:47 +04:00
|
|
|
virtual bool ImplementsLocking() const { return false; }
|
2013-08-26 16:50:16 +04:00
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
/**
|
|
|
|
* Indicates whether the TextureClient implementation is backed by an
|
|
|
|
* in-memory buffer. The consequence of this is that locking the
|
|
|
|
* TextureClient does not contend with locking the texture on the host side.
|
|
|
|
*/
|
|
|
|
virtual bool HasInternalBuffer() const = 0;
|
|
|
|
|
2013-12-12 05:44:44 +04:00
|
|
|
/**
|
|
|
|
* Allocate and deallocate a TextureChild actor.
|
|
|
|
*
|
2014-04-24 22:13:59 +04:00
|
|
|
* TextureChild is an implementation detail of TextureClient that is not
|
2013-12-12 05:44:44 +04:00
|
|
|
* exposed to the rest of the code base. CreateIPDLActor and DestroyIPDLActor
|
2014-04-24 22:13:59 +04:00
|
|
|
* are for use with the managing IPDL protocols only (so that they can
|
2013-12-12 05:44:44 +04:00
|
|
|
* implement AllocPextureChild and DeallocPTextureChild).
|
|
|
|
*/
|
|
|
|
static PTextureChild* CreateIPDLActor();
|
|
|
|
static bool DestroyIPDLActor(PTextureChild* actor);
|
|
|
|
|
2014-02-25 08:23:41 +04:00
|
|
|
/**
|
|
|
|
* Get the TextureClient corresponding to the actor passed in parameter.
|
|
|
|
*/
|
|
|
|
static TextureClient* AsTextureClient(PTextureChild* actor);
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
virtual bool IsAllocated() const = 0;
|
|
|
|
|
2013-08-03 21:29:18 +04:00
|
|
|
virtual gfx::IntSize GetSize() const = 0;
|
|
|
|
|
2013-09-30 16:42:47 +04:00
|
|
|
/**
|
|
|
|
* TextureFlags contain important information about various aspects
|
|
|
|
* of the texture, like how its liferime is managed, and how it
|
|
|
|
* should be displayed.
|
|
|
|
* See TextureFlags in CompositorTypes.h.
|
|
|
|
*/
|
2013-07-30 13:59:51 +04:00
|
|
|
TextureFlags GetFlags() const { return mFlags; }
|
|
|
|
|
2014-10-08 08:01:51 +04:00
|
|
|
bool HasFlags(TextureFlags aFlags) const
|
|
|
|
{
|
|
|
|
return (mFlags & aFlags) == aFlags;
|
|
|
|
}
|
|
|
|
|
2014-11-13 18:53:49 +03:00
|
|
|
void AddFlags(TextureFlags aFlags);
|
2014-11-13 04:47:10 +03:00
|
|
|
|
2014-11-13 18:53:49 +03:00
|
|
|
void RemoveFlags(TextureFlags aFlags);
|
|
|
|
|
|
|
|
void RecycleTexture(TextureFlags aFlags);
|
2014-10-08 08:01:51 +04:00
|
|
|
|
2014-03-10 22:34:57 +04:00
|
|
|
/**
|
2014-04-26 06:34:05 +04:00
|
|
|
* valid only for TextureFlags::RECYCLE TextureClient.
|
2014-03-10 22:34:57 +04:00
|
|
|
* When called this texture client will grab a strong reference and release
|
|
|
|
* it once the compositor notifies that it is done with the texture.
|
|
|
|
* NOTE: In this stage the texture client can no longer be used by the
|
|
|
|
* client in a transaction.
|
|
|
|
*/
|
|
|
|
void WaitForCompositorRecycle();
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
2013-08-08 16:53:12 +04:00
|
|
|
* After being shared with the compositor side, an immutable texture is never
|
2013-07-30 13:59:51 +04:00
|
|
|
* modified, it can only be read. It is safe to not Lock/Unlock immutable
|
|
|
|
* textures.
|
|
|
|
*/
|
2014-04-26 06:34:05 +04:00
|
|
|
bool IsImmutable() const { return !!(mFlags & TextureFlags::IMMUTABLE); }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-04-26 06:34:05 +04:00
|
|
|
void MarkImmutable() { AddFlags(TextureFlags::IMMUTABLE); }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2013-08-28 00:16:03 +04:00
|
|
|
bool IsSharedWithCompositor() const { return mShared; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
bool ShouldDeallocateInDestructor() const;
|
2013-09-06 13:04:50 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If this method returns false users of TextureClient are not allowed
|
|
|
|
* to access the shared data.
|
|
|
|
*/
|
|
|
|
bool IsValid() const { return mValid; }
|
|
|
|
|
2014-11-13 18:53:49 +03:00
|
|
|
/**
|
|
|
|
* Called when TextureClient is added to CompositableClient.
|
|
|
|
*/
|
|
|
|
void SetAddedToCompositableClient();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If this method retuns false, TextureClient is already added to CompositableClient,
|
|
|
|
* since its creation or recycling.
|
|
|
|
*/
|
|
|
|
bool IsAddedToCompositableClient() const { return mAddedToCompositableClient; }
|
|
|
|
|
2014-07-22 19:49:05 +04:00
|
|
|
/**
|
|
|
|
* kee the passed object alive until the IPDL actor is destroyed. This can
|
|
|
|
* help avoid race conditions in some cases.
|
|
|
|
* It's a temporary hack to ensure that DXGI textures don't get destroyed
|
|
|
|
* between serialization and deserialization.
|
|
|
|
*/
|
2015-03-26 03:05:25 +03:00
|
|
|
void KeepUntilFullDeallocation(UniquePtr<KeepAlive> aKeep, bool aMainThreadOnly = false);
|
2014-07-22 19:49:05 +04:00
|
|
|
|
2013-12-12 05:44:44 +04:00
|
|
|
/**
|
|
|
|
* Create and init the TextureChild/Parent IPDL actor pair.
|
|
|
|
*
|
|
|
|
* Should be called only once per TextureClient.
|
|
|
|
*/
|
|
|
|
bool InitIPDLActor(CompositableForwarder* aForwarder);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a pointer to the IPDLActor.
|
|
|
|
*
|
|
|
|
* This is to be used with IPDL messages only. Do not store the returned
|
|
|
|
* pointer.
|
|
|
|
*/
|
|
|
|
PTextureChild* GetIPDLActor();
|
|
|
|
|
2013-12-12 05:44:45 +04:00
|
|
|
/**
|
2014-02-05 00:32:02 +04:00
|
|
|
* Triggers the destruction of the shared data and the corresponding TextureHost.
|
|
|
|
*
|
2014-04-26 06:34:05 +04:00
|
|
|
* If the texture flags contain TextureFlags::DEALLOCATE_CLIENT, the destruction
|
2014-02-05 00:32:02 +04:00
|
|
|
* will be synchronously coordinated with the compositor side, otherwise it
|
|
|
|
* will be done asynchronously.
|
2015-01-23 17:35:16 +03:00
|
|
|
* If sync is true, the destruction will be synchronous regardless of the
|
|
|
|
* texture's flags (bad for performance, use with care).
|
2013-12-12 05:44:45 +04:00
|
|
|
*/
|
2015-01-23 17:35:16 +03:00
|
|
|
void ForceRemove(bool sync = false);
|
2013-12-12 05:44:45 +04:00
|
|
|
|
2015-05-13 02:42:00 +03:00
|
|
|
virtual void SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
|
2014-06-08 17:18:53 +04:00
|
|
|
{
|
2014-10-07 02:45:03 +04:00
|
|
|
mReleaseFenceHandle.Merge(aReleaseFenceHandle);
|
2014-06-08 17:18:53 +04:00
|
|
|
}
|
2014-02-25 08:23:41 +04:00
|
|
|
|
2015-05-13 02:42:00 +03:00
|
|
|
FenceHandle GetAndResetReleaseFenceHandle()
|
2014-02-25 08:23:41 +04:00
|
|
|
{
|
2015-05-13 02:42:00 +03:00
|
|
|
FenceHandle fence;
|
|
|
|
mReleaseFenceHandle.TransferToAnotherFenceHandle(fence);
|
|
|
|
return fence;
|
2014-02-25 08:23:41 +04:00
|
|
|
}
|
|
|
|
|
2015-05-13 02:42:00 +03:00
|
|
|
virtual void SetAcquireFenceHandle(const FenceHandle& aAcquireFenceHandle)
|
2014-06-08 17:18:53 +04:00
|
|
|
{
|
|
|
|
mAcquireFenceHandle = aAcquireFenceHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FenceHandle& GetAcquireFenceHandle() const
|
|
|
|
{
|
|
|
|
return mAcquireFenceHandle;
|
|
|
|
}
|
|
|
|
|
2014-03-27 05:01:15 +04:00
|
|
|
/**
|
2014-05-24 20:14:45 +04:00
|
|
|
* Set AsyncTransactionTracker of RemoveTextureFromCompositableAsync() transaction.
|
|
|
|
*/
|
|
|
|
virtual void SetRemoveFromCompositableTracker(AsyncTransactionTracker* aTracker) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function waits until the buffer is no longer being used.
|
2014-03-27 05:01:15 +04:00
|
|
|
*/
|
2015-01-27 21:05:35 +03:00
|
|
|
virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true) {}
|
2014-03-27 05:01:15 +04:00
|
|
|
|
2014-07-24 21:34:43 +04:00
|
|
|
/**
|
|
|
|
* Track how much of this texture is wasted.
|
|
|
|
* For example we might allocate a 256x256 tile but only use 10x10.
|
|
|
|
*/
|
|
|
|
void SetWaste(int aWasteArea) {
|
|
|
|
mWasteTracker.Update(aWasteArea, BytesPerPixel(GetFormat()));
|
|
|
|
}
|
|
|
|
|
2014-07-30 17:38:46 +04:00
|
|
|
/**
|
|
|
|
* This sets the readback sink that this texture is to use. This will
|
|
|
|
* receive the data for this texture as soon as it becomes available after
|
|
|
|
* texture unlock.
|
|
|
|
*/
|
|
|
|
virtual void SetReadbackSink(TextureReadbackSink* aReadbackSink) {
|
|
|
|
mReadbackSink = aReadbackSink;
|
|
|
|
}
|
2015-06-05 03:15:38 +03:00
|
|
|
|
2014-12-13 04:50:47 +03:00
|
|
|
virtual void SyncWithObject(SyncObject* aSyncObject) { }
|
2014-07-30 17:38:46 +04:00
|
|
|
|
2015-06-05 03:15:38 +03:00
|
|
|
void MarkShared() {
|
|
|
|
mShared = true;
|
|
|
|
}
|
|
|
|
|
2013-12-12 05:44:40 +04:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Called once, just before the destructor.
|
|
|
|
*
|
|
|
|
* Here goes the shut-down code that uses virtual methods.
|
|
|
|
* Must only be called by Release().
|
|
|
|
*/
|
2015-07-03 01:19:35 +03:00
|
|
|
B2G_ACL_EXPORT void Finalize();
|
2013-12-12 05:44:40 +04:00
|
|
|
|
2013-12-12 05:45:11 +04:00
|
|
|
friend class AtomicRefCountedWithFinalize<TextureClient>;
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
protected:
|
2014-02-05 00:32:02 +04:00
|
|
|
/**
|
|
|
|
* An invalid TextureClient cannot provide access to its shared data
|
|
|
|
* anymore. This usually means it will soon be destroyed.
|
|
|
|
*/
|
|
|
|
void MarkInvalid() { mValid = false; }
|
|
|
|
|
2014-04-10 11:24:59 +04:00
|
|
|
/**
|
|
|
|
* Should only be called *once* per texture, in TextureClient::InitIPDLActor.
|
|
|
|
* Some texture implementations rely on the fact that the descriptor will be
|
|
|
|
* deserialized.
|
|
|
|
* Calling ToSurfaceDescriptor again after it has already returned true,
|
|
|
|
* or never constructing a TextureHost with aDescriptor may result in a memory
|
2015-07-03 18:54:35 +03:00
|
|
|
* leak (see TextureClientD3D9 for example).
|
2014-04-10 11:24:59 +04:00
|
|
|
*/
|
|
|
|
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) = 0;
|
|
|
|
|
2014-06-27 17:26:51 +04:00
|
|
|
ISurfaceAllocator* GetAllocator()
|
|
|
|
{
|
|
|
|
return mAllocator;
|
|
|
|
}
|
|
|
|
|
2013-12-21 01:44:30 +04:00
|
|
|
RefPtr<TextureChild> mActor;
|
2014-06-27 17:26:51 +04:00
|
|
|
RefPtr<ISurfaceAllocator> mAllocator;
|
2013-07-30 13:59:51 +04:00
|
|
|
TextureFlags mFlags;
|
2014-02-25 08:23:41 +04:00
|
|
|
FenceHandle mReleaseFenceHandle;
|
2014-06-08 17:18:53 +04:00
|
|
|
FenceHandle mAcquireFenceHandle;
|
2014-07-24 21:34:43 +04:00
|
|
|
gl::GfxTextureWasteTracker mWasteTracker;
|
|
|
|
bool mShared;
|
|
|
|
bool mValid;
|
2014-11-13 18:53:49 +03:00
|
|
|
bool mAddedToCompositableClient;
|
2013-12-12 05:44:55 +04:00
|
|
|
|
2014-07-30 17:38:46 +04:00
|
|
|
RefPtr<TextureReadbackSink> mReadbackSink;
|
|
|
|
|
2013-12-12 05:44:55 +04:00
|
|
|
friend class TextureChild;
|
2014-06-27 17:26:51 +04:00
|
|
|
friend class RemoveTextureFromCompositableTracker;
|
2014-04-10 11:24:59 +04:00
|
|
|
friend void TestTextureClientSurface(TextureClient*, gfxImageSurface*);
|
|
|
|
friend void TestTextureClientYCbCr(TextureClient*, PlanarYCbCrData&);
|
2014-11-25 22:54:29 +03:00
|
|
|
|
|
|
|
#ifdef GFX_DEBUG_TRACK_CLIENTS_IN_POOL
|
|
|
|
public:
|
|
|
|
// Pointer to the pool this tile came from.
|
|
|
|
TextureClientPool* mPoolTracker;
|
|
|
|
#endif
|
2013-07-30 13:59:51 +04:00
|
|
|
};
|
|
|
|
|
2014-06-27 17:26:51 +04:00
|
|
|
/**
|
|
|
|
* Task that releases TextureClient pointer on a specified thread.
|
|
|
|
*/
|
|
|
|
class TextureClientReleaseTask : public Task
|
|
|
|
{
|
|
|
|
public:
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit TextureClientReleaseTask(TextureClient* aClient)
|
2014-06-27 17:26:51 +04:00
|
|
|
: mTextureClient(aClient) {
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Run() override
|
2014-06-27 17:26:51 +04:00
|
|
|
{
|
|
|
|
mTextureClient = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
mozilla::RefPtr<TextureClient> mTextureClient;
|
|
|
|
};
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* TextureClient that wraps a random access buffer such as a Shmem or raw memory.
|
|
|
|
* This class must be inherited to implement the memory allocation and access bits.
|
|
|
|
* (see ShmemTextureClient and MemoryTextureClient)
|
|
|
|
*/
|
|
|
|
class BufferTextureClient : public TextureClient
|
2013-12-05 22:39:22 +04:00
|
|
|
, public TextureClientYCbCr
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-03-08 01:34:04 +04:00
|
|
|
BufferTextureClient(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat,
|
2014-03-18 01:35:20 +04:00
|
|
|
gfx::BackendType aBackend, TextureFlags aFlags);
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
virtual ~BufferTextureClient();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsAllocated() const override = 0;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
virtual uint8_t* GetBuffer() const = 0;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override { return mSize; }
|
2013-08-03 21:29:18 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Lock(OpenMode aMode) override;
|
2014-01-07 20:20:11 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Unlock() override;
|
2014-01-07 20:20:11 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsLocked() const override { return mLocked; }
|
2014-01-24 18:25:04 +04:00
|
|
|
|
2014-10-08 08:01:51 +04:00
|
|
|
uint8_t* GetLockedData() const;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool CanExposeDrawTarget() const override { return true; }
|
2014-04-10 12:14:28 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::DrawTarget* BorrowDrawTarget() override;
|
2014-04-10 12:14:28 +04:00
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
virtual bool AllocateForSurface(gfx::IntSize aSize,
|
2015-03-21 19:28:04 +03:00
|
|
|
TextureAllocationFlags aFlags = ALLOC_DEFAULT) override;
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
// TextureClientYCbCr
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual TextureClientYCbCr* AsTextureClientYCbCr() override { return this; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool UpdateYCbCr(const PlanarYCbCrData& aData) override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
virtual bool AllocateForYCbCr(gfx::IntSize aYSize,
|
|
|
|
gfx::IntSize aCbCrSize,
|
2015-03-21 19:28:04 +03:00
|
|
|
StereoMode aStereoMode) override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2013-08-28 17:21:13 +04:00
|
|
|
// XXX - Bug 908196 - Make Allocate(uint32_t) and GetBufferSize() protected.
|
|
|
|
// these two methods should only be called by methods of BufferTextureClient
|
|
|
|
// that are overridden in GrallocTextureClient (which does not implement the
|
|
|
|
// two methods below)
|
|
|
|
virtual bool Allocate(uint32_t aSize) = 0;
|
|
|
|
|
|
|
|
virtual size_t GetBufferSize() const = 0;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasInternalBuffer() const override { return true; }
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<TextureClient>
|
2014-07-25 13:24:46 +04:00
|
|
|
CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT,
|
2015-03-21 19:28:04 +03:00
|
|
|
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
|
2014-07-25 13:24:46 +04:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
protected:
|
2014-01-07 20:20:11 +04:00
|
|
|
RefPtr<gfx::DrawTarget> mDrawTarget;
|
2013-07-30 13:59:51 +04:00
|
|
|
gfx::SurfaceFormat mFormat;
|
2013-08-03 21:29:18 +04:00
|
|
|
gfx::IntSize mSize;
|
2014-03-18 01:35:20 +04:00
|
|
|
gfx::BackendType mBackend;
|
2014-01-07 20:20:11 +04:00
|
|
|
OpenMode mOpenMode;
|
|
|
|
bool mLocked;
|
2013-07-30 13:59:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TextureClient that wraps shared memory.
|
|
|
|
* the corresponding texture on the host side is ShmemTextureHost.
|
|
|
|
*/
|
|
|
|
class ShmemTextureClient : public BufferTextureClient
|
|
|
|
{
|
|
|
|
public:
|
2014-03-08 01:34:04 +04:00
|
|
|
ShmemTextureClient(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat,
|
2014-03-18 01:35:20 +04:00
|
|
|
gfx::BackendType aBackend, TextureFlags aFlags);
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
protected:
|
2013-07-30 13:59:51 +04:00
|
|
|
~ShmemTextureClient();
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Allocate(uint32_t aSize) override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint8_t* GetBuffer() const override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual size_t GetBufferSize() const override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsAllocated() const override { return mAllocated; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasInternalBuffer() const override { return true; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-01-23 18:31:12 +04:00
|
|
|
mozilla::ipc::Shmem& GetShmem() { return mShmem; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
protected:
|
2014-01-23 18:31:12 +04:00
|
|
|
mozilla::ipc::Shmem mShmem;
|
2013-07-30 13:59:51 +04:00
|
|
|
bool mAllocated;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TextureClient that wraps raw memory.
|
|
|
|
* The corresponding texture on the host side is MemoryTextureHost.
|
|
|
|
* Can obviously not be used in a cross process setup.
|
|
|
|
*/
|
|
|
|
class MemoryTextureClient : public BufferTextureClient
|
|
|
|
{
|
|
|
|
public:
|
2014-03-08 01:34:04 +04:00
|
|
|
MemoryTextureClient(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat,
|
2014-03-18 01:35:20 +04:00
|
|
|
gfx::BackendType aBackend, TextureFlags aFlags);
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
protected:
|
2013-07-30 13:59:51 +04:00
|
|
|
~MemoryTextureClient();
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Allocate(uint32_t aSize) override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint8_t* GetBuffer() const override { return mBuffer; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual size_t GetBufferSize() const override { return mBufSize; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsAllocated() const override { return mBuffer != nullptr; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasInternalBuffer() const override { return true; }
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
protected:
|
|
|
|
uint8_t* mBuffer;
|
|
|
|
size_t mBufSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TextureClientAutoUnlock
|
|
|
|
{
|
|
|
|
TextureClient* mTexture;
|
|
|
|
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit TextureClientAutoUnlock(TextureClient* aTexture)
|
2013-07-30 13:59:51 +04:00
|
|
|
: mTexture(aTexture) {}
|
|
|
|
|
|
|
|
~TextureClientAutoUnlock()
|
|
|
|
{
|
|
|
|
mTexture->Unlock();
|
|
|
|
}
|
|
|
|
};
|
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
|
|
|
|
2014-07-22 19:49:05 +04:00
|
|
|
class KeepAlive
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~KeepAlive() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class TKeepAlive : public KeepAlive
|
|
|
|
{
|
|
|
|
public:
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit TKeepAlive(T* aData) : mData(aData) {}
|
2014-07-22 19:49:05 +04:00
|
|
|
protected:
|
|
|
|
RefPtr<T> mData;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|