Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/composite/GPUVideoTextureHost.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 "GPUVideoTextureHost.h"
8
#include "mozilla/dom/VideoDecoderManagerParent.h"
9
#include "ImageContainer.h"
10
#include "mozilla/layers/VideoBridgeParent.h"
11
12
namespace mozilla {
13
namespace layers {
14
15
GPUVideoTextureHost::GPUVideoTextureHost(TextureFlags aFlags,
16
                                         TextureHost* aWrappedTextureHost)
17
  : TextureHost(aFlags)
18
  , mWrappedTextureHost(aWrappedTextureHost)
19
0
{
20
0
  MOZ_COUNT_CTOR(GPUVideoTextureHost);
21
0
}
22
23
GPUVideoTextureHost::~GPUVideoTextureHost()
24
0
{
25
0
  MOZ_COUNT_DTOR(GPUVideoTextureHost);
26
0
}
27
28
GPUVideoTextureHost*
29
GPUVideoTextureHost::CreateFromDescriptor(
30
  TextureFlags aFlags,
31
  const SurfaceDescriptorGPUVideo& aDescriptor)
32
0
{
33
0
  TextureHost* wrappedTextureHost =
34
0
    VideoBridgeParent::GetSingleton()->LookupTexture(aDescriptor.handle());
35
0
  if (!wrappedTextureHost) {
36
0
    return nullptr;
37
0
  }
38
0
  return new GPUVideoTextureHost(aFlags, wrappedTextureHost);
39
0
}
40
41
bool
42
GPUVideoTextureHost::Lock()
43
0
{
44
0
  if (!mWrappedTextureHost) {
45
0
    return false;
46
0
  }
47
0
  return mWrappedTextureHost->Lock();
48
0
}
49
50
void
51
GPUVideoTextureHost::Unlock()
52
0
{
53
0
  if (!mWrappedTextureHost) {
54
0
    return;
55
0
  }
56
0
  mWrappedTextureHost->Unlock();
57
0
}
58
59
bool
60
GPUVideoTextureHost::BindTextureSource(CompositableTextureSourceRef& aTexture)
61
0
{
62
0
  if (!mWrappedTextureHost) {
63
0
    return false;
64
0
  }
65
0
  return mWrappedTextureHost->BindTextureSource(aTexture);
66
0
}
67
68
bool
69
GPUVideoTextureHost::AcquireTextureSource(CompositableTextureSourceRef& aTexture)
70
0
{
71
0
  if (!mWrappedTextureHost) {
72
0
    return false;
73
0
  }
74
0
  return mWrappedTextureHost->AcquireTextureSource(aTexture);
75
0
}
76
77
void
78
GPUVideoTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
79
0
{
80
0
  if (mWrappedTextureHost) {
81
0
    mWrappedTextureHost->SetTextureSourceProvider(aProvider);
82
0
  }
83
0
}
84
85
YUVColorSpace
86
GPUVideoTextureHost::GetYUVColorSpace() const
87
0
{
88
0
  if (mWrappedTextureHost) {
89
0
    return mWrappedTextureHost->GetYUVColorSpace();
90
0
  }
91
0
  return YUVColorSpace::UNKNOWN;
92
0
}
93
94
gfx::IntSize
95
GPUVideoTextureHost::GetSize() const
96
0
{
97
0
  if (!mWrappedTextureHost) {
98
0
    return gfx::IntSize();
99
0
  }
100
0
  return mWrappedTextureHost->GetSize();
101
0
}
102
103
gfx::SurfaceFormat
104
GPUVideoTextureHost::GetFormat() const
105
0
{
106
0
  if (!mWrappedTextureHost) {
107
0
    return gfx::SurfaceFormat::UNKNOWN;
108
0
  }
109
0
  return mWrappedTextureHost->GetFormat();
110
0
}
111
112
bool
113
GPUVideoTextureHost::HasIntermediateBuffer() const
114
0
{
115
0
  MOZ_ASSERT(mWrappedTextureHost);
116
0
117
0
  return mWrappedTextureHost->HasIntermediateBuffer();
118
0
}
119
120
void
121
GPUVideoTextureHost::CreateRenderTexture(const wr::ExternalImageId& aExternalImageId)
122
0
{
123
0
  MOZ_ASSERT(mWrappedTextureHost);
124
0
125
0
  mWrappedTextureHost->CreateRenderTexture(aExternalImageId);
126
0
}
127
128
uint32_t
129
GPUVideoTextureHost::NumSubTextures() const
130
0
{
131
0
  MOZ_ASSERT(mWrappedTextureHost);
132
0
  return mWrappedTextureHost->NumSubTextures();
133
0
}
134
135
void
136
GPUVideoTextureHost::PushResourceUpdates(wr::TransactionBuilder& aResources,
137
                                         ResourceUpdateOp aOp,
138
                                         const Range<wr::ImageKey>& aImageKeys,
139
                                         const wr::ExternalImageId& aExtID)
140
0
{
141
0
  MOZ_ASSERT(mWrappedTextureHost);
142
0
  mWrappedTextureHost->PushResourceUpdates(aResources, aOp, aImageKeys, aExtID);
143
0
}
144
145
void
146
GPUVideoTextureHost::PushDisplayItems(wr::DisplayListBuilder& aBuilder,
147
                                      const wr::LayoutRect& aBounds,
148
                                      const wr::LayoutRect& aClip,
149
                                      wr::ImageRendering aFilter,
150
                                      const Range<wr::ImageKey>& aImageKeys)
151
0
{
152
0
  MOZ_ASSERT(mWrappedTextureHost);
153
0
  MOZ_ASSERT(aImageKeys.length() > 0);
154
0
155
0
  mWrappedTextureHost->PushDisplayItems(aBuilder,
156
0
                                         aBounds,
157
0
                                         aClip,
158
0
                                         aFilter,
159
0
                                         aImageKeys);
160
0
}
161
162
bool
163
GPUVideoTextureHost::SupportsWrNativeTexture()
164
0
{
165
0
  MOZ_ASSERT(mWrappedTextureHost);
166
0
  return mWrappedTextureHost->SupportsWrNativeTexture();
167
0
}
168
169
} // namespace layers
170
} // namespace mozilla