gl_context_stub.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 UI_GL_GL_CONTEXT_STUB_H_
  5. #define UI_GL_GL_CONTEXT_STUB_H_
  6. #include "build/build_config.h"
  7. #include "ui/gl/gl_context.h"
  8. #include "ui/gl/gl_export.h"
  9. namespace gl {
  10. class GLShareGroup;
  11. // A GLContext that does nothing for unit tests.
  12. class GL_EXPORT GLContextStub : public GLContextReal {
  13. public:
  14. GLContextStub();
  15. explicit GLContextStub(GLShareGroup* share_group);
  16. GLContextStub(const GLContextStub&) = delete;
  17. GLContextStub& operator=(const GLContextStub&) = delete;
  18. // Implement GLContext.
  19. bool Initialize(GLSurface* compatible_surface,
  20. const GLContextAttribs& attribs) override;
  21. bool MakeCurrentImpl(GLSurface* surface) override;
  22. void ReleaseCurrent(GLSurface* surface) override;
  23. bool IsCurrent(GLSurface* surface) override;
  24. void* GetHandle() override;
  25. std::string GetGLVersion() override;
  26. std::string GetGLRenderer() override;
  27. unsigned int CheckStickyGraphicsResetStatusImpl() override;
  28. void SetUseStubApi(bool stub_api);
  29. void SetExtensionsString(const char* extensions);
  30. void SetGLVersionString(const char* version_str);
  31. bool HasRobustness();
  32. #if BUILDFLAG(IS_APPLE)
  33. void FlushForDriverCrashWorkaround() override;
  34. #endif
  35. protected:
  36. ~GLContextStub() override;
  37. GLApi* CreateGLApi(DriverGL* driver) override;
  38. private:
  39. bool use_stub_api_;
  40. std::string version_str_;
  41. unsigned int graphics_reset_status_ = 0; // GL_NO_ERROR
  42. };
  43. } // namespace gl
  44. #endif // UI_GL_GL_CONTEXT_STUB_H_