blob: 354b16684c26963409561b7e2fb2469eaf552b79 [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"
Blink Reformata30d4232018-04-07 15:31:0613#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
[email protected]9cdd7152014-01-14 14:20:4314
Khushal60916ba2018-01-19 19:47:4715namespace cc {
16class ImageDecodeCache;
17} // namespace cc
18
danakjcdf87872016-03-16 05:22:3519namespace gpu {
20namespace gles2 {
21class GLES2Interface;
Emircan Uysalerf75ae2a2017-11-16 23:01:4722} // namespace gles2
23} // namespace gpu
danakjcdf87872016-03-16 05:22:3524
Emircan Uysalerf75ae2a2017-11-16 23:01:4725namespace viz {
26class GLHelper;
27} // namespace viz
sadrul85cc5d82016-12-20 03:37:4128
Scott Violet7e33efc2018-08-29 22:30:1529namespace ws {
30class ContextProviderCommandBuffer;
31} // namespace ws
32
sadrul85cc5d82016-12-20 03:37:4133namespace content {
[email protected]9cdd7152014-01-14 14:20:4334
35class CONTENT_EXPORT WebGraphicsContext3DProviderImpl
kylecharc36cea22017-10-25 21:42:5636 : public blink::WebGraphicsContext3DProvider,
37 public viz::ContextLostObserver {
[email protected]9cdd7152014-01-14 14:20:4338 public:
kylecharc36cea22017-10-25 21:42:5639 WebGraphicsContext3DProviderImpl(
Scott Violet7e33efc2018-08-29 22:30:1540 scoped_refptr<ws::ContextProviderCommandBuffer> provider);
avi5c77d212015-09-25 20:08:2541 ~WebGraphicsContext3DProviderImpl() override;
[email protected]9cdd7152014-01-14 14:20:4342
43 // WebGraphicsContext3DProvider implementation.
Blink Reformat1c4d759e2017-04-09 16:34:5444 bool BindToCurrentThread() override;
45 gpu::gles2::GLES2Interface* ContextGL() override;
Kai Ninomiya05c10502018-08-30 20:06:2146 gpu::webgpu::WebGPUInterface* WebGPUInterface() override;
Blink Reformat1c4d759e2017-04-09 16:34:5447 GrContext* GetGrContext() override;
Zhenyao Moeb86a1712017-10-06 14:17:5248 const gpu::Capabilities& GetCapabilities() const override;
49 const gpu::GpuFeatureInfo& GetGpuFeatureInfo() const override;
Emircan Uysalerf75ae2a2017-11-16 23:01:4750 viz::GLHelper* GetGLHelper() override;
Yuta Kitamurad6c13d8e2017-12-01 06:09:4151 void SetLostContextCallback(base::RepeatingClosure) override;
Blink Reformat1c4d759e2017-04-09 16:34:5452 void SetErrorMessageCallback(
Yuta Kitamura63b6b3c2017-11-27 09:12:5853 base::RepeatingCallback<void(const char*, int32_t)>) override;
Adrienne Walkere0c4b6a2018-11-06 01:20:4054 cc::ImageDecodeCache* ImageDecodeCache(
Adrienne Walkeree29a5b82018-11-16 19:59:1255 SkColorType color_type,
56 sk_sp<SkColorSpace> color_space) override;
Saman Samif672c292019-01-29 17:43:2057 gpu::SharedImageInterface* SharedImageInterface() override;
[email protected]9cdd7152014-01-14 14:20:4358
Scott Violet7e33efc2018-08-29 22:30:1559 ws::ContextProviderCommandBuffer* context_provider() const {
danakj615aac22016-04-29 21:28:1660 return provider_.get();
61 }
62
[email protected]9cdd7152014-01-14 14:20:4363 private:
kylecharc36cea22017-10-25 21:42:5664 // viz::ContextLostObserver implementation.
65 void OnContextLost() override;
66
Scott Violet7e33efc2018-08-29 22:30:1567 scoped_refptr<ws::ContextProviderCommandBuffer> provider_;
Emircan Uysalerf75ae2a2017-11-16 23:01:4768 std::unique_ptr<viz::GLHelper> gl_helper_;
Yuta Kitamurad6c13d8e2017-12-01 06:09:4169 base::RepeatingClosure context_lost_callback_;
Adrienne Walkeree29a5b82018-11-16 19:59:1270 base::flat_map<std::pair<SkColorType, uint64_t>,
Adrienne Walkere0c4b6a2018-11-06 01:20:4071 std::unique_ptr<cc::ImageDecodeCache>>
Reza.Zakerinasab9afecdf2018-09-25 11:26:2672 image_decode_cache_map_;
kylecharc36cea22017-10-25 21:42:5673
74 DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DProviderImpl);
[email protected]9cdd7152014-01-14 14:20:4375};
76
77} // namespace content
78
79#endif // CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_