2012-12-12 14:47:28 -08:00
|
|
|
/* 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 SHAREDRGBIMAGE_H_
|
|
|
|
#define SHAREDRGBIMAGE_H_
|
|
|
|
|
|
|
|
#include "ImageContainer.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 02:20:52 -07:00
|
|
|
#include "ISurfaceAllocator.h"
|
2012-12-12 14:47:28 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
|
|
|
}
|
|
|
|
namespace layers {
|
2013-07-30 02:59:51 -07:00
|
|
|
class BufferTextureClient;
|
|
|
|
class TextureClient;
|
|
|
|
class ImageClient;
|
|
|
|
|
|
|
|
already_AddRefed<Image> CreateSharedRGBImage(ImageContainer* aImageContainer,
|
|
|
|
nsIntSize aSize,
|
|
|
|
gfxASurface::gfxImageFormat aImageFormat);
|
2012-12-12 14:47:28 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores RGB data in shared memory
|
|
|
|
* It is assumed that the image width and stride are equal
|
|
|
|
*/
|
2013-07-30 02:59:51 -07:00
|
|
|
class DeprecatedSharedRGBImage : public Image,
|
|
|
|
public ISharedImage
|
2012-12-12 14:47:28 -08:00
|
|
|
{
|
2013-07-30 02:59:51 -07:00
|
|
|
friend already_AddRefed<Image> CreateSharedRGBImage(ImageContainer* aImageContainer,
|
|
|
|
nsIntSize aSize,
|
|
|
|
gfxASurface::gfxImageFormat aImageFormat);
|
2012-12-12 14:47:28 -08:00
|
|
|
public:
|
2013-07-30 02:59:51 -07:00
|
|
|
typedef gfxASurface::gfxImageFormat gfxImageFormat;
|
2012-12-12 14:47:28 -08:00
|
|
|
struct Header {
|
|
|
|
gfxImageFormat mImageFormat;
|
|
|
|
};
|
|
|
|
|
2013-07-24 09:08:35 -07:00
|
|
|
DeprecatedSharedRGBImage(ISurfaceAllocator *aAllocator);
|
|
|
|
~DeprecatedSharedRGBImage();
|
2012-12-12 14:47:28 -08:00
|
|
|
|
|
|
|
uint8_t *GetBuffer();
|
|
|
|
|
|
|
|
gfxIntSize GetSize();
|
|
|
|
size_t GetBufferSize();
|
|
|
|
|
|
|
|
static uint8_t BytesPerPixel(gfxImageFormat aImageFormat);
|
|
|
|
already_AddRefed<gfxASurface> GetAsSurface();
|
|
|
|
|
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 02:20:52 -07:00
|
|
|
/**
|
|
|
|
* Setup the Surface descriptor to contain this image's shmem, while keeping
|
|
|
|
* ownership of the shmem.
|
2013-07-24 09:08:35 -07:00
|
|
|
* if the operation succeeds, return true and AddRef this DeprecatedSharedRGBImage.
|
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 02:20:52 -07:00
|
|
|
*/
|
|
|
|
bool ToSurfaceDescriptor(SurfaceDescriptor& aResult);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup the Surface descriptor to contain this image's shmem, and loose
|
|
|
|
* ownership of the shmem.
|
|
|
|
* if the operation succeeds, return true (and does _not_ AddRef this
|
2013-07-24 09:08:35 -07:00
|
|
|
* DeprecatedSharedRGBImage).
|
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 02:20:52 -07:00
|
|
|
*/
|
|
|
|
bool DropToSurfaceDescriptor(SurfaceDescriptor& aResult);
|
|
|
|
|
|
|
|
/**
|
2013-07-24 09:08:35 -07:00
|
|
|
* Returns a DeprecatedSharedRGBImage* iff the descriptor was initialized with
|
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 02:20:52 -07:00
|
|
|
* ToSurfaceDescriptor.
|
|
|
|
*/
|
2013-07-24 09:08:35 -07:00
|
|
|
static DeprecatedSharedRGBImage* FromSurfaceDescriptor(const SurfaceDescriptor& aDescriptor);
|
2012-12-12 14:47:28 -08:00
|
|
|
|
|
|
|
bool AllocateBuffer(nsIntSize aSize, gfxImageFormat aImageFormat);
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
TextureClient* GetTextureClient() MOZ_OVERRIDE { return nullptr; }
|
|
|
|
|
|
|
|
protected:
|
2012-12-12 14:47:28 -08:00
|
|
|
gfxIntSize mSize;
|
|
|
|
gfxImageFormat mImageFormat;
|
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 02:20:52 -07:00
|
|
|
ISurfaceAllocator* mSurfaceAllocator;
|
2012-12-12 14:47:28 -08:00
|
|
|
|
|
|
|
bool mAllocated;
|
|
|
|
ipc::Shmem *mShmem;
|
|
|
|
};
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
/**
|
|
|
|
* Stores RGB data in shared memory
|
|
|
|
* It is assumed that the image width and stride are equal
|
|
|
|
*/
|
|
|
|
class SharedRGBImage : public Image
|
|
|
|
, public ISharedImage
|
|
|
|
{
|
|
|
|
typedef gfxASurface::gfxImageFormat gfxImageFormat;
|
|
|
|
public:
|
|
|
|
SharedRGBImage(ImageClient* aCompositable);
|
|
|
|
~SharedRGBImage();
|
|
|
|
|
|
|
|
virtual TextureClient* GetTextureClient() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
gfxIntSize GetSize();
|
|
|
|
|
|
|
|
size_t GetBufferSize();
|
|
|
|
|
|
|
|
already_AddRefed<gfxASurface> GetAsSurface();
|
|
|
|
|
|
|
|
bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
|
|
|
|
private:
|
|
|
|
gfx::IntSize mSize;
|
|
|
|
RefPtr<ImageClient> mCompositable;
|
|
|
|
RefPtr<BufferTextureClient> mTextureClient;
|
|
|
|
};
|
|
|
|
|
2012-12-12 14:47:28 -08:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|