gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef GFXSHMCOWSURFACEWRAPPER
     6 #define GFXSHMCOWSURFACEWRAPPER
     8 #include "gfxReusableSurfaceWrapper.h"
     9 #include "mozilla/RefPtr.h"
    11 class gfxSharedImageSurface;
    13 namespace mozilla {
    14 namespace ipc {
    15 class Shmem;
    16 }
    17 namespace layers {
    18 class ISurfaceAllocator;
    19 }
    20 }
    22 /**
    23  * A cross-process capable implementation of gfxReusableSurfaceWrapper based
    24  * on gfxSharedImageSurface.
    25  */
    26 class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper {
    27 public:
    28   gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator,
    29                                        gfxSharedImageSurface* aSurface);
    30   ~gfxReusableSharedImageSurfaceWrapper();
    32   const unsigned char* GetReadOnlyData() const MOZ_OVERRIDE;
    33   gfxImageFormat Format() MOZ_OVERRIDE;
    34   gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) MOZ_OVERRIDE;
    35   void ReadLock() MOZ_OVERRIDE;
    36   void ReadUnlock() MOZ_OVERRIDE;
    38   Type GetType()
    39   {
    40     return TYPE_SHARED_IMAGE;
    41   }
    43   /**
    44    * Returns the shared memory segment that backs the shared image surface.
    45    */
    46   mozilla::ipc::Shmem& GetShmem();
    48   /**
    49    * Create a gfxReusableSurfaceWrapper from the shared memory segment of a
    50    * gfxSharedImageSurface. A ReadLock must be held, which will be adopted by
    51    * the returned gfxReusableSurfaceWrapper.
    52    */
    53   static already_AddRefed<gfxReusableSharedImageSurfaceWrapper>
    54   Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::ipc::Shmem& aShmem);
    56 private:
    57   mozilla::RefPtr<mozilla::layers::ISurfaceAllocator> mAllocator;
    58   nsRefPtr<gfxSharedImageSurface>         mSurface;
    59 };
    61 #endif // GFXSHMCOWSURFACEWRAPPER

mercurial