1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
android_webview / browser / gfx / output_surface_provider_webview.h [blame]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ANDROID_WEBVIEW_BROWSER_GFX_OUTPUT_SURFACE_PROVIDER_WEBVIEW_H_
#define ANDROID_WEBVIEW_BROWSER_GFX_OUTPUT_SURFACE_PROVIDER_WEBVIEW_H_
#include <memory>
#include "android_webview/browser/gfx/aw_gl_surface.h"
#include "android_webview/common/gfx/aw_gr_context_options_provider.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "components/viz/common/display/renderer_settings.h"
#include "gpu/command_buffer/service/gpu_task_scheduler_helper.h"
#include "gpu/command_buffer/service/shared_context_state.h"
namespace gpu {
class SharedContextState;
}
namespace viz {
class OutputSurface;
}
namespace android_webview {
class AwVulkanContextProvider;
// Effectively a data struct to pass pointers from render thread to viz thread.
//
// Lifetime: WebView
class OutputSurfaceProviderWebView {
public:
explicit OutputSurfaceProviderWebView(
AwVulkanContextProvider* vulkan_context_provider);
~OutputSurfaceProviderWebView();
std::unique_ptr<viz::DisplayCompositorMemoryAndTaskController>
CreateDisplayController();
std::unique_ptr<viz::OutputSurface> CreateOutputSurface(
viz::DisplayCompositorMemoryAndTaskController*
display_compositor_controller);
void MarkAllowContextLoss();
const viz::RendererSettings& renderer_settings() const {
return renderer_settings_;
}
const viz::DebugRendererSettings* debug_settings() const {
return &debug_settings_;
}
scoped_refptr<AwGLSurface> gl_surface() const { return gl_surface_; }
scoped_refptr<gpu::SharedContextState> shared_context_state() const {
return shared_context_state_;
}
private:
void InitializeContext();
const raw_ptr<AwVulkanContextProvider> vulkan_context_provider_;
const std::unique_ptr<AwGrContextOptionsProvider>
aw_gr_context_options_provider_;
// The member variables are effectively const after constructor, so it's safe
// to call accessors on different threads.
viz::RendererSettings renderer_settings_;
viz::DebugRendererSettings debug_settings_;
scoped_refptr<AwGLSurface> gl_surface_;
scoped_refptr<gpu::SharedContextState> shared_context_state_;
bool enable_vulkan_;
raw_ptr<bool> expect_context_loss_ = nullptr;
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_GFX_OUTPUT_SURFACE_PROVIDER_WEBVIEW_H_