blob: 75cbe0791dbfe857ba0b455695e2eeeb3eb1d6a5 [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"
9#include "base/memory/ref_counted.h"
kylecharc36cea22017-10-25 21:42:5610#include "components/viz/common/gpu/context_provider.h"
[email protected]9cdd7152014-01-14 14:20:4311#include "content/common/content_export.h"
12#include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h"
13
danakjcdf87872016-03-16 05:22:3514namespace gpu {
15namespace gles2 {
16class GLES2Interface;
Emircan Uysalerf75ae2a2017-11-16 23:01:4717} // namespace gles2
18} // namespace gpu
danakjcdf87872016-03-16 05:22:3519
sadrul85cc5d82016-12-20 03:37:4120namespace ui {
danakj615aac22016-04-29 21:28:1621class ContextProviderCommandBuffer;
Emircan Uysalerf75ae2a2017-11-16 23:01:4722} // namespace ui
23
24namespace viz {
25class GLHelper;
26} // namespace viz
sadrul85cc5d82016-12-20 03:37:4127
28namespace content {
[email protected]9cdd7152014-01-14 14:20:4329
30class CONTENT_EXPORT WebGraphicsContext3DProviderImpl
kylecharc36cea22017-10-25 21:42:5631 : public blink::WebGraphicsContext3DProvider,
32 public viz::ContextLostObserver {
[email protected]9cdd7152014-01-14 14:20:4333 public:
kylecharc36cea22017-10-25 21:42:5634 WebGraphicsContext3DProviderImpl(
sadrul85cc5d82016-12-20 03:37:4135 scoped_refptr<ui::ContextProviderCommandBuffer> provider,
danakj4dd43952016-08-23 21:18:3936 bool software_rendering);
avi5c77d212015-09-25 20:08:2537 ~WebGraphicsContext3DProviderImpl() override;
[email protected]9cdd7152014-01-14 14:20:4338
39 // WebGraphicsContext3DProvider implementation.
Blink Reformat1c4d759e2017-04-09 16:34:5440 bool BindToCurrentThread() override;
41 gpu::gles2::GLES2Interface* ContextGL() override;
42 GrContext* GetGrContext() override;
Emircan Uysalerf75ae2a2017-11-16 23:01:4743 void InvalidateGrContext(uint32_t state) override;
Zhenyao Moeb86a1712017-10-06 14:17:5244 const gpu::Capabilities& GetCapabilities() const override;
45 const gpu::GpuFeatureInfo& GetGpuFeatureInfo() const override;
Emircan Uysalerf75ae2a2017-11-16 23:01:4746 viz::GLHelper* GetGLHelper() override;
Blink Reformat1c4d759e2017-04-09 16:34:5447 bool IsSoftwareRendering() const override;
Yuta Kitamurad6c13d8e2017-12-01 06:09:4148 void SetLostContextCallback(base::RepeatingClosure) override;
Blink Reformat1c4d759e2017-04-09 16:34:5449 void SetErrorMessageCallback(
Yuta Kitamura63b6b3c2017-11-27 09:12:5850 base::RepeatingCallback<void(const char*, int32_t)>) override;
Yuta Kitamura66a7f392017-11-22 13:07:0251 void SignalQuery(uint32_t, base::OnceClosure) override;
[email protected]9cdd7152014-01-14 14:20:4352
sadrul85cc5d82016-12-20 03:37:4153 ui::ContextProviderCommandBuffer* context_provider() const {
danakj615aac22016-04-29 21:28:1654 return provider_.get();
55 }
56
[email protected]9cdd7152014-01-14 14:20:4357 private:
kylecharc36cea22017-10-25 21:42:5658 // viz::ContextLostObserver implementation.
59 void OnContextLost() override;
60
sadrul85cc5d82016-12-20 03:37:4161 scoped_refptr<ui::ContextProviderCommandBuffer> provider_;
Emircan Uysalerf75ae2a2017-11-16 23:01:4762 std::unique_ptr<viz::GLHelper> gl_helper_;
danakj4dd43952016-08-23 21:18:3963 const bool software_rendering_;
Yuta Kitamurad6c13d8e2017-12-01 06:09:4164 base::RepeatingClosure context_lost_callback_;
kylecharc36cea22017-10-25 21:42:5665
66 DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DProviderImpl);
[email protected]9cdd7152014-01-14 14:20:4367};
68
69} // namespace content
70
71#endif // CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_