Bug 1632310 [wpt PR 23186] - Add test for computed versus resolved style., a=testonly
[gecko.git] / gfx / layers / client / GPUVideoTextureClient.cpp
blob8a8f6f6e69e332d9c44d4ca81ffef9c2262850d4
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"
11 namespace mozilla {
12 namespace layers {
14 using namespace gfx;
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) {
24 aOutDescriptor = mSD;
25 return true;
28 void GPUVideoTextureData::FillInfo(TextureData::Info& aInfo) const {
29 aInfo.size = mSize;
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.hasIntermediateBuffer = false;
35 aInfo.hasSynchronization = false;
36 aInfo.supportsMoz2D = false;
37 aInfo.canExposeMappedData = false;
40 already_AddRefed<SourceSurface> GPUVideoTextureData::GetAsSourceSurface() {
41 return mManager->Readback(mSD);
44 void GPUVideoTextureData::Deallocate(LayersIPCChannel* aAllocator) {
45 mManager->DeallocateSurfaceDescriptor(mSD);
46 mSD = SurfaceDescriptorGPUVideo();
49 void GPUVideoTextureData::Forget(LayersIPCChannel* aAllocator) {
50 // We always need to manually deallocate on the client side.
51 // Ideally we'd set up our TextureClient with the DEALLOCATE_CLIENT
52 // flag, but that forces texture destruction to be synchronous.
53 // Instead let's just deallocate from here as well.
54 Deallocate(aAllocator);
57 } // namespace layers
58 } // namespace mozilla