factor EGL/GL and surface creation out of DisplayHardware
Change-Id: Icd85a6a4caad06f056578008af3e21666fa8b1f4
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
index 6cfb190..7695e7f 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
@@ -38,6 +38,15 @@
namespace android {
// ----------------------------------------------------------------------------
+sp<FramebufferSurface> FramebufferSurface::create() {
+ sp<FramebufferSurface> result = new FramebufferSurface();
+ if (result->fbDev == NULL) {
+ result = NULL;
+ }
+ return result;
+}
+
+// ----------------------------------------------------------------------------
/*
* This implements the (main) framebuffer management. This class is used
@@ -64,10 +73,19 @@
mUpdateOnDemand = (fbDev->setUpdateRect != 0);
const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags;
- const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi;
- const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi;
const_cast<int&>(ANativeWindow::minSwapInterval) = fbDev->minSwapInterval;
const_cast<int&>(ANativeWindow::maxSwapInterval) = fbDev->maxSwapInterval;
+
+ if (fbDev->xdpi == 0 || fbDev->ydpi == 0) {
+ ALOGE("invalid screen resolution from fb HAL (xdpi=%f, ydpi=%f), "
+ "defaulting to 160 dpi", fbDev->xdpi, fbDev->ydpi);
+ const_cast<float&>(ANativeWindow::xdpi) = 160;
+ const_cast<float&>(ANativeWindow::ydpi) = 160;
+ } else {
+ const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi;
+ const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi;
+ }
+
} else {
ALOGE("Couldn't get gralloc module");
}
@@ -139,6 +157,19 @@
}
}
+float FramebufferSurface::getRefreshRate() const {
+ /* FIXME: REFRESH_RATE is a temporary HACK until we are able to report the
+ * refresh rate properly from the HAL. The WindowManagerService now relies
+ * on this value.
+ */
+#ifndef REFRESH_RATE
+ return fbDev->fps;
+#else
+ return REFRESH_RATE;
+#warning "refresh rate set via makefile to REFRESH_RATE"
+#endif
+}
+
status_t FramebufferSurface::setUpdateRectangle(const Rect& r)
{
if (!mUpdateOnDemand) {