vulkan_renderengine: Check for support first

The vulkan_renderengine flag allows us to switch some users to using
Vulkan as part of the trunk stable process. But not all devices support
Vulkan.

Move canSupportSkiaVkRenderEngine into the RenderEngine header, so it
can be used by SurfaceFlinger. When the vulkan_renderengine flag is set,
check for support before choosing Vulkan. Do *not* log an error, since
this is specified broadly, so it is expected that the flag will be set
for devices that do not have support.

This introduces an extra call to initVulkanInterface, so log the amount
of time it takes. On my device, the first call is only ~17ms, so this
seems fine. The next call is much faster, ~4ms. The next call is not
interestingly different, possibly because the first call was already
made.

Bug: 293371537
Bug: 325619183
Test: atest librenderengine_test
Test: manual
Change-Id: Iba66e67347c69b95dc9c05ca838fa1391ef4ab81
diff --git a/libs/renderengine/tests/RenderEngineTest.cpp b/libs/renderengine/tests/RenderEngineTest.cpp
index 4c18704..7b8eb84 100644
--- a/libs/renderengine/tests/RenderEngineTest.cpp
+++ b/libs/renderengine/tests/RenderEngineTest.cpp
@@ -107,7 +107,7 @@
 
     virtual std::string name() = 0;
     virtual renderengine::RenderEngine::GraphicsApi graphicsApi() = 0;
-    virtual bool apiSupported() = 0;
+    bool apiSupported() { return renderengine::RenderEngine::canSupport(graphicsApi()); }
     std::unique_ptr<renderengine::RenderEngine> createRenderEngine() {
         renderengine::RenderEngineCreationArgs reCreationArgs =
                 renderengine::RenderEngineCreationArgs::Builder()
@@ -131,10 +131,6 @@
     renderengine::RenderEngine::GraphicsApi graphicsApi() override {
         return renderengine::RenderEngine::GraphicsApi::VK;
     }
-
-    bool apiSupported() override {
-        return skia::SkiaVkRenderEngine::canSupportSkiaVkRenderEngine();
-    }
 };
 
 class SkiaGLESRenderEngineFactory : public RenderEngineFactory {
@@ -144,8 +140,6 @@
     renderengine::RenderEngine::GraphicsApi graphicsApi() {
         return renderengine::RenderEngine::GraphicsApi::GL;
     }
-
-    bool apiSupported() override { return true; }
 };
 
 class RenderEngineTest : public ::testing::TestWithParam<std::shared_ptr<RenderEngineFactory>> {