LCOV - app.info - gfx/layers/ipc/ShadowLayers.cpp

LCOV - code coverage report
| Current view: | directory - gfx/layers/ipc - ShadowLayers.cpp (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 224 | 0 | 0.0 %
| Date: | 2012-06-02 | Functions: | 51 | 0 | 0.0 %

           1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
           2                 :  * vim: sw=2 ts=8 et :
           3                 :  */
           4                 : /* ***** BEGIN LICENSE BLOCK *****
           5                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           6                 :  *
           7                 :  * The contents of this file are subject to the Mozilla Public License Version
           8                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           9                 :  * the License. You may obtain a copy of the License at:
          10                 :  * http://www.mozilla.org/MPL/
          11                 :  *
          12                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          13                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          14                 :  * for the specific language governing rights and limitations under the
          15                 :  * License.
          16                 :  *
          17                 :  * The Original Code is Mozilla Code.
          18                 :  *
          19                 :  * The Initial Developer of the Original Code is
          20                 :  *   The Mozilla Foundation
          21                 :  * Portions created by the Initial Developer are Copyright (C) 2010
          22                 :  * the Initial Developer. All Rights Reserved.
          23                 :  *
          24                 :  * Contributor(s):
          25                 :  *   Chris Jones <jones.chris.g@gmail.com>
          26                 :  *
          27                 :  * Alternatively, the contents of this file may be used under the terms of
          28                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          29                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          31                 :  * of those above. If you wish to allow use of your version of this file only
          32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          33                 :  * use your version of this file under the terms of the MPL, indicate your
          34                 :  * decision by deleting the provisions above and replace them with the notice
          35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          36                 :  * the provisions above, a recipient may use your version of this file under
          37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          38                 :  *
          39                 :  * ***** END LICENSE BLOCK ***** */
          40                 :
          41                 : #include <set>
          42                 : #include <vector>
          43                 :
          44                 : #include "gfxSharedImageSurface.h"
          45                 :
          46                 : #include "mozilla/ipc/SharedMemorySysV.h"
          47                 : #include "mozilla/layers/PLayerChild.h"
          48                 : #include "mozilla/layers/PLayersChild.h"
          49                 : #include "mozilla/layers/PLayersParent.h"
          50                 : #include "ShadowLayers.h"
          51                 : #include "ShadowLayerChild.h"
          52                 : #include "gfxipc/ShadowLayerUtils.h"
          53                 :
          54                 : using namespace mozilla::ipc;
          55                 :
          56                 : namespace mozilla {
          57                 : namespace layers {
          58                 :
          59                 : typedef nsTArray<SurfaceDescriptor> BufferArray;
          60                 : typedef std::vector<Edit> EditVector;
          61                 : typedef std::set<ShadowableLayer*> ShadowableLayerSet;
          62                 :
          63                 : class Transaction
          64               0 : {
          65                 : public:
          66               0 :   Transaction() : mOpen(false) {}
          67                 :
          68               0 :   void Begin() { mOpen = true; }
          69                 :
          70               0 :   void AddEdit(const Edit& aEdit)
          71                 :   {
          72               0 :     NS_ABORT_IF_FALSE(!Finished(), "forgot BeginTransaction?");
          73               0 :     mCset.push_back(aEdit);
          74               0 :   }
          75               0 :   void AddPaint(const Edit& aPaint)
          76                 :   {
          77               0 :     NS_ABORT_IF_FALSE(!Finished(), "forgot BeginTransaction?");
          78               0 :     mPaints.push_back(aPaint);
          79               0 :   }
          80               0 :   void AddMutant(ShadowableLayer* aLayer)
          81                 :   {
          82               0 :     NS_ABORT_IF_FALSE(!Finished(), "forgot BeginTransaction?");
          83               0 :     mMutants.insert(aLayer);
          84               0 :   }
          85                 :   void AddBufferToDestroy(gfxSharedImageSurface* aBuffer)
          86                 :   {
          87                 :     return AddBufferToDestroy(aBuffer->GetShmem());
          88                 :   }
          89               0 :   void AddBufferToDestroy(const SurfaceDescriptor& aBuffer)
          90                 :   {
          91               0 :     NS_ABORT_IF_FALSE(!Finished(), "forgot BeginTransaction?");
          92               0 :     mDyingBuffers.AppendElement(aBuffer);
          93               0 :   }
          94                 :
          95               0 :   void End()
          96                 :   {
          97               0 :     mCset.clear();
          98               0 :     mPaints.clear();
          99               0 :     mDyingBuffers.Clear();
         100               0 :     mMutants.clear();
         101               0 :     mOpen = false;
         102               0 :   }
         103                 :
         104               0 :   bool Empty() const {
         105               0 :     return mCset.empty() && mPaints.empty() && mMutants.empty();
         106                 :   }
         107               0 :   bool Finished() const { return !mOpen && Empty(); }
         108                 :
         109                 :   EditVector mCset;
         110                 :   EditVector mPaints;
         111                 :   BufferArray mDyingBuffers;
         112                 :   ShadowableLayerSet mMutants;
         113                 :
         114                 : private:
         115                 :   bool mOpen;
         116                 :
         117                 :   // disabled
         118                 :   Transaction(const Transaction&);
         119                 :   Transaction& operator=(const Transaction&);
         120                 : };
         121                 : struct AutoTxnEnd {
         122               0 :   AutoTxnEnd(Transaction* aTxn) : mTxn(aTxn) {}
         123               0 :   ~AutoTxnEnd() { mTxn->End(); }
         124                 :   Transaction* mTxn;
         125                 : };
         126                 :
         127               0 : ShadowLayerForwarder::ShadowLayerForwarder()
         128                 :  : mShadowManager(NULL)
         129               0 :  , mParentBackend(LayerManager::LAYERS_NONE)
         130                 : {
         131               0 :   mTxn = new Transaction();
         132               0 : }
         133                 :
         134               0 : ShadowLayerForwarder::~ShadowLayerForwarder()
         135                 : {
         136               0 :   NS_ABORT_IF_FALSE(mTxn->Finished(), "unfinished transaction?");
         137               0 :   delete mTxn;
         138               0 : }
         139                 :
         140                 : void
         141               0 : ShadowLayerForwarder::BeginTransaction()
         142                 : {
         143               0 :   NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
         144               0 :   NS_ABORT_IF_FALSE(mTxn->Finished(), "uncommitted txn?");
         145               0 :   mTxn->Begin();
         146               0 : }
         147                 :
         148                 : static PLayerChild*
         149               0 : Shadow(ShadowableLayer* aLayer)
         150                 : {
         151               0 :   return aLayer->GetShadow();
         152                 : }
         153                 :
         154                 : template<typename OpCreateT>
         155                 : static void
         156               0 : CreatedLayer(Transaction* aTxn, ShadowableLayer* aLayer)
         157                 : {
         158               0 :   aTxn->AddEdit(OpCreateT(NULL, Shadow(aLayer)));
         159               0 : }
         160                 :
         161                 : void
         162               0 : ShadowLayerForwarder::CreatedThebesLayer(ShadowableLayer* aThebes)
         163                 : {
         164               0 :   CreatedLayer<OpCreateThebesLayer>(mTxn, aThebes);
         165               0 : }
         166                 : void
         167               0 : ShadowLayerForwarder::CreatedContainerLayer(ShadowableLayer* aContainer)
         168                 : {
         169               0 :   CreatedLayer<OpCreateContainerLayer>(mTxn, aContainer);
         170               0 : }
         171                 : void
         172               0 : ShadowLayerForwarder::CreatedImageLayer(ShadowableLayer* aImage)
         173                 : {
         174               0 :   CreatedLayer<OpCreateImageLayer>(mTxn, aImage);
         175               0 : }
         176                 : void
         177               0 : ShadowLayerForwarder::CreatedColorLayer(ShadowableLayer* aColor)
         178                 : {
         179               0 :   CreatedLayer<OpCreateColorLayer>(mTxn, aColor);
         180               0 : }
         181                 : void
         182               0 : ShadowLayerForwarder::CreatedCanvasLayer(ShadowableLayer* aCanvas)
         183                 : {
         184               0 :   CreatedLayer<OpCreateCanvasLayer>(mTxn, aCanvas);
         185               0 : }
         186                 :
         187                 : void
         188               0 : ShadowLayerForwarder::DestroyedThebesBuffer(ShadowableLayer* aThebes,
         189                 :                                             const SurfaceDescriptor& aBackBufferToDestroy)
         190                 : {
         191               0 :   mTxn->AddBufferToDestroy(aBackBufferToDestroy);
         192               0 : }
         193                 :
         194                 : void
         195               0 : ShadowLayerForwarder::Mutated(ShadowableLayer* aMutant)
         196                 : {
         197               0 :   mTxn->AddMutant(aMutant);
         198               0 : }
         199                 :
         200                 : void
         201               0 : ShadowLayerForwarder::SetRoot(ShadowableLayer* aRoot)
         202                 : {
         203               0 :   mTxn->AddEdit(OpSetRoot(NULL, Shadow(aRoot)));
         204               0 : }
         205                 : void
         206               0 : ShadowLayerForwarder::InsertAfter(ShadowableLayer* aContainer,
         207                 :                                   ShadowableLayer* aChild,
         208                 :                                   ShadowableLayer* aAfter)
         209                 : {
         210               0 :   if (aAfter)
         211                 :     mTxn->AddEdit(OpInsertAfter(NULL, Shadow(aContainer),
         212                 :                                 NULL, Shadow(aChild),
         213               0 :                                 NULL, Shadow(aAfter)));
         214                 :   else
         215                 :     mTxn->AddEdit(OpAppendChild(NULL, Shadow(aContainer),
         216               0 :                                 NULL, Shadow(aChild)));
         217               0 : }
         218                 : void
         219               0 : ShadowLayerForwarder::RemoveChild(ShadowableLayer* aContainer,
         220                 :                                   ShadowableLayer* aChild)
         221                 : {
         222                 :   mTxn->AddEdit(OpRemoveChild(NULL, Shadow(aContainer),
         223               0 :                               NULL, Shadow(aChild)));
         224               0 : }
         225                 :
         226                 : void
         227               0 : ShadowLayerForwarder::PaintedThebesBuffer(ShadowableLayer* aThebes,
         228                 :                                           const nsIntRegion& aUpdatedRegion,
         229                 :                                           const nsIntRect& aBufferRect,
         230                 :                                           const nsIntPoint& aBufferRotation,
         231                 :                                           const SurfaceDescriptor& aNewFrontBuffer)
         232                 : {
         233                 :   mTxn->AddPaint(OpPaintThebesBuffer(NULL, Shadow(aThebes),
         234                 :                                      ThebesBuffer(aNewFrontBuffer,
         235                 :                                                   aBufferRect,
         236               0 :                                                   aBufferRotation),
         237               0 :                                      aUpdatedRegion));
         238               0 : }
         239                 : void
         240               0 : ShadowLayerForwarder::PaintedImage(ShadowableLayer* aImage,
         241                 :                                    const SharedImage& aNewFrontImage)
         242                 : {
         243                 :   mTxn->AddPaint(OpPaintImage(NULL, Shadow(aImage),
         244               0 :                               aNewFrontImage));
         245               0 : }
         246                 : void
         247               0 : ShadowLayerForwarder::PaintedCanvas(ShadowableLayer* aCanvas,
         248                 :                                     bool aNeedYFlip,
         249                 :                                     const SurfaceDescriptor& aNewFrontSurface)
         250                 : {
         251                 :   mTxn->AddPaint(OpPaintCanvas(NULL, Shadow(aCanvas),
         252                 :                                aNewFrontSurface,
         253               0 :                                aNeedYFlip));
         254               0 : }
         255                 :
         256                 : bool
         257               0 : ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
         258                 : {
         259               0 :   NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
         260               0 :   NS_ABORT_IF_FALSE(!mTxn->Finished(), "forgot BeginTransaction?");
         261                 :
         262               0 :   AutoTxnEnd _(mTxn);
         263                 :
         264               0 :   if (mTxn->Empty()) {
         265               0 :     MOZ_LAYERS_LOG(("[LayersForwarder] 0-length cset (?), skipping Update()"));
         266               0 :     return true;
         267                 :   }
         268                 :
         269               0 :   MOZ_LAYERS_LOG(("[LayersForwarder] destroying buffers..."));
         270                 :
         271               0 :   for (PRUint32 i = 0; i < mTxn->mDyingBuffers.Length(); ++i) {
         272               0 :     DestroySharedSurface(&mTxn->mDyingBuffers[i]);
         273                 :   }
         274                 :
         275               0 :   MOZ_LAYERS_LOG(("[LayersForwarder] building transaction..."));
         276                 :
         277                 :   // We purposely add attribute-change ops to the final changeset
         278                 :   // before we add paint ops.  This allows layers to record the
         279                 :   // attribute changes before new pixels arrive, which can be useful
         280                 :   // for setting up back/front buffers.
         281               0 :   for (ShadowableLayerSet::const_iterator it = mTxn->mMutants.begin();
         282               0 :        it != mTxn->mMutants.end(); ++it) {
         283               0 :     ShadowableLayer* shadow = *it;
         284               0 :     Layer* mutant = shadow->AsLayer();
         285               0 :     NS_ABORT_IF_FALSE(!!mutant, "unshadowable layer?");
         286                 :
         287               0 :     LayerAttributes attrs;
         288               0 :     CommonLayerAttributes& common = attrs.common();
         289               0 :     common.visibleRegion() = mutant->GetVisibleRegion();
         290               0 :     common.transform() = mutant->GetTransform();
         291               0 :     common.contentFlags() = mutant->GetContentFlags();
         292               0 :     common.opacity() = mutant->GetOpacity();
         293               0 :     common.useClipRect() = !!mutant->GetClipRect();
         294               0 :     common.clipRect() = (common.useClipRect() ?
         295               0 :                          *mutant->GetClipRect() : nsIntRect());
         296               0 :     common.isFixedPosition() = mutant->GetIsFixedPosition();
         297               0 :     common.useTileSourceRect() = !!mutant->GetTileSourceRect();
         298               0 :     common.tileSourceRect() = (common.useTileSourceRect() ?
         299               0 :                                *mutant->GetTileSourceRect() : nsIntRect());
         300               0 :     attrs.specific() = null_t();
         301               0 :     mutant->FillSpecificAttributes(attrs.specific());
         302                 :
         303               0 :     mTxn->AddEdit(OpSetLayerAttributes(NULL, Shadow(shadow), attrs));
         304                 :   }
         305                 :
         306               0 :   AutoInfallibleTArray<Edit, 10> cset;
         307               0 :   size_t nCsets = mTxn->mCset.size() + mTxn->mPaints.size();
         308               0 :   NS_ABORT_IF_FALSE(nCsets > 0, "should have bailed by now");
         309                 :
         310               0 :   cset.SetCapacity(nCsets);
         311               0 :   if (!mTxn->mCset.empty()) {
         312               0 :     cset.AppendElements(&mTxn->mCset.front(), mTxn->mCset.size());
         313                 :   }
         314                 :   // Paints after non-paint ops, including attribute changes.  See
         315                 :   // above.
         316               0 :   if (!mTxn->mPaints.empty()) {
         317               0 :     cset.AppendElements(&mTxn->mPaints.front(), mTxn->mPaints.size());
         318                 :   }
         319                 :
         320               0 :   MOZ_LAYERS_LOG(("[LayersForwarder] syncing before send..."));
         321               0 :   PlatformSyncBeforeUpdate();
         322                 :
         323               0 :   MOZ_LAYERS_LOG(("[LayersForwarder] sending transaction..."));
         324               0 :   if (!mShadowManager->SendUpdate(cset, aReplies)) {
         325               0 :     MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
         326               0 :     return false;
         327                 :   }
         328                 :
         329               0 :   MOZ_LAYERS_LOG(("[LayersForwarder] ... done"));
         330               0 :   return true;
         331                 : }
         332                 :
         333                 : static gfxASurface::gfxImageFormat
         334               0 : OptimalFormatFor(gfxASurface::gfxContentType aContent)
         335                 : {
         336               0 :   switch (aContent) {
         337                 :   case gfxASurface::CONTENT_COLOR:
         338                 : #ifdef MOZ_GFX_OPTIMIZE_MOBILE
         339                 :     return gfxASurface::ImageFormatRGB16_565;
         340                 : #else
         341               0 :     return gfxASurface::ImageFormatRGB24;
         342                 : #endif
         343                 :   case gfxASurface::CONTENT_ALPHA:
         344               0 :     return gfxASurface::ImageFormatA8;
         345                 :   case gfxASurface::CONTENT_COLOR_ALPHA:
         346               0 :     return gfxASurface::ImageFormatARGB32;
         347                 :   default:
         348               0 :     NS_NOTREACHED("unknown gfxContentType");
         349               0 :     return gfxASurface::ImageFormatARGB32;
         350                 :   }
         351                 : }
         352                 :
         353                 : static SharedMemory::SharedMemoryType
         354               0 : OptimalShmemType()
         355                 : {
         356                 : #if defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_HAVE_SHAREDMEMORYSYSV)
         357                 :   // Use SysV memory because maemo5 on the N900 only allots 64MB to
         358                 :   // /dev/shm, even though it has 1GB(!!) of system memory.  Sys V shm
         359                 :   // is allocated from a different pool.  We don't want an arbitrary
         360                 :   // cap that's much much lower than available memory on the memory we
         361                 :   // use for layers.
         362                 :   return SharedMemory::TYPE_SYSV;
         363                 : #else
         364               0 :   return SharedMemory::TYPE_BASIC;
         365                 : #endif
         366                 : }
         367                 :
         368                 : bool
         369               0 : ShadowLayerForwarder::AllocDoubleBuffer(const gfxIntSize& aSize,
         370                 :                                         gfxASurface::gfxContentType aContent,
         371                 :                                         gfxSharedImageSurface** aFrontBuffer,
         372                 :                                         gfxSharedImageSurface** aBackBuffer)
         373                 : {
         374               0 :   return AllocBuffer(aSize, aContent, aFrontBuffer) &&
         375               0 :          AllocBuffer(aSize, aContent, aBackBuffer);
         376                 : }
         377                 :
         378                 : void
         379               0 : ShadowLayerForwarder::DestroySharedSurface(gfxSharedImageSurface* aSurface)
         380                 : {
         381               0 :   mShadowManager->DeallocShmem(aSurface->GetShmem());
         382               0 : }
         383                 :
         384                 : bool
         385               0 : ShadowLayerForwarder::AllocBuffer(const gfxIntSize& aSize,
         386                 :                                   gfxASurface::gfxContentType aContent,
         387                 :                                   gfxSharedImageSurface** aBuffer)
         388                 : {
         389               0 :   NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
         390                 :
         391               0 :   gfxASurface::gfxImageFormat format = OptimalFormatFor(aContent);
         392               0 :   SharedMemory::SharedMemoryType shmemType = OptimalShmemType();
         393                 :
         394                 :   nsRefPtr<gfxSharedImageSurface> back =
         395               0 :     gfxSharedImageSurface::CreateUnsafe(mShadowManager, aSize, format, shmemType);
         396               0 :   if (!back)
         397               0 :     return false;
         398                 :
         399               0 :   *aBuffer = nsnull;
         400               0 :   back.swap(*aBuffer);
         401               0 :   return true;
         402                 : }
         403                 :
         404                 : bool
         405               0 : ShadowLayerForwarder::AllocDoubleBuffer(const gfxIntSize& aSize,
         406                 :                                         gfxASurface::gfxContentType aContent,
         407                 :                                         SurfaceDescriptor* aFrontBuffer,
         408                 :                                         SurfaceDescriptor* aBackBuffer)
         409                 : {
         410               0 :   bool tryPlatformSurface = true;
         411                 : #ifdef DEBUG
         412               0 :   tryPlatformSurface = !PR_GetEnv("MOZ_LAYERS_FORCE_SHMEM_SURFACES");
         413                 : #endif
         414               0 :   if (tryPlatformSurface &&
         415               0 :       PlatformAllocDoubleBuffer(aSize, aContent, aFrontBuffer, aBackBuffer)) {
         416               0 :     return true;
         417                 :   }
         418                 :
         419               0 :   nsRefPtr<gfxSharedImageSurface> front;
         420               0 :   nsRefPtr<gfxSharedImageSurface> back;
         421               0 :   if (!AllocDoubleBuffer(aSize, aContent,
         422               0 :                          getter_AddRefs(front), getter_AddRefs(back))) {
         423               0 :     return false;
         424                 :   }
         425                 :
         426               0 :   *aFrontBuffer = front->GetShmem();
         427               0 :   *aBackBuffer = back->GetShmem();
         428               0 :   return true;
         429                 : }
         430                 :
         431                 : bool
         432               0 : ShadowLayerForwarder::AllocBuffer(const gfxIntSize& aSize,
         433                 :                                   gfxASurface::gfxContentType aContent,
         434                 :                                   SurfaceDescriptor* aBuffer)
         435                 : {
         436               0 :   bool tryPlatformSurface = true;
         437                 : #ifdef DEBUG
         438               0 :   tryPlatformSurface = !PR_GetEnv("MOZ_LAYERS_FORCE_SHMEM_SURFACES");
         439                 : #endif
         440               0 :   if (tryPlatformSurface &&
         441               0 :       PlatformAllocBuffer(aSize, aContent, aBuffer)) {
         442               0 :     return true;
         443                 :   }
         444                 :
         445               0 :   nsRefPtr<gfxSharedImageSurface> buffer;
         446               0 :   if (!AllocBuffer(aSize, aContent,
         447               0 :                    getter_AddRefs(buffer)))
         448               0 :     return false;
         449                 :
         450               0 :   *aBuffer = buffer->GetShmem();
         451               0 :   return true;
         452                 : }
         453                 :
         454                 : /*static*/ already_AddRefed<gfxASurface>
         455               0 : ShadowLayerForwarder::OpenDescriptor(const SurfaceDescriptor& aSurface)
         456                 : {
         457               0 :   nsRefPtr<gfxASurface> surf = PlatformOpenDescriptor(aSurface);
         458               0 :   if (surf) {
         459               0 :     return surf.forget();
         460                 :   }
         461                 :
         462               0 :   switch (aSurface.type()) {
         463                 :   case SurfaceDescriptor::TShmem: {
         464               0 :     surf = gfxSharedImageSurface::Open(aSurface.get_Shmem());
         465               0 :     return surf.forget();
         466                 :   }
         467                 :   default:
         468               0 :     NS_RUNTIMEABORT("unexpected SurfaceDescriptor type!");
         469               0 :     return nsnull;
         470                 :   }
         471                 : }
         472                 :
         473                 : // Destroy the Shmem SurfaceDescriptor |aSurface|.
         474                 : template<class ShmemDeallocator>
         475                 : static void
         476               0 : DestroySharedShmemSurface(SurfaceDescriptor* aSurface,
         477                 :                           ShmemDeallocator* aDeallocator)
         478                 : {
         479               0 :   switch (aSurface->type()) {
         480                 :   case SurfaceDescriptor::TShmem: {
         481               0 :     aDeallocator->DeallocShmem(aSurface->get_Shmem());
         482               0 :     *aSurface = SurfaceDescriptor();
         483               0 :     return;
         484                 :   }
         485                 :   default:
         486               0 :     NS_RUNTIMEABORT("unexpected SurfaceDescriptor type!");
         487               0 :     return;
         488                 :   }
         489                 : }
         490                 :
         491                 : void
         492               0 : ShadowLayerForwarder::DestroySharedSurface(SurfaceDescriptor* aSurface)
         493                 : {
         494               0 :   if (PlatformDestroySharedSurface(aSurface)) {
         495               0 :     return;
         496                 :   }
         497               0 :   if (aSurface->type() == SurfaceDescriptor::TShmem) {
         498               0 :     DestroySharedShmemSurface(aSurface, mShadowManager);
         499                 :   }
         500                 : }
         501                 :
         502                 :
         503                 : PLayerChild*
         504               0 : ShadowLayerForwarder::ConstructShadowFor(ShadowableLayer* aLayer)
         505                 : {
         506               0 :   NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
         507               0 :   return mShadowManager->SendPLayerConstructor(new ShadowLayerChild(aLayer));
         508                 : }
         509                 :
         510                 :
         511                 : void
         512               0 : ShadowLayerManager::DestroySharedSurface(gfxSharedImageSurface* aSurface,
         513                 :                                          PLayersParent* aDeallocator)
         514                 : {
         515               0 :   aDeallocator->DeallocShmem(aSurface->GetShmem());
         516               0 : }
         517                 :
         518                 : void
         519               0 : ShadowLayerManager::DestroySharedSurface(SurfaceDescriptor* aSurface,
         520                 :                                          PLayersParent* aDeallocator)
         521                 : {
         522               0 :   if (PlatformDestroySharedSurface(aSurface)) {
         523               0 :     return;
         524                 :   }
         525               0 :   if (aSurface->type() == SurfaceDescriptor::TShmem) {
         526               0 :     DestroySharedShmemSurface(aSurface, aDeallocator);
         527                 :   }
         528                 : }
         529                 :
         530                 :
         531                 : #if !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS)
         532                 :
         533                 : bool
         534                 : ShadowLayerForwarder::PlatformAllocDoubleBuffer(const gfxIntSize&,
         535                 :                                                 gfxASurface::gfxContentType,
         536                 :                                                 SurfaceDescriptor*,
         537                 :                                                 SurfaceDescriptor*)
         538                 : {
         539                 :   return false;
         540                 : }
         541                 :
         542                 : bool
         543                 : ShadowLayerForwarder::PlatformAllocBuffer(const gfxIntSize&,
         544                 :                                           gfxASurface::gfxContentType,
         545                 :                                           SurfaceDescriptor*)
         546                 : {
         547                 :   return false;
         548                 : }
         549                 :
         550                 : /*static*/ already_AddRefed<gfxASurface>
         551                 : ShadowLayerForwarder::PlatformOpenDescriptor(const SurfaceDescriptor&)
         552                 : {
         553                 :   return nsnull;
         554                 : }
         555                 :
         556                 : bool
         557                 : ShadowLayerForwarder::PlatformDestroySharedSurface(SurfaceDescriptor*)
         558                 : {
         559                 :   return false;
         560                 : }
         561                 :
         562                 : /*static*/ void
         563                 : ShadowLayerForwarder::PlatformSyncBeforeUpdate()
         564                 : {
         565                 : }
         566                 :
         567                 : bool
         568                 : ShadowLayerManager::PlatformDestroySharedSurface(SurfaceDescriptor*)
         569                 : {
         570                 :   return false;
         571                 : }
         572                 :
         573                 : /*static*/ void
         574                 : ShadowLayerManager::PlatformSyncBeforeReplyUpdate()
         575                 : {
         576                 : }
         577                 :
         578                 : #endif  // !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS)
         579                 :
         580                 : bool
         581               0 : IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface)
         582                 : {
         583               0 :   return SurfaceDescriptor::T__None != aSurface.type();
         584                 : }
         585                 :
         586                 : } // namespace layers
         587                 : } // namespace mozilla

Generated by: LCOV version 1.7