gles2_command_buffer_stub.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright (c) 2017 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_GLES2_COMMAND_BUFFER_STUB_H_
  5. #define GPU_IPC_SERVICE_GLES2_COMMAND_BUFFER_STUB_H_
  6. #include "base/containers/circular_deque.h"
  7. #include "base/memory/raw_ptr.h"
  8. #include "base/memory/weak_ptr.h"
  9. #include "build/build_config.h"
  10. #include "gpu/ipc/service/command_buffer_stub.h"
  11. #include "gpu/ipc/service/image_transport_surface_delegate.h"
  12. #include "ui/gfx/gpu_fence_handle.h"
  13. namespace gpu {
  14. struct Mailbox;
  15. class GPU_IPC_SERVICE_EXPORT GLES2CommandBufferStub
  16. : public CommandBufferStub,
  17. public ImageTransportSurfaceDelegate,
  18. public base::SupportsWeakPtr<GLES2CommandBufferStub> {
  19. public:
  20. GLES2CommandBufferStub(GpuChannel* channel,
  21. const mojom::CreateCommandBufferParams& init_params,
  22. CommandBufferId command_buffer_id,
  23. SequenceId sequence_id,
  24. int32_t stream_id,
  25. int32_t route_id);
  26. GLES2CommandBufferStub(const GLES2CommandBufferStub&) = delete;
  27. GLES2CommandBufferStub& operator=(const GLES2CommandBufferStub&) = delete;
  28. ~GLES2CommandBufferStub() override;
  29. // This must leave the GL context associated with the newly-created
  30. // CommandBufferStub current, so the GpuChannel can initialize
  31. // the gpu::Capabilities.
  32. gpu::ContextResult Initialize(
  33. CommandBufferStub* share_group,
  34. const mojom::CreateCommandBufferParams& init_params,
  35. base::UnsafeSharedMemoryRegion shared_state_shm) override;
  36. MemoryTracker* GetContextGroupMemoryTracker() const override;
  37. // DecoderClient implementation.
  38. void OnGpuSwitched(gl::GpuPreference active_gpu_heuristic) override;
  39. // ImageTransportSurfaceDelegate implementation:
  40. #if BUILDFLAG(IS_WIN)
  41. void DidCreateAcceleratedSurfaceChildWindow(
  42. SurfaceHandle parent_window,
  43. SurfaceHandle child_window) override;
  44. #endif
  45. const gles2::FeatureInfo* GetFeatureInfo() const override;
  46. const GpuPreferences& GetGpuPreferences() const override;
  47. viz::GpuVSyncCallback GetGpuVSyncCallback() override;
  48. base::TimeDelta GetGpuBlockedTimeSinceLastSwap() override;
  49. private:
  50. // CommandBufferStub overrides:
  51. void OnTakeFrontBuffer(const Mailbox& mailbox) override;
  52. void OnReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override;
  53. void CreateGpuFenceFromHandle(uint32_t id,
  54. gfx::GpuFenceHandle handle) override;
  55. void GetGpuFenceHandle(uint32_t gpu_fence_id,
  56. GetGpuFenceHandleCallback callback) override;
  57. void OnSwapBuffers(uint64_t swap_id, uint32_t flags) override;
  58. // The group of contexts that share namespaces with this context.
  59. scoped_refptr<gles2::ContextGroup> context_group_;
  60. // Keep a more specifically typed reference to the decoder to avoid
  61. // unnecessary casts. Owned by parent class.
  62. raw_ptr<gles2::GLES2Decoder> gles2_decoder_;
  63. base::WeakPtrFactory<GLES2CommandBufferStub> weak_ptr_factory_{this};
  64. };
  65. } // namespace gpu
  66. #endif // GPU_IPC_SERVICE_GLES2_COMMAND_BUFFER_STUB_H_