michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef SHAREDRGBIMAGE_H_ michael@0: #define SHAREDRGBIMAGE_H_ michael@0: michael@0: #include // for size_t michael@0: #include // for uint8_t michael@0: #include "ImageContainer.h" // for ISharedImage, Image, etc michael@0: #include "gfxTypes.h" michael@0: #include "mozilla/Attributes.h" // for MOZ_OVERRIDE michael@0: #include "mozilla/RefPtr.h" // for RefPtr michael@0: #include "mozilla/gfx/Point.h" // for IntSize michael@0: #include "mozilla/gfx/Types.h" // for SurfaceFormat michael@0: #include "nsCOMPtr.h" // for already_AddRefed michael@0: michael@0: namespace mozilla { michael@0: namespace ipc { michael@0: class Shmem; michael@0: } michael@0: michael@0: namespace layers { michael@0: michael@0: class BufferTextureClient; michael@0: class ImageClient; michael@0: class ISurfaceAllocator; michael@0: class TextureClient; michael@0: class SurfaceDescriptor; michael@0: michael@0: already_AddRefed CreateSharedRGBImage(ImageContainer* aImageContainer, michael@0: nsIntSize aSize, michael@0: gfxImageFormat aImageFormat); michael@0: michael@0: /** michael@0: * Stores RGB data in shared memory michael@0: * It is assumed that the image width and stride are equal michael@0: */ michael@0: class SharedRGBImage : public Image michael@0: , public ISharedImage michael@0: { michael@0: public: michael@0: SharedRGBImage(ImageClient* aCompositable); michael@0: ~SharedRGBImage(); michael@0: michael@0: virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; } michael@0: michael@0: virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE; michael@0: michael@0: virtual uint8_t* GetBuffer() MOZ_OVERRIDE; michael@0: michael@0: gfx::IntSize GetSize(); michael@0: michael@0: size_t GetBufferSize(); michael@0: michael@0: TemporaryRef GetAsSourceSurface(); michael@0: michael@0: bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat); michael@0: private: michael@0: gfx::IntSize mSize; michael@0: RefPtr mCompositable; michael@0: RefPtr mTextureClient; michael@0: }; michael@0: michael@0: } // namespace layers michael@0: } // namespace mozilla michael@0: michael@0: #endif