summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger
diff options
context:
space:
mode:
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r--services/surfaceflinger/Android.mk4
-rw-r--r--services/surfaceflinger/DisplayHardware/DisplayHardware.cpp11
-rw-r--r--services/surfaceflinger/LayerScreenshot.cpp46
-rw-r--r--services/surfaceflinger/LayerScreenshot.h6
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp35
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h4
6 files changed, 83 insertions, 23 deletions
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 61a8358..53502db 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -30,6 +30,10 @@ ifeq ($(TARGET_BOARD_PLATFORM), s5pc110)
LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY -DNEVER_DEFAULT_TO_ASYNC_MODE
endif
+ifneq (,$(findstring $(TARGET_DEVICE),tuna toro maguro))
+ LOCAL_CFLAGS += -DREFRESH_RATE=59
+endif
+
LOCAL_SHARED_LIBRARIES := \
libcutils \
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
index f4be168..329c052 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
@@ -141,6 +141,17 @@ void DisplayHardware::init(uint32_t dpy)
mDpiY = mNativeWindow->ydpi;
mRefreshRate = fbDev->fps;
+
+/* FIXME: this 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
+ mRefreshRate = fbDev->fps;
+#else
+ mRefreshRate = REFRESH_RATE;
+#warning "refresh rate set via makefile to REFRESH_RATE"
+#endif
+
EGLint w, h, dummy;
EGLint numConfigs=0;
EGLSurface surface;
diff --git a/services/surfaceflinger/LayerScreenshot.cpp b/services/surfaceflinger/LayerScreenshot.cpp
index e30ccbf..68e6660 100644
--- a/services/surfaceflinger/LayerScreenshot.cpp
+++ b/services/surfaceflinger/LayerScreenshot.cpp
@@ -27,6 +27,7 @@
#include "SurfaceFlinger.h"
#include "DisplayHardware/DisplayHardware.h"
+
namespace android {
// ---------------------------------------------------------------------------
@@ -45,23 +46,64 @@ LayerScreenshot::~LayerScreenshot()
}
}
+status_t LayerScreenshot::captureLocked() {
+ GLfloat u, v;
+ status_t result = mFlinger->renderScreenToTextureLocked(0, &mTextureName, &u, &v);
+ if (result != NO_ERROR) {
+ return result;
+ }
+ initTexture(u, v);
+ return NO_ERROR;
+}
+
status_t LayerScreenshot::capture() {
GLfloat u, v;
status_t result = mFlinger->renderScreenToTexture(0, &mTextureName, &u, &v);
if (result != NO_ERROR) {
return result;
}
+ initTexture(u, v);
+ return NO_ERROR;
+}
+void LayerScreenshot::initTexture(GLfloat u, GLfloat v) {
glBindTexture(GL_TEXTURE_2D, mTextureName);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
mTexCoords[0] = 0; mTexCoords[1] = v;
mTexCoords[2] = 0; mTexCoords[3] = 0;
mTexCoords[4] = u; mTexCoords[5] = 0;
mTexCoords[6] = u; mTexCoords[7] = v;
+}
- return NO_ERROR;
+void LayerScreenshot::initStates(uint32_t w, uint32_t h, uint32_t flags) {
+ LayerBaseClient::initStates(w, h, flags);
+ if (!(flags & ISurfaceComposer::eHidden)) {
+ capture();
+ }
+}
+
+uint32_t LayerScreenshot::doTransaction(uint32_t flags)
+{
+ const Layer::State& draw(drawingState());
+ const Layer::State& curr(currentState());
+
+ if (draw.flags & ISurfaceComposer::eLayerHidden) {
+ if (!(curr.flags & ISurfaceComposer::eLayerHidden)) {
+ // we're going from hidden to visible
+ status_t err = captureLocked();
+ if (err != NO_ERROR) {
+ LOGW("createScreenshotSurface failed (%s)", strerror(-err));
+ }
+ }
+ } else if (curr.flags & ISurfaceComposer::eLayerHidden) {
+ // we're going from visible to hidden
+ if (mTextureName) {
+ glDeleteTextures(1, &mTextureName);
+ mTextureName = 0;
+ }
+ }
+ return LayerBaseClient::doTransaction(flags);
}
void LayerScreenshot::onDraw(const Region& clip) const
diff --git a/services/surfaceflinger/LayerScreenshot.h b/services/surfaceflinger/LayerScreenshot.h
index e3a2b19..ab90047 100644
--- a/services/surfaceflinger/LayerScreenshot.h
+++ b/services/surfaceflinger/LayerScreenshot.h
@@ -41,12 +41,18 @@ public:
status_t capture();
+ virtual void initStates(uint32_t w, uint32_t h, uint32_t flags);
+ virtual uint32_t doTransaction(uint32_t flags);
virtual void onDraw(const Region& clip) const;
virtual bool isOpaque() const { return false; }
virtual bool isSecure() const { return false; }
virtual bool isProtectedByApp() const { return false; }
virtual bool isProtectedByDRM() const { return false; }
virtual const char* getTypeId() const { return "LayerScreenshot"; }
+
+private:
+ status_t captureLocked();
+ void initTexture(GLfloat u, GLfloat v);
};
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a6d4147..1b00e93 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1217,23 +1217,25 @@ void SurfaceFlinger::setTransactionState(const Vector<ComposerState>& state,
sp<Client> client( static_cast<Client *>(s.client.get()) );
transactionFlags |= setClientStateLocked(client, s.state);
}
+
if (transactionFlags) {
+ // this triggers the transaction
setTransactionFlags(transactionFlags);
- }
- // if this is a synchronous transaction, wait for it to take effect before
- // returning.
- if (flags & eSynchronous) {
- mTransationPending = true;
- }
- while (mTransationPending) {
- status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5));
- if (CC_UNLIKELY(err != NO_ERROR)) {
- // just in case something goes wrong in SF, return to the
- // called after a few seconds.
- LOGW_IF(err == TIMED_OUT, "closeGlobalTransaction timed out!");
- mTransationPending = false;
- break;
+ // if this is a synchronous transaction, wait for it to take effect
+ // before returning.
+ if (flags & eSynchronous) {
+ mTransationPending = true;
+ }
+ while (mTransationPending) {
+ status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5));
+ if (CC_UNLIKELY(err != NO_ERROR)) {
+ // just in case something goes wrong in SF, return to the
+ // called after a few seconds.
+ LOGW_IF(err == TIMED_OUT, "closeGlobalTransaction timed out!");
+ mTransationPending = false;
+ break;
+ }
}
}
}
@@ -1360,11 +1362,6 @@ sp<LayerScreenshot> SurfaceFlinger::createScreenshotSurface(
uint32_t w, uint32_t h, uint32_t flags)
{
sp<LayerScreenshot> layer = new LayerScreenshot(this, display, client);
- status_t err = layer->capture();
- if (err != NO_ERROR) {
- layer.clear();
- LOGW("createScreenshotSurface failed (%s)", strerror(-err));
- }
return layer;
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index ea5bfa7..17028db 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -186,6 +186,8 @@ public:
status_t renderScreenToTexture(DisplayID dpy,
GLuint* textureName, GLfloat* uOut, GLfloat* vOut);
+ status_t renderScreenToTextureLocked(DisplayID dpy,
+ GLuint* textureName, GLfloat* uOut, GLfloat* vOut);
status_t postMessageAsync(const sp<MessageBase>& msg,
nsecs_t reltime=0, uint32_t flags = 0);
@@ -328,8 +330,6 @@ private:
status_t turnElectronBeamOnImplLocked(int32_t mode);
status_t electronBeamOffAnimationImplLocked();
status_t electronBeamOnAnimationImplLocked();
- status_t renderScreenToTextureLocked(DisplayID dpy,
- GLuint* textureName, GLfloat* uOut, GLfloat* vOut);
void debugFlashRegions();
void debugShowFPS() const;