[RenderEngine] Only compile Graphite if either Graphite flag is enabled
RE-Graphite will be *compiled* if either the graphite_renderengine
or force_compile_graphite_renderengine ready-only flag is enabled at
compile time (inclusive OR).
RE-Graphite can be compiled and *enabled* by:
1. setting just graphite_renderengine=true, or
2. setting both force_compile_graphite_renderengine=true and the
debug.renderengine.graphite system property to true.
Why RenderEngine needs a dep on libsurfaceflingerflags now:
libsurfaceflinger_common pulls in SF's FlagManager, which is layered on
top of the API that's autogenerated for SF's aconfig module,
libsurfaceflingerflags.
The COM_ANDROID_GRAPHICS_SURFACEFLINGER_FLAGS(...) macro is defined by
com_android_graphics_surfaceflinger_flags.h in that latter aconfig
module, and that header is not exported by the higher-level FlagManager
code.
Bug: b/293371537
Bug: b/331678326
Bug: b/341728634
Test: boot and bloaty (see b/331678326)
Flag: com.android.graphics.surfaceflinger.flags.graphite_renderengine
Change-Id: I9d0b15bda08430552716a9a1f7cd59d91ee7b9a6
diff --git a/libs/renderengine/tests/RenderEngineTest.cpp b/libs/renderengine/tests/RenderEngineTest.cpp
index 4dcaff9..a8a9823 100644
--- a/libs/renderengine/tests/RenderEngineTest.cpp
+++ b/libs/renderengine/tests/RenderEngineTest.cpp
@@ -22,6 +22,7 @@
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wextra"
+#include <com_android_graphics_surfaceflinger_flags.h>
#include <cutils/properties.h>
#include <gtest/gtest.h>
#include <renderengine/ExternalTexture.h>
@@ -41,6 +42,14 @@
#include "../skia/SkiaVkRenderEngine.h"
#include "../threaded/RenderEngineThreaded.h"
+// TODO: b/341728634 - Clean up conditional compilation.
+#if COM_ANDROID_GRAPHICS_SURFACEFLINGER_FLAGS(GRAPHITE_RENDERENGINE) || \
+ COM_ANDROID_GRAPHICS_SURFACEFLINGER_FLAGS(FORCE_COMPILE_GRAPHITE_RENDERENGINE)
+#define COMPILE_GRAPHITE_RENDERENGINE 1
+#else
+#define COMPILE_GRAPHITE_RENDERENGINE 0
+#endif
+
constexpr int DEFAULT_DISPLAY_WIDTH = 128;
constexpr int DEFAULT_DISPLAY_HEIGHT = 256;
constexpr int DEFAULT_DISPLAY_OFFSET = 64;
@@ -152,6 +161,8 @@
}
};
+// TODO: b/341728634 - Clean up conditional compilation.
+#if COMPILE_GRAPHITE_RENDERENGINE
class GraphiteVkRenderEngineFactory : public RenderEngineFactory {
public:
std::string name() override { return "GraphiteVkRenderEngineFactory"; }
@@ -164,6 +175,7 @@
return renderengine::RenderEngine::SkiaBackend::GRAPHITE;
}
};
+#endif
class RenderEngineTest : public ::testing::TestWithParam<std::shared_ptr<RenderEngineFactory>> {
public:
@@ -1497,10 +1509,15 @@
expectBufferColor(Rect(kGreyLevels, 1), generator, 2);
}
+// TODO: b/341728634 - Clean up conditional compilation.
INSTANTIATE_TEST_SUITE_P(PerRenderEngineType, RenderEngineTest,
testing::Values(std::make_shared<SkiaGLESRenderEngineFactory>(),
- std::make_shared<GaneshVkRenderEngineFactory>(),
- std::make_shared<GraphiteVkRenderEngineFactory>()));
+ std::make_shared<GaneshVkRenderEngineFactory>()
+#if COMPILE_GRAPHITE_RENDERENGINE
+ ,
+ std::make_shared<GraphiteVkRenderEngineFactory>()
+#endif
+ ));
TEST_P(RenderEngineTest, drawLayers_noLayersToDraw) {
if (!GetParam()->apiSupported()) {