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/. */
7 #include "GPUVideoTextureClient.h"
8 #include "GPUVideoImage.h"
9 #include "mozilla/gfx/2D.h"
16 GPUVideoTextureData::GPUVideoTextureData(IGPUVideoSurfaceManager
* aManager
,
17 const SurfaceDescriptorGPUVideo
& aSD
,
18 const gfx::IntSize
& aSize
)
19 : mManager(aManager
), mSD(aSD
), mSize(aSize
) {}
21 GPUVideoTextureData::~GPUVideoTextureData() = default;
23 bool GPUVideoTextureData::Serialize(SurfaceDescriptor
& aOutDescriptor
) {
28 void GPUVideoTextureData::FillInfo(TextureData::Info
& aInfo
) const {
30 // TODO: We should probably try do better for this.
31 // layers::Image doesn't expose a format, so it's hard
32 // to figure out in VideoDecoderParent.
33 aInfo
.format
= SurfaceFormat::B8G8R8X8
;
34 aInfo
.hasSynchronization
= false;
35 aInfo
.supportsMoz2D
= false;
36 aInfo
.canExposeMappedData
= false;
39 already_AddRefed
<SourceSurface
> GPUVideoTextureData::GetAsSourceSurface() {
40 return mManager
->Readback(mSD
);
43 void GPUVideoTextureData::Deallocate(LayersIPCChannel
* aAllocator
) {
44 mManager
->DeallocateSurfaceDescriptor(mSD
);
45 mSD
= SurfaceDescriptorGPUVideo();
48 void GPUVideoTextureData::Forget(LayersIPCChannel
* aAllocator
) {
49 // We always need to manually deallocate on the client side.
50 // Ideally we'd set up our TextureClient with the DEALLOCATE_CLIENT
51 // flag, but that forces texture destruction to be synchronous.
52 // Instead let's just deallocate from here as well.
53 Deallocate(aAllocator
);
57 } // namespace mozilla