[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" |
Reza.Zakerinasab | 9afecdf | 2018-09-25 11:26:26 | [diff] [blame] | 9 | #include "base/containers/flat_map.h" |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 11 | #include "components/viz/common/gpu/context_provider.h" |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 12 | #include "content/common/content_export.h" |
Nathan Zabriskie | 0db1d9e41 | 2019-11-19 00:55:17 | [diff] [blame] | 13 | #include "gpu/command_buffer/client/gles2_interface.h" |
| 14 | #include "gpu/command_buffer/client/raster_interface.h" |
| 15 | #include "gpu/command_buffer/client/webgpu_interface.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 16 | #include "third_party/blink/public/platform/web_graphics_context_3d_provider.h" |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 17 | |
Khushal | 60916ba | 2018-01-19 19:47:47 | [diff] [blame] | 18 | namespace cc { |
| 19 | class ImageDecodeCache; |
| 20 | } // namespace cc |
| 21 | |
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 22 | namespace viz { |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 23 | class ContextProviderCommandBuffer; |
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 24 | } // namespace viz |
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 25 | |
Nathan Zabriskie | 92461a0 | 2020-02-06 20:44:27 | [diff] [blame] | 26 | namespace gpu { |
| 27 | class GLHelper; |
| 28 | } // namespace gpu |
| 29 | |
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 30 | namespace content { |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 31 | |
| 32 | class CONTENT_EXPORT WebGraphicsContext3DProviderImpl |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 33 | : public blink::WebGraphicsContext3DProvider, |
| 34 | public viz::ContextLostObserver { |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 35 | public: |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 36 | WebGraphicsContext3DProviderImpl( |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 37 | scoped_refptr<viz::ContextProviderCommandBuffer> provider); |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 38 | ~WebGraphicsContext3DProviderImpl() override; |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 39 | |
| 40 | // WebGraphicsContext3DProvider implementation. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 41 | bool BindToCurrentThread() override; |
Nathan Zabriskie | 0db1d9e41 | 2019-11-19 00:55:17 | [diff] [blame] | 42 | gpu::InterfaceBase* InterfaceBase() override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 43 | gpu::gles2::GLES2Interface* ContextGL() override; |
Nathan Zabriskie | 95fc6d2 | 2019-10-30 22:09:12 | [diff] [blame] | 44 | gpu::raster::RasterInterface* RasterInterface() override; |
Kai Ninomiya | 05c1050 | 2018-08-30 20:06:21 | [diff] [blame] | 45 | gpu::webgpu::WebGPUInterface* WebGPUInterface() override; |
Stephen White | 9bd12b6a | 2020-04-28 00:11:24 | [diff] [blame] | 46 | bool IsContextLost() override; |
Robert Phillips | dbb0b7d | 2020-07-29 16:07:44 | [diff] [blame] | 47 | GrDirectContext* GetGrContext() override; |
Zhenyao Mo | eb86a171 | 2017-10-06 14:17:52 | [diff] [blame] | 48 | const gpu::Capabilities& GetCapabilities() const override; |
| 49 | const gpu::GpuFeatureInfo& GetGpuFeatureInfo() const override; |
Zhenyao Mo | 8963f02 | 2019-05-30 22:10:51 | [diff] [blame] | 50 | const blink::WebglPreferences& GetWebglPreferences() const override; |
Nathan Zabriskie | 92461a0 | 2020-02-06 20:44:27 | [diff] [blame] | 51 | gpu::GLHelper* GetGLHelper() override; |
Yuta Kitamura | d6c13d8e | 2017-12-01 06:09:41 | [diff] [blame] | 52 | void SetLostContextCallback(base::RepeatingClosure) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 53 | void SetErrorMessageCallback( |
Yuta Kitamura | 63b6b3c | 2017-11-27 09:12:58 | [diff] [blame] | 54 | base::RepeatingCallback<void(const char*, int32_t)>) override; |
Eric Karl | eae2706 | 2019-05-23 18:57:55 | [diff] [blame] | 55 | cc::ImageDecodeCache* ImageDecodeCache(SkColorType color_type) override; |
Saman Sami | f672c29 | 2019-01-29 17:43:20 | [diff] [blame] | 56 | gpu::SharedImageInterface* SharedImageInterface() override; |
Miyoung Shin | ccbe3323 | 2019-06-19 04:14:30 | [diff] [blame] | 57 | void CopyVideoFrame(media::PaintCanvasVideoRenderer* video_render, |
| 58 | media::VideoFrame* video_frame, |
| 59 | cc::PaintCanvas* canvas) override; |
Dan Sanders | 3b04f4d | 2020-12-05 01:12:44 | [diff] [blame] | 60 | viz::RasterContextProvider* RasterContextProvider() const override; |
danakj | 615aac2 | 2016-04-29 21:28:16 | [diff] [blame] | 61 | |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 62 | private: |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 63 | // viz::ContextLostObserver implementation. |
| 64 | void OnContextLost() override; |
| 65 | |
Scott Violet | 703b824 | 2019-06-11 19:34:36 | [diff] [blame] | 66 | scoped_refptr<viz::ContextProviderCommandBuffer> provider_; |
Nathan Zabriskie | 92461a0 | 2020-02-06 20:44:27 | [diff] [blame] | 67 | std::unique_ptr<gpu::GLHelper> gl_helper_; |
Yuta Kitamura | d6c13d8e | 2017-12-01 06:09:41 | [diff] [blame] | 68 | base::RepeatingClosure context_lost_callback_; |
Eric Karl | eae2706 | 2019-05-23 18:57:55 | [diff] [blame] | 69 | base::flat_map<SkColorType, std::unique_ptr<cc::ImageDecodeCache>> |
Reza.Zakerinasab | 9afecdf | 2018-09-25 11:26:26 | [diff] [blame] | 70 | image_decode_cache_map_; |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 71 | |
| 72 | DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DProviderImpl); |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } // namespace content |
| 76 | |
| 77 | #endif // CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ |