gl_image_native_pixmap.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2016 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_NATIVE_PIXMAP_H_
  5. #define UI_GL_GL_IMAGE_NATIVE_PIXMAP_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include "ui/gfx/native_pixmap.h"
  9. #include "ui/gl/gl_export.h"
  10. #include "ui/gl/gl_image_egl.h"
  11. namespace gl {
  12. class GL_EXPORT GLImageNativePixmap : public gl::GLImageEGL {
  13. public:
  14. GLImageNativePixmap(const gfx::Size& size,
  15. gfx::BufferFormat format,
  16. gfx::BufferPlane plane = gfx::BufferPlane::DEFAULT);
  17. // Create an EGLImage from a given NativePixmap.
  18. bool Initialize(scoped_refptr<gfx::NativePixmap> pixmap);
  19. bool InitializeForOverlay(scoped_refptr<gfx::NativePixmap> pixmap);
  20. // Create an EGLImage from a given GL texture.
  21. bool InitializeFromTexture(uint32_t texture_id);
  22. // Export the wrapped EGLImage to dmabuf fds.
  23. gfx::NativePixmapHandle ExportHandle();
  24. // Overridden from GLImage:
  25. unsigned GetInternalFormat() override;
  26. unsigned GetDataType() override;
  27. bool BindTexImage(unsigned target) override;
  28. bool CopyTexImage(unsigned target) override;
  29. bool CopyTexSubImage(unsigned target,
  30. const gfx::Point& offset,
  31. const gfx::Rect& rect) override;
  32. void Flush() override;
  33. void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
  34. uint64_t process_tracing_id,
  35. const std::string& dump_name) override;
  36. scoped_refptr<gfx::NativePixmap> GetNativePixmap() override;
  37. protected:
  38. ~GLImageNativePixmap() override;
  39. private:
  40. gfx::BufferFormat format_;
  41. scoped_refptr<gfx::NativePixmap> pixmap_;
  42. gfx::BufferPlane plane_;
  43. bool has_image_flush_external_;
  44. bool has_image_dma_buf_export_;
  45. bool did_initialize_;
  46. };
  47. } // namespace gl
  48. #endif // UI_GL_GL_IMAGE_NATIVE_PIXMAP_H_