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_TEXTUREHOST_H
|
|
|
|
#define MOZILLA_GFX_TEXTUREHOST_H
|
|
|
|
|
2017-06-07 18:44:04 +03:00
|
|
|
#include <functional>
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stddef.h> // for size_t
|
|
|
|
#include <stdint.h> // for uint64_t, uint32_t, uint8_t
|
2013-09-25 00:45:14 +04:00
|
|
|
#include "gfxTypes.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
2015-03-21 19:28:04 +03:00
|
|
|
#include "mozilla/Attributes.h" // for override
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h" // for RefPtr, already_AddRefed, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/gfx/2D.h" // for DataSourceSurface
|
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize, IntPoint
|
|
|
|
#include "mozilla/gfx/Types.h" // for SurfaceFormat, etc
|
2014-10-16 17:48:29 +04:00
|
|
|
#include "mozilla/layers/Compositor.h" // for Compositor
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/CompositorTypes.h" // for TextureFlags, etc
|
|
|
|
#include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc
|
2015-12-16 21:50:58 +03:00
|
|
|
#include "mozilla/layers/LayersSurfaces.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/mozalloc.h" // for operator delete
|
2017-05-18 19:25:41 +03:00
|
|
|
#include "mozilla/Range.h"
|
2014-07-22 02:55:02 +04:00
|
|
|
#include "mozilla/UniquePtr.h" // for UniquePtr
|
2017-04-20 04:24:13 +03:00
|
|
|
#include "mozilla/webrender/WebRenderTypes.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
|
|
|
#include "nsDebug.h" // for NS_RUNTIMEABORT
|
2014-02-27 01:36:35 +04:00
|
|
|
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsRegion.h" // for nsIntRegion
|
2014-03-08 01:34:04 +04:00
|
|
|
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nscore.h" // for nsACString
|
2013-12-12 05:45:11 +04:00
|
|
|
#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
|
2015-04-21 18:04:57 +03:00
|
|
|
#include "mozilla/gfx/Rect.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
|
|
|
|
2017-07-04 23:50:40 +03:00
|
|
|
class MacIOSurface;
|
2013-07-30 13:59:51 +04:00
|
|
|
namespace mozilla {
|
2013-08-12 03:17:23 +04:00
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace ipc
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2017-05-18 17:59:07 +03:00
|
|
|
namespace wr {
|
2017-06-07 18:44:04 +03:00
|
|
|
class DisplayListBuilder;
|
2017-09-04 14:59:42 +03:00
|
|
|
class ResourceUpdateQueue;
|
2017-05-18 17:59:07 +03:00
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
class BufferDescriptor;
|
2016-07-09 04:59:59 +03:00
|
|
|
class BufferTextureHost;
|
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 Compositor;
|
2014-05-06 05:56:40 +04:00
|
|
|
class CompositableParentManager;
|
2016-06-02 12:00:21 +03:00
|
|
|
class ReadLockDescriptor;
|
2016-04-13 00:04:50 +03:00
|
|
|
class CompositorBridgeParent;
|
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 SurfaceDescriptor;
|
2016-05-19 16:04:14 +03:00
|
|
|
class HostIPCAllocator;
|
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 ISurfaceAllocator;
|
2017-03-31 17:29:14 +03:00
|
|
|
class MacIOSurfaceTextureHostOGL;
|
2014-02-25 08:23:41 +04:00
|
|
|
class TextureHostOGL;
|
2016-06-02 12:00:17 +03:00
|
|
|
class TextureReadLock;
|
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 TextureSourceOGL;
|
2013-05-03 21:34:29 +04:00
|
|
|
class TextureSourceD3D11;
|
2013-05-01 04:42:05 +04:00
|
|
|
class TextureSourceBasic;
|
2013-12-11 23:52:50 +04:00
|
|
|
class DataTextureSource;
|
2013-12-12 05:44:44 +04:00
|
|
|
class PTextureParent;
|
|
|
|
class TextureParent;
|
2017-03-07 13:37:28 +03:00
|
|
|
class WebRenderTextureHost;
|
2016-07-09 04:59:59 +03:00
|
|
|
class WrappingTextureSourceYCbCrBasic;
|
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-07-30 13:59:51 +04:00
|
|
|
* A view on a TextureHost where the texture is internally represented as tiles
|
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
|
|
|
* (contrast with a tiled buffer, where each texture is a tile). For iteration by
|
|
|
|
* the texture's buffer host.
|
|
|
|
* This is only useful when the underlying surface is too big to fit in one
|
|
|
|
* device texture, which forces us to split it in smaller parts.
|
|
|
|
* Tiled Compositable is a different thing.
|
|
|
|
*/
|
2014-04-28 15:27:25 +04:00
|
|
|
class BigImageIterator
|
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
|
|
|
{
|
|
|
|
public:
|
2014-04-28 15:27:25 +04:00
|
|
|
virtual void BeginBigImageIteration() = 0;
|
|
|
|
virtual void EndBigImageIteration() {};
|
2015-04-21 18:04:57 +03:00
|
|
|
virtual gfx::IntRect GetTileRect() = 0;
|
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
|
|
|
virtual size_t GetTileCount() = 0;
|
|
|
|
virtual bool NextTile() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TextureSource is the interface for texture objects that can be composited
|
|
|
|
* by a given compositor backend. Since the drawing APIs are different
|
|
|
|
* between backends, the TextureSource interface is split into different
|
|
|
|
* interfaces (TextureSourceOGL, etc.), and TextureSource mostly provide
|
|
|
|
* access to these interfaces.
|
|
|
|
*
|
|
|
|
* This class is used on the compositor side.
|
|
|
|
*/
|
2014-12-02 16:28:19 +03:00
|
|
|
class TextureSource: public RefCounted<TextureSource>
|
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
|
|
|
{
|
|
|
|
public:
|
2014-12-02 16:28:19 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(TextureSource)
|
2014-04-14 23:04:24 +04:00
|
|
|
|
2013-09-13 06:39:26 +04:00
|
|
|
TextureSource();
|
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-12-02 16:28:19 +03:00
|
|
|
virtual ~TextureSource();
|
|
|
|
|
2016-02-08 13:57:00 +03:00
|
|
|
virtual const char* Name() const = 0;
|
|
|
|
|
2014-10-07 17:58:59 +04:00
|
|
|
/**
|
|
|
|
* Should be overridden in order to deallocate the data that is associated
|
|
|
|
* with the rendering backend, such as GL textures.
|
|
|
|
*/
|
|
|
|
virtual void DeallocateDeviceData() {}
|
|
|
|
|
|
|
|
|
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-07-30 13:59:51 +04:00
|
|
|
* Return the size of the texture in texels.
|
|
|
|
* If this is a tile iterator, GetSize must return the size of the current tile.
|
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
|
|
|
*/
|
|
|
|
virtual gfx::IntSize GetSize() const = 0;
|
2013-07-24 19:34:09 +04:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Return the pixel format of this texture
|
|
|
|
*/
|
2014-01-10 23:06:16 +04:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const { return gfx::SurfaceFormat::UNKNOWN; }
|
2013-07-24 19:34:09 +04:00
|
|
|
|
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-08-04 11:46:17 +04:00
|
|
|
* Cast to a TextureSource for for each backend..
|
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
|
|
|
*/
|
2016-05-16 12:29:57 +03:00
|
|
|
virtual TextureSourceOGL* AsSourceOGL() {
|
|
|
|
gfxCriticalNote << "Failed to cast " << Name() << " into a TextureSourceOGL";
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-05-03 21:34:29 +04:00
|
|
|
virtual TextureSourceD3D11* AsSourceD3D11() { return nullptr; }
|
2013-05-01 04:42:05 +04:00
|
|
|
virtual TextureSourceBasic* AsSourceBasic() { return nullptr; }
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Cast to a DataTextureSurce.
|
|
|
|
*/
|
|
|
|
virtual DataTextureSource* AsDataTextureSource() { return nullptr; }
|
2016-07-09 04:59:59 +03:00
|
|
|
virtual WrappingTextureSourceYCbCrBasic* AsWrappingTextureSourceYCbCrBasic() { return nullptr; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Overload this if the TextureSource supports big textures that don't fit in
|
|
|
|
* one device texture and must be tiled internally.
|
|
|
|
*/
|
2014-04-28 15:27:25 +04:00
|
|
|
virtual BigImageIterator* AsBigImageIterator() { return nullptr; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2017-03-22 06:32:53 +03:00
|
|
|
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) {}
|
2014-01-07 20:20:11 +04:00
|
|
|
|
2016-07-09 04:59:59 +03:00
|
|
|
virtual void Unbind() {}
|
|
|
|
|
2014-10-07 17:58:59 +04:00
|
|
|
void SetNextSibling(TextureSource* aTexture) { mNextSibling = aTexture; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-10-07 17:58:59 +04:00
|
|
|
TextureSource* GetNextSibling() const { return mNextSibling; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-10-07 17:58:59 +04:00
|
|
|
/**
|
|
|
|
* In some rare cases we currently need to consider a group of textures as one
|
|
|
|
* TextureSource, that can be split in sub-TextureSources.
|
|
|
|
*/
|
|
|
|
TextureSource* GetSubSource(int index)
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
|
|
|
switch (index) {
|
|
|
|
case 0: return this;
|
|
|
|
case 1: return GetNextSibling();
|
|
|
|
case 2: return GetNextSibling() ? GetNextSibling()->GetNextSibling() : nullptr;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
void AddCompositableRef() { ++mCompositableCount; }
|
|
|
|
|
|
|
|
void ReleaseCompositableRef() {
|
|
|
|
--mCompositableCount;
|
|
|
|
MOZ_ASSERT(mCompositableCount >= 0);
|
|
|
|
}
|
|
|
|
|
2017-06-20 11:17:18 +03:00
|
|
|
// When iterating as a BigImage, this creates temporary TextureSources wrapping
|
|
|
|
// individual tiles.
|
|
|
|
virtual RefPtr<TextureSource> ExtractCurrentTile() {
|
|
|
|
NS_WARNING("Implementation does not expose tile sources");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
int NumCompositableRefs() const { return mCompositableCount; }
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
protected:
|
2014-10-07 17:58:59 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TextureSource> mNextSibling;
|
2014-10-16 21:08:32 +04:00
|
|
|
int mCompositableCount;
|
|
|
|
};
|
|
|
|
|
2016-06-02 12:00:33 +03:00
|
|
|
/// Equivalent of a RefPtr<TextureSource>, that calls AddCompositableRef and
|
|
|
|
/// ReleaseCompositableRef in addition to the usual AddRef and Release.
|
|
|
|
///
|
|
|
|
/// The semantoics of these CompositableTextureRefs are important because they
|
|
|
|
/// are used both as a synchronization/safety mechanism, and as an optimization
|
|
|
|
/// mechanism. They are also tricky and subtle because we use them in a very
|
|
|
|
/// implicit way (assigning to a CompositableTextureRef is less visible than
|
|
|
|
/// explicitly calling a method or whatnot).
|
|
|
|
/// It is Therefore important to be careful about the way we use this tool.
|
|
|
|
///
|
|
|
|
/// CompositableTextureRef is a mechanism that lets us count how many compositables
|
|
|
|
/// are using a given texture (for TextureSource and TextureHost).
|
|
|
|
/// We use it to run specific code when a texture is not used anymore, and also
|
|
|
|
/// we trigger fast paths on some operations when we can see that the texture's
|
|
|
|
/// CompositableTextureRef counter is equal to 1 (the texture is not shared
|
|
|
|
/// between compositables).
|
|
|
|
/// This means that it is important to observe the following rules:
|
|
|
|
/// * CompositableHosts that receive UseTexture and similar messages *must* store
|
|
|
|
/// all of the TextureHosts they receive in CompositableTextureRef slots for as
|
|
|
|
/// long as they may be using them.
|
|
|
|
/// * CompositableHosts must store each texture in a *single* CompositableTextureRef
|
|
|
|
/// slot to ensure that the counter properly reflects how many compositables are
|
|
|
|
/// using the texture.
|
|
|
|
/// If a compositable needs to hold two references to a given texture (for example
|
|
|
|
/// to have a pointer to the current texture in a list of textures that may be
|
|
|
|
/// used), it can hold its extra references with RefPtr or whichever pointer type
|
|
|
|
/// makes sense.
|
2014-11-17 13:06:25 +03:00
|
|
|
template<typename T>
|
|
|
|
class CompositableTextureRef {
|
2014-10-16 21:08:32 +04:00
|
|
|
public:
|
2014-11-17 13:06:25 +03:00
|
|
|
CompositableTextureRef() {}
|
2014-10-16 21:08:32 +04:00
|
|
|
|
2014-12-16 06:41:21 +03:00
|
|
|
explicit CompositableTextureRef(const CompositableTextureRef& aOther)
|
|
|
|
{
|
|
|
|
*this = aOther;
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit CompositableTextureRef(T* aOther)
|
|
|
|
{
|
|
|
|
*this = aOther;
|
|
|
|
}
|
|
|
|
|
2014-11-17 13:06:25 +03:00
|
|
|
~CompositableTextureRef()
|
2014-10-16 21:08:32 +04:00
|
|
|
{
|
|
|
|
if (mRef) {
|
|
|
|
mRef->ReleaseCompositableRef();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-16 06:41:21 +03:00
|
|
|
CompositableTextureRef& operator=(const CompositableTextureRef& aOther)
|
|
|
|
{
|
|
|
|
if (aOther.get()) {
|
|
|
|
aOther->AddCompositableRef();
|
|
|
|
}
|
|
|
|
if (mRef) {
|
|
|
|
mRef->ReleaseCompositableRef();
|
|
|
|
}
|
|
|
|
mRef = aOther.get();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-11-17 13:06:25 +03:00
|
|
|
CompositableTextureRef& operator=(T* aOther)
|
2014-10-16 21:08:32 +04:00
|
|
|
{
|
|
|
|
if (aOther) {
|
|
|
|
aOther->AddCompositableRef();
|
|
|
|
}
|
|
|
|
if (mRef) {
|
|
|
|
mRef->ReleaseCompositableRef();
|
|
|
|
}
|
|
|
|
mRef = aOther;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-11-17 13:06:25 +03:00
|
|
|
T* get() const { return mRef; }
|
|
|
|
operator T*() const { return mRef; }
|
|
|
|
T* operator->() const { return mRef; }
|
|
|
|
T& operator*() const { return *mRef; }
|
2014-10-16 21:08:32 +04:00
|
|
|
|
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<T> mRef;
|
2013-07-30 13:59:51 +04:00
|
|
|
};
|
|
|
|
|
2014-11-17 13:06:25 +03:00
|
|
|
typedef CompositableTextureRef<TextureSource> CompositableTextureSourceRef;
|
|
|
|
typedef CompositableTextureRef<TextureHost> CompositableTextureHostRef;
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Interface for TextureSources that can be updated from a DataSourceSurface.
|
|
|
|
*
|
|
|
|
* All backend should implement at least one DataTextureSource.
|
|
|
|
*/
|
2014-10-07 17:58:59 +04:00
|
|
|
class DataTextureSource : public TextureSource
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DataTextureSource()
|
2016-02-25 16:15:34 +03:00
|
|
|
: mOwner(0)
|
|
|
|
, mUpdateSerial(0)
|
2013-07-30 13:59:51 +04:00
|
|
|
{}
|
|
|
|
|
2016-02-08 13:57:00 +03:00
|
|
|
virtual const char* Name() const override { return "DataTextureSource"; }
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual DataTextureSource* AsDataTextureSource() override { return this; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload a (portion of) surface to the TextureSource.
|
|
|
|
*
|
|
|
|
* The DataTextureSource doesn't own aSurface, although it owns and manage
|
|
|
|
* the device texture it uploads to internally.
|
|
|
|
*/
|
|
|
|
virtual bool Update(gfx::DataSourceSurface* aSurface,
|
|
|
|
nsIntRegion* aDestRegion = nullptr,
|
|
|
|
gfx::IntPoint* aSrcOffset = nullptr) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A facility to avoid reuploading when it is not necessary.
|
|
|
|
* The caller of Update can use GetUpdateSerial to see if the number has changed
|
|
|
|
* since last update, and call SetUpdateSerial after each successful update.
|
|
|
|
* The caller is responsible for managing the update serial except when the
|
|
|
|
* texture data is deallocated in which case the TextureSource should always
|
|
|
|
* reset the update serial to zero.
|
|
|
|
*/
|
|
|
|
uint32_t GetUpdateSerial() const { return mUpdateSerial; }
|
|
|
|
void SetUpdateSerial(uint32_t aValue) { mUpdateSerial = aValue; }
|
|
|
|
|
|
|
|
// By default at least set the update serial to zero.
|
|
|
|
// overloaded versions should do that too.
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateDeviceData() override
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
|
|
|
SetUpdateSerial(0);
|
|
|
|
}
|
|
|
|
|
2013-08-08 16:53:12 +04:00
|
|
|
#ifdef DEBUG
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Provide read access to the data as a DataSourceSurface.
|
|
|
|
*
|
|
|
|
* This is expected to be very slow and should be used for mostly debugging.
|
|
|
|
* XXX - implement everywhere and make it pure virtual.
|
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> ReadBack() { return nullptr; };
|
2013-08-08 16:53:12 +04:00
|
|
|
#endif
|
|
|
|
|
2016-02-25 16:15:34 +03:00
|
|
|
void SetOwner(TextureHost* aOwner)
|
|
|
|
{
|
|
|
|
auto newOwner = (uintptr_t)aOwner;
|
|
|
|
if (newOwner != mOwner) {
|
|
|
|
mOwner = newOwner;
|
|
|
|
SetUpdateSerial(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsOwnedBy(TextureHost* aOwner) const { return mOwner == (uintptr_t)aOwner; }
|
|
|
|
|
|
|
|
bool HasOwner() const { return !IsOwnedBy(nullptr); }
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
private:
|
2016-02-25 16:15:34 +03:00
|
|
|
// We store mOwner as an integer rather than as a pointer to make it clear
|
|
|
|
// it is not intended to be dereferenced.
|
|
|
|
uintptr_t mOwner;
|
2013-07-30 13:59:51 +04:00
|
|
|
uint32_t mUpdateSerial;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TextureHost is a thin abstraction over texture data that need to be shared
|
|
|
|
* between the content process and the compositor process. It is the
|
|
|
|
* compositor-side half of a TextureClient/TextureHost pair. A corresponding
|
|
|
|
* TextureClient lives on the content-side.
|
|
|
|
*
|
|
|
|
* TextureHost only knows how to deserialize or synchronize generic image data
|
|
|
|
* (SurfaceDescriptor) and provide access to one or more TextureSource objects
|
|
|
|
* (these provide the necessary APIs for compositor backends to composite the
|
|
|
|
* image).
|
|
|
|
*
|
|
|
|
* A TextureHost implementation corresponds to one SurfaceDescriptor type, as
|
|
|
|
* opposed to TextureSource that corresponds to device textures.
|
|
|
|
* This means that for YCbCr planes, even though they are represented as
|
|
|
|
* 3 textures internally (3 TextureSources), we use 1 TextureHost and not 3,
|
|
|
|
* because the 3 planes are stored in the same buffer of shared memory, before
|
|
|
|
* they are uploaded separately.
|
|
|
|
*
|
|
|
|
* There is always one and only one TextureHost per TextureClient, and the
|
|
|
|
* TextureClient/Host pair only owns one buffer of image data through its
|
|
|
|
* lifetime. This means that the lifetime of the underlying shared data
|
|
|
|
* matches the lifetime of the TextureClient/Host pair. It also means
|
|
|
|
* TextureClient/Host do not implement double buffering, which is the
|
|
|
|
* reponsibility of the compositable (which would use two Texture pairs).
|
|
|
|
*
|
|
|
|
* The Lock/Unlock mecanism here mirrors Lock/Unlock in TextureClient.
|
|
|
|
*
|
|
|
|
*/
|
2013-12-12 05:45:01 +04:00
|
|
|
class TextureHost
|
2013-12-12 05:45:11 +04:00
|
|
|
: public AtomicRefCountedWithFinalize<TextureHost>
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2013-12-12 05:45:01 +04:00
|
|
|
/**
|
|
|
|
* Called once, just before the destructor.
|
|
|
|
*
|
|
|
|
* Here goes the shut-down code that uses virtual methods.
|
|
|
|
* Must only be called by Release().
|
|
|
|
*/
|
|
|
|
void Finalize();
|
|
|
|
|
2013-12-12 05:45:11 +04:00
|
|
|
friend class AtomicRefCountedWithFinalize<TextureHost>;
|
2013-07-30 13:59:51 +04:00
|
|
|
public:
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit TextureHost(TextureFlags aFlags);
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
protected:
|
2013-09-13 06:39:26 +04:00
|
|
|
virtual ~TextureHost();
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Factory method.
|
|
|
|
*/
|
2015-10-06 09:39:00 +03:00
|
|
|
static already_AddRefed<TextureHost> Create(
|
|
|
|
const SurfaceDescriptor& aDesc,
|
|
|
|
ISurfaceAllocator* aDeallocator,
|
|
|
|
LayersBackend aBackend,
|
2017-04-20 04:24:13 +03:00
|
|
|
TextureFlags aFlags,
|
|
|
|
wr::MaybeExternalImageId& aExternalImageId);
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lock the texture host for compositing.
|
|
|
|
*/
|
|
|
|
virtual bool Lock() { return true; }
|
|
|
|
/**
|
2016-09-05 08:17:00 +03:00
|
|
|
* Unlock the texture host after compositing. Lock() and Unlock() should be
|
|
|
|
* called in pair.
|
2013-07-30 13:59:51 +04:00
|
|
|
*/
|
|
|
|
virtual void Unlock() {}
|
|
|
|
|
2016-09-05 08:17:00 +03:00
|
|
|
/**
|
|
|
|
* Lock the texture host for compositing without using compositor.
|
|
|
|
*/
|
|
|
|
virtual bool LockWithoutCompositor() { return true; }
|
|
|
|
/**
|
|
|
|
* Similar to Unlock(), but it should be called with LockWithoutCompositor().
|
|
|
|
*/
|
|
|
|
virtual void UnlockWithoutCompositor() {}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Note that the texture host format can be different from its corresponding
|
|
|
|
* texture source's. For example a ShmemTextureHost can have the ycbcr
|
|
|
|
* format and produce 3 "alpha" textures sources.
|
|
|
|
*/
|
|
|
|
virtual gfx::SurfaceFormat GetFormat() const = 0;
|
2016-02-23 05:26:27 +03:00
|
|
|
/**
|
|
|
|
* Return the format used for reading the texture.
|
|
|
|
* Apple's YCBCR_422 is R8G8B8X8.
|
|
|
|
*/
|
|
|
|
virtual gfx::SurfaceFormat GetReadFormat() const { return GetFormat(); }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2016-10-18 20:09:00 +03:00
|
|
|
virtual YUVColorSpace GetYUVColorSpace() const { return YUVColorSpace::UNKNOWN; }
|
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
/**
|
|
|
|
* Called during the transaction. The TextureSource may or may not be composited.
|
|
|
|
*
|
|
|
|
* Note that this is called outside of lock/unlock.
|
|
|
|
*/
|
|
|
|
virtual void PrepareTextureSource(CompositableTextureSourceRef& aTexture) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called at composition time, just before compositing the TextureSource composited.
|
|
|
|
*
|
|
|
|
* Note that this is called only withing lock/unlock.
|
|
|
|
*/
|
2015-03-27 13:16:34 +03:00
|
|
|
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) = 0;
|
2014-10-16 21:08:32 +04:00
|
|
|
|
2017-06-20 11:17:17 +03:00
|
|
|
/**
|
|
|
|
* Called when preparing the rendering pipeline for advanced-layers. This is
|
|
|
|
* a lockless version of BindTextureSource.
|
|
|
|
*/
|
|
|
|
virtual bool AcquireTextureSource(CompositableTextureSourceRef& aTexture) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
/**
|
|
|
|
* Called when another TextureHost will take over.
|
|
|
|
*/
|
2016-06-02 12:00:21 +03:00
|
|
|
virtual void UnbindTextureSource();
|
2014-10-16 21:08:32 +04:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Is called before compositing if the shared data has changed since last
|
|
|
|
* composition.
|
|
|
|
* This method should be overload in cases like when we need to do a texture
|
|
|
|
* upload for example.
|
|
|
|
*
|
|
|
|
* @param aRegion The region that has been changed, if nil, it means that the
|
|
|
|
* entire surface should be updated.
|
|
|
|
*/
|
2015-06-02 13:21:00 +03:00
|
|
|
void Updated(const nsIntRegion* aRegion = nullptr);
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
/**
|
2017-03-22 06:32:54 +03:00
|
|
|
* Sets this TextureHost's compositor. A TextureHost can change compositor
|
|
|
|
* on certain occasions, in particular if it belongs to an async Compositable.
|
2013-07-30 13:59:51 +04:00
|
|
|
* aCompositor can be null, in which case the TextureHost must cleanup all
|
2017-03-22 06:32:54 +03:00
|
|
|
* of its device textures.
|
|
|
|
*
|
|
|
|
* Setting mProvider from this callback implicitly causes the texture to
|
|
|
|
* be locked for an extra frame after being detached from a compositable.
|
2013-07-30 13:59:51 +04:00
|
|
|
*/
|
2017-03-22 06:32:54 +03:00
|
|
|
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) {}
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
/**
|
2013-08-08 16:53:12 +04:00
|
|
|
* Should be overridden in order to deallocate the data that is associated
|
2013-07-30 13:59:51 +04:00
|
|
|
* with the rendering backend, such as GL textures.
|
|
|
|
*/
|
|
|
|
virtual void DeallocateDeviceData() {}
|
|
|
|
|
|
|
|
/**
|
2013-08-08 16:53:12 +04:00
|
|
|
* Should be overridden in order to deallocate the data that is shared with
|
2013-07-30 13:59:51 +04:00
|
|
|
* the content side, such as shared memory.
|
|
|
|
*/
|
|
|
|
virtual void DeallocateSharedData() {}
|
|
|
|
|
2013-12-12 05:44:45 +04:00
|
|
|
/**
|
|
|
|
* Should be overridden in order to force the TextureHost to drop all references
|
|
|
|
* to it's shared data.
|
|
|
|
*
|
|
|
|
* This is important to ensure the correctness of the deallocation protocol.
|
|
|
|
*/
|
|
|
|
virtual void ForgetSharedData() {}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
virtual gfx::IntSize GetSize() const = 0;
|
|
|
|
|
2015-07-20 02:03:10 +03:00
|
|
|
/**
|
|
|
|
* Should be overridden if TextureHost supports crop rect.
|
|
|
|
*/
|
|
|
|
virtual void SetCropRect(nsIntRect aCropRect) {}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Debug facility.
|
2013-08-08 16:53:12 +04:00
|
|
|
* XXX - cool kids use Moz2D. See bug 882113.
|
2013-07-30 13:59:51 +04:00
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() = 0;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* XXX - Flags should only be set at creation time, this will be removed.
|
|
|
|
*/
|
|
|
|
void SetFlags(TextureFlags aFlags) { mFlags = aFlags; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XXX - Flags should only be set at creation time, this will be removed.
|
|
|
|
*/
|
|
|
|
void AddFlag(TextureFlags aFlag) { mFlags |= aFlag; }
|
|
|
|
|
|
|
|
TextureFlags GetFlags() { return mFlags; }
|
|
|
|
|
2013-12-12 05:44:44 +04:00
|
|
|
/**
|
|
|
|
* Allocate and deallocate a TextureParent actor.
|
|
|
|
*
|
|
|
|
* TextureParent< is an implementation detail of TextureHost that is not
|
|
|
|
* exposed to the rest of the code base. CreateIPDLActor and DestroyIPDLActor
|
|
|
|
* are for use with the managing IPDL protocols only (so that they can
|
|
|
|
* implement AllocPTextureParent and DeallocPTextureParent).
|
|
|
|
*/
|
2016-05-19 16:04:14 +03:00
|
|
|
static PTextureParent* CreateIPDLActor(HostIPCAllocator* aAllocator,
|
2014-01-22 02:06:18 +04:00
|
|
|
const SurfaceDescriptor& aSharedData,
|
2015-10-06 09:39:00 +03:00
|
|
|
LayersBackend aLayersBackend,
|
2016-06-15 14:28:10 +03:00
|
|
|
TextureFlags aFlags,
|
2017-04-20 04:24:13 +03:00
|
|
|
uint64_t aSerial,
|
|
|
|
const wr::MaybeExternalImageId& aExternalImageId);
|
2013-12-12 05:44:44 +04:00
|
|
|
static bool DestroyIPDLActor(PTextureParent* actor);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy the TextureChild/Parent pair.
|
|
|
|
*/
|
|
|
|
static bool SendDeleteIPDLActor(PTextureParent* actor);
|
|
|
|
|
2016-01-07 13:17:40 +03:00
|
|
|
static void ReceivedDestroy(PTextureParent* actor);
|
|
|
|
|
2013-12-12 05:44:44 +04:00
|
|
|
/**
|
|
|
|
* Get the TextureHost corresponding to the actor passed in parameter.
|
|
|
|
*/
|
|
|
|
static TextureHost* AsTextureHost(PTextureParent* actor);
|
|
|
|
|
2016-06-15 14:28:10 +03:00
|
|
|
static uint64_t GetTextureSerial(PTextureParent* actor);
|
|
|
|
|
2014-02-25 08:23:41 +04:00
|
|
|
/**
|
|
|
|
* Return a pointer to the IPDLActor.
|
|
|
|
*
|
|
|
|
* This is to be used with IPDL messages only. Do not store the returned
|
|
|
|
* pointer.
|
|
|
|
*/
|
|
|
|
PTextureParent* GetIPDLActor();
|
|
|
|
|
2013-09-27 13:48:42 +04:00
|
|
|
// If a texture host holds a reference to shmem, it should override this method
|
|
|
|
// to forget about the shmem _without_ releasing it.
|
2013-12-12 05:45:01 +04:00
|
|
|
virtual void OnShutdown() {}
|
2013-09-27 13:48:42 +04:00
|
|
|
|
2014-06-19 04:04:05 +04:00
|
|
|
// Forget buffer actor. Used only for hacky fix for bug 966446.
|
2014-02-07 05:32:29 +04:00
|
|
|
virtual void ForgetBufferActor() {}
|
|
|
|
|
2013-09-23 15:28:40 +04:00
|
|
|
virtual const char *Name() { return "TextureHost"; }
|
2014-06-20 02:36:25 +04:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-03-08 01:34:04 +04:00
|
|
|
/**
|
|
|
|
* Indicates whether the TextureHost implementation is backed by an
|
|
|
|
* in-memory buffer. The consequence of this is that locking the
|
|
|
|
* TextureHost does not contend with locking the texture on the client side.
|
|
|
|
*/
|
2016-02-25 16:15:58 +03:00
|
|
|
virtual bool HasIntermediateBuffer() const { return false; }
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2014-11-17 13:06:25 +03:00
|
|
|
void AddCompositableRef() { ++mCompositableCount; }
|
|
|
|
|
|
|
|
void ReleaseCompositableRef()
|
|
|
|
{
|
|
|
|
--mCompositableCount;
|
|
|
|
MOZ_ASSERT(mCompositableCount >= 0);
|
|
|
|
if (mCompositableCount == 0) {
|
|
|
|
UnbindTextureSource();
|
2016-06-15 14:28:10 +03:00
|
|
|
// Send mFwdTransactionId to client side if necessary.
|
|
|
|
NotifyNotUsed();
|
2014-11-17 13:06:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int NumCompositableRefs() const { return mCompositableCount; }
|
|
|
|
|
2016-06-15 14:28:10 +03:00
|
|
|
void SetLastFwdTransactionId(uint64_t aTransactionId);
|
|
|
|
|
2016-06-02 12:00:21 +03:00
|
|
|
void DeserializeReadLock(const ReadLockDescriptor& aDesc,
|
|
|
|
ISurfaceAllocator* aAllocator);
|
2017-02-27 06:12:12 +03:00
|
|
|
void SetReadLock(TextureReadLock* aReadLock);
|
2016-06-02 12:00:17 +03:00
|
|
|
|
|
|
|
TextureReadLock* GetReadLock() { return mReadLock; }
|
|
|
|
|
2016-07-09 04:59:59 +03:00
|
|
|
virtual BufferTextureHost* AsBufferTextureHost() { return nullptr; }
|
2017-03-31 17:29:14 +03:00
|
|
|
virtual MacIOSurfaceTextureHostOGL* AsMacIOSurfaceTextureHost() { return nullptr; }
|
2017-03-07 13:37:28 +03:00
|
|
|
virtual WebRenderTextureHost* AsWebRenderTextureHost() { return nullptr; }
|
|
|
|
|
2017-06-15 12:07:46 +03:00
|
|
|
// Create the corresponding RenderTextureHost type of this texture, and
|
|
|
|
// register the RenderTextureHost into render thread.
|
|
|
|
virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId)
|
|
|
|
{
|
2017-06-28 20:31:57 +03:00
|
|
|
MOZ_RELEASE_ASSERT(false, "No CreateRenderTexture() implementation for this TextureHost type.");
|
2017-06-15 12:07:46 +03:00
|
|
|
}
|
|
|
|
|
2017-06-07 18:44:04 +03:00
|
|
|
// Create all necessary image keys for this textureHost rendering.
|
|
|
|
// @param aImageKeys - [out] The set of ImageKeys used for this textureHost
|
|
|
|
// composing.
|
|
|
|
// @param aImageKeyAllocator - [in] The function which is used for creating
|
|
|
|
// the new ImageKey.
|
|
|
|
virtual void GetWRImageKeys(nsTArray<wr::ImageKey>& aImageKeys,
|
|
|
|
const std::function<wr::ImageKey()>& aImageKeyAllocator)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImageKeys.IsEmpty());
|
|
|
|
MOZ_ASSERT_UNREACHABLE("No GetWRImageKeys() implementation for this TextureHost type.");
|
|
|
|
}
|
|
|
|
|
2017-09-04 14:59:42 +03:00
|
|
|
// Add all necessary TextureHost informations to the resource update queue.
|
|
|
|
// Then, WR will use this informations to read from the TextureHost.
|
|
|
|
virtual void AddWRImage(wr::ResourceUpdateQueue& aResources,
|
2017-05-18 19:25:41 +03:00
|
|
|
Range<const wr::ImageKey>& aImageKeys,
|
2017-05-18 17:59:07 +03:00
|
|
|
const wr::ExternalImageId& aExtID)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT_UNREACHABLE("No AddWRImage() implementation for this TextureHost type.");
|
|
|
|
}
|
|
|
|
|
2017-06-07 18:44:04 +03:00
|
|
|
// Put all necessary WR commands into DisplayListBuilder for this textureHost rendering.
|
|
|
|
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-06-07 18:44:04 +03:00
|
|
|
wr::ImageRendering aFilter,
|
|
|
|
Range<const wr::ImageKey>& aKeys)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT_UNREACHABLE("No PushExternalImage() implementation for this TextureHost type.");
|
|
|
|
}
|
|
|
|
|
2017-07-04 23:50:40 +03:00
|
|
|
/**
|
|
|
|
* Some API's can use the cross-process IOSurface directly, such as OpenVR
|
|
|
|
*/
|
|
|
|
virtual MacIOSurface* GetMacIOSurface() { return nullptr; }
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
protected:
|
2016-06-02 12:00:33 +03:00
|
|
|
void ReadUnlock();
|
|
|
|
|
2014-11-13 18:53:49 +03:00
|
|
|
void RecycleTexture(TextureFlags aFlags);
|
|
|
|
|
2015-06-02 13:21:00 +03:00
|
|
|
virtual void UpdatedInternal(const nsIntRegion *Region) {}
|
|
|
|
|
2016-06-15 14:28:10 +03:00
|
|
|
/**
|
|
|
|
* Called when mCompositableCount becomes 0.
|
|
|
|
*/
|
2017-03-04 00:14:27 +03:00
|
|
|
virtual void NotifyNotUsed();
|
2016-06-15 14:28:10 +03:00
|
|
|
|
2016-06-21 19:06:34 +03:00
|
|
|
// for Compositor.
|
|
|
|
void CallNotifyNotUsed();
|
|
|
|
|
2014-02-25 08:23:41 +04:00
|
|
|
PTextureParent* mActor;
|
2017-03-22 06:32:54 +03:00
|
|
|
RefPtr<TextureSourceProvider> mProvider;
|
2016-06-02 12:00:17 +03:00
|
|
|
RefPtr<TextureReadLock> mReadLock;
|
2013-07-30 13:59:51 +04:00
|
|
|
TextureFlags mFlags;
|
2014-11-17 13:06:25 +03:00
|
|
|
int mCompositableCount;
|
2016-06-15 14:28:10 +03:00
|
|
|
uint64_t mFwdTransactionId;
|
2014-02-25 08:23:41 +04:00
|
|
|
|
2016-06-21 19:06:34 +03:00
|
|
|
friend class Compositor;
|
2014-02-25 08:23:41 +04:00
|
|
|
friend class TextureParent;
|
2016-06-15 14:28:10 +03:00
|
|
|
friend class TiledLayerBufferComposite;
|
2017-03-22 06:32:53 +03:00
|
|
|
friend class TextureSourceProvider;
|
2013-07-30 13:59:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TextureHost that wraps a random access buffer such as a Shmem or some raw
|
|
|
|
* memory.
|
|
|
|
*
|
|
|
|
* This TextureHost is backend-independent and the backend-specific bits are
|
|
|
|
* in the TextureSource.
|
|
|
|
* This class must be inherited to implement GetBuffer and DeallocSharedData
|
|
|
|
* (see ShmemTextureHost and MemoryTextureHost)
|
|
|
|
*
|
|
|
|
* Uploads happen when Lock is called.
|
|
|
|
*
|
|
|
|
* BufferTextureHost supports YCbCr and flavours of RGBA images (RGBX, A, etc.).
|
|
|
|
*/
|
|
|
|
class BufferTextureHost : public TextureHost
|
|
|
|
{
|
|
|
|
public:
|
2015-12-16 21:50:58 +03:00
|
|
|
BufferTextureHost(const BufferDescriptor& aDescriptor, TextureFlags aFlags);
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
~BufferTextureHost();
|
|
|
|
|
|
|
|
virtual uint8_t* GetBuffer() = 0;
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2014-02-21 01:04:11 +04:00
|
|
|
virtual size_t GetBufferSize() = 0;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Lock() override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Unlock() override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2016-02-25 16:15:34 +03:00
|
|
|
virtual void PrepareTextureSource(CompositableTextureSourceRef& aTexture) override;
|
|
|
|
|
2015-03-27 13:16:34 +03:00
|
|
|
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
|
2017-06-20 11:17:17 +03:00
|
|
|
virtual bool AcquireTextureSource(CompositableTextureSourceRef& aTexture) override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2016-06-02 12:00:29 +03:00
|
|
|
virtual void UnbindTextureSource() override;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateDeviceData() override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2017-03-22 06:32:54 +03:00
|
|
|
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
2016-06-02 12:00:21 +03:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Return the format that is exposed to the compositor when calling
|
2015-03-27 13:16:34 +03:00
|
|
|
* BindTextureSource.
|
2013-07-30 13:59:51 +04:00
|
|
|
*
|
|
|
|
* If the shared format is YCbCr and the compositor does not support it,
|
2014-01-10 23:06:16 +04:00
|
|
|
* GetFormat will be RGB32 (even though mFormat is SurfaceFormat::YUV).
|
2013-07-30 13:59:51 +04:00
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2016-10-18 20:09:00 +03:00
|
|
|
virtual YUVColorSpace GetYUVColorSpace() const override;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override { return mSize; }
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
|
2013-08-08 16:53:12 +04:00
|
|
|
|
2016-02-25 16:15:58 +03:00
|
|
|
virtual bool HasIntermediateBuffer() const override { return mHasIntermediateBuffer; }
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2016-07-09 04:59:59 +03:00
|
|
|
virtual BufferTextureHost* AsBufferTextureHost() override { return this; }
|
|
|
|
|
|
|
|
const BufferDescriptor& GetBufferDescriptor() const { return mDescriptor; }
|
|
|
|
|
2017-06-15 12:07:46 +03:00
|
|
|
virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId) override;
|
|
|
|
|
2017-06-07 18:44:04 +03:00
|
|
|
virtual void GetWRImageKeys(nsTArray<wr::ImageKey>& aImageKeys,
|
|
|
|
const std::function<wr::ImageKey()>& aImageKeyAllocator) override;
|
|
|
|
|
2017-09-04 14:59:42 +03:00
|
|
|
virtual void AddWRImage(wr::ResourceUpdateQueue& aResources,
|
2017-05-18 19:25:41 +03:00
|
|
|
Range<const wr::ImageKey>& aImageKeys,
|
2017-05-18 17:59:07 +03:00
|
|
|
const wr::ExternalImageId& aExtID) override;
|
|
|
|
|
2017-06-07 18:44:04 +03:00
|
|
|
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-06-07 18:44:04 +03:00
|
|
|
wr::ImageRendering aFilter,
|
|
|
|
Range<const wr::ImageKey>& aImageKeys) override;
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
protected:
|
|
|
|
bool Upload(nsIntRegion *aRegion = nullptr);
|
2017-06-20 11:17:17 +03:00
|
|
|
bool UploadIfNeeded();
|
|
|
|
bool MaybeUpload(nsIntRegion *aRegion);
|
2016-02-25 16:15:52 +03:00
|
|
|
bool EnsureWrappingTextureSource();
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-06-02 13:21:00 +03:00
|
|
|
virtual void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override;
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
BufferDescriptor mDescriptor;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Compositor> mCompositor;
|
|
|
|
RefPtr<DataTextureSource> mFirstSource;
|
2013-07-30 13:59:51 +04:00
|
|
|
nsIntRegion mMaybeUpdatedRegion;
|
|
|
|
gfx::IntSize mSize;
|
|
|
|
gfx::SurfaceFormat mFormat;
|
|
|
|
uint32_t mUpdateSerial;
|
|
|
|
bool mLocked;
|
2014-08-29 07:06:26 +04:00
|
|
|
bool mNeedsFullUpdate;
|
2016-02-25 16:15:58 +03:00
|
|
|
bool mHasIntermediateBuffer;
|
2016-07-09 04:59:59 +03:00
|
|
|
|
|
|
|
class DataTextureSourceYCbCrBasic;
|
2013-07-30 13:59:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TextureHost that wraps shared memory.
|
|
|
|
* the corresponding texture on the client side is ShmemTextureClient.
|
|
|
|
* This TextureHost is backend-independent.
|
|
|
|
*/
|
|
|
|
class ShmemTextureHost : public BufferTextureHost
|
|
|
|
{
|
|
|
|
public:
|
2013-12-12 05:44:47 +04:00
|
|
|
ShmemTextureHost(const mozilla::ipc::Shmem& aShmem,
|
2015-12-16 21:50:58 +03:00
|
|
|
const BufferDescriptor& aDesc,
|
2013-07-30 13:59:51 +04:00
|
|
|
ISurfaceAllocator* aDeallocator,
|
|
|
|
TextureFlags aFlags);
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
protected:
|
2013-07-30 13:59:51 +04:00
|
|
|
~ShmemTextureHost();
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateSharedData() override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ForgetSharedData() override;
|
2013-12-12 05:44:45 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint8_t* GetBuffer() override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual size_t GetBufferSize() override;
|
2014-02-21 01:04:11 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual const char *Name() override { return "ShmemTextureHost"; }
|
2013-09-23 15:28:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void OnShutdown() override;
|
2013-09-27 13:48:42 +04:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
protected:
|
2014-07-22 02:55:02 +04:00
|
|
|
UniquePtr<mozilla::ipc::Shmem> mShmem;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ISurfaceAllocator> mDeallocator;
|
2013-07-30 13:59:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TextureHost that wraps raw memory.
|
|
|
|
* The corresponding texture on the client side is MemoryTextureClient.
|
|
|
|
* Can obviously not be used in a cross process setup.
|
|
|
|
* This TextureHost is backend-independent.
|
|
|
|
*/
|
|
|
|
class MemoryTextureHost : public BufferTextureHost
|
|
|
|
{
|
|
|
|
public:
|
2013-12-12 05:44:47 +04:00
|
|
|
MemoryTextureHost(uint8_t* aBuffer,
|
2015-12-16 21:50:58 +03:00
|
|
|
const BufferDescriptor& aDesc,
|
2013-07-30 13:59:51 +04:00
|
|
|
TextureFlags aFlags);
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
protected:
|
2013-07-30 13:59:51 +04:00
|
|
|
~MemoryTextureHost();
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DeallocateSharedData() override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ForgetSharedData() override;
|
2013-12-12 05:44:45 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint8_t* GetBuffer() override;
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual size_t GetBufferSize() override;
|
2014-02-21 01:04:11 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual const char *Name() override { return "MemoryTextureHost"; }
|
2013-09-23 15:28:40 +04:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
protected:
|
|
|
|
uint8_t* mBuffer;
|
|
|
|
};
|
|
|
|
|
2013-12-19 20:20:51 +04:00
|
|
|
class MOZ_STACK_CLASS AutoLockTextureHost
|
|
|
|
{
|
|
|
|
public:
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit AutoLockTextureHost(TextureHost* aTexture)
|
2013-12-19 20:20:51 +04:00
|
|
|
: mTexture(aTexture)
|
|
|
|
{
|
2013-12-21 02:30:52 +04:00
|
|
|
mLocked = mTexture ? mTexture->Lock() : false;
|
2013-12-19 20:20:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
~AutoLockTextureHost()
|
|
|
|
{
|
2013-12-21 02:30:52 +04:00
|
|
|
if (mTexture && mLocked) {
|
2013-12-19 20:20:51 +04:00
|
|
|
mTexture->Unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-21 02:30:52 +04:00
|
|
|
bool Failed() { return mTexture && !mLocked; }
|
2013-12-19 20:20:51 +04:00
|
|
|
|
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TextureHost> mTexture;
|
2013-12-19 20:20:51 +04:00
|
|
|
bool mLocked;
|
|
|
|
};
|
|
|
|
|
2016-09-05 08:17:00 +03:00
|
|
|
class MOZ_STACK_CLASS AutoLockTextureHostWithoutCompositor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AutoLockTextureHostWithoutCompositor(TextureHost* aTexture)
|
|
|
|
: mTexture(aTexture)
|
|
|
|
{
|
|
|
|
mLocked = mTexture ? mTexture->LockWithoutCompositor() : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoLockTextureHostWithoutCompositor()
|
|
|
|
{
|
|
|
|
if (mTexture && mLocked) {
|
|
|
|
mTexture->UnlockWithoutCompositor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Failed() { return mTexture && !mLocked; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
RefPtr<TextureHost> mTexture;
|
|
|
|
bool mLocked;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* This can be used as an offscreen rendering target by the compositor, and
|
|
|
|
* subsequently can be used as a source by the compositor.
|
|
|
|
*/
|
2014-10-07 17:58:59 +04:00
|
|
|
class CompositingRenderTarget: public TextureSource
|
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
|
|
|
{
|
|
|
|
public:
|
2014-10-07 17:58:59 +04:00
|
|
|
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit CompositingRenderTarget(const gfx::IntPoint& aOrigin)
|
2014-11-04 01:27:32 +03:00
|
|
|
: mClearOnBind(false)
|
|
|
|
, mOrigin(aOrigin)
|
2015-05-19 20:51:26 +03:00
|
|
|
, mHasComplexProjection(false)
|
2013-11-07 13:53:08 +04:00
|
|
|
{}
|
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
|
|
|
virtual ~CompositingRenderTarget() {}
|
|
|
|
|
2016-02-08 13:57:00 +03:00
|
|
|
virtual const char* Name() const override { return "CompositingRenderTarget"; }
|
|
|
|
|
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
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<gfx::DataSourceSurface> Dump(Compositor* aCompositor) { return nullptr; }
|
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
|
2013-11-07 13:53:08 +04:00
|
|
|
|
2014-11-04 01:27:32 +03:00
|
|
|
/**
|
|
|
|
* Perform a clear when recycling a non opaque surface.
|
|
|
|
* The clear is deferred to when the render target is bound.
|
|
|
|
*/
|
|
|
|
void ClearOnBind() {
|
|
|
|
mClearOnBind = true;
|
|
|
|
}
|
|
|
|
|
2015-05-19 20:51:26 +03:00
|
|
|
const gfx::IntPoint& GetOrigin() const { return mOrigin; }
|
2014-11-04 01:27:32 +03:00
|
|
|
gfx::IntRect GetRect() { return gfx::IntRect(GetOrigin(), GetSize()); }
|
|
|
|
|
2015-05-19 20:51:26 +03:00
|
|
|
/**
|
|
|
|
* If a Projection matrix is set, then it is used for rendering to
|
|
|
|
* this render target instead of generating one. If no explicit
|
|
|
|
* projection is set, Compositors are expected to generate an
|
|
|
|
* orthogonal maaping that maps 0..1 to the full size of the render
|
|
|
|
* target.
|
|
|
|
*/
|
|
|
|
bool HasComplexProjection() const { return mHasComplexProjection; }
|
|
|
|
void ClearProjection() { mHasComplexProjection = false; }
|
|
|
|
void SetProjection(const gfx::Matrix4x4& aNewMatrix, bool aEnableDepthBuffer,
|
|
|
|
float aZNear, float aZFar)
|
|
|
|
{
|
|
|
|
mProjectionMatrix = aNewMatrix;
|
|
|
|
mEnableDepthBuffer = aEnableDepthBuffer;
|
|
|
|
mZNear = aZNear;
|
|
|
|
mZFar = aZFar;
|
|
|
|
mHasComplexProjection = true;
|
|
|
|
}
|
|
|
|
void GetProjection(gfx::Matrix4x4& aMatrix, bool& aEnableDepth, float& aZNear, float& aZFar)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mHasComplexProjection);
|
|
|
|
aMatrix = mProjectionMatrix;
|
|
|
|
aEnableDepth = mEnableDepthBuffer;
|
|
|
|
aZNear = mZNear;
|
|
|
|
aZFar = mZFar;
|
|
|
|
}
|
2014-11-04 01:27:32 +03:00
|
|
|
protected:
|
|
|
|
bool mClearOnBind;
|
2013-11-07 13:53:08 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
gfx::IntPoint mOrigin;
|
2015-05-19 20:51:26 +03:00
|
|
|
|
|
|
|
gfx::Matrix4x4 mProjectionMatrix;
|
|
|
|
float mZNear, mZFar;
|
|
|
|
bool mHasComplexProjection;
|
|
|
|
bool mEnableDepthBuffer;
|
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-07-30 13:59:51 +04:00
|
|
|
/**
|
|
|
|
* Creates a TextureHost that can be used with any of the existing backends
|
|
|
|
* Not all SurfaceDescriptor types are supported
|
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<TextureHost>
|
2013-12-12 05:44:47 +04:00
|
|
|
CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
|
2013-07-30 13:59:51 +04:00
|
|
|
ISurfaceAllocator* aDeallocator,
|
2017-03-07 13:37:28 +03:00
|
|
|
LayersBackend aBackend,
|
2013-07-30 13:59:51 +04:00
|
|
|
TextureFlags aFlags);
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2013-07-30 13:59:51 +04:00
|
|
|
|
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
|