Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/SourceSurfaceVolatileData.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "SourceSurfaceVolatileData.h"
8
9
#include "gfxAlphaRecovery.h"
10
#include "mozilla/Likely.h"
11
#include "mozilla/Types.h" // for decltype
12
13
namespace mozilla {
14
namespace gfx {
15
16
bool
17
SourceSurfaceVolatileData::Init(const IntSize &aSize,
18
                                int32_t aStride,
19
                                SurfaceFormat aFormat)
20
0
{
21
0
  mSize = aSize;
22
0
  mStride = aStride;
23
0
  mFormat = aFormat;
24
0
25
0
  size_t alignment = size_t(1) << gfxAlphaRecovery::GoodAlignmentLog2();
26
0
  mVBuf = new VolatileBuffer();
27
0
  if (MOZ_UNLIKELY(!mVBuf->Init(aStride * aSize.height, alignment))) {
28
0
    mVBuf = nullptr;
29
0
    return false;
30
0
  }
31
0
32
0
  return true;
33
0
}
34
35
void
36
SourceSurfaceVolatileData::GuaranteePersistance()
37
0
{
38
0
  MOZ_ASSERT_UNREACHABLE("Should use SourceSurfaceRawData wrapper!");
39
0
}
40
41
void
42
SourceSurfaceVolatileData::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
43
                                                  size_t& aHeapSizeOut,
44
                                                  size_t& aNonHeapSizeOut,
45
                                                  size_t& aExtHandlesOut) const
46
0
{
47
0
  if (mVBuf) {
48
0
    aHeapSizeOut += mVBuf->HeapSizeOfExcludingThis(aMallocSizeOf);
49
0
    aNonHeapSizeOut += mVBuf->NonHeapSizeOfExcludingThis();
50
#ifdef ANDROID
51
    if (!mVBuf->OnHeap()) {
52
      // Volatile buffers keep a file handle open on Android.
53
      ++aExtHandlesOut;
54
    }
55
#endif
56
  }
57
0
}
58
59
} // namespace gfx
60
} // namespace mozilla