From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- gfx/webrender_bindings/RenderCompositorD3D11SWGL.h | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 gfx/webrender_bindings/RenderCompositorD3D11SWGL.h (limited to 'gfx/webrender_bindings/RenderCompositorD3D11SWGL.h') diff --git a/gfx/webrender_bindings/RenderCompositorD3D11SWGL.h b/gfx/webrender_bindings/RenderCompositorD3D11SWGL.h new file mode 100644 index 0000000000..2365230f66 --- /dev/null +++ b/gfx/webrender_bindings/RenderCompositorD3D11SWGL.h @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef MOZILLA_GFX_RENDERCOMPOSITOR_D3D11_H +#define MOZILLA_GFX_RENDERCOMPOSITOR_D3D11_H + +#include "mozilla/gfx/2D.h" +#include "mozilla/layers/ScreenshotGrabber.h" +#include "mozilla/layers/TextureD3D11.h" +#include "mozilla/layers/CompositorD3D11.h" +#include "mozilla/webrender/RenderCompositorLayersSWGL.h" + +namespace mozilla { + +namespace wr { + +class SurfaceD3D11SWGL; + +class RenderCompositorD3D11SWGL : public RenderCompositorLayersSWGL { + public: + static UniquePtr Create( + const RefPtr& aWidget, nsACString& aError); + + RenderCompositorD3D11SWGL(layers::CompositorD3D11* aCompositor, + const RefPtr& aWidget, + void* aContext); + virtual ~RenderCompositorD3D11SWGL(); + + void Pause() override; + bool Resume() override; + + GLenum IsContextLost(bool aForce) override; + + layers::WebRenderCompositor CompositorType() const override { + return layers::WebRenderCompositor::D3D11; + } + RenderCompositorD3D11SWGL* AsRenderCompositorD3D11SWGL() override { + return this; + } + + bool BeginFrame() override; + + bool MaybeReadback(const gfx::IntSize& aReadbackSize, + const wr::ImageFormat& aReadbackFormat, + const Range& aReadbackBuffer, + bool* aNeedsYFlip) override; + + layers::CompositorD3D11* GetCompositorD3D11() { + return mCompositor->AsCompositorD3D11(); + } + + ID3D11Device* GetDevice() { return GetCompositorD3D11()->GetDevice(); } + + private: + already_AddRefed CreateStagingTexture( + const gfx::IntSize aSize); + already_AddRefed CreateStagingSurface( + const gfx::IntSize aSize); + + void HandleExternalImage(RenderTextureHost* aExternalImage, + FrameSurface& aFrameSurface) override; + UniquePtr DoCreateSurface( + wr::DeviceIntSize aTileSize, bool aIsOpaque) override; + UniquePtr DoCreateTile( + Surface* aSurface) override; + + class TileD3D11 : public RenderCompositorLayersSWGL::Tile { + public: + TileD3D11(layers::DataTextureSourceD3D11* aTexture, + ID3D11Texture2D* aStagingTexture, + gfx::DataSourceSurface* aDataSourceSurface, Surface* aOwner, + RenderCompositorD3D11SWGL* aRenderCompositor); + virtual ~TileD3D11() {} + + bool Map(wr::DeviceIntRect aDirtyRect, wr::DeviceIntRect aValidRect, + void** aData, int32_t* aStride) override; + void Unmap(const gfx::IntRect& aDirtyRect) override; + layers::DataTextureSource* GetTextureSource() override { return mTexture; } + bool IsValid() override; + + private: + RefPtr mTexture; + RefPtr mStagingTexture; + RefPtr mSurface; + SurfaceD3D11SWGL* mOwner; + RenderCompositorD3D11SWGL* mRenderCompositor; + }; + + enum UploadMode { + Upload_Immediate, + Upload_Staging, + Upload_StagingNoBlock, + Upload_StagingPooled + }; + UploadMode GetUploadMode(); + UploadMode mUploadMode = Upload_Staging; + + RefPtr mCurrentStagingTexture; + bool mCurrentStagingTextureIsTemp = false; +}; + +class SurfaceD3D11SWGL : public RenderCompositorLayersSWGL::Surface { + public: + SurfaceD3D11SWGL(wr::DeviceIntSize aTileSize, bool aIsOpaque); + virtual ~SurfaceD3D11SWGL() {} + + SurfaceD3D11SWGL* AsSurfaceD3D11SWGL() override { return this; } + + nsTArray> mStagingPool; +}; + +} // namespace wr +} // namespace mozilla + +#endif -- cgit v1.2.3