#pragma once
#if ENABLE(WEBXR)
#include "ExceptionOr.h"
#include "WebXRLayer.h"
#include <wtf/IsoMalloc.h>
#include <wtf/Ref.h>
#include <wtf/RefPtr.h>
#include <wtf/Variant.h>
namespace WebCore {
class IntSize;
class WebGLFramebuffer;
class WebGLRenderingContext;
#if ENABLE(WEBGL2)
class WebGL2RenderingContext;
#endif
class WebXRSession;
class WebXRView;
class WebXRViewport;
struct XRWebGLLayerInit;
class WebXRWebGLLayer : public WebXRLayer {
WTF_MAKE_ISO_ALLOCATED(WebXRWebGLLayer);
public:
using WebXRRenderingContext = WTF::Variant<
RefPtr<WebGLRenderingContext>
#if ENABLE(WEBGL2)
, RefPtr<WebGL2RenderingContext>
#endif
>;
static ExceptionOr<Ref<WebXRWebGLLayer>> create(Ref<WebXRSession>&&, WebXRRenderingContext&&, const XRWebGLLayerInit&);
~WebXRWebGLLayer();
bool antialias() const;
bool ignoreDepthValues() const;
WebGLFramebuffer* framebuffer() const;
unsigned framebufferWidth() const;
unsigned framebufferHeight() const;
RefPtr<WebXRViewport> getViewport(const WebXRView&);
static double getNativeFramebufferScaleFactor(const WebXRSession&);
const WebXRSession& session() { return m_session; }
private:
WebXRWebGLLayer(Ref<WebXRSession>&&, WebXRRenderingContext&&, const XRWebGLLayerInit&);
static IntSize computeNativeWebGLFramebufferResolution();
static IntSize computeRecommendedWebGLFramebufferResolution();
Ref<WebXRSession> m_session;
WebXRRenderingContext m_context;
bool m_antialias { false };
bool m_ignoreDepthValues { false };
bool m_isCompositionDisabled { false };
struct {
RefPtr<WebGLFramebuffer> object;
unsigned width { 0 };
unsigned height { 0 };
} m_framebuffer;
};
}
#endif // ENABLE(WEBXR)