forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaw_render_thread_context_provider.h
84 lines (65 loc) · 2.74 KB
/
aw_render_thread_context_provider.h
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
76
77
78
79
80
81
82
83
84
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ANDROID_WEBVIEW_BROWSER_AW_RENDER_THREAD_CONTEXT_PROVIDER_H_
#define ANDROID_WEBVIEW_BROWSER_AW_RENDER_THREAD_CONTEXT_PROVIDER_H_
#include <stdint.h>
#include <memory>
#include "base/macros.h"
#include "base/observer_list.h"
#include "base/threading/thread_checker.h"
#include "components/viz/common/gpu/context_provider.h"
#include "gpu/ipc/in_process_command_buffer.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/gpu/GrContext.h"
namespace gl {
class GLSurface;
}
namespace gpu {
class GLInProcessContext;
namespace gles2 {
class GLES2TraceImplementation;
} // namespace gles2
} // namespace gpu
namespace android_webview {
class AwRenderThreadContextProvider
: public base::RefCountedThreadSafe<AwRenderThreadContextProvider>,
public viz::ContextProvider {
public:
static scoped_refptr<AwRenderThreadContextProvider> Create(
scoped_refptr<gl::GLSurface> surface,
scoped_refptr<gpu::InProcessCommandBuffer::Service> service);
// Gives the GL internal format that should be used for calling CopyTexImage2D
// on the default framebuffer.
uint32_t GetCopyTextureInternalFormat();
// viz::ContextProvider implementation.
void AddRef() const override;
void Release() const override;
gpu::ContextResult BindToCurrentThread() override;
const gpu::Capabilities& ContextCapabilities() const override;
const gpu::GpuFeatureInfo& GetGpuFeatureInfo() const override;
gpu::gles2::GLES2Interface* ContextGL() override;
gpu::ContextSupport* ContextSupport() override;
class GrContext* GrContext() override;
viz::ContextCacheController* CacheController() override;
base::Lock* GetLock() override;
void AddObserver(viz::ContextLostObserver* obs) override;
void RemoveObserver(viz::ContextLostObserver* obs) override;
protected:
friend class base::RefCountedThreadSafe<AwRenderThreadContextProvider>;
AwRenderThreadContextProvider(
scoped_refptr<gl::GLSurface> surface,
scoped_refptr<gpu::InProcessCommandBuffer::Service> service);
~AwRenderThreadContextProvider() override;
private:
void OnLostContext();
base::ThreadChecker main_thread_checker_;
std::unique_ptr<gpu::GLInProcessContext> context_;
std::unique_ptr<gpu::gles2::GLES2TraceImplementation> trace_impl_;
sk_sp<class GrContext> gr_context_;
std::unique_ptr<viz::ContextCacheController> cache_controller_;
base::ObserverList<viz::ContextLostObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(AwRenderThreadContextProvider);
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_AW_RENDER_THREAD_CONTEXT_PROVIDER_H_