gl_in_process_context.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_IPC_GL_IN_PROCESS_CONTEXT_H_
  5. #define GPU_IPC_GL_IN_PROCESS_CONTEXT_H_
  6. #include <memory>
  7. #include "base/task/single_thread_task_runner.h"
  8. #include "gpu/command_buffer/common/context_creation_attribs.h"
  9. #include "gpu/command_buffer/service/command_buffer_task_executor.h"
  10. #include "gpu/ipc/gl_in_process_context_export.h"
  11. #include "gpu/ipc/in_process_command_buffer.h"
  12. #include "ui/gfx/native_widget_types.h"
  13. namespace gpu {
  14. class SharedImageInterface;
  15. class TransferBuffer;
  16. struct GpuFeatureInfo;
  17. struct SharedMemoryLimits;
  18. namespace gles2 {
  19. class GLES2CmdHelper;
  20. class GLES2Implementation;
  21. }
  22. // Wraps everything needed to use an in process GL context.
  23. class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext {
  24. public:
  25. // You must call Initialize() before using the context.
  26. GLInProcessContext();
  27. GLInProcessContext(const GLInProcessContext&) = delete;
  28. GLInProcessContext& operator=(const GLInProcessContext&) = delete;
  29. ~GLInProcessContext();
  30. // Initialize the GLInProcessContext, if |is_offscreen| is true, renders to an
  31. // offscreen context. |attrib_list| must be null or a NONE-terminated list
  32. // of attribute/value pairs.
  33. // If |surface| is not null, then it must match |is_offscreen|,
  34. // |window| must be gfx::kNullAcceleratedWidget, and the command buffer
  35. // service must run on the same thread as this client because GLSurface is
  36. // not thread safe. If |surface| is null, then the other parameters are used
  37. // to correctly create a surface.
  38. ContextResult Initialize(CommandBufferTaskExecutor* task_executor,
  39. const ContextCreationAttribs& attribs,
  40. const SharedMemoryLimits& memory_limits,
  41. ImageFactory* image_factory);
  42. const Capabilities& GetCapabilities() const;
  43. const GpuFeatureInfo& GetGpuFeatureInfo() const;
  44. // Allows direct access to the GLES2 implementation so a GLInProcessContext
  45. // can be used without making it current.
  46. gles2::GLES2Implementation* GetImplementation();
  47. SharedImageInterface* GetSharedImageInterface();
  48. private:
  49. // The destruction order is important, don't reorder these member variables.
  50. std::unique_ptr<InProcessCommandBuffer> command_buffer_;
  51. std::unique_ptr<gles2::GLES2CmdHelper> gles2_helper_;
  52. std::unique_ptr<TransferBuffer> transfer_buffer_;
  53. std::unique_ptr<gles2::GLES2Implementation> gles2_implementation_;
  54. };
  55. } // namespace gpu
  56. #endif // GPU_IPC_GL_IN_PROCESS_CONTEXT_H_