Advertisement
Guest User

Untitled

a guest
Nov 19th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. diff --git a/hybris/tests/test_hwcomposer.cpp b/hybris/tests/test_hwcomposer.cpp
  2. index b6e47c5..0b94932 100644
  3. --- a/hybris/tests/test_hwcomposer.cpp
  4. +++ b/hybris/tests/test_hwcomposer.cpp
  5. @@ -19,6 +19,7 @@
  6. #include <EGL/egl.h>
  7. #include <GLES2/gl2.h>
  8. #include <assert.h>
  9. +#include <stdlib.h>
  10. #include <stdio.h>
  11. #include <math.h>
  12. #include <stddef.h>
  13. @@ -129,6 +130,20 @@ void HWComposer::present(HWComposerNativeWindowBuffer *buffer)
  14. }
  15. }
  16.  
  17. +inline static uint32_t interpreted_version(hw_device_t *hwc_device)
  18. +{
  19. + uint32_t version = hwc_device->version;
  20. +
  21. + if ((version & 0xffff0000) == 0) {
  22. + // Assume header version is always 1
  23. + uint32_t header_version = 1;
  24. +
  25. + // Legacy version encoding
  26. + version = (version << 16) | header_version;
  27. + }
  28. + return version;
  29. +}
  30. +
  31. int main(int argc, char **argv)
  32. {
  33. EGLDisplay display;
  34. @@ -166,7 +174,21 @@ int main(int argc, char **argv)
  35. err = hwc_open_1(hwcModule, &hwcDevicePtr);
  36. assert(err == 0);
  37.  
  38. - hwcDevicePtr->blank(hwcDevicePtr, 0, 0);
  39. + hw_device_t *hwcDevice = &hwcDevicePtr->common;
  40. +
  41. + uint32_t hwc_version = interpreted_version(hwcDevice);
  42. +
  43. +#ifdef HWC_DEVICE_API_VERSION_1_4
  44. + if (hwc_version == HWC_DEVICE_API_VERSION_1_4) {
  45. + hwcDevicePtr->setPowerMode(hwcDevicePtr, 0, HWC_POWER_MODE_NORMAL);
  46. + } else
  47. +#endif
  48. +#ifdef HWC_DEVICE_API_VERSION_1_5
  49. + if (hwc_version == HWC_DEVICE_API_VERSION_1_5) {
  50. + hwcDevicePtr->setPowerMode(hwcDevicePtr, 0, HWC_POWER_MODE_NORMAL);
  51. + } else
  52. +#endif
  53. + hwcDevicePtr->blank(hwcDevicePtr, 0, 0);
  54.  
  55. uint32_t configs[5];
  56. size_t numConfigs = 5;
  57. @@ -199,12 +221,32 @@ int main(int argc, char **argv)
  58. layer->handle = 0;
  59. layer->transform = 0;
  60. layer->blending = HWC_BLENDING_NONE;
  61. - layer->sourceCrop = r;
  62. +#ifdef HWC_DEVICE_API_VERSION_1_3
  63. + layer->sourceCropf.top = 0.0f;
  64. + layer->sourceCropf.left = 0.0f;
  65. + layer->sourceCropf.bottom = (float) attr_values[1];
  66. + layer->sourceCropf.right = (float) attr_values[0];
  67. +#else
  68. + layer->sourceCrop = r;
  69. +#endif
  70. layer->displayFrame = r;
  71. layer->visibleRegionScreen.numRects = 1;
  72. layer->visibleRegionScreen.rects = &layer->displayFrame;
  73. layer->acquireFenceFd = -1;
  74. layer->releaseFenceFd = -1;
  75. +#if (ANDROID_VERSION_MAJOR >= 4) && (ANDROID_VERSION_MINOR >= 3) || (ANDROID_VERSION_MAJOR >= 5)
  76. + // We've observed that qualcomm chipsets enters into compositionType == 6
  77. + // (HWC_BLIT), an undocumented composition type which gives us rendering
  78. + // glitches and warnings in logcat. By setting the planarAlpha to non-
  79. + // opaque, we attempt to force the HWC into using HWC_FRAMEBUFFER for this
  80. + // layer so the HWC_FRAMEBUFFER_TARGET layer actually gets used.
  81. + bool tryToForceGLES = getenv("QPA_HWC_FORCE_GLES") != NULL;
  82. + layer->planeAlpha = tryToForceGLES ? 1 : 255;
  83. +#endif
  84. +#ifdef HWC_DEVICE_API_VERSION_1_5
  85. + layer->surfaceDamage.numRects = 0;
  86. +#endif
  87. +
  88. layer = &list->hwLayers[1];
  89. memset(layer, 0, sizeof(hwc_layer_1_t));
  90. layer->compositionType = HWC_FRAMEBUFFER_TARGET;
  91. @@ -213,12 +255,25 @@ int main(int argc, char **argv)
  92. layer->handle = 0;
  93. layer->transform = 0;
  94. layer->blending = HWC_BLENDING_NONE;
  95. - layer->sourceCrop = r;
  96. +#ifdef HWC_DEVICE_API_VERSION_1_3
  97. + layer->sourceCropf.top = 0.0f;
  98. + layer->sourceCropf.left = 0.0f;
  99. + layer->sourceCropf.bottom = (float) attr_values[1];
  100. + layer->sourceCropf.right = (float) attr_values[0];
  101. +#else
  102. + layer->sourceCrop = r;
  103. +#endif
  104. layer->displayFrame = r;
  105. layer->visibleRegionScreen.numRects = 1;
  106. layer->visibleRegionScreen.rects = &layer->displayFrame;
  107. layer->acquireFenceFd = -1;
  108. layer->releaseFenceFd = -1;
  109. +#if (ANDROID_VERSION_MAJOR >= 4) && (ANDROID_VERSION_MINOR >= 3) || (ANDROID_VERSION_MAJOR >= 5)
  110. + layer->planeAlpha = 0xff;
  111. +#endif
  112. +#ifdef HWC_DEVICE_API_VERSION_1_5
  113. + layer->surfaceDamage.numRects = 0;
  114. +#endif
  115.  
  116. list->retireFenceFd = -1;
  117. list->flags = HWC_GEOMETRY_CHANGED;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement