1 // Copyright (c) 2017 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 #include "gpu/config/gpu_feature_info.h" 6 7 #include <algorithm> 8 9 #include "gpu/config/gpu_blocklist.h" 10 #include "gpu/config/gpu_driver_bug_list.h" 11 #include "gpu/config/gpu_driver_bug_workaround_type.h" 12 #include "ui/gl/gl_context.h" 13 14 namespace gpu { 15 GpuFeatureInfo()16GpuFeatureInfo::GpuFeatureInfo() { 17 for (auto& status : status_values) 18 status = kGpuFeatureStatusUndefined; 19 } 20 21 GpuFeatureInfo::GpuFeatureInfo(const GpuFeatureInfo&) = default; 22 23 GpuFeatureInfo::GpuFeatureInfo(GpuFeatureInfo&&) = default; 24 25 GpuFeatureInfo::~GpuFeatureInfo() = default; 26 27 GpuFeatureInfo& GpuFeatureInfo::operator=(const GpuFeatureInfo&) = default; 28 29 GpuFeatureInfo& GpuFeatureInfo::operator=(GpuFeatureInfo&&) = default; 30 ApplyToGLContext(gl::GLContext * gl_context) const31void GpuFeatureInfo::ApplyToGLContext(gl::GLContext* gl_context) const { 32 DCHECK(gl_context); 33 gl::GLWorkarounds gl_workarounds; 34 if (IsWorkaroundEnabled(gpu::CLEAR_TO_ZERO_OR_ONE_BROKEN)) { 35 gl_workarounds.clear_to_zero_or_one_broken = true; 36 } 37 if (IsWorkaroundEnabled(RESET_TEXIMAGE2D_BASE_LEVEL)) { 38 gl_workarounds.reset_teximage2d_base_level = true; 39 } 40 gl_context->SetGLWorkarounds(gl_workarounds); 41 gl_context->SetDisabledGLExtensions(this->disabled_extensions); 42 } 43 IsWorkaroundEnabled(int32_t workaround) const44bool GpuFeatureInfo::IsWorkaroundEnabled(int32_t workaround) const { 45 return std::find(this->enabled_gpu_driver_bug_workarounds.begin(), 46 this->enabled_gpu_driver_bug_workarounds.end(), 47 workaround) != 48 this->enabled_gpu_driver_bug_workarounds.end(); 49 } 50 IsInitialized() const51bool GpuFeatureInfo::IsInitialized() const { 52 // Check if any feature status is undefined. 53 return status_values[GPU_FEATURE_TYPE_ACCELERATED_GL] != 54 kGpuFeatureStatusUndefined; 55 } 56 57 } // namespace gpu 58