LCOV - code coverage report
Current view: top level - gfx/layers/client - TextureClientSharedSurface.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 35 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "TextureClientSharedSurface.h"
       7             : 
       8             : #include "GLContext.h"
       9             : #include "mozilla/gfx/2D.h"
      10             : #include "mozilla/gfx/Logging.h"        // for gfxDebug
      11             : #include "mozilla/layers/ISurfaceAllocator.h"
      12             : #include "mozilla/Unused.h"
      13             : #include "nsThreadUtils.h"
      14             : #include "SharedSurface.h"
      15             : 
      16             : using namespace mozilla::gl;
      17             : 
      18             : namespace mozilla {
      19             : namespace layers {
      20             : 
      21             : 
      22           0 : SharedSurfaceTextureData::SharedSurfaceTextureData(UniquePtr<gl::SharedSurface> surf)
      23           0 :   : mSurf(Move(surf))
      24           0 : {}
      25             : 
      26           0 : SharedSurfaceTextureData::~SharedSurfaceTextureData()
      27           0 : {}
      28             : 
      29             : void
      30           0 : SharedSurfaceTextureData::Deallocate(LayersIPCChannel*)
      31           0 : {}
      32             : 
      33             : void
      34           0 : SharedSurfaceTextureData::FillInfo(TextureData::Info& aInfo) const
      35             : {
      36           0 :   aInfo.size = mSurf->mSize;
      37           0 :   aInfo.format = gfx::SurfaceFormat::UNKNOWN;
      38           0 :   aInfo.hasIntermediateBuffer = false;
      39           0 :   aInfo.hasSynchronization = false;
      40           0 :   aInfo.supportsMoz2D = false;
      41           0 :   aInfo.canExposeMappedData = false;
      42           0 : }
      43             : 
      44             : bool
      45           0 : SharedSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
      46             : {
      47           0 :   return mSurf->ToSurfaceDescriptor(&aOutDescriptor);
      48             : }
      49             : 
      50             : 
      51           0 : SharedSurfaceTextureClient::SharedSurfaceTextureClient(SharedSurfaceTextureData* aData,
      52             :                                                        TextureFlags aFlags,
      53           0 :                                                        LayersIPCChannel* aAllocator)
      54           0 : : TextureClient(aData, aFlags, aAllocator)
      55             : {
      56           0 :   mWorkaroundAnnoyingSharedSurfaceLifetimeIssues = true;
      57           0 : }
      58             : 
      59             : already_AddRefed<SharedSurfaceTextureClient>
      60           0 : SharedSurfaceTextureClient::Create(UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
      61             :                                    LayersIPCChannel* aAllocator, TextureFlags aFlags)
      62             : {
      63           0 :   if (!surf) {
      64           0 :     return nullptr;
      65             :   }
      66           0 :   TextureFlags flags = aFlags | TextureFlags::RECYCLE | surf->GetTextureFlags();
      67           0 :   SharedSurfaceTextureData* data = new SharedSurfaceTextureData(Move(surf));
      68           0 :   return MakeAndAddRef<SharedSurfaceTextureClient>(data, flags, aAllocator);
      69             : }
      70             : 
      71           0 : SharedSurfaceTextureClient::~SharedSurfaceTextureClient()
      72             : {
      73             :   // XXX - Things break when using the proper destruction handshake with
      74             :   // SharedSurfaceTextureData because the TextureData outlives its gl
      75             :   // context. Having a strong reference to the gl context creates a cycle.
      76             :   // This needs to be fixed in a better way, though, because deleting
      77             :   // the TextureData here can race with the compositor and cause flashing.
      78           0 :   TextureData* data = mData;
      79           0 :   mData = nullptr;
      80             : 
      81           0 :   Destroy();
      82             : 
      83           0 :   if (data) {
      84             :     // Destroy mData right away without doing the proper deallocation handshake,
      85             :     // because SharedSurface depends on things that may not outlive the texture's
      86             :     // destructor so we can't wait until we know the compositor isn't using the
      87             :     // texture anymore.
      88             :     // It goes without saying that this is really bad and we should fix the bugs
      89             :     // that block doing the right thing such as bug 1224199 sooner rather than
      90             :     // later.
      91           0 :     delete data;
      92             :   }
      93           0 : }
      94             : 
      95             : } // namespace layers
      96             : } // namespace mozilla

Generated by: LCOV version 1.13