RenderCompositorEGL.h (2470B)
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 const RefPtr<widget::CompositorWidget>& aWidget, nsACString& aError); 21 22 explicit RenderCompositorEGL(const RefPtr<widget::CompositorWidget>& aWidget, 23 RefPtr<gl::GLContext>&& aGL); 24 virtual ~RenderCompositorEGL(); 25 26 bool BeginFrame() override; 27 RenderedFrameId EndFrame(const nsTArray<DeviceIntRect>& aDirtyRects) final; 28 void Pause() override; 29 bool Resume() override; 30 bool IsPaused() override; 31 32 gl::GLContext* gl() const override { return mGL; } 33 34 bool MakeCurrent() override; 35 36 bool UseANGLE() const override { return false; } 37 38 LayoutDeviceIntSize GetBufferSize() 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 size_t GetBufferAge() const override; 46 void SetBufferDamageRegion(const wr::DeviceIntRect* aRects, 47 size_t aNumRects) override; 48 49 RefPtr<layers::Fence> GetAndResetReleaseFence() override; 50 51 protected: 52 EGLSurface CreateEGLSurface(); 53 54 void DestroyEGLSurface(); 55 56 RefPtr<gl::GLContext> mGL; 57 58 EGLSurface mEGLSurface; 59 60 // Whether we are in the process of handling a NEW_SURFACE error. On Android 61 // this is used to allow the widget an opportunity to recover from the first 62 // instance, before raising a WebRenderError on subsequent occurences. 63 bool mHandlingNewSurfaceError = false; 64 65 // FileDescriptor of release fence. 66 // Release fence is a fence that is used for waiting until usage/composite of 67 // AHardwareBuffer is ended. The fence is delivered to client side via 68 // ImageBridge. It is used only on android. 69 RefPtr<layers::Fence> mReleaseFence; 70 }; 71 72 } // namespace wr 73 } // namespace mozilla 74 75 #endif // MOZILLA_GFX_RENDERCOMPOSITOR_EGL_H