Revert-gpu-android-Remove-setup-for-disabling-AImageReader.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. From: csagan5 <32685696+csagan5@users.noreply.github.com>
  2. Date: Tue, 5 May 2020 07:22:20 +0200
  3. Subject: Revert "gpu/android: Remove setup for disabling AImageReader."
  4. This reverts commit dcd5a39518246eb999f1cc63bf1ec95d93fd5b2f.
  5. ---
  6. base/android/android_image_reader_compat.cc | 8 +++++++-
  7. base/android/android_image_reader_compat.h | 4 ++++
  8. gpu/config/gpu_util.cc | 8 ++++++++
  9. gpu/config/gpu_workaround_list.txt | 1 +
  10. gpu/ipc/service/gpu_init.cc | 11 +++++++++++
  11. 5 files changed, 31 insertions(+), 1 deletion(-)
  12. diff --git a/base/android/android_image_reader_compat.cc b/base/android/android_image_reader_compat.cc
  13. --- a/base/android/android_image_reader_compat.cc
  14. +++ b/base/android/android_image_reader_compat.cc
  15. @@ -22,6 +22,8 @@
  16. namespace base {
  17. namespace android {
  18. +bool AndroidImageReader::disable_support_ = false;
  19. +
  20. AndroidImageReader& AndroidImageReader::GetInstance() {
  21. // C++11 static local variable initialization is
  22. // thread-safe.
  23. @@ -29,8 +31,12 @@ AndroidImageReader& AndroidImageReader::GetInstance() {
  24. return *instance;
  25. }
  26. +void AndroidImageReader::DisableSupport() {
  27. + disable_support_ = true;
  28. +}
  29. +
  30. bool AndroidImageReader::IsSupported() {
  31. - return is_supported_;
  32. + return !disable_support_ && is_supported_;
  33. }
  34. AndroidImageReader::AndroidImageReader() {
  35. diff --git a/base/android/android_image_reader_compat.h b/base/android/android_image_reader_compat.h
  36. --- a/base/android/android_image_reader_compat.h
  37. +++ b/base/android/android_image_reader_compat.h
  38. @@ -22,6 +22,9 @@ class BASE_EXPORT AndroidImageReader {
  39. // Thread safe GetInstance.
  40. static AndroidImageReader& GetInstance();
  41. + // Disable image reader support.
  42. + static void DisableSupport();
  43. +
  44. // Check if the image reader usage is supported. This function returns TRUE
  45. // if android version is >=OREO, image reader support is not disabled and all
  46. // the required functions are loaded.
  47. @@ -64,6 +67,7 @@ class BASE_EXPORT AndroidImageReader {
  48. AndroidImageReader();
  49. bool LoadFunctions();
  50. + static bool disable_support_;
  51. bool is_supported_;
  52. pAImage_delete AImage_delete_;
  53. pAImage_deleteAsync AImage_deleteAsync_;
  54. diff --git a/gpu/config/gpu_util.cc b/gpu/config/gpu_util.cc
  55. --- a/gpu/config/gpu_util.cc
  56. +++ b/gpu/config/gpu_util.cc
  57. @@ -108,6 +108,9 @@ GpuFeatureStatus GetAndroidSurfaceControlFeatureStatus(
  58. #if !defined(OS_ANDROID)
  59. return kGpuFeatureStatusDisabled;
  60. #else
  61. + if (blacklisted_features.count(GPU_FEATURE_TYPE_ANDROID_SURFACE_CONTROL))
  62. + return kGpuFeatureStatusBlacklisted;
  63. +
  64. if (!gpu_preferences.enable_android_surface_control)
  65. return kGpuFeatureStatusDisabled;
  66. @@ -349,6 +352,11 @@ void AdjustGpuFeatureStatusToWorkarounds(GpuFeatureInfo* gpu_feature_info) {
  67. gpu_feature_info->status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL2] =
  68. kGpuFeatureStatusBlacklisted;
  69. }
  70. +
  71. + if (gpu_feature_info->IsWorkaroundEnabled(DISABLE_AIMAGEREADER)) {
  72. + gpu_feature_info->status_values[GPU_FEATURE_TYPE_ANDROID_SURFACE_CONTROL] =
  73. + kGpuFeatureStatusBlacklisted;
  74. + }
  75. }
  76. // Estimates roughly user total disk space by counting in the drives where
  77. diff --git a/gpu/config/gpu_workaround_list.txt b/gpu/config/gpu_workaround_list.txt
  78. --- a/gpu/config/gpu_workaround_list.txt
  79. +++ b/gpu/config/gpu_workaround_list.txt
  80. @@ -13,6 +13,7 @@ decode_encode_srgb_for_generatemipmap
  81. depth_stencil_renderbuffer_resize_emulation
  82. disable_2d_canvas_auto_flush
  83. disable_accelerated_vpx_decode
  84. +disable_aimagereader
  85. disable_async_readpixels
  86. disable_av_sample_buffer_display_layer
  87. disable_blend_equation_advanced
  88. diff --git a/gpu/ipc/service/gpu_init.cc b/gpu/ipc/service/gpu_init.cc
  89. --- a/gpu/ipc/service/gpu_init.cc
  90. +++ b/gpu/ipc/service/gpu_init.cc
  91. @@ -524,6 +524,12 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
  92. ui::OzonePlatform::GetInstance()->AfterSandboxEntry();
  93. #endif
  94. +#if defined(OS_ANDROID)
  95. + // Disable AImageReader if the workaround is enabled.
  96. + if (gpu_feature_info_.IsWorkaroundEnabled(DISABLE_AIMAGEREADER)) {
  97. + base::android::AndroidImageReader::DisableSupport();
  98. + }
  99. +#endif
  100. #if defined(USE_OZONE)
  101. gpu_feature_info_.supported_buffer_formats_for_allocation_and_texturing =
  102. std::move(supported_buffer_formats_for_texturing);
  103. @@ -550,6 +556,11 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
  104. default_offscreen_surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size());
  105. + // Disable AImageReader if the workaround is enabled.
  106. + if (gpu_feature_info_.IsWorkaroundEnabled(DISABLE_AIMAGEREADER)) {
  107. + base::android::AndroidImageReader::DisableSupport();
  108. + }
  109. +
  110. UMA_HISTOGRAM_ENUMERATION("GPU.GLImplementation", gl::GetGLImplementation());
  111. }
  112. #else
  113. --
  114. 2.17.1