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_
|
|
|
|
|
2013-08-11 16:17:23 -07:00
|
|
|
#include <stddef.h> // for size_t
|
|
|
|
#include <stdint.h> // for uint8_t
|
|
|
|
#include "ImageContainer.h" // for ISharedImage, Image, etc
|
2013-09-24 13:45:14 -07:00
|
|
|
#include "gfxTypes.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE
|
|
|
|
#include "mozilla/RefPtr.h" // for RefPtr
|
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
|
|
|
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
2012-12-12 14:47:28 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
|
|
|
}
|
2013-08-11 16:17:23 -07:00
|
|
|
|
2012-12-12 14:47:28 -08:00
|
|
|
namespace layers {
|
2013-08-11 16:17:23 -07:00
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
class BufferTextureClient;
|
|
|
|
class ImageClient;
|
2013-08-11 16:17:23 -07:00
|
|
|
class ISurfaceAllocator;
|
|
|
|
class TextureClient;
|
|
|
|
class SurfaceDescriptor;
|
2013-07-30 02:59:51 -07:00
|
|
|
|
|
|
|
already_AddRefed<Image> CreateSharedRGBImage(ImageContainer* aImageContainer,
|
|
|
|
nsIntSize aSize,
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxImageFormat aImageFormat);
|
2012-12-12 14:47:28 -08:00
|
|
|
|
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
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SharedRGBImage(ImageClient* aCompositable);
|
2014-07-15 08:37:45 -07:00
|
|
|
|
|
|
|
protected:
|
2013-07-30 02:59:51 -07:00
|
|
|
~SharedRGBImage();
|
|
|
|
|
2014-07-15 08:37:45 -07:00
|
|
|
public:
|
2013-08-06 09:47:44 -07:00
|
|
|
virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
|
|
|
|
|
2014-02-16 14:23:39 -08:00
|
|
|
virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
|
2013-07-30 02:59:51 -07:00
|
|
|
|
|
|
|
virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
|
|
|
|
|
2013-12-13 09:32:02 -08:00
|
|
|
gfx::IntSize GetSize();
|
2013-07-30 02:59:51 -07:00
|
|
|
|
|
|
|
size_t GetBufferSize();
|
|
|
|
|
2014-01-17 08:22:56 -08:00
|
|
|
TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
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
|