surfaceflinger: simplify BufferLayerConsumer constructor

Remove texTarget and isControlledByApp.

Test: boots
Change-Id: Ica15c618d5aaaf17a1dfc6abe1e0a2777015f1a0
diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp
index 05bb96a..9ade402 100644
--- a/services/surfaceflinger/BufferLayerConsumer.cpp
+++ b/services/surfaceflinger/BufferLayerConsumer.cpp
@@ -105,9 +105,8 @@
     return hasEglAndroidImageCrop() && (crop.left == 0 && crop.top == 0);
 }
 
-BufferLayerConsumer::BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex,
-                                         uint32_t texTarget, bool isControlledByApp)
-      : ConsumerBase(bq, isControlledByApp),
+BufferLayerConsumer::BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex)
+      : ConsumerBase(bq, false),
         mCurrentCrop(Rect::EMPTY_RECT),
         mCurrentTransform(0),
         mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
@@ -119,7 +118,6 @@
         mDefaultHeight(1),
         mFilteringEnabled(true),
         mTexName(tex),
-        mTexTarget(texTarget),
         mEglDisplay(EGL_NO_DISPLAY),
         mEglContext(EGL_NO_CONTEXT),
         mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT) {
@@ -167,7 +165,7 @@
         if (err == BufferQueue::NO_BUFFER_AVAILABLE) {
             // We always bind the texture even if we don't update its contents.
             BLC_LOGV("updateTexImage: no buffers were available");
-            glBindTexture(mTexTarget, mTexName);
+            glBindTexture(sTexTarget, mTexName);
             err = NO_ERROR;
         } else {
             BLC_LOGE("updateTexImage: acquire failed: %s (%d)", strerror(-err), err);
@@ -179,7 +177,7 @@
     err = updateAndReleaseLocked(item);
     if (err != NO_ERROR) {
         // We always bind the texture.
-        glBindTexture(mTexTarget, mTexName);
+        glBindTexture(sTexTarget, mTexName);
         return err;
     }
 
@@ -299,7 +297,7 @@
         BLC_LOGW("bindTextureImage: clearing GL error: %#04x", error);
     }
 
-    glBindTexture(mTexTarget, mTexName);
+    glBindTexture(sTexTarget, mTexName);
     if (mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT && mCurrentTextureImage == NULL) {
         BLC_LOGE("bindTextureImage: no currently-bound texture");
         return NO_INIT;
@@ -311,7 +309,7 @@
                  mCurrentTexture);
         return UNKNOWN_ERROR;
     }
-    mCurrentTextureImage->bindToTextureTarget(mTexTarget);
+    mCurrentTextureImage->bindToTextureTarget(sTexTarget);
 
     // Wait for the new buffer to be ready.
     return doGLFenceWaitLocked();
@@ -387,10 +385,6 @@
     return OK;
 }
 
-uint32_t BufferLayerConsumer::getCurrentTextureTarget() const {
-    return mTexTarget;
-}
-
 void BufferLayerConsumer::getTransformMatrix(float mtx[16]) {
     Mutex::Autolock lock(mMutex);
     memcpy(mtx, mCurrentTransformMatrix, sizeof(mCurrentTransformMatrix));
diff --git a/services/surfaceflinger/BufferLayerConsumer.h b/services/surfaceflinger/BufferLayerConsumer.h
index 4b34d75..3e08aa4 100644
--- a/services/surfaceflinger/BufferLayerConsumer.h
+++ b/services/surfaceflinger/BufferLayerConsumer.h
@@ -53,16 +53,12 @@
  */
 class BufferLayerConsumer : public ConsumerBase {
 public:
-    enum { TEXTURE_EXTERNAL = 0x8D65 }; // GL_TEXTURE_EXTERNAL_OES
     typedef ConsumerBase::FrameAvailableListener FrameAvailableListener;
 
     // BufferLayerConsumer constructs a new BufferLayerConsumer object.
     // The tex parameter indicates the name of the OpenGL ES
-    // texture to which images are to be streamed. texTarget specifies the
-    // OpenGL ES texture target to which the texture will be bound in
-    // updateTexImage.
-    BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex, uint32_t texureTarget,
-                        bool isControlledByApp);
+    // texture to which images are to be streamed.
+    BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex);
 
     // updateTexImage acquires the most recently queued buffer, and sets the
     // image contents of the target texture to it.
@@ -147,10 +143,6 @@
     // returned.
     sp<GraphicBuffer> getCurrentBuffer(int* outSlot = nullptr) const;
 
-    // getCurrentTextureTarget returns the texture target of the current
-    // texture as returned by updateTexImage().
-    uint32_t getCurrentTextureTarget() const;
-
     // getCurrentCrop returns the cropping rectangle of the current buffer.
     Rect getCurrentCrop() const;
 
@@ -203,7 +195,7 @@
     status_t updateAndReleaseLocked(const BufferItem& item,
                                     PendingRelease* pendingRelease = nullptr);
 
-    // Binds mTexName and the current buffer to mTexTarget.  Uses
+    // Binds mTexName and the current buffer to sTexTarget.  Uses
     // mCurrentTexture if it's set, mCurrentTextureImage if not.  If the
     // bind succeeds, this calls doGLFenceWait.
     status_t bindTextureImageLocked();
@@ -288,6 +280,10 @@
     // before the outstanding accesses have completed.
     status_t syncForReleaseLocked(EGLDisplay dpy);
 
+    // sTexTarget is the GL texture target with which the GL texture object is
+    // associated.
+    static constexpr uint32_t sTexTarget = 0x8D65; // GL_TEXTURE_EXTERNAL_OES
+
     // The default consumer usage flags that BufferLayerConsumer always sets on its
     // BufferQueue instance; these will be OR:d with any additional flags passed
     // from the BufferLayerConsumer user. In particular, BufferLayerConsumer will always
@@ -345,15 +341,6 @@
     // be bound when updateTexImage is called. It is set at construction time.
     const uint32_t mTexName;
 
-    // mTexTarget is the GL texture target with which the GL texture object is
-    // associated.  It is set in the constructor and never changed.  It is
-    // almost always GL_TEXTURE_EXTERNAL_OES except for one use case in Android
-    // Browser.  In that case it is set to GL_TEXTURE_2D to allow
-    // glCopyTexSubImage to read from the texture.  This is a hack to work
-    // around a GL driver limitation on the number of FBO attachments, which the
-    // browser's tile cache exceeds.
-    const uint32_t mTexTarget;
-
     // EGLSlot contains the information and object references that
     // BufferLayerConsumer maintains about a BufferQueue buffer slot.
     struct EglSlot {
diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.h b/services/surfaceflinger/SurfaceFlingerConsumer.h
index 7fecd55..1453e35 100644
--- a/services/surfaceflinger/SurfaceFlingerConsumer.h
+++ b/services/surfaceflinger/SurfaceFlingerConsumer.h
@@ -40,7 +40,7 @@
 
     SurfaceFlingerConsumer(const sp<IGraphicBufferConsumer>& consumer,
             uint32_t tex, Layer* layer)
-        : BufferLayerConsumer(consumer, tex, BufferLayerConsumer::TEXTURE_EXTERNAL, false),
+        : BufferLayerConsumer(consumer, tex),
           mTransformToDisplayInverse(false), mSurfaceDamage(), mLayer(layer)
     {}