display.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Copyright (c) 2012 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 GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_
  5. #define GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_
  6. #include <EGL/egl.h>
  7. #include <stddef.h>
  8. #include <stdint.h>
  9. #include <memory>
  10. #include <vector>
  11. #include "base/memory/ref_counted.h"
  12. #include "base/synchronization/lock.h"
  13. namespace gles2_conform_support::egl {
  14. class Config;
  15. class Context;
  16. class Surface;
  17. class ThreadState;
  18. class Display {
  19. public:
  20. explicit Display();
  21. Display(const Display&) = delete;
  22. Display& operator=(const Display&) = delete;
  23. ~Display();
  24. bool is_initialized() const { return is_initialized_; }
  25. void ReleaseCurrentForReleaseThread(ThreadState*);
  26. // A function for windowless GTF tests.
  27. void SetNextCreateWindowSurfaceCreatesPBuffer(EGLint width, EGLint height);
  28. EGLBoolean Initialize(ThreadState* ts, EGLint* major, EGLint* minor);
  29. EGLBoolean Terminate(ThreadState* ts);
  30. const char* QueryString(ThreadState* ts, EGLint name);
  31. // Config routines.
  32. EGLBoolean GetConfigAttrib(ThreadState* ts,
  33. EGLConfig cfg,
  34. EGLint attribute,
  35. EGLint* value);
  36. EGLBoolean ChooseConfig(ThreadState* ts,
  37. const EGLint* attrib_list,
  38. EGLConfig* configs,
  39. EGLint config_size,
  40. EGLint* num_config);
  41. EGLBoolean GetConfigs(ThreadState*,
  42. EGLConfig*,
  43. EGLint config_size,
  44. EGLint* num_config);
  45. // Surface routines.
  46. static bool IsValidNativeWindow(EGLNativeWindowType);
  47. EGLSurface CreatePbufferSurface(ThreadState*,
  48. EGLConfig,
  49. const EGLint* attrib_list);
  50. EGLSurface CreateWindowSurface(ThreadState*,
  51. EGLConfig,
  52. EGLNativeWindowType win,
  53. const EGLint* attrib_list);
  54. EGLBoolean DestroySurface(ThreadState*, EGLSurface);
  55. EGLBoolean SwapBuffers(ThreadState*, EGLSurface);
  56. // Context routines.
  57. EGLContext CreateContext(ThreadState*,
  58. EGLConfig,
  59. EGLSurface share_ctx,
  60. const EGLint* attrib_list);
  61. EGLBoolean DestroyContext(ThreadState*, EGLContext);
  62. EGLBoolean ReleaseCurrent(ThreadState*);
  63. EGLBoolean MakeCurrent(ThreadState*, EGLSurface, EGLSurface, EGLContext);
  64. uint64_t GenerateFenceSyncRelease();
  65. private:
  66. void InitializeConfigsIfNeeded();
  67. const Config* GetConfig(EGLConfig);
  68. Surface* GetSurface(EGLSurface);
  69. Context* GetContext(EGLContext);
  70. EGLSurface DoCreatePbufferSurface(ThreadState* ts,
  71. const Config* config,
  72. EGLint width,
  73. EGLint height);
  74. base::Lock lock_;
  75. bool is_initialized_;
  76. uint64_t next_fence_sync_release_;
  77. std::vector<scoped_refptr<Surface>> surfaces_;
  78. std::vector<scoped_refptr<Context>> contexts_;
  79. std::unique_ptr<Config> configs_[2];
  80. // GTF windowless support.
  81. bool next_create_window_surface_creates_pbuffer_;
  82. EGLint window_surface_pbuffer_width_;
  83. EGLint window_surface_pbuffer_height_;
  84. };
  85. } // namespace gles2_conform_support::egl
  86. #endif // GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_