blob: a60e48882b092c25aae1fa79d74e8ef3bfe78932 [file] [log] [blame]
[email protected]9cdd7152014-01-14 14:20:431// 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.Zakerinasab9afecdf2018-09-25 11:26:269#include "base/containers/flat_map.h"
[email protected]9cdd7152014-01-14 14:20:4310#include "base/memory/ref_counted.h"
kylecharc36cea22017-10-25 21:42:5611#include "components/viz/common/gpu/context_provider.h"
[email protected]9cdd7152014-01-14 14:20:4312#include "content/common/content_export.h"
Nathan Zabriskie0db1d9e412019-11-19 00:55:1713#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 Reformata30d4232018-04-07 15:31:0616#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
[email protected]9cdd7152014-01-14 14:20:4317
Khushal60916ba2018-01-19 19:47:4718namespace cc {
19class ImageDecodeCache;
20} // namespace cc
21
Emircan Uysalerf75ae2a2017-11-16 23:01:4722namespace viz {
Scott Violet703b8242019-06-11 19:34:3623class ContextProviderCommandBuffer;
Emircan Uysalerf75ae2a2017-11-16 23:01:4724} // namespace viz
sadrul85cc5d82016-12-20 03:37:4125
Nathan Zabriskie92461a02020-02-06 20:44:2726namespace gpu {
27class GLHelper;
28} // namespace gpu
29
sadrul85cc5d82016-12-20 03:37:4130namespace content {
[email protected]9cdd7152014-01-14 14:20:4331
32class CONTENT_EXPORT WebGraphicsContext3DProviderImpl
kylecharc36cea22017-10-25 21:42:5633 : public blink::WebGraphicsContext3DProvider,
34 public viz::ContextLostObserver {
[email protected]9cdd7152014-01-14 14:20:4335 public:
kylecharc36cea22017-10-25 21:42:5636 WebGraphicsContext3DProviderImpl(
Scott Violet703b8242019-06-11 19:34:3637 scoped_refptr<viz::ContextProviderCommandBuffer> provider);
avi5c77d212015-09-25 20:08:2538 ~WebGraphicsContext3DProviderImpl() override;
[email protected]9cdd7152014-01-14 14:20:4339
40 // WebGraphicsContext3DProvider implementation.
Blink Reformat1c4d759e2017-04-09 16:34:5441 bool BindToCurrentThread() override;
Nathan Zabriskie0db1d9e412019-11-19 00:55:1742 gpu::InterfaceBase* InterfaceBase() override;
Blink Reformat1c4d759e2017-04-09 16:34:5443 gpu::gles2::GLES2Interface* ContextGL() override;
Nathan Zabriskie95fc6d22019-10-30 22:09:1244 gpu::raster::RasterInterface* RasterInterface() override;
Kai Ninomiya05c10502018-08-30 20:06:2145 gpu::webgpu::WebGPUInterface* WebGPUInterface() override;
Stephen White9bd12b6a2020-04-28 00:11:2446 bool IsContextLost() override;
Robert Phillipsdbb0b7d2020-07-29 16:07:4447 GrDirectContext* GetGrContext() override;
Zhenyao Moeb86a1712017-10-06 14:17:5248 const gpu::Capabilities& GetCapabilities() const override;
49 const gpu::GpuFeatureInfo& GetGpuFeatureInfo() const override;
Zhenyao Mo8963f022019-05-30 22:10:5150 const blink::WebglPreferences& GetWebglPreferences() const override;
Nathan Zabriskie92461a02020-02-06 20:44:2751 gpu::GLHelper* GetGLHelper() override;
Yuta Kitamurad6c13d8e2017-12-01 06:09:4152 void SetLostContextCallback(base::RepeatingClosure) override;
Blink Reformat1c4d759e2017-04-09 16:34:5453 void SetErrorMessageCallback(
Yuta Kitamura63b6b3c2017-11-27 09:12:5854 base::RepeatingCallback<void(const char*, int32_t)>) override;
Eric Karleae27062019-05-23 18:57:5555 cc::ImageDecodeCache* ImageDecodeCache(SkColorType color_type) override;
Saman Samif672c292019-01-29 17:43:2056 gpu::SharedImageInterface* SharedImageInterface() override;
Miyoung Shinccbe33232019-06-19 04:14:3057 void CopyVideoFrame(media::PaintCanvasVideoRenderer* video_render,
58 media::VideoFrame* video_frame,
59 cc::PaintCanvas* canvas) override;
Dan Sanders3b04f4d2020-12-05 01:12:4460 viz::RasterContextProvider* RasterContextProvider() const override;
danakj615aac22016-04-29 21:28:1661
[email protected]9cdd7152014-01-14 14:20:4362 private:
kylecharc36cea22017-10-25 21:42:5663 // viz::ContextLostObserver implementation.
64 void OnContextLost() override;
65
Scott Violet703b8242019-06-11 19:34:3666 scoped_refptr<viz::ContextProviderCommandBuffer> provider_;
Nathan Zabriskie92461a02020-02-06 20:44:2767 std::unique_ptr<gpu::GLHelper> gl_helper_;
Yuta Kitamurad6c13d8e2017-12-01 06:09:4168 base::RepeatingClosure context_lost_callback_;
Eric Karleae27062019-05-23 18:57:5569 base::flat_map<SkColorType, std::unique_ptr<cc::ImageDecodeCache>>
Reza.Zakerinasab9afecdf2018-09-25 11:26:2670 image_decode_cache_map_;
kylecharc36cea22017-10-25 21:42:5671
72 DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DProviderImpl);
[email protected]9cdd7152014-01-14 14:20:4373};
74
75} // namespace content
76
77#endif // CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_