LCOV - code coverage report
Current view: top level - gfx/layers - TextureSourceProvider.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 8 30 26.7 %
Date: 2017-07-14 16:53:18 Functions: 2 7 28.6 %
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 "mozilla/layers/TextureSourceProvider.h"
       7             : #include "mozilla/layers/TextureHost.h"
       8             : 
       9             : namespace mozilla {
      10             : namespace layers {
      11             : 
      12           0 : TextureSourceProvider::~TextureSourceProvider()
      13             : {
      14           0 :   ReadUnlockTextures();
      15           0 : }
      16             : 
      17             : void
      18          27 : TextureSourceProvider::ReadUnlockTextures()
      19             : {
      20          27 :   for (auto& texture : mUnlockAfterComposition) {
      21           0 :     texture->ReadUnlock();
      22             :   }
      23          27 :   mUnlockAfterComposition.Clear();
      24          27 : }
      25             : 
      26             : void
      27           0 : TextureSourceProvider::UnlockAfterComposition(TextureHost* aTexture)
      28             : {
      29           0 :   mUnlockAfterComposition.AppendElement(aTexture);
      30           0 : }
      31             : 
      32             : bool
      33           0 : TextureSourceProvider::NotifyNotUsedAfterComposition(TextureHost* aTextureHost)
      34             : {
      35           0 :   mNotifyNotUsedAfterComposition.AppendElement(aTextureHost);
      36             : 
      37             :   // If Compositor holds many TextureHosts without compositing,
      38             :   // the TextureHosts should be flushed to reduce memory consumption.
      39           0 :   const int thresholdCount = 5;
      40           0 :   const double thresholdSec = 2.0f;
      41           0 :   if (mNotifyNotUsedAfterComposition.Length() > thresholdCount) {
      42           0 :     TimeStamp lastCompositionEndTime = GetLastCompositionEndTime();
      43           0 :     TimeDuration duration = lastCompositionEndTime ? TimeStamp::Now() - lastCompositionEndTime : TimeDuration();
      44             :     // Check if we could flush
      45           0 :     if (duration.ToSeconds() > thresholdSec) {
      46           0 :       FlushPendingNotifyNotUsed();
      47             :     }
      48             :   }
      49           0 :   return true;
      50             : }
      51             : 
      52             : void
      53          29 : TextureSourceProvider::FlushPendingNotifyNotUsed()
      54             : {
      55          29 :   for (auto& textureHost : mNotifyNotUsedAfterComposition) {
      56           0 :     textureHost->CallNotifyNotUsed();
      57             :   }
      58          29 :   mNotifyNotUsedAfterComposition.Clear();
      59          29 : }
      60             : 
      61             : void
      62           0 : TextureSourceProvider::Destroy()
      63             : {
      64           0 :   ReadUnlockTextures();
      65           0 :   FlushPendingNotifyNotUsed();
      66           0 : }
      67             : 
      68             : } // namespace layers
      69             : } // namespace mozilla

Generated by: LCOV version 1.13