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
android_webview / browser / gfx / aw_draw_fn_impl.h [blame]
// Copyright 2016 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_AW_DRAW_FN_IMPL_H_
#define ANDROID_WEBVIEW_BROWSER_GFX_AW_DRAW_FN_IMPL_H_
#include <optional>
#include "android_webview/browser/gfx/aw_vulkan_context_provider.h"
#include "android_webview/browser/gfx/compositor_frame_consumer.h"
#include "android_webview/browser/gfx/render_thread_manager.h"
#include "android_webview/public/browser/draw_fn.h"
#include "base/android/scoped_java_ref.h"
#include "third_party/skia/include/core/SkRefCnt.h"
namespace android_webview {
// Lifetime: WebView
class AwDrawFnImpl {
public:
// Safe to call even on versions where draw_fn functor is not supported.
static bool IsUsingVulkan();
static void ReportRenderingThreads(int functor,
const pid_t* thread_ids,
size_t size);
AwDrawFnImpl();
AwDrawFnImpl(const AwDrawFnImpl&) = delete;
AwDrawFnImpl& operator=(const AwDrawFnImpl&) = delete;
~AwDrawFnImpl();
void ReleaseHandle(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
jint GetFunctorHandle(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
jlong GetCompositorFrameConsumer(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
int functor_handle() { return functor_handle_; }
void OnSync(AwDrawFn_OnSyncParams* params);
void OnContextDestroyed();
void DrawGL(AwDrawFn_DrawGLParams* params);
void InitVk(AwDrawFn_InitVkParams* params);
void DrawVk(AwDrawFn_DrawVkParams* params);
void PostDrawVk(AwDrawFn_PostDrawVkParams* params);
void RemoveOverlays(AwDrawFn_RemoveOverlaysParams* params);
private:
CompositorFrameConsumer* GetCompositorFrameConsumer() {
return &render_thread_manager_;
}
int functor_handle_;
RenderThreadManager render_thread_manager_;
// Vulkan context provider for Vk rendering.
scoped_refptr<AwVulkanContextProvider> vulkan_context_provider_;
std::optional<AwVulkanContextProvider::ScopedSecondaryCBDraw>
scoped_secondary_cb_draw_;
bool skip_next_post_draw_vk_ = false;
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_GFX_AW_DRAW_FN_IMPL_H_