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 09:20:52 +00: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 GFX_LAYERS_ISURFACEDEALLOCATOR
|
|
|
|
#define GFX_LAYERS_ISURFACEDEALLOCATOR
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
#include <stddef.h> // for size_t
|
|
|
|
#include <stdint.h> // for uint32_t
|
2013-09-24 20:45:14 +00:00
|
|
|
#include "gfxTypes.h"
|
2013-12-20 16:46:29 +00:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-12-08 06:09:10 +00:00
|
|
|
#include "nsIMemoryReporter.h" // for nsIMemoryReporter
|
2013-11-14 21:54:25 +00:00
|
|
|
#include "mozilla/Atomics.h" // for Atomic
|
2014-03-13 05:17:05 +00:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for ShmemSection
|
2014-03-07 21:34:04 +00:00
|
|
|
#include "LayersTypes.h"
|
2016-06-23 07:47:25 +00:00
|
|
|
#include "gfxPrefs.h"
|
2014-03-19 04:02:42 +00:00
|
|
|
#include "mozilla/layers/AtomicRefCountedWithFinalize.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 09:20:52 +00:00
|
|
|
|
2013-05-04 02:57:18 +00:00
|
|
|
/*
|
|
|
|
* FIXME [bjacob] *** PURE CRAZYNESS WARNING ***
|
2016-03-17 13:58:58 +00:00
|
|
|
* (I think that this doesn't apply anymore.)
|
2013-05-04 02:57:18 +00:00
|
|
|
*
|
|
|
|
* This #define is actually needed here, because subclasses of ISurfaceAllocator,
|
|
|
|
* namely ShadowLayerForwarder, will or will not override AllocGrallocBuffer
|
|
|
|
* depending on whether MOZ_HAVE_SURFACEDESCRIPTORGRALLOC is defined.
|
|
|
|
*/
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
#define MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
#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 09:20:52 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace ipc
|
2014-04-07 01:32:48 +00:00
|
|
|
namespace gfx {
|
|
|
|
class DataSourceSurface;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace gfx
|
2013-08-11 23:17:23 +00: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 09:20:52 +00:00
|
|
|
namespace layers {
|
|
|
|
|
2016-02-25 13:15:52 +00:00
|
|
|
class CompositableForwarder;
|
2016-03-17 13:58:58 +00:00
|
|
|
class ShadowLayerForwarder;
|
2016-05-12 22:00:04 +00:00
|
|
|
class TextureForwarder;
|
2016-03-17 13:58:58 +00:00
|
|
|
|
|
|
|
class ShmemAllocator;
|
|
|
|
class ShmemSectionAllocator;
|
|
|
|
class LegacySurfaceDescriptorAllocator;
|
|
|
|
class ClientIPCAllocator;
|
2016-05-19 13:04:14 +00: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 09:20:52 +00:00
|
|
|
|
|
|
|
enum BufferCapabilities {
|
|
|
|
DEFAULT_BUFFER_CAPS = 0,
|
|
|
|
/**
|
2014-06-17 17:35:51 +00:00
|
|
|
* The allocated buffer must be efficiently mappable as a DataSourceSurface.
|
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 09:20:52 +00:00
|
|
|
*/
|
2013-05-27 14:12:13 +00:00
|
|
|
MAP_AS_IMAGE_SURFACE = 1 << 0,
|
|
|
|
/**
|
|
|
|
* The allocated buffer will be used for GL rendering only
|
|
|
|
*/
|
|
|
|
USING_GL_RENDERING_ONLY = 1 << 1
|
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 09:20:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SurfaceDescriptor;
|
|
|
|
|
|
|
|
|
2013-11-18 02:06:21 +00:00
|
|
|
mozilla::ipc::SharedMemory::SharedMemoryType OptimalShmemType();
|
2014-04-07 01:32:48 +00: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 09:20:52 +00:00
|
|
|
/**
|
|
|
|
* An interface used to create and destroy surfaces that are shared with the
|
|
|
|
* Compositor process (using shmem, or gralloc, or other platform specific memory)
|
|
|
|
*
|
|
|
|
* Most of the methods here correspond to methods that are implemented by IPDL
|
|
|
|
* actors without a common polymorphic interface.
|
|
|
|
* These methods should be only called in the ipdl implementor's thread, unless
|
|
|
|
* specified otherwise in the implementing class.
|
|
|
|
*/
|
2014-03-19 04:02:42 +00:00
|
|
|
class ISurfaceAllocator : public AtomicRefCountedWithFinalize<ISurfaceAllocator>
|
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 09:20:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-02-21 02:33:49 +00:00
|
|
|
MOZ_DECLARE_REFCOUNTED_TYPENAME(ISurfaceAllocator)
|
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 09:20:52 +00:00
|
|
|
|
2016-06-16 22:27:08 +00:00
|
|
|
ISurfaceAllocator(const char* aName) : AtomicRefCountedWithFinalize(aName) {}
|
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
// down-casting
|
2014-03-19 04:02:42 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual ShmemAllocator* AsShmemAllocator() { 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 09:20:52 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual ShmemSectionAllocator* AsShmemSectionAllocator() { return nullptr; }
|
2014-03-13 05:17:05 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual CompositableForwarder* AsCompositableForwarder() { return nullptr; }
|
2014-03-13 05:17:05 +00:00
|
|
|
|
2016-05-12 22:00:04 +00:00
|
|
|
virtual TextureForwarder* AsTextureForwarder() { return nullptr; }
|
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual ShadowLayerForwarder* AsLayerForwarder() { return nullptr; }
|
2014-03-13 05:17:05 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual ClientIPCAllocator* AsClientAllocator() { 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 09:20:52 +00:00
|
|
|
|
2016-05-19 13:04:14 +00:00
|
|
|
virtual HostIPCAllocator* AsHostIPCAllocator() { return nullptr; }
|
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual LegacySurfaceDescriptorAllocator*
|
|
|
|
AsLegacySurfaceDescriptorAllocator() { 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 09:20:52 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
// ipc info
|
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 09:20:52 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual bool IPCOpen() const { return true; }
|
2014-03-12 12:16:37 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual bool IsSameProcess() const = 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 09:20:52 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual bool UsesImageBridge() const { return false; }
|
2014-05-01 01:52:00 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
protected:
|
|
|
|
void Finalize() {}
|
2014-03-26 01:28:47 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual ~ISurfaceAllocator() {}
|
2014-07-19 12:33:12 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
friend class AtomicRefCountedWithFinalize<ISurfaceAllocator>;
|
|
|
|
};
|
2013-11-27 15:18:38 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
/// Methods that are specific to the client/child side.
|
|
|
|
class ClientIPCAllocator : public ISurfaceAllocator
|
|
|
|
{
|
|
|
|
public:
|
2016-06-16 22:27:08 +00:00
|
|
|
ClientIPCAllocator(const char* aName) : ISurfaceAllocator(aName) {}
|
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual ClientIPCAllocator* AsClientAllocator() override { return this; }
|
2014-07-15 13:22:35 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual MessageLoop * GetMessageLoop() const = 0;
|
2014-06-27 13:26:51 +00:00
|
|
|
|
2016-06-23 07:47:25 +00:00
|
|
|
virtual int32_t GetMaxTextureSize() const { return gfxPrefs::MaxTextureSize(); }
|
2016-06-15 11:28:10 +00:00
|
|
|
|
|
|
|
virtual void CancelWaitForRecycle(uint64_t aTextureId) = 0;
|
2016-03-17 13:58:58 +00:00
|
|
|
};
|
2013-09-27 09:48:42 +00:00
|
|
|
|
2016-05-19 13:04:14 +00:00
|
|
|
/// Methods that are specific to the host/parent side.
|
|
|
|
class HostIPCAllocator : public ISurfaceAllocator
|
|
|
|
{
|
|
|
|
public:
|
2016-06-16 22:27:08 +00:00
|
|
|
HostIPCAllocator(const char* aName) : ISurfaceAllocator(aName) {}
|
|
|
|
|
2016-05-19 13:04:14 +00:00
|
|
|
virtual HostIPCAllocator* AsHostIPCAllocator() override { return this; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get child side's process Id.
|
|
|
|
*/
|
|
|
|
virtual base::ProcessId GetChildProcessId() = 0;
|
2016-06-15 11:28:10 +00:00
|
|
|
|
|
|
|
virtual void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) = 0;
|
|
|
|
|
|
|
|
virtual void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) = 0;
|
|
|
|
|
|
|
|
void SendFenceHandleIfPresent(PTextureParent* aTexture);
|
|
|
|
|
|
|
|
virtual void SendPendingAsyncMessages();
|
|
|
|
|
|
|
|
virtual void SetAboutToSendAsyncMessages()
|
|
|
|
{
|
|
|
|
mAboutToSendAsyncMessages = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsAboutToSendAsyncMessages()
|
|
|
|
{
|
|
|
|
return mAboutToSendAsyncMessages;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::vector<AsyncParentMessageData> mPendingAsyncMessage;
|
|
|
|
bool mAboutToSendAsyncMessages = false;
|
2016-05-19 13:04:14 +00:00
|
|
|
};
|
|
|
|
|
2016-06-15 11:28:10 +00:00
|
|
|
/// Specific to the CompositorBridgeParent/CrossProcessCompositorBridgeParent.
|
|
|
|
class CompositorBridgeParentIPCAllocator : public HostIPCAllocator
|
|
|
|
{
|
|
|
|
public:
|
2016-06-16 22:27:08 +00:00
|
|
|
CompositorBridgeParentIPCAllocator(const char* aName) : HostIPCAllocator(aName) {}
|
2016-06-15 11:28:10 +00:00
|
|
|
virtual void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) override;
|
|
|
|
};
|
2016-05-19 13:04:14 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
/// An allocator can provide shared memory.
|
|
|
|
///
|
|
|
|
/// The allocated shmems can be deallocated on either process, as long as they
|
|
|
|
/// belong to the same channel.
|
|
|
|
class ShmemAllocator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool AllocShmem(size_t aSize,
|
|
|
|
mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
|
|
|
|
mozilla::ipc::Shmem* aShmem) = 0;
|
|
|
|
virtual bool AllocUnsafeShmem(size_t aSize,
|
|
|
|
mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
|
|
|
|
mozilla::ipc::Shmem* aShmem) = 0;
|
|
|
|
virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) = 0;
|
|
|
|
};
|
2014-04-03 06:04:04 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
/// An allocator that can group allocations in bigger chunks of shared memory.
|
|
|
|
///
|
|
|
|
/// The allocated shmem sections can only be deallocated by the same allocator
|
|
|
|
/// instance (and only in the child process).
|
|
|
|
class ShmemSectionAllocator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool AllocShmemSection(uint32_t aSize, ShmemSection* aShmemSection) = 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 09:20:52 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual void DeallocShmemSection(ShmemSection& aShmemSection) = 0;
|
2014-03-13 05:17:05 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual void MemoryPressure() {}
|
|
|
|
};
|
2014-03-13 05:17:05 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
/// Some old stuff that's still around and used for screenshots.
|
|
|
|
///
|
|
|
|
/// New code should not need this (see TextureClient).
|
|
|
|
class LegacySurfaceDescriptorAllocator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool AllocSurfaceDescriptor(const gfx::IntSize& aSize,
|
|
|
|
gfxContentType aContent,
|
|
|
|
SurfaceDescriptor* aBuffer) = 0;
|
2013-11-27 15:19:34 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual bool AllocSurfaceDescriptorWithCaps(const gfx::IntSize& aSize,
|
|
|
|
gfxContentType aContent,
|
|
|
|
uint32_t aCaps,
|
|
|
|
SurfaceDescriptor* aBuffer) = 0;
|
2014-06-27 13:26:51 +00:00
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
virtual void DestroySurfaceDescriptor(SurfaceDescriptor* aSurface) = 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 09:20:52 +00:00
|
|
|
};
|
|
|
|
|
2016-03-17 13:58:58 +00:00
|
|
|
already_AddRefed<gfx::DrawTarget>
|
|
|
|
GetDrawTargetForDescriptor(const SurfaceDescriptor& aDescriptor, gfx::BackendType aBackend);
|
|
|
|
|
|
|
|
already_AddRefed<gfx::DataSourceSurface>
|
|
|
|
GetSurfaceForDescriptor(const SurfaceDescriptor& aDescriptor);
|
|
|
|
|
|
|
|
uint8_t*
|
|
|
|
GetAddressFromDescriptor(const SurfaceDescriptor& aDescriptor);
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class GfxMemoryImageReporter final : public nsIMemoryReporter
|
2013-11-14 21:54:25 +00:00
|
|
|
{
|
2014-06-23 18:49:07 +00:00
|
|
|
~GfxMemoryImageReporter() {}
|
|
|
|
|
2013-11-14 21:54:25 +00:00
|
|
|
public:
|
2013-12-08 06:09:10 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2013-11-14 21:54:25 +00:00
|
|
|
GfxMemoryImageReporter()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
// There must be only one instance of this class, due to |sAmount|
|
|
|
|
// being static.
|
|
|
|
static bool hasRun = false;
|
|
|
|
MOZ_ASSERT(!hasRun);
|
|
|
|
hasRun = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-12-08 06:09:10 +00:00
|
|
|
MOZ_DEFINE_MALLOC_SIZE_OF_ON_ALLOC(MallocSizeOfOnAlloc)
|
|
|
|
MOZ_DEFINE_MALLOC_SIZE_OF_ON_FREE(MallocSizeOfOnFree)
|
|
|
|
|
2013-11-14 21:54:25 +00:00
|
|
|
static void DidAlloc(void* aPointer)
|
|
|
|
{
|
|
|
|
sAmount += MallocSizeOfOnAlloc(aPointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WillFree(void* aPointer)
|
|
|
|
{
|
|
|
|
sAmount -= MallocSizeOfOnFree(aPointer);
|
|
|
|
}
|
|
|
|
|
2013-12-08 06:09:10 +00:00
|
|
|
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsISupports* aData, bool aAnonymize) override
|
2013-12-08 06:09:10 +00:00
|
|
|
{
|
|
|
|
return MOZ_COLLECT_REPORT(
|
|
|
|
"explicit/gfx/heap-textures", KIND_HEAP, UNITS_BYTES, sAmount,
|
|
|
|
"Heap memory shared between threads by texture clients and hosts.");
|
|
|
|
}
|
2013-11-14 21:54:25 +00:00
|
|
|
|
2013-12-08 06:09:10 +00:00
|
|
|
private:
|
2016-01-06 02:26:17 +00:00
|
|
|
// Typically we use |size_t| in memory reporters, but in the past this
|
|
|
|
// variable has sometimes gone negative due to missing DidAlloc() calls.
|
|
|
|
// Therefore, we use a signed type so that any such negative values show up
|
|
|
|
// as negative in about:memory, rather than as enormous positive numbers.
|
|
|
|
static mozilla::Atomic<ptrdiff_t> sAmount;
|
2013-11-14 21:54:25 +00:00
|
|
|
};
|
|
|
|
|
2016-05-12 22:00:04 +00:00
|
|
|
/// A simple shmem section allocator that can only allocate small
|
|
|
|
/// fixed size elements (only intended to be used to store tile
|
|
|
|
/// copy-on-write locks for now).
|
|
|
|
class FixedSizeSmallShmemSectionAllocator final : public ShmemSectionAllocator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum AllocationStatus
|
|
|
|
{
|
|
|
|
STATUS_ALLOCATED,
|
|
|
|
STATUS_FREED
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ShmemSectionHeapHeader
|
|
|
|
{
|
|
|
|
Atomic<uint32_t> mTotalBlocks;
|
|
|
|
Atomic<uint32_t> mAllocatedBlocks;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ShmemSectionHeapAllocation
|
|
|
|
{
|
|
|
|
Atomic<uint32_t> mStatus;
|
|
|
|
uint32_t mSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit FixedSizeSmallShmemSectionAllocator(ClientIPCAllocator* aShmProvider);
|
|
|
|
|
|
|
|
~FixedSizeSmallShmemSectionAllocator();
|
|
|
|
|
|
|
|
virtual bool AllocShmemSection(uint32_t aSize, ShmemSection* aShmemSection) override;
|
|
|
|
|
|
|
|
virtual void DeallocShmemSection(ShmemSection& aShmemSection) override;
|
|
|
|
|
|
|
|
virtual void MemoryPressure() override { ShrinkShmemSectionHeap(); }
|
|
|
|
|
|
|
|
// can be called on the compositor process.
|
|
|
|
static void FreeShmemSection(ShmemSection& aShmemSection);
|
|
|
|
|
|
|
|
void ShrinkShmemSectionHeap();
|
|
|
|
|
|
|
|
ShmemAllocator* GetShmAllocator() { return mShmProvider->AsShmemAllocator(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* In order to avoid shutdown crashes, we need to test for mShmProvider->AsShmemAllocator()
|
|
|
|
* here. Basically, there's a case where we have the following class hierarchy:
|
|
|
|
*
|
|
|
|
* ClientIPCAllocator -> TextureForwarder -> CompositableForwarder -> ShadowLayerForwarder
|
|
|
|
*
|
|
|
|
* In ShadowLayerForwarder's dtor, we tear down the actor and close the IPC channel.
|
|
|
|
* In TextureForwarder's dtor, we destroy the FixedSizeSmallShmemAllocator and that in turn calls
|
|
|
|
* ClientIPCAllocator::IPCOpen() to determine whether we can dealloc some shmem regions.
|
|
|
|
*
|
|
|
|
* This does not work. In the above class diagram, as the ShadowLayerForwarder's dtor has run
|
|
|
|
* its course, the ClientIPCAllocator object we're holding on to is now just a plain
|
|
|
|
* ClientIPCAllocator and so we call ClientIPCAllocator's IPCOpen() which unconditionally
|
|
|
|
* returns true. We therefore have to rely on AsShmemAllocator() to determine whether we can
|
|
|
|
* do these deallocs as ClientIPCAllocator::AsShmemAllocator() returns nullptr.
|
|
|
|
*
|
|
|
|
* Ideally, we should move a lot of this destruction work into non-destructor Destroy() methods
|
|
|
|
* which do cleanup before we destroy the objects.
|
|
|
|
*/
|
|
|
|
bool IPCOpen() const { return mShmProvider->AsShmemAllocator() && mShmProvider->IPCOpen(); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::vector<mozilla::ipc::Shmem> mUsedShmems;
|
|
|
|
ClientIPCAllocator* mShmProvider;
|
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
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 09:20:52 +00:00
|
|
|
|
|
|
|
#endif
|