[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" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 13 | #include "third_party/blink/public/platform/web_graphics_context_3d_provider.h" |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 14 | |
Khushal | 60916ba | 2018-01-19 19:47:47 | [diff] [blame] | 15 | namespace cc { |
16 | class ImageDecodeCache; | ||||
17 | } // namespace cc | ||||
18 | |||||
danakj | cdf8787 | 2016-03-16 05:22:35 | [diff] [blame] | 19 | namespace gpu { |
20 | namespace gles2 { | ||||
21 | class GLES2Interface; | ||||
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 22 | } // namespace gles2 |
23 | } // namespace gpu | ||||
danakj | cdf8787 | 2016-03-16 05:22:35 | [diff] [blame] | 24 | |
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 25 | namespace viz { |
26 | class GLHelper; | ||||
27 | } // namespace viz | ||||
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 28 | |
Scott Violet | 7e33efc | 2018-08-29 22:30:15 | [diff] [blame] | 29 | namespace ws { |
30 | class ContextProviderCommandBuffer; | ||||
31 | } // namespace ws | ||||
32 | |||||
sadrul | 85cc5d8 | 2016-12-20 03:37:41 | [diff] [blame] | 33 | namespace content { |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 34 | |
35 | class CONTENT_EXPORT WebGraphicsContext3DProviderImpl | ||||
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 36 | : public blink::WebGraphicsContext3DProvider, |
37 | public viz::ContextLostObserver { | ||||
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 38 | public: |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 39 | WebGraphicsContext3DProviderImpl( |
Scott Violet | 7e33efc | 2018-08-29 22:30:15 | [diff] [blame] | 40 | scoped_refptr<ws::ContextProviderCommandBuffer> provider); |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 41 | ~WebGraphicsContext3DProviderImpl() override; |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 42 | |
43 | // WebGraphicsContext3DProvider implementation. | ||||
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 44 | bool BindToCurrentThread() override; |
45 | gpu::gles2::GLES2Interface* ContextGL() override; | ||||
Kai Ninomiya | 05c1050 | 2018-08-30 20:06:21 | [diff] [blame] | 46 | gpu::webgpu::WebGPUInterface* WebGPUInterface() override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 47 | GrContext* 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; | ||||
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 50 | viz::GLHelper* GetGLHelper() override; |
Yuta Kitamura | d6c13d8e | 2017-12-01 06:09:41 | [diff] [blame] | 51 | void SetLostContextCallback(base::RepeatingClosure) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 52 | void SetErrorMessageCallback( |
Yuta Kitamura | 63b6b3c | 2017-11-27 09:12:58 | [diff] [blame] | 53 | base::RepeatingCallback<void(const char*, int32_t)>) override; |
Adrienne Walker | e0c4b6a | 2018-11-06 01:20:40 | [diff] [blame] | 54 | cc::ImageDecodeCache* ImageDecodeCache( |
Adrienne Walker | ee29a5b8 | 2018-11-16 19:59:12 | [diff] [blame] | 55 | SkColorType color_type, |
56 | sk_sp<SkColorSpace> color_space) override; | ||||
Saman Sami | f672c29 | 2019-01-29 17:43:20 | [diff] [blame^] | 57 | gpu::SharedImageInterface* SharedImageInterface() override; |
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 58 | |
Scott Violet | 7e33efc | 2018-08-29 22:30:15 | [diff] [blame] | 59 | ws::ContextProviderCommandBuffer* context_provider() const { |
danakj | 615aac2 | 2016-04-29 21:28:16 | [diff] [blame] | 60 | return provider_.get(); |
61 | } | ||||
62 | |||||
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 63 | private: |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 64 | // viz::ContextLostObserver implementation. |
65 | void OnContextLost() override; | ||||
66 | |||||
Scott Violet | 7e33efc | 2018-08-29 22:30:15 | [diff] [blame] | 67 | scoped_refptr<ws::ContextProviderCommandBuffer> provider_; |
Emircan Uysaler | f75ae2a | 2017-11-16 23:01:47 | [diff] [blame] | 68 | std::unique_ptr<viz::GLHelper> gl_helper_; |
Yuta Kitamura | d6c13d8e | 2017-12-01 06:09:41 | [diff] [blame] | 69 | base::RepeatingClosure context_lost_callback_; |
Adrienne Walker | ee29a5b8 | 2018-11-16 19:59:12 | [diff] [blame] | 70 | base::flat_map<std::pair<SkColorType, uint64_t>, |
Adrienne Walker | e0c4b6a | 2018-11-06 01:20:40 | [diff] [blame] | 71 | std::unique_ptr<cc::ImageDecodeCache>> |
Reza.Zakerinasab | 9afecdf | 2018-09-25 11:26:26 | [diff] [blame] | 72 | image_decode_cache_map_; |
kylechar | c36cea2 | 2017-10-25 21:42:56 | [diff] [blame] | 73 | |
74 | DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DProviderImpl); | ||||
[email protected] | 9cdd715 | 2014-01-14 14:20:43 | [diff] [blame] | 75 | }; |
76 | |||||
77 | } // namespace content | ||||
78 | |||||
79 | #endif // CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ |