OSDN Git Service

SF: Disable FenceTracker from makefile
authorPablo Ceballos <pceballos@google.com>
Wed, 30 Mar 2016 22:28:05 +0000 (15:28 -0700)
committerPablo Ceballos <pceballos@google.com>
Wed, 30 Mar 2016 22:28:05 +0000 (15:28 -0700)
- Add tracing to the FenceTracker.
- Disable it by default with #ifdefs, it can be enabled in the
  makefile.

Bug 27882222

Change-Id: I640e028c4dc97b46e800a7f21cdb2cb6a4b4ff18

services/surfaceflinger/Android.mk
services/surfaceflinger/FenceTracker.cpp
services/surfaceflinger/SurfaceFlinger.cpp
services/surfaceflinger/SurfaceFlinger_hwc1.cpp

index d0a0401..44a3334 100644 (file)
@@ -40,7 +40,7 @@ LOCAL_SRC_FILES := \
 
 LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\"
 LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-
+#LOCAL_CFLAGS += -DENABLE_FENCE_TRACKING
 
 USE_HWC2 := false
 ifeq ($(USE_HWC2),true)
index 7da1d93..885d712 100644 (file)
  * limitations under the License.
  */
 
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+
 #include <inttypes.h>
 #include "FenceTracker.h"
 #include "Layer.h"
+#include <utils/Trace.h>
 
 namespace android {
 
@@ -78,6 +81,7 @@ static inline bool isValidTimestamp(nsecs_t time) {
 }
 
 void FenceTracker::checkFencesForCompletion() {
+    ATRACE_CALL();
     for (auto& frame : mFrames) {
         if (frame.retireFence != Fence::NO_FENCE) {
             nsecs_t time = frame.retireFence->getSignalTime();
@@ -115,6 +119,7 @@ void FenceTracker::checkFencesForCompletion() {
 
 void FenceTracker::addFrame(nsecs_t refreshStartTime, sp<Fence> retireFence,
         const Vector<sp<Layer>>& layers, sp<Fence> glDoneFence) {
+    ATRACE_CALL();
     Mutex::Autolock lock(mMutex);
     FrameRecord& frame = mFrames[mOffset];
     FrameRecord& prevFrame = mFrames[(mOffset + MAX_FRAME_HISTORY - 1) %
index 9b43849..ea9fe21 100644 (file)
@@ -910,7 +910,11 @@ bool SurfaceFlinger::handleMessageInvalidate() {
 void SurfaceFlinger::handleMessageRefresh() {
     ATRACE_CALL();
 
+#ifdef ENABLE_FENCE_TRACKING
     nsecs_t refreshStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+#else
+    nsecs_t refreshStartTime = 0;
+#endif
     static nsecs_t previousExpectedPresent = 0;
     nsecs_t expectedPresent = mPrimaryDispSync.computeNextRefresh(0);
     static bool previousFrameMissed = false;
@@ -1000,7 +1004,11 @@ void SurfaceFlinger::preComposition()
     }
 }
 
+#ifdef ENABLE_FENCE_TRACKING
 void SurfaceFlinger::postComposition(nsecs_t refreshStartTime)
+#else
+void SurfaceFlinger::postComposition(nsecs_t /*refreshStartTime*/)
+#endif
 {
     ATRACE_CALL();
     ALOGV("postComposition");
@@ -1028,8 +1036,10 @@ void SurfaceFlinger::postComposition(nsecs_t refreshStartTime)
         }
     }
 
+#ifdef ENABLE_FENCE_TRACKING
     mFenceTracker.addFrame(refreshStartTime, presentFence,
             hw->getVisibleLayersSortedByZ(), hw->getClientTargetAcquireFence());
+#endif
 
     if (mAnimCompositionPending) {
         mAnimCompositionPending = false;
@@ -2548,12 +2558,14 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
                 dumpAll = false;
             }
 
+#ifdef ENABLE_FENCE_TRACKING
             if ((index < numArgs) &&
                     (args[index] == String16("--fences"))) {
                 index++;
                 mFenceTracker.dump(&result);
                 dumpAll = false;
             }
+#endif
         }
 
         if (dumpAll) {
index 11f19d0..a63ec50 100644 (file)
@@ -927,7 +927,11 @@ bool SurfaceFlinger::handleMessageInvalidate() {
 void SurfaceFlinger::handleMessageRefresh() {
     ATRACE_CALL();
 
+#ifdef ENABLE_FENCE_TRACKING
     nsecs_t refreshStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+#else
+    nsecs_t refreshStartTime = 0;
+#endif
     static nsecs_t previousExpectedPresent = 0;
     nsecs_t expectedPresent = mPrimaryDispSync.computeNextRefresh(0);
     static bool previousFrameMissed = false;
@@ -1009,7 +1013,11 @@ void SurfaceFlinger::preComposition()
     }
 }
 
+#ifdef ENABLE_FENCE_TRACKING
 void SurfaceFlinger::postComposition(nsecs_t refreshStartTime)
+#else
+void SurfaceFlinger::postComposition(nsecs_t /*refreshStartTime*/)
+#endif
 {
     const LayerVector& layers(mDrawingState.layersSortedByZ);
     const size_t count = layers.size();
@@ -1035,8 +1043,10 @@ void SurfaceFlinger::postComposition(nsecs_t refreshStartTime)
         }
     }
 
+#ifdef ENABLE_FENCE_TRACKING
     mFenceTracker.addFrame(refreshStartTime, presentFence,
             hw->getVisibleLayersSortedByZ(), hw->getClientTargetAcquireFence());
+#endif
 
     if (mAnimCompositionPending) {
         mAnimCompositionPending = false;
@@ -2586,12 +2596,14 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
                 dumpAll = false;
             }
 
+#ifdef ENABLE_FENCE_TRACKING
             if ((index < numArgs) &&
                     (args[index] == String16("--fences"))) {
                 index++;
                 mFenceTracker.dump(&result);
                 dumpAll = false;
             }
+#endif
         }
 
         if (dumpAll) {