Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge changes Ia732806b,Ibd397fb3 into ics

* changes:
  Hold a reference to the allocated buffers in GraphicBufferAlloc
  opengl: remove unused adreno flag from the makefile
  • Loading branch information...
commit 48ba49d343f4b9faab092983c07c5557e22ec612 2 parents 72c57da + f7519f3
Giulio Cervera authored Gerrit Code Review committed
8  include/surfaceflinger/IGraphicBufferAlloc.h
@@ -38,6 +38,14 @@ class IGraphicBufferAlloc : public IInterface
38 38
      */
39 39
     virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
40 40
             PixelFormat format, uint32_t usage, status_t* error) = 0;
  41
+
  42
+#ifdef QCOM_HARDWARE
  43
+    /* Free all but one of the GraphicBuffer objects that the server is
  44
+     * currently referencing. If bufIndex is not a valid index of the buffers
  45
+     * the server is referencing, then all buffers are freed.
  46
+     */
  47
+    virtual void freeAllGraphicBuffersExcept(int bufIndex) = 0;
  48
+#endif
41 49
 };
42 50
 
43 51
 // ----------------------------------------------------------------------------
21  libs/gui/IGraphicBufferAlloc.cpp
@@ -32,6 +32,9 @@ namespace android {
32 32
 
33 33
 enum {
34 34
     CREATE_GRAPHIC_BUFFER = IBinder::FIRST_CALL_TRANSACTION,
  35
+#ifdef QCOM_HARDWARE
  36
+    FREE_ALL_GRAPHIC_BUFFERS_EXCEPT,
  37
+#endif
35 38
 };
36 39
 
37 40
 class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc>
@@ -63,6 +66,16 @@ class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc>
63 66
         *error = result;
64 67
         return graphicBuffer;
65 68
     }
  69
+
  70
+#ifdef QCOM_HARDWARE
  71
+    virtual void freeAllGraphicBuffersExcept(int bufIdx) {
  72
+        Parcel data, reply;
  73
+        data.writeInterfaceToken(
  74
+                IGraphicBufferAlloc::getInterfaceDescriptor());
  75
+        data.writeInt32(bufIdx);
  76
+        remote()->transact(FREE_ALL_GRAPHIC_BUFFERS_EXCEPT, data, &reply);
  77
+    }
  78
+#endif
66 79
 };
67 80
 
68 81
 IMPLEMENT_META_INTERFACE(GraphicBufferAlloc, "android.ui.IGraphicBufferAlloc");
@@ -108,6 +121,14 @@ status_t BnGraphicBufferAlloc::onTransact(
108 121
             }
109 122
             return NO_ERROR;
110 123
         } break;
  124
+#ifdef QCOM_HARDWARE
  125
+        case FREE_ALL_GRAPHIC_BUFFERS_EXCEPT: {
  126
+            CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
  127
+            int bufIdx = data.readInt32();
  128
+            freeAllGraphicBuffersExcept(bufIdx);
  129
+            return NO_ERROR;
  130
+        } break;
  131
+#endif
111 132
         default:
112 133
             return BBinder::onTransact(code, data, reply, flags);
113 134
     }
6  libs/gui/SurfaceTexture.cpp
@@ -1104,6 +1104,9 @@ void SurfaceTexture::freeAllBuffersLocked() {
1104 1104
     for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
1105 1105
         freeBufferLocked(i);
1106 1106
     }
  1107
+#ifdef QCOM_HARDWARE
  1108
+    mGraphicBufferAlloc->freeAllGraphicBuffersExcept(-1);
  1109
+#endif
1107 1110
 }
1108 1111
 
1109 1112
 void SurfaceTexture::freeAllBuffersExceptHeadLocked() {
@@ -1120,6 +1123,9 @@ void SurfaceTexture::freeAllBuffersExceptHeadLocked() {
1120 1123
             freeBufferLocked(i);
1121 1124
         }
1122 1125
     }
  1126
+#ifdef QCOM_HARDWARE
  1127
+    mGraphicBufferAlloc->freeAllGraphicBuffersExcept(head);
  1128
+#endif
1123 1129
 }
1124 1130
 
1125 1131
 status_t SurfaceTexture::drainQueueLocked() {
4  opengl/libs/Android.mk
@@ -39,10 +39,6 @@ LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
39 39
 LOCAL_CFLAGS += -fvisibility=hidden
40 40
 LOCAL_CFLAGS += -DEGL_TRACE=1
41 41
 
42  
-ifeq ($(TARGET_BOARD_PLATFORM),msm7k)
43  
-LOCAL_CFLAGS += -DADRENO130=1
44  
-endif
45  
-
46 42
 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
47 43
   LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
48 44
 endif
16  services/surfaceflinger/SurfaceFlinger.cpp
@@ -2724,9 +2724,25 @@ sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h
2724 2724
                 w, h, strerror(-err), graphicBuffer->handle);
2725 2725
         return 0;
2726 2726
     }
  2727
+#ifdef QCOM_HARDWARE
  2728
+    Mutex::Autolock _l(mLock);
  2729
+    mBuffers.add(graphicBuffer);
  2730
+#endif
2727 2731
     return graphicBuffer;
2728 2732
 }
2729 2733
 
  2734
+#ifdef QCOM_HARDWARE
  2735
+void GraphicBufferAlloc::freeAllGraphicBuffersExcept(int bufIdx) {
  2736
+    Mutex::Autolock _l(mLock);
  2737
+    if (0 <= bufIdx && bufIdx < mBuffers.size()) {
  2738
+        sp<GraphicBuffer> b(mBuffers[bufIdx]);
  2739
+        mBuffers.clear();
  2740
+        mBuffers.add(b);
  2741
+    } else {
  2742
+        mBuffers.clear();
  2743
+    }
  2744
+}
  2745
+#endif
2730 2746
 // ---------------------------------------------------------------------------
2731 2747
 
2732 2748
 GraphicPlane::GraphicPlane()
6  services/surfaceflinger/SurfaceFlinger.h
@@ -97,6 +97,12 @@ class GraphicBufferAlloc : public BnGraphicBufferAlloc
97 97
     virtual ~GraphicBufferAlloc();
98 98
     virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
99 99
         PixelFormat format, uint32_t usage, status_t* error);
  100
+#ifdef QCOM_HARDWARE
  101
+    virtual void freeAllGraphicBuffersExcept(int bufIdx);
  102
+private:
  103
+    Vector<sp<GraphicBuffer> > mBuffers;
  104
+    Mutex mLock;
  105
+#endif
100 106
 };
101 107
 
102 108
 // ---------------------------------------------------------------------------

0 notes on commit 48ba49d

Please sign in to comment.
Something went wrong with that request. Please try again.