gecko-dev/gfx/layers/ipc/SharedRGBImage.h

79 строки
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
*/
2013-07-24 20:01:39 +04:00
class SharedRGBImage : public Image
{
typedef gfxASurface::gfxImageFormat gfxImageFormat;
public:
struct Header {
gfxImageFormat mImageFormat;
};
2013-07-24 20:01:39 +04:00
SharedRGBImage(ISurfaceAllocator *aAllocator);
~SharedRGBImage();
2013-07-24 20:01:39 +04:00
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.
2013-07-24 20:01:39 +04:00
* 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
2013-07-24 20:01:39 +04:00
* SharedRGBImage).
*/
bool DropToSurfaceDescriptor(SurfaceDescriptor& aResult);
/**
2013-07-24 20:01:39 +04:00
* Returns a SharedRGBImage* iff the descriptor was initialized with
* ToSurfaceDescriptor.
*/
2013-07-24 20:01:39 +04:00
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