SF: Separate RenderEngine into interface and impl
This allows the RenderEngine to be substituted by a GMock for tests.
RE::RenderEngine is now a pure virtual interface class.
RE::impl::RenderEngine is the normal/base implementation.
Similarly, RE::Image and RE::Surface are pure virtual interfaces.
RE::impl::Image and RE::impl::Surface are the normal implementations.
Test: Builds
Bug: None
Change-Id: Ib5e658df4bb4efc1a9c0ae95feaf0c1e052cdc94
diff --git a/services/surfaceflinger/RenderEngine/Surface.h b/services/surfaceflinger/RenderEngine/Surface.h
index 8b10be9..d4d3d8c 100644
--- a/services/surfaceflinger/RenderEngine/Surface.h
+++ b/services/surfaceflinger/RenderEngine/Surface.h
@@ -23,39 +23,60 @@
struct ANativeWindow;
namespace android {
-
-class RenderEngine;
-
namespace RE {
class Surface {
public:
+ virtual ~Surface() = 0;
+
+ virtual void setCritical(bool enable) = 0;
+ virtual void setAsync(bool enable) = 0;
+
+ virtual void setNativeWindow(ANativeWindow* window) = 0;
+ virtual void swapBuffers() const = 0;
+
+ virtual int32_t queryRedSize() const = 0;
+ virtual int32_t queryGreenSize() const = 0;
+ virtual int32_t queryBlueSize() const = 0;
+ virtual int32_t queryAlphaSize() const = 0;
+
+ virtual int32_t queryWidth() const = 0;
+ virtual int32_t queryHeight() const = 0;
+};
+
+namespace impl {
+
+class RenderEngine;
+
+class Surface final : public RE::Surface {
+public:
Surface(const RenderEngine& engine);
~Surface();
Surface(const Surface&) = delete;
Surface& operator=(const Surface&) = delete;
- void setCritical(bool enable) { mCritical = enable; }
- void setAsync(bool enable) { mAsync = enable; }
+ // RE::Surface implementation
+ void setCritical(bool enable) override { mCritical = enable; }
+ void setAsync(bool enable) override { mAsync = enable; }
- void setNativeWindow(ANativeWindow* window);
- void swapBuffers() const;
+ void setNativeWindow(ANativeWindow* window) override;
+ void swapBuffers() const override;
- int32_t queryRedSize() const;
- int32_t queryGreenSize() const;
- int32_t queryBlueSize() const;
- int32_t queryAlphaSize() const;
+ int32_t queryRedSize() const override;
+ int32_t queryGreenSize() const override;
+ int32_t queryBlueSize() const override;
+ int32_t queryAlphaSize() const override;
- int32_t queryWidth() const;
- int32_t queryHeight() const;
+ int32_t queryWidth() const override;
+ int32_t queryHeight() const override;
private:
EGLint queryConfig(EGLint attrib) const;
EGLint querySurface(EGLint attrib) const;
// methods internal to RenderEngine
- friend class android::RenderEngine;
+ friend class RenderEngine;
bool getAsync() const { return mAsync; }
EGLSurface getEGLSurface() const { return mEGLSurface; }
@@ -69,5 +90,6 @@
EGLSurface mEGLSurface = EGL_NO_SURFACE;
};
+} // namespace impl
} // namespace RE
} // namespace android