Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/client/GPUVideoTextureClient.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 "GPUVideoTextureClient.h"
8
#include "mozilla/dom/VideoDecoderManagerChild.h"
9
#include "mozilla/gfx/2D.h"
10
11
namespace mozilla {
12
namespace layers {
13
14
using namespace gfx;
15
16
GPUVideoTextureData::GPUVideoTextureData(dom::VideoDecoderManagerChild* aManager,
17
                                         const SurfaceDescriptorGPUVideo& aSD,
18
                                         const gfx::IntSize& aSize)
19
  : mManager(aManager)
20
  , mSD(aSD)
21
  , mSize(aSize)
22
0
{}
23
24
GPUVideoTextureData::~GPUVideoTextureData()
25
0
{
26
0
}
27
28
bool
29
GPUVideoTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
30
0
{
31
0
  aOutDescriptor = mSD;
32
0
  return true;
33
0
}
34
35
void
36
GPUVideoTextureData::FillInfo(TextureData::Info& aInfo) const
37
0
{
38
0
  aInfo.size = mSize;
39
0
  // TODO: We should probably try do better for this.
40
0
  // layers::Image doesn't expose a format, so it's hard
41
0
  // to figure out in VideoDecoderParent.
42
0
  aInfo.format = SurfaceFormat::B8G8R8X8;
43
0
  aInfo.hasIntermediateBuffer = false;
44
0
  aInfo.hasSynchronization = false;
45
0
  aInfo.supportsMoz2D = false;
46
0
  aInfo.canExposeMappedData = false;
47
0
}
48
49
already_AddRefed<SourceSurface>
50
GPUVideoTextureData::GetAsSourceSurface()
51
0
{
52
0
  return mManager->Readback(mSD);
53
0
}
54
55
void
56
GPUVideoTextureData::Deallocate(LayersIPCChannel* aAllocator)
57
0
{
58
0
  mManager->DeallocateSurfaceDescriptorGPUVideo(mSD);
59
0
  mSD = SurfaceDescriptorGPUVideo();
60
0
}
61
62
void
63
GPUVideoTextureData::Forget(LayersIPCChannel* aAllocator)
64
0
{
65
0
  // We always need to manually deallocate on the client side.
66
0
  // Ideally we'd set up our TextureClient with the DEALLOCATE_CLIENT
67
0
  // flag, but that forces texture destruction to be synchronous.
68
0
  // Instead let's just deallocate from here as well.
69
0
  Deallocate(aAllocator);
70
0
}
71
72
} // namespace layers
73
} // namespace mozilla