output_surface_provider_webview.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2019 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 ANDROID_WEBVIEW_BROWSER_GFX_OUTPUT_SURFACE_PROVIDER_WEBVIEW_H_
  5. #define ANDROID_WEBVIEW_BROWSER_GFX_OUTPUT_SURFACE_PROVIDER_WEBVIEW_H_
  6. #include <memory>
  7. #include "android_webview/browser/gfx/aw_gl_surface.h"
  8. #include "base/memory/raw_ptr.h"
  9. #include "base/memory/ref_counted.h"
  10. #include "components/viz/common/display/renderer_settings.h"
  11. #include "gpu/command_buffer/service/gpu_task_scheduler_helper.h"
  12. #include "gpu/command_buffer/service/shared_context_state.h"
  13. namespace gpu {
  14. class SharedContextState;
  15. }
  16. namespace viz {
  17. class OutputSurface;
  18. }
  19. namespace android_webview {
  20. class AwVulkanContextProvider;
  21. // Effectively a data struct to pass pointers from render thread to viz thread.
  22. class OutputSurfaceProviderWebView {
  23. public:
  24. explicit OutputSurfaceProviderWebView(
  25. AwVulkanContextProvider* vulkan_context_provider);
  26. ~OutputSurfaceProviderWebView();
  27. std::unique_ptr<viz::DisplayCompositorMemoryAndTaskController>
  28. CreateDisplayController();
  29. std::unique_ptr<viz::OutputSurface> CreateOutputSurface(
  30. viz::DisplayCompositorMemoryAndTaskController*
  31. display_compositor_controller);
  32. void MarkExpectContextLoss();
  33. const viz::RendererSettings& renderer_settings() const {
  34. return renderer_settings_;
  35. }
  36. const viz::DebugRendererSettings* debug_settings() const {
  37. return &debug_settings_;
  38. }
  39. scoped_refptr<AwGLSurface> gl_surface() const { return gl_surface_; }
  40. scoped_refptr<gpu::SharedContextState> shared_context_state() const {
  41. return shared_context_state_;
  42. }
  43. private:
  44. void InitializeContext();
  45. const raw_ptr<AwVulkanContextProvider> vulkan_context_provider_;
  46. // The member variables are effectively const after constructor, so it's safe
  47. // to call accessors on different threads.
  48. viz::RendererSettings renderer_settings_;
  49. viz::DebugRendererSettings debug_settings_;
  50. scoped_refptr<AwGLSurface> gl_surface_;
  51. scoped_refptr<gpu::SharedContextState> shared_context_state_;
  52. bool enable_vulkan_;
  53. raw_ptr<bool> expect_context_loss_ = nullptr;
  54. };
  55. } // namespace android_webview
  56. #endif // ANDROID_WEBVIEW_BROWSER_GFX_OUTPUT_SURFACE_PROVIDER_WEBVIEW_H_