#ifndef UI_GL_EGL_SURFACE_IO_SURFACE_H_
#define UI_GL_EGL_SURFACE_IO_SURFACE_H_
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <IOSurface/IOSurfaceRef.h>
#include <memory>
#include "components/viz/common/resources/shared_image_format.h"
#include "ui/gl/gl_export.h"
namespace gl {
class GL_EXPORT ScopedEGLSurfaceIOSurface {
public:
static std::unique_ptr<ScopedEGLSurfaceIOSurface> Create(
EGLDisplay display,
unsigned gl_target,
IOSurfaceRef io_surface,
uint32_t plane,
viz::SharedImageFormat format);
~ScopedEGLSurfaceIOSurface();
bool BindTexImage();
void ReleaseTexImage();
EGLDisplay GetDisplay() { return display_; }
private:
explicit ScopedEGLSurfaceIOSurface(EGLDisplay display);
bool ValidateTarget(unsigned target) const;
bool CreatePBuffer(IOSurfaceRef io_surface,
uint32_t plane,
viz::SharedImageFormat format);
void DestroyPBuffer();
EGLDisplay display_ = nullptr;
EGLConfig dummy_config_ = EGL_NO_CONFIG_KHR;
EGLint texture_target_ = EGL_NO_TEXTURE;
EGLSurface pbuffer_ = EGL_NO_SURFACE;
bool texture_bound_ = false;
};
}
#endif