Enable SkiaPipelines to interoperate with existing GlesDriver configs.
Test: hwui unit tests
Change-Id: Icd94d0e21130d86fb5514801f999d0018a69e151
diff --git a/libs/hwui/debug/GlesDriver.cpp b/libs/hwui/debug/GlesDriver.cpp
index b8ef639..97e8f3a 100644
--- a/libs/hwui/debug/GlesDriver.cpp
+++ b/libs/hwui/debug/GlesDriver.cpp
@@ -36,6 +36,11 @@
return ret;
}
+sk_sp<const GrGLInterface> GlesDriver::getSkiaInterface() {
+ sk_sp<const GrGLInterface> skiaInterface(GrGLCreateNativeInterface());
+ return skiaInterface;
+}
+
} // namespace debug
} // namespace uirenderer
} // namespace android
diff --git a/libs/hwui/debug/GlesDriver.h b/libs/hwui/debug/GlesDriver.h
index ca6f4b6..3c36487 100644
--- a/libs/hwui/debug/GlesDriver.h
+++ b/libs/hwui/debug/GlesDriver.h
@@ -28,6 +28,7 @@
#include <GLES3/gl31.h>
#include <GLES3/gl32.h>
+#include <gl/GrGLInterface.h>
#include <memory>
namespace android {
@@ -39,6 +40,7 @@
class GlesDriver {
public:
virtual ~GlesDriver() {}
+ virtual sk_sp<const GrGLInterface> getSkiaInterface();
#define GL_ENTRY(ret, api, ...) virtual ret api##_(__VA_ARGS__) = 0;
#include "gles_decls.in"
diff --git a/libs/hwui/debug/NullGlesDriver.cpp b/libs/hwui/debug/NullGlesDriver.cpp
index e9dbc74..8fbe4bf 100644
--- a/libs/hwui/debug/NullGlesDriver.cpp
+++ b/libs/hwui/debug/NullGlesDriver.cpp
@@ -20,6 +20,11 @@
namespace uirenderer {
namespace debug {
+sk_sp<const GrGLInterface> NullGlesDriver::getSkiaInterface() {
+ sk_sp<const GrGLInterface> skiaInterface(GrGLCreateNullInterface());
+ return skiaInterface;
+}
+
struct {
GLboolean scissorEnabled;
} gState;
diff --git a/libs/hwui/debug/NullGlesDriver.h b/libs/hwui/debug/NullGlesDriver.h
index d731379..37ca8f34 100644
--- a/libs/hwui/debug/NullGlesDriver.h
+++ b/libs/hwui/debug/NullGlesDriver.h
@@ -24,6 +24,8 @@
class NullGlesDriver : public FatalBaseDriver {
public:
+ virtual sk_sp<const GrGLInterface> getSkiaInterface() override;
+
virtual void glGenBuffers_(GLsizei n, GLuint *buffers) override;
virtual void glGenFramebuffers_(GLsizei n, GLuint *framebuffers) override;
virtual void glGenRenderbuffers_(GLsizei n, GLuint *renderbuffers) override;
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index beaa85e..de95bee 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -30,6 +30,10 @@
#include <gl/GrGLInterface.h>
#include <string>
+#ifdef HWUI_GLES_WRAP_ENABLED
+#include "debug/GlesDriver.h"
+#endif
+
#define GLES_VERSION 2
// Android-specific addition that is used to show when frames began in systrace
@@ -131,7 +135,12 @@
mRenderThread.renderState().onGLContextCreated();
if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL) {
+#ifdef HWUI_GLES_WRAP_ENABLED
+ debug::GlesDriver* driver = debug::GlesDriver::get();
+ sk_sp<const GrGLInterface> glInterface(driver->getSkiaInterface());
+#else
sk_sp<const GrGLInterface> glInterface(GrGLCreateNativeInterface());
+#endif
LOG_ALWAYS_FATAL_IF(!glInterface.get());
GrContextOptions options;