Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. diff --git a/hybris/tests/test_hwcomposer.cpp b/hybris/tests/test_hwcomposer.cpp
  2. index b6e47c5..44a04e6 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 +181,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 +228,32 @@ int main(int argc, char **argv)
  58. layer->handle = 0;
  59. layer->transform = 0;
  60. layer->blending = HWC_BLENDING_NONE;
  61. +#ifdef HWC_DEVICE_API_VERSION_1_3
  62. + layer->sourceCropf.top = 0.0f;
  63. + layer->sourceCropf.left = 0.0f;
  64. + layer->sourceCropf.bottom = (float) attr_values[1];
  65. + layer->sourceCropf.right = (float) attr_values[0];
  66. +#else
  67. layer->sourceCrop = r;
  68. +#endif
  69. layer->displayFrame = r;
  70. layer->visibleRegionScreen.numRects = 1;
  71. layer->visibleRegionScreen.rects = &layer->displayFrame;
  72. layer->acquireFenceFd = -1;
  73. layer->releaseFenceFd = -1;
  74. +#if (ANDROID_VERSION_MAJOR >= 4) && (ANDROID_VERSION_MINOR >= 3) || (ANDROID_VERSION_MAJOR >= 5)
  75. + // We've observed that qualcomm chipsets enters into compositionType == 6
  76. + // (HWC_BLIT), an undocumented composition type which gives us rendering
  77. + // glitches and warnings in logcat. By setting the planarAlpha to non-
  78. + // opaque, we attempt to force the HWC into using HWC_FRAMEBUFFER for this
  79. + // layer so the HWC_FRAMEBUFFER_TARGET layer actually gets used.
  80. + bool tryToForceGLES = getenv("QPA_HWC_FORCE_GLES") != NULL;
  81. + layer->planeAlpha = tryToForceGLES ? 1 : 255;
  82. +#endif
  83. +#ifdef HWC_DEVICE_API_VERSION_1_5
  84. + layer->surfaceDamage.numRects = 0;
  85. +#endif
  86. +
  87. layer = &list->hwLayers[1];
  88. memset(layer, 0, sizeof(hwc_layer_1_t));
  89. layer->compositionType = HWC_FRAMEBUFFER_TARGET;
  90. @@ -213,12 +262,23 @@ int main(int argc, char **argv)
  91. layer->handle = 0;
  92. layer->transform = 0;
  93. layer->blending = HWC_BLENDING_NONE;
  94. +#ifdef HWC_DEVICE_API_VERSION_1_3
  95. + layer->sourceCropf.top = 0.0f;
  96. + layer->sourceCropf.left = 0.0f;
  97. + layer->sourceCropf.bottom = (float) attr_values[1];
  98. + layer->sourceCropf.right = (float) attr_values[0];
  99. +#else
  100. layer->sourceCrop = r;
  101. +#endif
  102. layer->displayFrame = r;
  103. layer->visibleRegionScreen.numRects = 1;
  104. layer->visibleRegionScreen.rects = &layer->displayFrame;
  105. layer->acquireFenceFd = -1;
  106. layer->releaseFenceFd = -1;
  107. +#if (ANDROID_VERSION_MAJOR >= 4) && (ANDROID_VERSION_MINOR >= 3) || (ANDROID_VERSION_MAJOR >= 5)
  108. + layer->planeAlpha = 0xff;
  109. +#endif
  110. + layer->surfaceDamage.numRects = 0;
  111.  
  112. list->retireFenceFd = -1;
  113. list->flags = HWC_GEOMETRY_CHANGED;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement