Avi Drissman | 05dfbc82 | 2022-09-13 21:25:34 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "gpu/config/gpu_feature_info.h" |
| 6 | |
Peter Kasting | fb15d03 | 2022-09-29 03:06:57 | [diff] [blame] | 7 | #include "base/containers/contains.h" |
Chris Blume | 29bf536 | 2019-09-06 02:34:45 | [diff] [blame] | 8 | #include "gpu/config/gpu_blocklist.h" |
Zhenyao Mo | 2eb1fe5 | 2018-01-13 05:49:25 | [diff] [blame] | 9 | #include "gpu/config/gpu_driver_bug_list.h" |
Zhenyao Mo | 08c9149 | 2017-08-24 22:57:57 | [diff] [blame] | 10 | #include "ui/gl/gl_context.h" |
| 11 | |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 12 | namespace gpu { |
| 13 | |
| 14 | GpuFeatureInfo::GpuFeatureInfo() { |
| 15 | for (auto& status : status_values) |
| 16 | status = kGpuFeatureStatusUndefined; |
| 17 | } |
| 18 | |
Zhenyao Mo | d4dba105 | 2017-07-27 23:02:39 | [diff] [blame] | 19 | GpuFeatureInfo::GpuFeatureInfo(const GpuFeatureInfo&) = default; |
| 20 | |
| 21 | GpuFeatureInfo::GpuFeatureInfo(GpuFeatureInfo&&) = default; |
| 22 | |
Chris Watkins | 8103077 | 2017-12-07 01:20:56 | [diff] [blame] | 23 | GpuFeatureInfo::~GpuFeatureInfo() = default; |
Zhenyao Mo | d4dba105 | 2017-07-27 23:02:39 | [diff] [blame] | 24 | |
| 25 | GpuFeatureInfo& GpuFeatureInfo::operator=(const GpuFeatureInfo&) = default; |
| 26 | |
| 27 | GpuFeatureInfo& GpuFeatureInfo::operator=(GpuFeatureInfo&&) = default; |
| 28 | |
Zhenyao Mo | 08c9149 | 2017-08-24 22:57:57 | [diff] [blame] | 29 | void GpuFeatureInfo::ApplyToGLContext(gl::GLContext* gl_context) const { |
| 30 | DCHECK(gl_context); |
Zhenyao Mo | 08c9149 | 2017-08-24 22:57:57 | [diff] [blame] | 31 | gl_context->SetDisabledGLExtensions(this->disabled_extensions); |
| 32 | } |
| 33 | |
| 34 | bool GpuFeatureInfo::IsWorkaroundEnabled(int32_t workaround) const { |
Peter Kasting | fb15d03 | 2022-09-29 03:06:57 | [diff] [blame] | 35 | return base::Contains(this->enabled_gpu_driver_bug_workarounds, workaround); |
Zhenyao Mo | 08c9149 | 2017-08-24 22:57:57 | [diff] [blame] | 36 | } |
| 37 | |
Zhenyao Mo | 2eb1fe5 | 2018-01-13 05:49:25 | [diff] [blame] | 38 | bool GpuFeatureInfo::IsInitialized() const { |
Zhenyao Mo | f920e13 | 2017-12-19 20:16:50 | [diff] [blame] | 39 | // Check if any feature status is undefined. |
Sean Gilhuly | 1e54ddb | 2019-11-28 18:52:28 | [diff] [blame] | 40 | return status_values[GPU_FEATURE_TYPE_ACCELERATED_GL] != |
Zhenyao Mo | f920e13 | 2017-12-19 20:16:50 | [diff] [blame] | 41 | kGpuFeatureStatusUndefined; |
| 42 | } |
| 43 | |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 44 | } // namespace gpu |