Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/ipc/VideoBridgeParent.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 "VideoBridgeParent.h"
8
#include "CompositorThread.h"
9
#include "mozilla/layers/TextureHost.h"
10
11
namespace mozilla {
12
namespace layers {
13
14
using namespace mozilla::ipc;
15
using namespace mozilla::gfx;
16
17
static VideoBridgeParent* sVideoBridgeSingleton;
18
19
VideoBridgeParent::VideoBridgeParent()
20
  : mClosed(false)
21
0
{
22
0
  mSelfRef = this;
23
0
  sVideoBridgeSingleton = this;
24
0
  mCompositorThreadRef = CompositorThreadHolder::GetSingleton();
25
0
}
26
27
VideoBridgeParent::~VideoBridgeParent()
28
0
{
29
0
  sVideoBridgeSingleton = nullptr;
30
0
}
31
32
/* static */ VideoBridgeParent*
33
VideoBridgeParent::GetSingleton()
34
0
{
35
0
  return sVideoBridgeSingleton;
36
0
}
37
38
TextureHost*
39
VideoBridgeParent::LookupTexture(uint64_t aSerial)
40
0
{
41
0
  return TextureHost::AsTextureHost(mTextureMap[aSerial]);
42
0
}
43
44
void
45
VideoBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
46
0
{
47
0
  // Can't alloc/dealloc shmems from now on.
48
0
  mClosed = true;
49
0
}
50
51
void
52
VideoBridgeParent::DeallocPVideoBridgeParent()
53
0
{
54
0
  mCompositorThreadRef = nullptr;
55
0
  mSelfRef = nullptr;
56
0
}
57
58
PTextureParent*
59
VideoBridgeParent::AllocPTextureParent(const SurfaceDescriptor& aSharedData,
60
                                       const ReadLockDescriptor& aReadLock,
61
                                       const LayersBackend& aLayersBackend,
62
                                       const TextureFlags& aFlags,
63
                                       const uint64_t& aSerial)
64
0
{
65
0
  PTextureParent* parent =
66
0
    TextureHost::CreateIPDLActor(this, aSharedData, aReadLock, aLayersBackend, aFlags, aSerial, Nothing());
67
0
68
0
  if (!parent) {
69
0
    return nullptr;
70
0
  }
71
0
72
0
  mTextureMap[aSerial] = parent;
73
0
  return parent;
74
0
}
75
76
bool
77
VideoBridgeParent::DeallocPTextureParent(PTextureParent* actor)
78
0
{
79
0
  mTextureMap.erase(TextureHost::GetTextureSerial(actor));
80
0
  return TextureHost::DestroyIPDLActor(actor);
81
0
}
82
83
void
84
VideoBridgeParent::SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage)
85
0
{
86
0
  MOZ_ASSERT(false, "AsyncMessages not supported");
87
0
}
88
89
bool
90
VideoBridgeParent::AllocShmem(size_t aSize,
91
                              ipc::SharedMemory::SharedMemoryType aType,
92
                              ipc::Shmem* aShmem)
93
0
{
94
0
  if (mClosed) {
95
0
    return false;
96
0
  }
97
0
  return PVideoBridgeParent::AllocShmem(aSize, aType, aShmem);
98
0
}
99
100
bool
101
VideoBridgeParent::AllocUnsafeShmem(size_t aSize,
102
                                    ipc::SharedMemory::SharedMemoryType aType,
103
                                    ipc::Shmem* aShmem)
104
0
{
105
0
  if (mClosed) {
106
0
    return false;
107
0
  }
108
0
  return PVideoBridgeParent::AllocUnsafeShmem(aSize, aType, aShmem);
109
0
}
110
111
void
112
VideoBridgeParent::DeallocShmem(ipc::Shmem& aShmem)
113
0
{
114
0
  if (mClosed) {
115
0
    return;
116
0
  }
117
0
  PVideoBridgeParent::DeallocShmem(aShmem);
118
0
}
119
120
bool
121
VideoBridgeParent::IsSameProcess() const
122
0
{
123
0
  return OtherPid() == base::GetCurrentProcId();
124
0
}
125
126
void
127
VideoBridgeParent::NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId)
128
0
{
129
0
}
130
131
} // namespace layers
132
} // namespace mozilla