SF: Add onLayerDisplayed method to LayerBE
Add onLayerDisplayed method to LayerBE class and make the data
for the class private.
Merged-in: I2a5b03d542d46fc0c2e1d6d725fb87580980427d
Test: Compile/Run manually
Change-Id: I2a5b03d542d46fc0c2e1d6d725fb87580980427d
diff --git a/services/surfaceflinger/Android.bp b/services/surfaceflinger/Android.bp
index ff994f5..cba94d2 100644
--- a/services/surfaceflinger/Android.bp
+++ b/services/surfaceflinger/Android.bp
@@ -103,6 +103,7 @@
"FrameTracker.cpp",
"GpuService.cpp",
"Layer.cpp",
+ "LayerBE.cpp",
"LayerProtoHelper.cpp",
"LayerRejecter.cpp",
"LayerStats.cpp",
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index b78ef97..e503955 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -61,11 +61,6 @@
namespace android {
-LayerBE::LayerBE()
- : mMesh(Mesh::TRIANGLE_FAN, 4, 2, 2) {
-}
-
-
int32_t Layer::sSequence = 1;
Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name, uint32_t w,
@@ -96,7 +91,8 @@
mQueueItems(),
mLastFrameNumberReceived(0),
mAutoRefresh(false),
- mFreezeGeometryUpdates(false) {
+ mFreezeGeometryUpdates(false),
+ mBE{this} {
mCurrentCrop.makeInvalid();
diff --git a/services/surfaceflinger/LayerBE.cpp b/services/surfaceflinger/LayerBE.cpp
new file mode 100644
index 0000000..22e38aa
--- /dev/null
+++ b/services/surfaceflinger/LayerBE.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_NDEBUG 0
+#undef LOG_TAG
+#define LOG_TAG "LayerBE"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+
+#include "Layer.h"
+
+namespace android {
+
+LayerBE::LayerBE(Layer* layer)
+ : mLayer(layer),
+ mMesh(Mesh::TRIANGLE_FAN, 4, 2, 2) {
+ compositionInfo.layer = this;
+}
+
+void LayerBE::onLayerDisplayed(const sp<Fence>& releaseFence) {
+ mLayer->onLayerDisplayed(releaseFence);
+}
+
+void CompositionInfo::dumpHwc(const char* tag) const {
+ ALOGV("[%s]\thwcLayer=%p", tag, static_cast<HWC2::Layer*>(*hwc.hwcLayer));
+ ALOGV("[%s]\tfence=%p", tag, hwc.fence.get());
+ ALOGV("[%s]\ttransform=%d", tag, hwc.transform);
+ ALOGV("[%s]\tz=%d", tag, hwc.z);
+ ALOGV("[%s]\ttype=%d", tag, hwc.type);
+ ALOGV("[%s]\tappId=%d", tag, hwc.appId);
+ ALOGV("[%s]\tdisplayFrame=%4d %4d %4d %4d", tag, hwc.displayFrame.left, hwc.displayFrame.top, hwc.displayFrame.right, hwc.displayFrame.bottom);
+ ALOGV("[%s]\talpha=%.3f", tag, hwc.alpha);
+ ALOGV("[%s]\tsourceCrop=%6.1f %6.1f %6.1f %6.1f", tag, hwc.sourceCrop.left, hwc.sourceCrop.top, hwc.sourceCrop.right, hwc.sourceCrop.bottom);
+
+ std::string label = tag;
+ label+=":visibleRegion";
+ hwc.visibleRegion.dump(label.c_str());
+ label = tag;
+ label+=":surfaceDamage";
+ hwc.surfaceDamage.dump(label.c_str());
+}
+
+void CompositionInfo::dumpRe(const char* tag) const {
+ ALOGV("[%s]\tblackoutLayer=%d", tag, re.blackoutLayer);
+ ALOGV("[%s]\tclearArea=%d", tag, re.clearArea);
+ ALOGV("[%s]\tpreMultipliedAlpha=%d", tag, re.preMultipliedAlpha);
+ ALOGV("[%s]\topaque=%d\n", tag, re.opaque);
+ ALOGV("[%s]\ttexture:name(%d), target(%d), size(%d/%d)", tag, re.texture.getTextureName(), re.texture.getTextureTarget(), (unsigned int)re.texture.getWidth(), (unsigned int)re.texture.getHeight());
+ ALOGV("[%s]\tuseIdentityTransform=%d\n", tag, re.useIdentityTransform);
+}
+
+void CompositionInfo::dump(const char* tag) const {
+ ALOGV("[%s] CompositionInfo", tag);
+ ALOGV("[%s]\tLayerName: %s", tag, layerName.c_str());
+ ALOGV("[%s]\tCompositionType: %d", tag, compositionType);
+ ALOGV("[%s]\tmBuffer = %p", tag, mBuffer.get());
+ ALOGV("[%s]\tmBufferSlot=%d", tag, mBufferSlot);
+ switch (compositionType) {
+ case HWC2::Composition::Device:
+ dumpHwc(tag);
+ break;
+ case HWC2::Composition::Client:
+ dumpRe(tag);
+ default:
+ break;
+ }
+}
+
+}; // namespace android
diff --git a/services/surfaceflinger/LayerBE.h b/services/surfaceflinger/LayerBE.h
index 14619f6..75766bf 100644
--- a/services/surfaceflinger/LayerBE.h
+++ b/services/surfaceflinger/LayerBE.h
@@ -30,6 +30,8 @@
namespace android {
+class LayerBE;
+
class LayerContainer
{
public:
@@ -56,9 +58,11 @@
};
struct CompositionInfo {
+ std::string layerName;
HWC2::Composition compositionType;
sp<GraphicBuffer> mBuffer = nullptr;
int mBufferSlot = BufferQueue::INVALID_BUFFER_SLOT;
+ LayerBE* layer = nullptr;
struct {
std::shared_ptr<LayerContainer> hwcLayer;
int32_t hwid = -1;
@@ -87,12 +91,26 @@
Texture texture;
bool useIdentityTransform = false;
} re;
+
+ void dump(const char* tag) const;
+ void dumpHwc(const char* tag) const;
+ void dumpRe(const char* tag) const;
};
class LayerBE {
public:
- LayerBE();
+ friend class Layer;
+ friend class BufferLayer;
+ friend class ColorLayer;
+ friend class SurfaceFlinger;
+ LayerBE(Layer* layer);
+
+ void onLayerDisplayed(const sp<Fence>& releaseFence);
+ Mesh& getMesh() { return mMesh; }
+
+private:
+ Layer*const mLayer;
// The mesh used to draw the layer in GLES composition mode
Mesh mMesh;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index c8a9f69..7ae5b21 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2034,7 +2034,7 @@
displayDevice->getClientTargetAcquireFence());
}
- layer->onLayerDisplayed(releaseFence);
+ layer->getBE().onLayerDisplayed(releaseFence);
}
// We've got a list of layers needing fences, that are disjoint with
@@ -2043,7 +2043,7 @@
if (!displayDevice->getLayersNeedingFences().isEmpty()) {
sp<Fence> presentFence = getBE().mHwc->getPresentFence(hwcId);
for (auto& layer : displayDevice->getLayersNeedingFences()) {
- layer->onLayerDisplayed(presentFence);
+ layer->getBE().onLayerDisplayed(presentFence);
}
}