[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 1 | // Copyright 2014 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 | |||||
5 | #ifndef CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ | ||||
6 | #define CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ | ||||
7 | |||||
8 | #include "base/compiler_specific.h" | ||||
9 | #include "base/memory/ref_counted.h" | ||||
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 10 | #include "components/viz/common/gpu/context_provider.h" |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 11 | #include "content/common/content_export.h" |
12 | #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" | ||||
13 | |||||
danakj | cdf8787 | 2016-03-16 05:22:35 | [diff] [blame] | 14 | namespace gpu { |
15 | namespace gles2 { | ||||
16 | class GLES2Interface; | ||||
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 17 | } // namespace gles2 |
18 | } // namespace gpu | ||||
danakj | cdf8787 | 2016-03-16 05:22:35 | [diff] [blame] | 19 | |
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 20 | namespace ui { |
danakj | 615aac2 | 2016-04-29 21:28:16 | [diff] [blame] | 21 | class ContextProviderCommandBuffer; |
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 22 | } // namespace ui |
23 | |||||
24 | namespace viz { | ||||
25 | class GLHelper; | ||||
26 | } // namespace viz | ||||
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 27 | |
28 | namespace content { | ||||
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 29 | |
30 | class CONTENT_EXPORT WebGraphicsContext3DProviderImpl | ||||
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 31 | : public blink::WebGraphicsContext3DProvider, |
32 | public viz::ContextLostObserver { | ||||
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 33 | public: |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 34 | WebGraphicsContext3DProviderImpl( |
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 35 | scoped_refptr<ui::ContextProviderCommandBuffer> provider, |
danakj | 4dd4395 | 2016-08-23 21:18:39 | [diff] [blame] | 36 | bool software_rendering); |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 37 | ~WebGraphicsContext3DProviderImpl() override; |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 38 | |
39 | // WebGraphicsContext3DProvider implementation. | ||||
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 40 | bool BindToCurrentThread() override; |
41 | gpu::gles2::GLES2Interface* ContextGL() override; | ||||
42 | GrContext* GetGrContext() override; | ||||
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 43 | void InvalidateGrContext(uint32_t state) override; |
Zhenyao Mo | eb86a171 | 2017-10-06 14:17:52 | [diff] [blame] | 44 | const gpu::Capabilities& GetCapabilities() const override; |
45 | const gpu::GpuFeatureInfo& GetGpuFeatureInfo() const override; | ||||
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 46 | viz::GLHelper* GetGLHelper() override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 47 | bool IsSoftwareRendering() const override; |
Yuta Kitamura | d6c13d8e | 2017-12-01 06:09:41 | [diff] [blame] | 48 | void SetLostContextCallback(base::RepeatingClosure) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 49 | void SetErrorMessageCallback( |
Yuta Kitamura | 63b6b3c | 2017-11-27 09:12:58 | [diff] [blame] | 50 | base::RepeatingCallback<void(const char*, int32_t)>) override; |
Yuta Kitamura | 66a7f39 | 2017-11-22 13:07:02 | [diff] [blame] | 51 | void SignalQuery(uint32_t, base::OnceClosure) override; |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 52 | |
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 53 | ui::ContextProviderCommandBuffer* context_provider() const { |
danakj | 615aac2 | 2016-04-29 21:28:16 | [diff] [blame] | 54 | return provider_.get(); |
55 | } | ||||
56 | |||||
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 57 | private: |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 58 | // viz::ContextLostObserver implementation. |
59 | void OnContextLost() override; | ||||
60 | |||||
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 61 | scoped_refptr<ui::ContextProviderCommandBuffer> provider_; |
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 62 | std::unique_ptr<viz::GLHelper> gl_helper_; |
danakj | 4dd4395 | 2016-08-23 21:18:39 | [diff] [blame] | 63 | const bool software_rendering_; |
Yuta Kitamura | d6c13d8e | 2017-12-01 06:09:41 | [diff] [blame] | 64 | base::RepeatingClosure context_lost_callback_; |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 65 | |
66 | DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DProviderImpl); | ||||
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 67 | }; |
68 | |||||
69 | } // namespace content | ||||
70 | |||||
71 | #endif // CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ |