summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/surfaceflinger/Layer.cpp22
-rw-r--r--services/surfaceflinger/Layer.h3
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp12
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h2
-rw-r--r--services/surfaceflinger/SurfaceTracing.cpp6
-rw-r--r--services/surfaceflinger/SurfaceTracing.h1
-rw-r--r--services/surfaceflinger/layerproto/layers.proto21
-rw-r--r--services/surfaceflinger/layerproto/layerstrace.proto3
8 files changed, 60 insertions, 10 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 766871e3b0..64cfb3d699 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -719,9 +719,14 @@ std::vector<compositionengine::LayerFE::LayerSettings> Layer::prepareClientCompo
Hwc2::IComposerClient::Composition Layer::getCompositionType(
const sp<const DisplayDevice>& display) const {
const auto outputLayer = findOutputLayerForDisplay(display);
- LOG_FATAL_IF(!outputLayer);
- return outputLayer->getState().hwc ? (*outputLayer->getState().hwc).hwcCompositionType
- : Hwc2::IComposerClient::Composition::CLIENT;
+ if (outputLayer == nullptr) {
+ return Hwc2::IComposerClient::Composition::INVALID;
+ }
+ if (outputLayer->getState().hwc) {
+ return (*outputLayer->getState().hwc).hwcCompositionType;
+ } else {
+ return Hwc2::IComposerClient::Composition::CLIENT;
+ }
}
bool Layer::getClearClientTarget(const sp<const DisplayDevice>& display) const {
@@ -2052,13 +2057,20 @@ void Layer::setInputInfo(const InputWindowInfo& info) {
setTransactionFlags(eTransactionNeeded);
}
-LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) const {
+LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags,
+ const sp<const DisplayDevice>& device) const {
LayerProto* layerProto = layersProto.add_layers();
writeToProtoDrawingState(layerProto, traceFlags);
writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags);
+ // Only populate for the primary display.
+ if (device) {
+ const Hwc2::IComposerClient::Composition compositionType = getCompositionType(device);
+ layerProto->set_hwc_composition_type(static_cast<HwcCompositionType>(compositionType));
+ }
+
for (const sp<Layer>& layer : mDrawingChildren) {
- layer->writeToProto(layersProto, traceFlags);
+ layer->writeToProto(layersProto, traceFlags, device);
}
return layerProto;
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 5d2144aed4..20d72324c3 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -506,7 +506,8 @@ public:
bool isRemovedFromCurrentState() const;
LayerProto* writeToProto(LayersProto& layersProto,
- uint32_t traceFlags = SurfaceTracing::TRACE_ALL) const;
+ uint32_t traceFlags = SurfaceTracing::TRACE_ALL,
+ const sp<const DisplayDevice>& device = nullptr) const;
// Write states that are modified by the main thread. This includes drawing
// state as well as buffer data. This should be called in the main or tracing
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 1d00624199..c995db4972 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4450,13 +4450,20 @@ void SurfaceFlinger::dumpWideColorInfo(std::string& result) const {
}
LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t traceFlags) const {
+ Mutex::Autolock _l(mStateLock);
+ const auto device = getDefaultDisplayDeviceLocked();
LayersProto layersProto;
for (const sp<Layer>& layer : mDrawingState.layersSortedByZ) {
- layer->writeToProto(layersProto, traceFlags);
+ layer->writeToProto(layersProto, traceFlags, device);
}
+
return layersProto;
}
+void SurfaceFlinger::dumpHwc(std::string& result) const {
+ getHwComposer().dump(result);
+}
+
void SurfaceFlinger::dumpOffscreenLayersProto(LayersProto& layersProto, uint32_t traceFlags) const {
// Add a fake invisible root layer to the proto output and parent all the offscreen layers to
// it.
@@ -4471,7 +4478,8 @@ void SurfaceFlinger::dumpOffscreenLayersProto(LayersProto& layersProto, uint32_t
rootProto->add_children(offscreenLayer->sequence);
// Add layer
- LayerProto* layerProto = offscreenLayer->writeToProto(layersProto, traceFlags);
+ LayerProto* layerProto =
+ offscreenLayer->writeToProto(layersProto, traceFlags, nullptr /*device*/);
layerProto->set_parent(offscreenRootLayerId);
}
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 477d7a5c5c..83f01319d3 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -921,6 +921,8 @@ private:
LayersProto dumpDrawingStateProto(uint32_t traceFlags = SurfaceTracing::TRACE_ALL) const;
void dumpOffscreenLayersProto(LayersProto& layersProto,
uint32_t traceFlags = SurfaceTracing::TRACE_ALL) const;
+ // Dumps state from HW Composer
+ void dumpHwc(std::string& result) const;
LayersProto dumpProtoFromMainThread(uint32_t traceFlags = SurfaceTracing::TRACE_ALL)
EXCLUDES(mStateLock);
void dumpOffscreenLayers(std::string& result) EXCLUDES(mStateLock);
diff --git a/services/surfaceflinger/SurfaceTracing.cpp b/services/surfaceflinger/SurfaceTracing.cpp
index eb5c7de0fe..c5556ec28f 100644
--- a/services/surfaceflinger/SurfaceTracing.cpp
+++ b/services/surfaceflinger/SurfaceTracing.cpp
@@ -170,6 +170,12 @@ LayersTraceProto SurfaceTracing::traceLayersLocked(const char* where) {
mFlinger.dumpOffscreenLayersProto(layers);
entry.mutable_layers()->Swap(&layers);
+ if (mTraceFlags & SurfaceTracing::TRACE_HWC) {
+ std::string hwcDump;
+ mFlinger.dumpHwc(hwcDump);
+ entry.set_hwc_blob(hwcDump);
+ }
+
return entry;
}
diff --git a/services/surfaceflinger/SurfaceTracing.h b/services/surfaceflinger/SurfaceTracing.h
index 18524f02d8..3c24881d7c 100644
--- a/services/surfaceflinger/SurfaceTracing.h
+++ b/services/surfaceflinger/SurfaceTracing.h
@@ -56,6 +56,7 @@ public:
TRACE_CRITICAL = 1 << 0,
TRACE_INPUT = 1 << 1,
TRACE_EXTRA = 1 << 2,
+ TRACE_HWC = 1 << 3,
TRACE_ALL = 0xffffffff
};
void setTraceFlags(uint32_t flags);
diff --git a/services/surfaceflinger/layerproto/layers.proto b/services/surfaceflinger/layerproto/layers.proto
index 8afe5039f8..7f1f542e4b 100644
--- a/services/surfaceflinger/layerproto/layers.proto
+++ b/services/surfaceflinger/layerproto/layers.proto
@@ -9,6 +9,23 @@ message LayersProto {
repeated LayerProto layers = 1;
}
+// Must match definition in the IComposerClient HAL
+enum HwcCompositionType {
+ // Invalid composition type
+ INVALID = 0;
+ // Layer was composited by the client into the client target buffer
+ CLIENT = 1;
+ // Layer was composited by the device through hardware overlays
+ DEVICE = 2;
+ // Layer was composited by the device using a color
+ SOLID_COLOR = 3;
+ // Similar to DEVICE, but the layer position may have been asynchronously set
+ // through setCursorPosition
+ CURSOR = 4;
+ // Layer was composited by the device via a sideband stream.
+ SIDEBAND = 5;
+}
+
// Information about each layer.
message LayerProto {
// unique id per layer.
@@ -73,7 +90,7 @@ message LayerProto {
int32 window_type = 33 [deprecated=true];
int32 app_id = 34 [deprecated=true];
// The layer's composition type
- int32 hwc_composition_type = 35;
+ HwcCompositionType hwc_composition_type = 35;
// If it's a buffer layer, indicate if the content is protected
bool is_protected = 36;
// Current frame number being rendered.
@@ -190,4 +207,4 @@ message InputWindowInfoProto {
message ColorTransformProto {
// This will be a 4x4 matrix of float values
repeated float val = 1;
-} \ No newline at end of file
+}
diff --git a/services/surfaceflinger/layerproto/layerstrace.proto b/services/surfaceflinger/layerproto/layerstrace.proto
index bee17d2d86..ac33a0ef9c 100644
--- a/services/surfaceflinger/layerproto/layerstrace.proto
+++ b/services/surfaceflinger/layerproto/layerstrace.proto
@@ -48,4 +48,7 @@ message LayersTraceProto {
optional string where = 2;
optional LayersProto layers = 3;
+
+ // Blob for the current HWC information for all layers, reported by dumpsys.
+ optional string hwc_blob = 4;
}