2013-08-19 17:59:25 +04: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 GFXSHMCOWSURFACEWRAPPER
|
|
|
|
#define GFXSHMCOWSURFACEWRAPPER
|
|
|
|
|
|
|
|
#include "gfxReusableSurfaceWrapper.h"
|
2013-12-03 22:44:38 +04:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-08-19 17:59:25 +04:00
|
|
|
|
|
|
|
class gfxSharedImageSurface;
|
|
|
|
|
2013-10-08 03:15:59 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
|
|
|
}
|
|
|
|
namespace layers {
|
|
|
|
class ISurfaceAllocator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-19 17:59:25 +04:00
|
|
|
/**
|
|
|
|
* A cross-process capable implementation of gfxReusableSurfaceWrapper based
|
|
|
|
* on gfxSharedImageSurface.
|
|
|
|
*/
|
|
|
|
class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper {
|
|
|
|
public:
|
|
|
|
gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator,
|
|
|
|
gfxSharedImageSurface* aSurface);
|
2014-07-15 19:37:45 +04:00
|
|
|
protected:
|
2013-08-19 17:59:25 +04:00
|
|
|
~gfxReusableSharedImageSurfaceWrapper();
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
const unsigned char* GetReadOnlyData() const override;
|
|
|
|
gfxImageFormat Format() override;
|
|
|
|
gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) override;
|
|
|
|
void ReadLock() override;
|
|
|
|
void ReadUnlock() override;
|
2013-08-19 17:59:25 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
Type GetType() override
|
2013-08-19 17:59:27 +04:00
|
|
|
{
|
|
|
|
return TYPE_SHARED_IMAGE;
|
|
|
|
}
|
|
|
|
|
2013-08-19 17:59:25 +04:00
|
|
|
/**
|
|
|
|
* Returns the shared memory segment that backs the shared image surface.
|
|
|
|
*/
|
|
|
|
mozilla::ipc::Shmem& GetShmem();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a gfxReusableSurfaceWrapper from the shared memory segment of a
|
|
|
|
* gfxSharedImageSurface. A ReadLock must be held, which will be adopted by
|
|
|
|
* the returned gfxReusableSurfaceWrapper.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<gfxReusableSharedImageSurfaceWrapper>
|
|
|
|
Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem);
|
|
|
|
|
|
|
|
private:
|
2013-12-03 22:44:38 +04:00
|
|
|
mozilla::RefPtr<mozilla::layers::ISurfaceAllocator> mAllocator;
|
2013-08-19 17:59:25 +04:00
|
|
|
nsRefPtr<gfxSharedImageSurface> mSurface;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GFXSHMCOWSURFACEWRAPPER
|