summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2013-03-20 11:37:21 -0700
committerJesse Hall <jessehall@google.com>2013-03-22 09:56:58 -0700
commit13f01cbdbd34779a234bc674df79e23672fd5c0b (patch)
tree9b1c9334f276ff039a2621fe0e639ff06249473c /services/surfaceflinger
parent8d8c75976171d194ca8f94727b22e3bf7676b9dd (diff)
downloadframeworks_native-13f01cbdbd34779a234bc674df79e23672fd5c0b.zip
frameworks_native-13f01cbdbd34779a234bc674df79e23672fd5c0b.tar.gz
frameworks_native-13f01cbdbd34779a234bc674df79e23672fd5c0b.tar.bz2
Pass sp<Fence>s around instead of file descriptors
Change-Id: Iac70584a2207940730e8f803a543e4e9a4000c47
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r--services/surfaceflinger/DisplayDevice.cpp4
-rw-r--r--services/surfaceflinger/DisplayHardware/DisplaySurface.h2
-rw-r--r--services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp14
-rw-r--r--services/surfaceflinger/DisplayHardware/FramebufferSurface.h2
-rw-r--r--services/surfaceflinger/DisplayHardware/HWComposer.cpp10
-rw-r--r--services/surfaceflinger/DisplayHardware/HWComposer.h4
-rw-r--r--services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp3
-rw-r--r--services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h2
-rw-r--r--services/surfaceflinger/Layer.cpp2
9 files changed, 20 insertions, 23 deletions
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 5493e7d..e16abef 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -235,8 +235,8 @@ void DisplayDevice::swapBuffers(HWComposer& hwc) const {
void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const {
if (hwc.initCheck() == NO_ERROR) {
- int fd = hwc.getAndResetReleaseFenceFd(mType);
- mDisplaySurface->onFrameCommitted(fd);
+ sp<Fence> fence = hwc.getAndResetReleaseFence(mType);
+ mDisplaySurface->onFrameCommitted(fence);
}
}
diff --git a/services/surfaceflinger/DisplayHardware/DisplaySurface.h b/services/surfaceflinger/DisplayHardware/DisplaySurface.h
index 6445848..bc717a9 100644
--- a/services/surfaceflinger/DisplayHardware/DisplaySurface.h
+++ b/services/surfaceflinger/DisplayHardware/DisplaySurface.h
@@ -52,7 +52,7 @@ public:
// hardware composer and a release fence is available for the buffer.
// Further operations on the buffer can be queued as long as they wait for
// the fence to signal.
- virtual void onFrameCommitted(int fenceFd) = 0;
+ virtual void onFrameCommitted(const sp<Fence>& fence) = 0;
virtual void dump(String8& result) const = 0;
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
index 83ab38e..c35ac95 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
@@ -140,14 +140,12 @@ void FramebufferSurface::freeBufferLocked(int slotIndex) {
}
}
-void FramebufferSurface::onFrameCommitted(int fenceFd) {
- if (fenceFd >= 0) {
- sp<Fence> fence(new Fence(fenceFd));
- if (mCurrentBufferSlot != BufferQueue::INVALID_BUFFER_SLOT) {
- status_t err = addReleaseFence(mCurrentBufferSlot, fence);
- ALOGE_IF(err, "setReleaseFenceFd: failed to add the fence: %s (%d)",
- strerror(-err), err);
- }
+void FramebufferSurface::onFrameCommitted(const sp<Fence>& fence) {
+ if (fence->isValid() &&
+ mCurrentBufferSlot != BufferQueue::INVALID_BUFFER_SLOT) {
+ status_t err = addReleaseFence(mCurrentBufferSlot, fence);
+ ALOGE_IF(err, "setReleaseFenceFd: failed to add the fence: %s (%d)",
+ strerror(-err), err);
}
}
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
index 1402740..164f81f 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
@@ -43,7 +43,7 @@ public:
virtual status_t compositionComplete();
virtual status_t advanceFrame();
- virtual void onFrameCommitted(int fenceFd);
+ virtual void onFrameCommitted(const sp<Fence>& fence);
// Implementation of DisplaySurface::dump(). Note that ConsumerBase also
// has a non-virtual dump() with the same signature.
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 8599a29..eb7d128 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -627,9 +627,9 @@ bool HWComposer::hasGlesComposition(int32_t id) const {
return mDisplayData[id].hasFbComp;
}
-int HWComposer::getAndResetReleaseFenceFd(int32_t id) {
+sp<Fence> HWComposer::getAndResetReleaseFence(int32_t id) {
if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
- return BAD_INDEX;
+ return Fence::NO_FENCE;
int fd = INVALID_OPERATION;
if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
@@ -640,7 +640,7 @@ int HWComposer::getAndResetReleaseFenceFd(int32_t id) {
disp.framebufferTarget->releaseFenceFd = -1;
}
}
- return fd;
+ return fd >= 0 ? new Fence(fd) : Fence::NO_FENCE;
}
status_t HWComposer::commit() {
@@ -803,10 +803,10 @@ public:
virtual uint32_t getHints() const {
return getLayer()->hints;
}
- virtual int getAndResetReleaseFenceFd() {
+ virtual sp<Fence> getAndResetReleaseFence() {
int fd = getLayer()->releaseFenceFd;
getLayer()->releaseFenceFd = -1;
- return fd;
+ return fd >= 0 ? new Fence(fd) : Fence::NO_FENCE;
}
virtual void setAcquireFenceFd(int fenceFd) {
getLayer()->acquireFenceFd = fenceFd;
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index fdbd2d9..346526a 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -114,7 +114,7 @@ public:
// get the releaseFence file descriptor for a display's framebuffer layer.
// the release fence is only valid after commit()
- int getAndResetReleaseFenceFd(int32_t id);
+ sp<Fence> getAndResetReleaseFence(int32_t id);
// needed forward declarations
class LayerListIterator;
@@ -141,7 +141,7 @@ public:
public:
virtual int32_t getCompositionType() const = 0;
virtual uint32_t getHints() const = 0;
- virtual int getAndResetReleaseFenceFd() = 0;
+ virtual sp<Fence> getAndResetReleaseFence() = 0;
virtual void setDefaultState() = 0;
virtual void setSkip(bool skip) = 0;
virtual void setBlending(uint32_t blending) = 0;
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
index fac6c3e..255b77f 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
@@ -70,9 +70,8 @@ status_t VirtualDisplaySurface::advanceFrame() {
return mHwc.fbPost(mDisplayId, fence, mAcquiredBuffer);
}
-void VirtualDisplaySurface::onFrameCommitted(int fenceFd) {
+void VirtualDisplaySurface::onFrameCommitted(const sp<Fence>& fence) {
Mutex::Autolock lock(mMutex);
- sp<Fence> fence(new Fence(fenceFd));
if (mAcquiredBuffer != NULL) {
status_t result = mSource->releaseBuffer(fence);
ALOGE_IF(result != NO_ERROR, "VirtualDisplaySurface \"%s\": "
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
index 85a7a87..1347680 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
@@ -58,7 +58,7 @@ public:
virtual status_t compositionComplete();
virtual status_t advanceFrame();
- virtual void onFrameCommitted(int fenceFd);
+ virtual void onFrameCommitted(const sp<Fence>& fence);
virtual void dump(String8& result) const;
private:
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 1677c76..a4c613c 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -144,7 +144,7 @@ void Layer::onLayerDisplayed(const sp<const DisplayDevice>& hw,
HWComposer::HWCLayerInterface* layer) {
if (layer) {
layer->onDisplayed();
- mSurfaceFlingerConsumer->setReleaseFence(layer->getAndResetReleaseFenceFd());
+ mSurfaceFlingerConsumer->setReleaseFence(layer->getAndResetReleaseFence());
}
}