Merge "Hidden API for setting p2p NFC modes."
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index d344737..ff550d9 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -16,11 +16,13 @@
 */
 
 #define LOG_TAG "GraphicBufferAllocator"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
 
 #include <cutils/log.h>
 
 #include <utils/Singleton.h>
 #include <utils/String8.h>
+#include <utils/Trace.h>
 
 #include <ui/GraphicBufferAllocator.h>
 
@@ -91,6 +93,7 @@
 status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat format,
         int usage, buffer_handle_t* handle, int32_t* stride)
 {
+    ATRACE_CALL();
     // make sure to not allocate a N x 0 or 0 x N buffer, since this is
     // allowed from an API stand-point allocate a 1x1 buffer instead.
     if (!w || !h)
@@ -128,6 +131,7 @@
 
 status_t GraphicBufferAllocator::free(buffer_handle_t handle)
 {
+    ATRACE_CALL();
     status_t err;
 
     err = mAllocDev->free(mAllocDev, handle);
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index b173c85..967da98 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -15,12 +15,14 @@
  */
 
 #define LOG_TAG "GraphicBufferMapper"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
 
 #include <stdint.h>
 #include <errno.h>
 
 #include <utils/Errors.h>
 #include <utils/Log.h>
+#include <utils/Trace.h>
 
 #include <ui/GraphicBufferMapper.h>
 #include <ui/Rect.h>
@@ -46,6 +48,7 @@
 
 status_t GraphicBufferMapper::registerBuffer(buffer_handle_t handle)
 {
+    ATRACE_CALL();
     status_t err;
 
     err = mAllocMod->registerBuffer(mAllocMod, handle);
@@ -57,6 +60,7 @@
 
 status_t GraphicBufferMapper::unregisterBuffer(buffer_handle_t handle)
 {
+    ATRACE_CALL();
     status_t err;
 
     err = mAllocMod->unregisterBuffer(mAllocMod, handle);
@@ -69,6 +73,7 @@
 status_t GraphicBufferMapper::lock(buffer_handle_t handle, 
         int usage, const Rect& bounds, void** vaddr)
 {
+    ATRACE_CALL();
     status_t err;
 
     err = mAllocMod->lock(mAllocMod, handle, usage,
@@ -81,6 +86,7 @@
 
 status_t GraphicBufferMapper::unlock(buffer_handle_t handle)
 {
+    ATRACE_CALL();
     status_t err;
 
     err = mAllocMod->unlock(mAllocMod, handle);
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp
index af0da0b..3c045d7 100644
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+
 #include <stdint.h>
 #include <sys/types.h>
 
@@ -21,6 +23,7 @@
 #include <gui/DisplayEventReceiver.h>
 
 #include <utils/Errors.h>
+#include <utils/Trace.h>
 
 #include "DisplayHardware/DisplayHardware.h"
 #include "DisplayEventConnection.h"
@@ -146,6 +149,7 @@
             // at least one listener requested VSYNC
             mLock.unlock();
             timestamp = mHw.waitForRefresh();
+            ATRACE_INT("VSYNC", mDeliveredEvents&1);
             mLock.lock();
             mDeliveredEvents++;
             mLastVSyncTimestamp = timestamp;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 42ed4fa..7f61fe4 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -460,6 +460,7 @@
 
 void SurfaceFlinger::postFramebuffer()
 {
+    ATRACE_CALL();
     // mSwapRegion can be empty here is some cases, for instance if a hidden
     // or fully transparent window is updating.
     // in that case, we need to flip anyways to not risk a deadlock with
@@ -504,6 +505,8 @@
 
 void SurfaceFlinger::handleTransaction(uint32_t transactionFlags)
 {
+    ATRACE_CALL();
+
     Mutex::Autolock _l(mStateLock);
     const nsecs_t now = systemTime();
     mDebugInTransaction = now;
@@ -601,6 +604,8 @@
 void SurfaceFlinger::computeVisibleRegions(
     const LayerVector& currentLayers, Region& dirtyRegion, Region& opaqueRegion)
 {
+    ATRACE_CALL();
+
     const GraphicPlane& plane(graphicPlane(0));
     const Transform& planeTransform(plane.transform());
     const DisplayHardware& hw(plane.displayHardware());
@@ -841,6 +846,8 @@
 
 void SurfaceFlinger::handleRepaint()
 {
+    ATRACE_CALL();
+
     // compute the invalid region
     mSwapRegion.orSelf(mDirtyRegion);