diff options
Diffstat (limited to 'gfx/webrender_bindings/RenderCompositorSWGL.h')
-rw-r--r-- | gfx/webrender_bindings/RenderCompositorSWGL.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/gfx/webrender_bindings/RenderCompositorSWGL.h b/gfx/webrender_bindings/RenderCompositorSWGL.h new file mode 100644 index 0000000000..b0f53520e0 --- /dev/null +++ b/gfx/webrender_bindings/RenderCompositorSWGL.h @@ -0,0 +1,79 @@ +/* -*- 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_SWGL_H +#define MOZILLA_GFX_RENDERCOMPOSITOR_SWGL_H + +#include "mozilla/gfx/2D.h" +#include "mozilla/webrender/RenderCompositor.h" + +namespace mozilla { + +namespace wr { + +class RenderCompositorSWGL : public RenderCompositor { + public: + static UniquePtr<RenderCompositor> Create( + RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError); + + RenderCompositorSWGL(RefPtr<widget::CompositorWidget>&& aWidget, + void* aContext); + virtual ~RenderCompositorSWGL(); + + void* swgl() const override { return mContext; } + + bool MakeCurrent() override; + + bool BeginFrame() override; + void CancelFrame() override; + RenderedFrameId EndFrame(const nsTArray<DeviceIntRect>& aDirtyRects) final; + + void StartCompositing(const wr::DeviceIntRect* aDirtyRects, + size_t aNumDirtyRects, + const wr::DeviceIntRect* aOpaqueRects, + size_t aNumOpaqueRects) override; + + bool UsePartialPresent() override { return true; } + + void Pause() override; + bool Resume() override; + + layers::WebRenderBackend BackendType() const override { + return layers::WebRenderBackend::SOFTWARE; + } + layers::WebRenderCompositor CompositorType() const override { + return layers::WebRenderCompositor::SOFTWARE; + } + + bool SurfaceOriginIsTopLeft() override { return true; } + + LayoutDeviceIntSize GetBufferSize() override; + + bool SupportsExternalBufferTextures() const override { return true; } + + // Interface for wr::Compositor + CompositorCapabilities GetCompositorCapabilities() override; + + private: + void* mContext = nullptr; + RefPtr<gfx::DrawTarget> mDT; + LayoutDeviceIntRegion mRegion; + RefPtr<gfx::DataSourceSurface> mSurface; + uint8_t* mMappedData = nullptr; + int32_t mMappedStride = 0; + + void ClearMappedBuffer(); + + bool AllocateMappedBuffer(const wr::DeviceIntRect* aOpaqueRects, + size_t aNumOpaqueRects); + + void CommitMappedBuffer(bool aDirty = true); +}; + +} // namespace wr +} // namespace mozilla + +#endif |