Bug 1874684 - Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet
[gecko.git] / gfx / webrender_bindings / RenderCompositorOGLSWGL.h
blob7752574311bf0096bae39a4dff2d7aeb78d209f5
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_OGL_SWGL_H
8 #define MOZILLA_GFX_RENDERCOMPOSITOR_OGL_SWGL_H
10 #include "mozilla/layers/Compositor.h"
11 #include "mozilla/webrender/RenderCompositorLayersSWGL.h"
13 namespace mozilla {
15 namespace layers {
16 class TextureImageTextureSourceOGL;
19 namespace wr {
21 class RenderCompositorOGLSWGL : public RenderCompositorLayersSWGL {
22 public:
23 static UniquePtr<RenderCompositor> Create(
24 const RefPtr<widget::CompositorWidget>& aWidget, nsACString& aError);
26 RenderCompositorOGLSWGL(layers::Compositor* aCompositor,
27 const RefPtr<widget::CompositorWidget>& aWidget,
28 void* aContext);
29 virtual ~RenderCompositorOGLSWGL();
31 gl::GLContext* GetGLContext();
33 bool MakeCurrent() override;
35 bool BeginFrame() override;
36 RenderedFrameId EndFrame(const nsTArray<DeviceIntRect>& aDirtyRects) override;
38 void GetCompositorCapabilities(CompositorCapabilities* aCaps) override;
40 // Returns true for requesting rendering during readback.
41 // RenderCompositorOGLSWGL::MaybeReadback() requests rendering.
42 // This value is not used by WebRender, since native compositor API is used
43 // for sw-wr.
44 bool UsePartialPresent() override { return true; }
45 bool RequestFullRender() override;
47 void Pause() override;
48 bool Resume() override;
49 bool IsPaused() override;
51 LayoutDeviceIntSize GetBufferSize() override;
53 layers::WebRenderCompositor CompositorType() const override {
54 return layers::WebRenderCompositor::OPENGL;
57 bool MaybeReadback(const gfx::IntSize& aReadbackSize,
58 const wr::ImageFormat& aReadbackFormat,
59 const Range<uint8_t>& aReadbackBuffer,
60 bool* aNeedsYFlip) override;
62 private:
63 void HandleExternalImage(RenderTextureHost* aExternalImage,
64 FrameSurface& aFrameSurface) override;
65 UniquePtr<RenderCompositorLayersSWGL::Tile> DoCreateTile(
66 Surface* aSurface) override;
68 EGLSurface CreateEGLSurface();
69 void DestroyEGLSurface();
71 EGLSurface mEGLSurface = EGL_NO_SURFACE;
72 bool mFullRender = false;
74 #ifdef MOZ_WIDGET_ANDROID
75 // Whether we are in the process of handling a NEW_SURFACE error. On Android
76 // this is used to allow the widget an opportunity to recover from the first
77 // instance, before raising a WebRenderError on subsequent occurences.
78 bool mHandlingNewSurfaceError = false;
79 #endif
81 class TileOGL : public RenderCompositorLayersSWGL::Tile {
82 public:
83 TileOGL(RefPtr<layers::TextureImageTextureSourceOGL>&& aTexture,
84 const gfx::IntSize& aSize);
85 virtual ~TileOGL();
87 bool Map(wr::DeviceIntRect aDirtyRect, wr::DeviceIntRect aValidRect,
88 void** aData, int32_t* aStride) override;
89 void Unmap(const gfx::IntRect& aDirtyRect) override;
90 layers::DataTextureSource* GetTextureSource() override;
91 bool IsValid() override { return true; }
93 private:
94 RefPtr<layers::TextureImageTextureSourceOGL> mTexture;
95 RefPtr<gfx::DataSourceSurface> mSurface;
96 RefPtr<gfx::DataSourceSurface> mSubSurface;
97 GLuint mPBO = 0;
101 } // namespace wr
102 } // namespace mozilla
104 #endif