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 #ifndef MOZILLA_GFX_RENDERCOMPOSITOR_EGL_H
8 #define MOZILLA_GFX_RENDERCOMPOSITOR_EGL_H
9 
10 #include "GLTypes.h"
11 #include "mozilla/webrender/RenderCompositor.h"
12 
13 namespace mozilla {
14 
15 namespace wr {
16 
17 class RenderCompositorEGL : public RenderCompositor {
18  public:
19   static UniquePtr<RenderCompositor> Create(
20       RefPtr<widget::CompositorWidget> aWidget);
21 
22   explicit RenderCompositorEGL(RefPtr<widget::CompositorWidget> aWidget);
23   virtual ~RenderCompositorEGL();
24 
25   bool BeginFrame() override;
26   RenderedFrameId EndFrame(const nsTArray<DeviceIntRect>& aDirtyRects) final;
27   void Pause() override;
28   bool Resume() override;
29 
30   gl::GLContext* gl() const override;
31 
32   bool MakeCurrent() override;
33 
UseANGLE()34   bool UseANGLE() const override { return false; }
35 
36   LayoutDeviceIntSize GetBufferSize() override;
37 
38   CompositorCapabilities GetCompositorCapabilities() override;
39 
40   // Interface for partial present
41   bool UsePartialPresent() override;
42   bool RequestFullRender() override;
43   uint32_t GetMaxPartialPresentRects() override;
44   bool ShouldDrawPreviousPartialPresentRegions() override;
45 
46  protected:
47   EGLSurface CreateEGLSurface();
48 
49   void DestroyEGLSurface();
50 
51   EGLSurface mEGLSurface;
52 #ifdef MOZ_WIDGET_ANDROID
53   // On android we must track our own surface size.
54   LayoutDeviceIntSize mEGLSurfaceSize;
55 #endif
56 
57   EGLint mBufferAge;
58 };
59 
60 }  // namespace wr
61 }  // namespace mozilla
62 
63 #endif  // MOZILLA_GFX_RENDERCOMPOSITOR_EGL_H
64