tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GPUVideoTextureClient.cpp (2057B)


      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 "GPUVideoImage.h"
      9 #include "mozilla/gfx/2D.h"
     10 
     11 namespace mozilla {
     12 namespace layers {
     13 
     14 using namespace gfx;
     15 
     16 GPUVideoTextureData::GPUVideoTextureData(IGPUVideoSurfaceManager* aManager,
     17                                         const SurfaceDescriptorGPUVideo& aSD,
     18                                         const gfx::IntSize& aSize)
     19    : mManager(aManager), mSD(aSD), mSize(aSize) {}
     20 
     21 GPUVideoTextureData::~GPUVideoTextureData() = default;
     22 
     23 bool GPUVideoTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) {
     24  aOutDescriptor = mSD;
     25  return true;
     26 }
     27 
     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.hasSynchronization = false;
     35  aInfo.supportsMoz2D = false;
     36  aInfo.canExposeMappedData = false;
     37 }
     38 
     39 already_AddRefed<SourceSurface> GPUVideoTextureData::GetAsSourceSurface() {
     40  return mManager->Readback(mSD);
     41 }
     42 
     43 void GPUVideoTextureData::OnSetCurrent() { mManager->OnSetCurrent(mSD); }
     44 
     45 void GPUVideoTextureData::Deallocate(LayersIPCChannel* aAllocator) {
     46  mManager->DeallocateSurfaceDescriptor(mSD);
     47  mSD = SurfaceDescriptorGPUVideo();
     48 }
     49 
     50 void GPUVideoTextureData::Forget(LayersIPCChannel* aAllocator) {
     51  // We always need to manually deallocate on the client side.
     52  // Ideally we'd set up our TextureClient with the DEALLOCATE_CLIENT
     53  // flag, but that forces texture destruction to be synchronous.
     54  // Instead let's just deallocate from here as well.
     55  Deallocate(aAllocator);
     56 }
     57 
     58 }  // namespace layers
     59 }  // namespace mozilla