gpu_feature_info.cc 1.8 KB

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