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 #ifndef MOZILLA_GFX_RENDERCOMPOSITOR_SWGL_H
8 #define MOZILLA_GFX_RENDERCOMPOSITOR_SWGL_H
10 #include "mozilla/gfx/2D.h"
11 #include "mozilla/webrender/RenderCompositor.h"
17 class RenderCompositorSWGL
: public RenderCompositor
{
19 static UniquePtr
<RenderCompositor
> Create(
20 RefPtr
<widget::CompositorWidget
>&& aWidget
, nsACString
& aError
);
22 RenderCompositorSWGL(RefPtr
<widget::CompositorWidget
>&& aWidget
,
24 virtual ~RenderCompositorSWGL();
26 void* swgl() const override
{ return mContext
; }
28 bool MakeCurrent() override
;
30 bool BeginFrame() override
;
31 void CancelFrame() override
;
32 RenderedFrameId
EndFrame(const nsTArray
<DeviceIntRect
>& aDirtyRects
) final
;
34 bool UsePartialPresent() override
{ return true; }
36 void Pause() override
;
37 bool Resume() override
;
39 layers::WebRenderBackend
BackendType() const override
{
40 return layers::WebRenderBackend::SOFTWARE
;
42 layers::WebRenderCompositor
CompositorType() const override
{
43 return layers::WebRenderCompositor::SOFTWARE
;
46 bool SurfaceOriginIsTopLeft() override
{ return true; }
48 LayoutDeviceIntSize
GetBufferSize() override
;
50 bool SupportsExternalBufferTextures() const override
{ return true; }
52 // Interface for wr::Compositor
53 CompositorCapabilities
GetCompositorCapabilities() override
;
56 void* mContext
= nullptr;
57 RefPtr
<gfx::DrawTarget
> mDT
;
58 LayoutDeviceIntRegion mRegion
;
59 RefPtr
<gfx::DataSourceSurface
> mSurface
;
60 uint8_t* mMappedData
= nullptr;
61 int32_t mMappedStride
= 0;
63 void ClearMappedBuffer();
65 void CommitMappedBuffer();
69 } // namespace mozilla