surfaceflinger: move SurfaceFlingerConsumer::mLayer
Move mLayer and related methods to the base class,
BufferLayerConsumer.
Test: boots
Change-Id: I835ec0990b5bbdbd2b61444b6fbad700e0cb8c14
diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp
index 938a330..ae3c96c 100644
--- a/services/surfaceflinger/BufferLayerConsumer.cpp
+++ b/services/surfaceflinger/BufferLayerConsumer.cpp
@@ -21,6 +21,8 @@
#include "BufferLayerConsumer.h"
+#include "Layer.h"
+
#include <inttypes.h>
#include <EGL/egl.h>
@@ -105,7 +107,8 @@
return hasEglAndroidImageCrop() && (crop.left == 0 && crop.top == 0);
}
-BufferLayerConsumer::BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex)
+BufferLayerConsumer::BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex,
+ Layer* layer)
: ConsumerBase(bq, false),
mCurrentCrop(Rect::EMPTY_RECT),
mCurrentTransform(0),
@@ -118,6 +121,7 @@
mDefaultHeight(1),
mFilteringEnabled(true),
mTexName(tex),
+ mLayer(layer),
mEglDisplay(EGL_NO_DISPLAY),
mEglContext(EGL_NO_CONTEXT),
mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT) {
@@ -538,6 +542,21 @@
ConsumerBase::freeBufferLocked(slotIndex);
}
+void BufferLayerConsumer::onDisconnect() {
+ sp<Layer> l = mLayer.promote();
+ if (l.get()) {
+ l->onDisconnect();
+ }
+}
+
+void BufferLayerConsumer::addAndGetFrameTimestamps(const NewFrameEventsEntry* newTimestamps,
+ FrameEventHistoryDelta* outDelta) {
+ sp<Layer> l = mLayer.promote();
+ if (l.get()) {
+ l->addAndGetFrameTimestamps(newTimestamps, outDelta);
+ }
+}
+
void BufferLayerConsumer::abandonLocked() {
BLC_LOGV("abandonLocked");
mCurrentTextureImage.clear();
diff --git a/services/surfaceflinger/BufferLayerConsumer.h b/services/surfaceflinger/BufferLayerConsumer.h
index 8382b46..f8da6bf 100644
--- a/services/surfaceflinger/BufferLayerConsumer.h
+++ b/services/surfaceflinger/BufferLayerConsumer.h
@@ -33,6 +33,7 @@
namespace android {
// ----------------------------------------------------------------------------
+class Layer;
class String8;
/*
@@ -58,7 +59,7 @@
// BufferLayerConsumer constructs a new BufferLayerConsumer object.
// The tex parameter indicates the name of the OpenGL ES
// texture to which images are to be streamed.
- BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex);
+ BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex, Layer* layer);
// updateTexImage acquires the most recently queued buffer, and sets the
// image contents of the target texture to it.
@@ -254,6 +255,11 @@
// This method must be called with mMutex locked.
virtual void freeBufferLocked(int slotIndex);
+ // IConsumerListener interface
+ void onDisconnect() override;
+ void addAndGetFrameTimestamps(const NewFrameEventsEntry* newTimestamps,
+ FrameEventHistoryDelta* outDelta) override;
+
// computeCurrentTransformMatrixLocked computes the transform matrix for the
// current texture. It uses mCurrentTransform and the current GraphicBuffer
// to compute this matrix and stores it in mCurrentTransformMatrix.
@@ -332,6 +338,9 @@
// be bound when updateTexImage is called. It is set at construction time.
const uint32_t mTexName;
+ // The layer for this BufferLayerConsumer
+ const wp<Layer> mLayer;
+
// EGLSlot contains the information and object references that
// BufferLayerConsumer maintains about a BufferQueue buffer slot.
struct EglSlot {
diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.cpp b/services/surfaceflinger/SurfaceFlingerConsumer.cpp
index 8c42bb6..769825d 100644
--- a/services/surfaceflinger/SurfaceFlingerConsumer.cpp
+++ b/services/surfaceflinger/SurfaceFlingerConsumer.cpp
@@ -244,22 +244,6 @@
}
}
-void SurfaceFlingerConsumer::onDisconnect() {
- sp<Layer> l = mLayer.promote();
- if (l.get()) {
- l->onDisconnect();
- }
-}
-
-void SurfaceFlingerConsumer::addAndGetFrameTimestamps(
- const NewFrameEventsEntry* newTimestamps,
- FrameEventHistoryDelta *outDelta) {
- sp<Layer> l = mLayer.promote();
- if (l.get()) {
- l->addAndGetFrameTimestamps(newTimestamps, outDelta);
- }
-}
-
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.h b/services/surfaceflinger/SurfaceFlingerConsumer.h
index 1453e35..9eb5351 100644
--- a/services/surfaceflinger/SurfaceFlingerConsumer.h
+++ b/services/surfaceflinger/SurfaceFlingerConsumer.h
@@ -40,8 +40,8 @@
SurfaceFlingerConsumer(const sp<IGraphicBufferConsumer>& consumer,
uint32_t tex, Layer* layer)
- : BufferLayerConsumer(consumer, tex),
- mTransformToDisplayInverse(false), mSurfaceDamage(), mLayer(layer)
+ : BufferLayerConsumer(consumer, tex, layer),
+ mTransformToDisplayInverse(false), mSurfaceDamage()
{}
class BufferRejecter {
@@ -82,11 +82,6 @@
virtual void setReleaseFence(const sp<Fence>& fence) override;
bool releasePendingBuffer();
- void onDisconnect() override;
- void addAndGetFrameTimestamps(
- const NewFrameEventsEntry* newTimestamps,
- FrameEventHistoryDelta* outDelta) override;
-
private:
virtual void onSidebandStreamChanged();
@@ -103,9 +98,6 @@
// A release that is pending on the receipt of a new release fence from
// presentDisplay
PendingRelease mPendingRelease;
-
- // The layer for this SurfaceFlingerConsumer
- const wp<Layer> mLayer;
};
// ----------------------------------------------------------------------------