surfaceflinger: add support for android.hardware.graphics
This adds a new path to HWC2 to use
android.hardware.graphics.composer@2.1::IComposer instead of hwcomposer2.
Which path to use is determined by whether BYPASS_IHWC is set at compile
time. When it is set, the old path, kept for HWC2On1Adapter, is used.
When it is not set, the new path is taken.
BYPASS_IHWC2 is set when TARGET_USES_HWC2 is not.
Test: Maps, Camera, YouTube, etc.
Change-Id: I37aceafd1733fa9f76e7f7db4f59ad4776415306
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h
index 32a9de0..1145ba1 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -17,6 +17,10 @@
#ifndef ANDROID_SF_HWC2_H
#define ANDROID_SF_HWC2_H
+#ifndef USE_HWC2
+#define BYPASS_IHWC
+#endif
+
#define HWC2_INCLUDE_STRINGIFICATION
#define HWC2_USE_CPP11
#include <hardware/hwcomposer2.h>
@@ -42,6 +46,9 @@
class GraphicBuffer;
class Rect;
class Region;
+ namespace Hwc2 {
+ class Composer;
+ };
}
namespace HWC2 {
@@ -57,7 +64,11 @@
class Device
{
public:
+#ifdef BYPASS_IHWC
explicit Device(hwc2_device_t* device);
+#else
+ Device();
+#endif
~Device();
friend class HWC2::Display;
@@ -98,6 +109,7 @@
private:
// Initialization methods
+#ifdef BYPASS_IHWC
template <typename PFN>
[[clang::warn_unused_result]] bool loadFunctionPointer(
FunctionDescriptor desc, PFN& outPFN) {
@@ -121,6 +133,7 @@
auto pfn = reinterpret_cast<hwc2_function_pointer_t>(hook);
mRegisterCallback(mHwcDevice, intCallback, callbackData, pfn);
}
+#endif
void loadCapabilities();
void loadFunctionPointers();
@@ -132,6 +145,7 @@
// Member variables
+#ifdef BYPASS_IHWC
hwc2_device_t* mHwcDevice;
// Device function pointers
@@ -181,6 +195,9 @@
HWC2_PFN_SET_LAYER_TRANSFORM mSetLayerTransform;
HWC2_PFN_SET_LAYER_VISIBLE_REGION mSetLayerVisibleRegion;
HWC2_PFN_SET_LAYER_Z_ORDER mSetLayerZOrder;
+#else
+ std::unique_ptr<android::Hwc2::Composer> mComposer;
+#endif // BYPASS_IHWC
std::unordered_set<Capability> mCapabilities;
std::unordered_map<hwc2_display_t, std::weak_ptr<Display>> mDisplays;