gpu_channel_manager_delegate.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_DELEGATE_H_
  5. #define GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_DELEGATE_H_
  6. #include "build/build_config.h"
  7. #include "gpu/command_buffer/common/constants.h"
  8. #include "gpu/config/gpu_info.h"
  9. #include "gpu/ipc/common/gpu_disk_cache_type.h"
  10. #include "gpu/ipc/common/surface_handle.h"
  11. #include "gpu/ipc/service/display_context.h"
  12. class GURL;
  13. namespace gpu {
  14. // TODO(kylechar): Rename this class. It's used to provide GpuServiceImpl
  15. // functionality to multiple classes in src/gpu/ so delegate is inaccurate.
  16. class GpuChannelManagerDelegate {
  17. public:
  18. // Registers/unregistered display compositor contexts that don't have a GPU
  19. // channel and aren't tracked by GpuChannelManager.
  20. virtual void RegisterDisplayContext(DisplayContext* display_context) = 0;
  21. virtual void UnregisterDisplayContext(DisplayContext* display_context) = 0;
  22. // Force the loss of all GL contexts.
  23. virtual void LoseAllContexts() = 0;
  24. // Called on any successful context creation.
  25. virtual void DidCreateContextSuccessfully() = 0;
  26. // Tells the delegate that an offscreen context was created for the provided
  27. // |active_url|.
  28. virtual void DidCreateOffscreenContext(const GURL& active_url) = 0;
  29. // Notification from GPU that the channel is destroyed.
  30. virtual void DidDestroyChannel(int client_id) = 0;
  31. // Notification that all GPU channels are shutdown properly.
  32. // Note this is NOT called in error conditions such as losing channel due to
  33. // context loss, or from debug messages.
  34. virtual void DidDestroyAllChannels() = 0;
  35. // Tells the delegate that an offscreen context was destroyed for the provided
  36. // |active_url|.
  37. virtual void DidDestroyOffscreenContext(const GURL& active_url) = 0;
  38. // Tells the delegate that a context was lost.
  39. virtual void DidLoseContext(bool offscreen,
  40. error::ContextLostReason reason,
  41. const GURL& active_url) = 0;
  42. // Tells the delegate to cache the given blob information in persistent
  43. // storage. The embedder is expected to repopulate the in-memory cache through
  44. // the respective GpuChannelManager API.
  45. virtual void StoreBlobToDisk(const gpu::GpuDiskCacheHandle& handle,
  46. const std::string& key,
  47. const std::string& shader) = 0;
  48. // Cleanly exits the GPU process in response to an error. This will not exit
  49. // with in-process GPU as that would also exit the browser. This can only be
  50. // called from the GPU thread.
  51. virtual void MaybeExitOnContextLost() = 0;
  52. // Returns true if the GPU process is exiting. This can be called from any
  53. // thread.
  54. virtual bool IsExiting() const = 0;
  55. // Returns GPU Scheduler
  56. virtual gpu::Scheduler* GetGpuScheduler() = 0;
  57. #if BUILDFLAG(IS_WIN)
  58. // Tells the delegate that |child_window| was created in the GPU process and
  59. // to send an IPC to make SetParent() syscall. This syscall is blocked by the
  60. // GPU sandbox and must be made in the browser process.
  61. virtual void SendCreatedChildWindow(SurfaceHandle parent_window,
  62. SurfaceHandle child_window) = 0;
  63. #endif
  64. protected:
  65. virtual ~GpuChannelManagerDelegate() = default;
  66. };
  67. } // namespace gpu
  68. #endif // GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_DELEGATE_H_