gecko/gfx/layers/ipc/SharedRGBImage.h
Bas Schouten 341383c413 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

79 lines
2.1 KiB
C++

/* 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"
#include "ISurfaceAllocator.h"
namespace mozilla {
namespace ipc {
class Shmem;
}
namespace layers {
/**
* Stores RGB data in shared memory
* It is assumed that the image width and stride are equal
*/
class SharedRGBImage : public Image
{
typedef gfxASurface::gfxImageFormat gfxImageFormat;
public:
struct Header {
gfxImageFormat mImageFormat;
};
SharedRGBImage(ISurfaceAllocator *aAllocator);
~SharedRGBImage();
static already_AddRefed<SharedRGBImage> Create(ImageContainer* aImageContainer,
nsIntSize aSize,
gfxImageFormat aImageFormat);
uint8_t *GetBuffer();
gfxIntSize GetSize();
size_t GetBufferSize();
static uint8_t BytesPerPixel(gfxImageFormat aImageFormat);
already_AddRefed<gfxASurface> GetAsSurface();
/**
* Setup the Surface descriptor to contain this image's shmem, while keeping
* ownership of the shmem.
* if the operation succeeds, return true and AddRef this SharedRGBImage.
*/
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
* SharedRGBImage).
*/
bool DropToSurfaceDescriptor(SurfaceDescriptor& aResult);
/**
* Returns a SharedRGBImage* iff the descriptor was initialized with
* ToSurfaceDescriptor.
*/
static SharedRGBImage* FromSurfaceDescriptor(const SurfaceDescriptor& aDescriptor);
private:
bool AllocateBuffer(nsIntSize aSize, gfxImageFormat aImageFormat);
gfxIntSize mSize;
gfxImageFormat mImageFormat;
ISurfaceAllocator* mSurfaceAllocator;
bool mAllocated;
ipc::Shmem *mShmem;
};
} // namespace layers
} // namespace mozilla
#endif