gl_image_egl.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GL_GL_IMAGE_EGL_H_
  5. #define UI_GL_GL_IMAGE_EGL_H_
  6. #include <EGL/eglplatform.h>
  7. #include "base/memory/raw_ptr.h"
  8. #include "base/threading/thread_checker.h"
  9. #include "ui/gl/gl_export.h"
  10. #include "ui/gl/gl_image.h"
  11. namespace gl {
  12. // Abstract base class for EGL-based images.
  13. class GL_EXPORT GLImageEGL : public GLImage {
  14. public:
  15. explicit GLImageEGL(const gfx::Size& size);
  16. GLImageEGL(const GLImageEGL&) = delete;
  17. GLImageEGL& operator=(const GLImageEGL&) = delete;
  18. // Overridden from GLImage:
  19. gfx::Size GetSize() override;
  20. void* GetEGLImage() const override;
  21. BindOrCopy ShouldBindOrCopy() override;
  22. bool BindTexImage(unsigned target) override;
  23. void ReleaseTexImage(unsigned target) override {}
  24. protected:
  25. ~GLImageEGL() override;
  26. // Same semantic as specified for eglCreateImageKHR. There two main usages:
  27. // 1- When using the |target| EGL_GL_TEXTURE_2D_KHR it is required to pass
  28. // a valid |context|. This allows to create an EGLImage from a GL texture.
  29. // Then this EGLImage can be converted to an external resource to be shared
  30. // with other client APIs.
  31. // 2- When using the |target| EGL_NATIVE_PIXMAP_KHR or EGL_LINUX_DMA_BUF_EXT
  32. // it is required to pass EGL_NO_CONTEXT. This allows to create an EGLImage
  33. // from an external resource. Then this EGLImage can be converted to a GL
  34. // texture.
  35. bool Initialize(void* context /* EGLContext */,
  36. unsigned target /* EGLenum */,
  37. void* buffer /* EGLClientBuffer */,
  38. const EGLint* attrs);
  39. raw_ptr<void> egl_image_ /* EGLImageKHR */;
  40. const gfx::Size size_;
  41. base::ThreadChecker thread_checker_;
  42. };
  43. } // namespace gl
  44. #endif // UI_GL_GL_IMAGE_EGL_H_