目录

Android-dumpsys-SufaceFlinger

Android dumpsys SufaceFlinger

Android dumpsys SufaceFlinger

SurfaceFlinger::dumpAllLocked

@rameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
SurfaceFlinger::doDump    
    SurfaceFlinger::dumpAllLocked
        result.append("Build configuration:");
        colorizer.reset(result);
        appendSfConfigString(result);
        result.append("\n");
    
        result.append("\nDisplay identification data:\n");
        dumpDisplayIdentificationData(result);
    
        result.append("\nWide-Color information:\n");
        dumpWideColorInfo(result);
    
        colorizer.bold(result);
        result.append("Sync configuration: ");
        colorizer.reset(result);
        result.append(SyncFeatures::getInstance().toString());
        result.append("\n\n");
    
        colorizer.bold(result);
        result.append("Scheduler:\n");
        colorizer.reset(result);
        dumpVSync(result);
        result.append("\n");
    
        dumpStaticScreenStats(result);
        result.append("\n");
    
        StringAppendF(&result, "Total missed frame count: %u\n", mFrameMissedCount.load());
        StringAppendF(&result, "HWC missed frame count: %u\n", mHwcFrameMissedCount.load());
        StringAppendF(&result, "GPU missed frame count: %u\n\n", mGpuFrameMissedCount.load());
    
        dumpBufferingStats(result);
        
        colorizer.bold(result);
        StringAppendF(&result, "Visible layers (count = %zu)\n", mNumLayers.load());
        StringAppendF(&result, "GraphicBufferProducers: %zu, max %zu\n", mGraphicBufferProducerList.size(), mMaxGraphicBufferProducerListSize);
        colorizer.reset(result);
        mDrawingState.traverseInZOrder([&](Layer* layer) {
            auto* compositionState = layer->getCompositionState();
            if (!compositionState || !compositionState->isVisible) return;
            android::base::StringAppendF(&result, "* Layer %p (%s)\n", layer, layer->getDebugName() ? layer->getDebugName()  : "<unknown>");
@frameworks/native/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp
            compositionState->dump(result);
                dumpVal(out, "isSecure", isSecure);
                dumpVal(out, "geomUsesSourceCrop", geomUsesSourceCrop);
                dumpVal(out, "geomBufferUsesDisplayInverseTransform", geomBufferUsesDisplayInverseTransform);
                dumpVal(out, "geomLayerTransform", geomLayerTransform);
                out.append("\n      ");
                dumpVal(out, "geomBufferSize", geomBufferSize);
                dumpVal(out, "geomContentCrop", geomContentCrop);
                dumpVal(out, "geomCrop", geomCrop);
                dumpVal(out, "geomBufferTransform", geomBufferTransform);
                out.append("\n      ");
                dumpVal(out, "transparentRegionHint", transparentRegionHint);
                out.append("      ");
                dumpVal(out, "geomLayerBounds", geomLayerBounds);
                out.append("      ");
                dumpVal(out, "shadowRadius", shadowRadius);
                out.append("\n      ");
                dumpVal(out, "blend", toString(blendMode), blendMode);
                dumpVal(out, "alpha", alpha);
                dumpVal(out, "backgroundBlurRadius", backgroundBlurRadius);
                if (stretchEffect.hasEffect()) {
                    dumpVal(out, "stretchEffect", stretchEffect);
                }        
                dumpVal(out, "composition type", toString(compositionType), compositionType);
                out.append("\n      buffer: ");
                dumpVal(out, "slot", bufferSlot);
                dumpVal(out, "buffer", buffer.get());
                out.append("\n      ");
                dumpVal(out, "sideband stream", sidebandStream.get());
                out.append("\n      ");
                dumpVal(out, "color", color);
                out.append("\n      ");
                dumpVal(out, "isOpaque", isOpaque);
                dumpVal(out, "hasProtectedContent", hasProtectedContent);
                dumpVal(out, "isColorspaceAgnostic", isColorspaceAgnostic);
                dumpVal(out, "dataspace", toString(dataspace), dataspace);
                dumpVal(out, "hdr metadata types", hdrMetadata.validTypes);
                dumpVal(out, "colorTransform", colorTransform);        
        });
        StringAppendF(&result, "Displays (%zu entries)\n", mDisplays.size());   
        for (const auto& [token, display] : mDisplays) {     
@frameworks/native/services/surfaceflinger/DisplayDevice.cpp    
            display->dump(result);        //看下面的 DisplayDevice::dump
    
        result.append("SurfaceFlinger global state:\n");
@frameworks/native/libs/renderengine/skia/SkiaGLRenderEngine.cpp    
        getRenderEngine().dump(result);
            StringAppendF(&result, "\n ------------RE-----------------\n");
            StringAppendF(&result, "EGL implementation : %s\n", extensions.getEGLVersion());
            StringAppendF(&result, "%s\n", extensions.getEGLExtensions());
            StringAppendF(&result, "GLES: %s, %s, %s\n", extensions.getVendor(), extensions.getRenderer(),
                          extensions.getVersion());
            StringAppendF(&result, "%s\n", extensions.getExtensions());
            StringAppendF(&result, "RenderEngine supports protected context: %d\n",
                          supportsProtectedContent());
            StringAppendF(&result, "RenderEngine is in protected context: %d\n", mInProtectedContext);
            StringAppendF(&result, "RenderEngine shaders cached since last dump/primeCache: %d\n",
                          mSkSLCacheMonitor.shadersCachedSinceLastCall());
            StringAppendF(&result, "Skia CPU Caches: ");
            cpuReporter.logTotals(result);
@frameworks/native/libs/renderengine/skia/debug/SkiaMemoryReporter.cpp        
                StringAppendF(&log, " %.0f bytes, %.2f %s (%.2f %s is purgeable)\n", mTotalSize.value, total.value, total.units, purgeable.value, purgeable.units);        
            cpuReporter.logOutput(result);   
                for (const auto& resourceCategory : mResourceMap) {                   
                    const char* entry = (traceValue.count > 1) ? "entries" : "entry";
                    StringAppendF(&log, "  %s: %.2f %s (%d %s)\n", categoryItem->first.c_str(),  traceValue.value, traceValue.units, traceValue.count, entry);
            SkiaMemoryReporter gpuReporter(gpuResourceMap, true);
            mGrContext->dumpMemoryStatistics(&gpuReporter);
            StringAppendF(&result, "Skia's GPU Caches: ");
            gpuReporter.logTotals(result);
            gpuReporter.logOutput(result);
            StringAppendF(&result, "Skia's Wrapped Objects:\n");
            gpuReporter.logOutput(result, true);
    
            StringAppendF(&result, "RenderEngine tracked buffers: %zu\n",
                          mGraphicBufferExternalRefs.size());
            StringAppendF(&result, "Dumping buffer ids...\n");
            for (const auto& [id, refCounts] : mGraphicBufferExternalRefs) {
                StringAppendF(&result, "- 0x%" PRIx64 " - %d refs \n", id, refCounts);
            }
            StringAppendF(&result, "RenderEngine AHB/BackendTexture cache size: %zu\n",
                          mTextureCache.size());
            StringAppendF(&result, "Dumping buffer ids...\n");
            // TODO(178539829): It would be nice to know which layer these are coming from and what
            // the texture sizes are.
            for (const auto& [id, unused] : mTextureCache) {
                StringAppendF(&result, "- 0x%" PRIx64 "\n", id);
            }
            StringAppendF(&result, "\n");    
            
            SkiaMemoryReporter gpuProtectedReporter(gpuResourceMap, true);
            if (mProtectedGrContext) {
                mProtectedGrContext->dumpMemoryStatistics(&gpuProtectedReporter);
            }
            StringAppendF(&result, "Skia's GPU Protected Caches: ");
            gpuProtectedReporter.logTotals(result);
            gpuProtectedReporter.logOutput(result);
            StringAppendF(&result, "Skia's Protected Wrapped Objects:\n");
            gpuProtectedReporter.logOutput(result, true);
    
            StringAppendF(&result, "\n");
            StringAppendF(&result, "RenderEngine runtime effects: %zu\n", mRuntimeEffects.size());
            for (const auto& [linearEffect, unused] : mRuntimeEffects) {
                StringAppendF(&result, "- inputDataspace: %s\n",
                              dataspaceDetails(
                                      static_cast<android_dataspace>(linearEffect.inputDataspace))
                                      .c_str());
                StringAppendF(&result, "- outputDataspace: %s\n",
                              dataspaceDetails(
                                      static_cast<android_dataspace>(linearEffect.outputDataspace))
                                      .c_str());
                StringAppendF(&result, "undoPremultipliedAlpha: %s\n",
                              linearEffect.undoPremultipliedAlpha ? "true" : "false");
            }        
            
        result.append("ClientCache state:\n");
        ClientCache::getInstance().dump(result);
        DebugEGLImageTracker::getInstance()->dump(result);
    
        if (const auto display = getDefaultDisplayDeviceLocked()) {
            display->getCompositionDisplay()->getState().undefinedRegion.dump(result,
                                                                              "undefinedRegion");
            StringAppendF(&result, "  orientation=%s, isPoweredOn=%d\n",
                          toCString(display->getOrientation()), display->isPoweredOn());
        }
        StringAppendF(&result,
                      "  transaction-flags         : %08x\n"
                      "  gpu_to_cpu_unsupported    : %d\n",
                      mTransactionFlags.load(), !mGpuToCpuSupported);
    
        if (const auto display = getDefaultDisplayDeviceLocked()) {
            std::string fps, xDpi, yDpi;
            if (const auto activeMode = display->getActiveMode()) {
                fps = to_string(activeMode->getFps());
                xDpi = base::StringPrintf("%.2f", activeMode->getDpiX());
                yDpi = base::StringPrintf("%.2f", activeMode->getDpiY());
            } else {
                fps = "unknown";
                xDpi = "unknown";
                yDpi = "unknown";
            }
            StringAppendF(&result,
                          "  refresh-rate              : %s\n"
                          "  x-dpi                     : %s\n"
                          "  y-dpi                     : %s\n",
                          fps.c_str(), xDpi.c_str(), yDpi.c_str());
        }
    
        StringAppendF(&result, "  transaction time: %f us\n", inTransactionDuration / 1000.0);    
@frameworks/native/services/surfaceflinger/SurfaceTracing.cpp
        mTracing.dump(result);
            base::StringAppendF(&result, "Tracing state: %s\n", mEnabled ? "enabled" : "disabled");    
            
        for (const auto& [token, display] : mDisplays) {
            StringAppendF(&result, "Display %s (%s) HWC layers:\n", to_string(*displayId).c_str(),
                          (isDisplayActiveLocked(display) ? "active" : "inactive"));
@frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp                      
            Layer::miniDumpHeader(result);
                result.append(kDumpTableRowLength, '-');
                result.append("\n");
                result.append(" Layer name\n");
                result.append("           Z | ");
                result.append(" Window Type | ");
                result.append(" Comp Type | ");
                result.append(" Transform | ");
                result.append("  Disp Frame (LTRB) | ");
                result.append("         Source Crop (LTRB) | ");
                result.append("    Frame Rate (Explicit) (Seamlessness) [Focused]\n");
                result.append(kDumpTableRowLength, '-');
                result.append("\n");        
            
            const DisplayDevice& ref = *display;
            mCurrentState.traverseInZOrder([&](Layer* layer) { layer->miniDump(result, ref); });
                StringAppendF(&result, " %s\n", name.c_str());
            
                const State& layerState(getDrawingState());
                const auto& outputLayerState = outputLayer->getState();
            
                if (layerState.zOrderRelativeOf != nullptr || mDrawingParent != nullptr) {
                    StringAppendF(&result, "  rel %6d | ", layerState.z);
                } else {
                    StringAppendF(&result, "  %10d | ", layerState.z);
                }
                StringAppendF(&result, "  %10d | ", mWindowType);
                StringAppendF(&result, "%10s | ", toString(getCompositionType(display)).c_str());
                StringAppendF(&result, "%10s | ", toString(outputLayerState.bufferTransform).c_str());
                const Rect& frame = outputLayerState.displayFrame;
                StringAppendF(&result, "%4d %4d %4d %4d | ", frame.left, frame.top, frame.right, frame.bottom);
                const FloatRect& crop = outputLayerState.sourceCrop;
                StringAppendF(&result, "%6.1f %6.1f %6.1f %6.1f | ", crop.left, crop.top, crop.right,
                              crop.bottom);
                const auto frameRate = getFrameRateForLayerTree();
                if (frameRate.rate.isValid() || frameRate.type != FrameRateCompatibility::Default) {
                    StringAppendF(&result, "%s %15s %17s", to_string(frameRate.rate).c_str(),
                                  frameRateCompatibilityString(frameRate.type).c_str(),
                                  toString(frameRate.seamlessness).c_str());
                } else {
                    result.append(41, ' ');
                }
            
                const auto focused = isLayerFocusedBasedOnPriority(getFrameRateSelectionPriority());
                StringAppendF(&result, "    [%s]\n", focused ? "*" : " ");
            
                result.append(kDumpTableRowLength, '-'); 
        plannerArgs.add(String16("--layers"));
        dumpPlannerInfo(plannerArgs, result);
            for (const auto& [token, display] : mDisplays) {     
@frameworks/native/services/surfaceflinger/CompositionEngine/src/Output.cpp                      
                compositionDisplay->dumpPlannerInfo(args, result);
                    base::StringAppendF(&out, "Planner is disabled\n");    
        result.append("h/w composer state:\n");
        colorizer.reset(result);
        bool hwcDisabled = mDebugDisableHWC || mDebugRegion;
        StringAppendF(&result, "  h/w composer %s\n", hwcDisabled ? "disabled" : "enabled");      
@hardware/rockchip/hwcomposer/drmhwc2/drmhwctwo.cpp
        getHwComposer().dump(result);  //看下面的DrmHwcTwo::Dump
        
        const GraphicBufferAllocator& alloc(GraphicBufferAllocator::get());
@frameworks/native/libs/ui/GraphicBufferAllocator.cpp    
        alloc.dump(result);
            result.append("GraphicBufferAllocator buffers:\n");
            const size_t count = list.size();
            StringAppendF(&result, "%10s | %11s | %18s | %s | %8s | %10s | %s\n", "Handle", "Size",
                          "W (Stride) x H", "Layers", "Format", "Usage", "Requestor");
            for (size_t i = 0; i < count; i++) {
                const alloc_rec_t& rec(list.valueAt(i));
                std::string sizeStr = (rec.size)
                        ? base::StringPrintf("%7.2f KiB", static_cast<double>(rec.size) / 1024.0)
                        : "unknown";
                StringAppendF(&result, "%10p | %11s | %4u (%4u) x %4u | %6u | %8X | 0x%8" PRIx64 " | %s\n",
                              list.keyAt(i), sizeStr.c_str(), rec.width, rec.stride, rec.height,
                              rec.layerCount, rec.format, rec.usage, rec.requestorName.c_str());
                total += rec.size;
            }
            StringAppendF(&result, "Total allocated by GraphicBufferAllocator (estimate): %.2f KB\n",
                          static_cast<double>(total) / 1024.0); 
@frameworks/native/libs/ui/Gralloc4.cpp
            result.append(mAllocator->dumpDebugInfo(less));           
                return mMapper.dumpBuffers(less);
                    stream << "Imported gralloc buffers:\n";
                    for (const auto& bufferDump : bufferDumps) {
                        uint64_t allocationSize = 0;
                        status_t err = bufferDumpHelper(bufferDump, &stream, &allocationSize, less);          
                           status_t error = metadataDumpHelper(bufferDump, StandardMetadataType::BUFFER_ID, gralloc4::decodeBufferId, &bufferId);      
                            *outDump << "+ name:" << name << ", id:" << bufferId << ", size:" << allocationSizeKiB
                                     << "KiB, w/h:" << width << "x" << height << ", usage: 0x" << std::hex << usage
                                     << std::dec << ", req fmt:" << static_cast<int32_t>(pixelFormatRequested)
                                     << ", fourcc/mod:" << pixelFormatFourCC << "/" << pixelFormatModifier
                                     << ", dataspace: 0x" << std::hex << static_cast<uint32_t>(dataspace) << std::dec
                                     << ", compressed: ";      
                             for (const auto& planeLayout : planeLayouts) {   
                                 *outDump << "\tplanes: ";       
                                 *outDump << " w/h:" << planeLayout.widthInSamples << "x" << planeLayout.heightInSamples
                                         << ", stride:" << planeLayout.strideInBytes
                                         << " bytes, size:" << planeLayout.totalSizeInBytes;
                    stream << "Total imported by gralloc: " << totalAllocationSizeKiB << "KiB\n";    
                    
@frameworks/native/services/surfaceflinger/TimeStats/TimeStats.cpp
        result.append(mTimeStats->miniDump()); 
            std::string result = "TimeStats miniDump:\n";
            std::lock_guard<std::mutex> lock(mMutex);
            android::base::StringAppendF(&result, "Number of layers currently being tracked is %zu\n",
                                         mTimeStatsTracker.size());
            android::base::StringAppendF(&result, "Number of layers in the stats pool is %zu\n",
                                         mTimeStats.stats.size());       
                                         
    LayersTraceFileProto traceFileProto = SurfaceTracing::createLayersTraceFileProto();                                                                                       
    dumpDisplayProto(*layersTrace);
        displayProto->set_layer_stack(display->getLayerStack());
    result.append(LayerProtoParser::layerTreeToString(layerTree));
        for (const LayerProtoParser::Layer* layer : layerTree.topLevelLayers) {
@frameworks/native/services/surfaceflinger/layerproto/LayerProtoParser.cpp            
            result.append(layerToString(layer));
                result.append(layer->to_string());
                    StringAppendF(&result, "+ %s (%s) uid=%d\n", type.c_str(), name.c_str(), ownerUid);
                    result.append(transparentRegion.to_string("TransparentRegion").c_str());
                    result.append(visibleRegion.to_string("VisibleRegion").c_str());
                    result.append(damageRegion.to_string("SurfaceDamageRegion").c_str());
                
                    StringAppendF(&result, "      layerStack=%4d, z=%9d, pos=(%g,%g), size=(%4d,%4d), ", layerStack,
                                  z, static_cast<double>(position.x), static_cast<double>(position.y), size.x,
                                  size.y);
                
                    StringAppendF(&result, "crop=%s, ", crop.to_string().c_str());
                    StringAppendF(&result, "cornerRadius=%f, ", cornerRadius);
                    StringAppendF(&result, "isProtected=%1d, ", isProtected);
                    StringAppendF(&result, "isTrustedOverlay=%1d, ", isTrustedOverlay);
                    StringAppendF(&result, "isOpaque=%1d, invalidate=%1d, ", isOpaque, invalidate);
                    StringAppendF(&result, "dataspace=%s, ", dataspace.c_str());
                    StringAppendF(&result, "defaultPixelFormat=%s, ", pixelFormat.c_str());
                    StringAppendF(&result, "backgroundBlurRadius=%1d, ", backgroundBlurRadius);
                    StringAppendF(&result, "color=(%.3f,%.3f,%.3f,%.3f), flags=0x%08x, ",
                                  static_cast<double>(color.r), static_cast<double>(color.g),
                                  static_cast<double>(color.b), static_cast<double>(color.a), flags);
                    StringAppendF(&result, "tr=%s", transform.to_string().c_str());
                    result.append("\n");
                    StringAppendF(&result, "      parent=%s\n", parent == nullptr ? "none" : parent->name.c_str());
                    StringAppendF(&result, "      zOrderRelativeOf=%s\n",
                                  zOrderRelativeOf == nullptr ? "none" : zOrderRelativeOf->name.c_str());
                    StringAppendF(&result, "      activeBuffer=%s,", activeBuffer.to_string().c_str());
                    StringAppendF(&result, " tr=%s", bufferTransform.to_string().c_str());
                    StringAppendF(&result, " queued-frames=%d, mRefreshPending=%d,", queuedFrames, refreshPending);
                    StringAppendF(&result, " metadata={");
                    bool first = true;
                    for (const auto& entry : metadata.mMap) {
                        if (!first) result.append(", ");
                        first = false;
                        result.append(metadata.itemToString(entry.first, ":"));
                    }
                    result.append("},");
                    StringAppendF(&result, " cornerRadiusCrop=%s, ", cornerRadiusCrop.to_string().c_str());
                    StringAppendF(&result, " shadowRadius=%.3f, ", shadowRadius);                
    dumpOffscreenLayers(result);     
        result.append("Offscreen Layers:\n");               
        for (Layer* offscreenLayer : mOffscreenLayers) {
@frameworks/native/services/surfaceflinger/Layer.cpp            
            layer->dumpCallingUidPid(result);
                StringAppendF(&result, "Layer %s (%s) callingPid:%d callingUid:%d ownerUid:%d\n", getName().c_str(), getType(), mCallingPid, mCallingUid, mOwnerUid);
            

DisplayDevice::dump

@frameworks/native/services/surfaceflinger/DisplayDevice.cpp
DisplayDevice::dump
    StringAppendF(&result, "+ %s\n", getDebugName().c_str());        //+ DisplayDevice{0, internal, primary, "Internal display"}
    StringAppendF(&result, "   powerMode=%s (%d)\n", to_string(mPowerMode).c_str(),
                  static_cast<int32_t>(mPowerMode));
    const auto activeMode = getActiveMode();
    StringAppendF(&result, "   activeMode=%s\n",
                  activeMode ? to_string(*activeMode).c_str() : "none");
    result.append("   supportedModes=\n");

@frameworks/native/services/surfaceflinger/CompositionEngine/src/Display.cpp
    getCompositionDisplay()->dump(result);  //Display::dump
        StringAppendF(&out, "   Composition Display State: [\"%s\"]", getName().c_str());
        out.append("\n   ");
        dumpVal(out, "isVirtual", mIsVirtual);
        dumpVal(out, "DisplayId", to_string(mId));
        out.append("\n");
@frameworks/native/services/surfaceflinger/CompositionEngine/src/Output.cpp
        Output::dumpBase(out);   //Output::dumpBase
@frameworks/native/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h        
            dumpState(out);
@frameworks/native/services/surfaceflinger/CompositionEngine/src/OutputCompositionState.cpp
                mState.dump(out);
                    out.append("   ");
                    dumpVal(out, "isEnabled", isEnabled);
                    dumpVal(out, "isSecure", isSecure);
                
                    dumpVal(out, "usesClientComposition", usesClientComposition);
                    dumpVal(out, "usesDeviceComposition", usesDeviceComposition);
                    dumpVal(out, "flipClientTarget", flipClientTarget);
                    dumpVal(out, "reusedClientComposition", reusedClientComposition);
                
                    dumpVal(out, "layerStack", layerStackId);
                    dumpVal(out, "layerStackInternal", layerStackInternal);
                
                    out.append("\n   ");
                
                    dumpVal(out, "transform", transform);
                
                    out.append("\n   ");
                    dumpVal(out, "layerStackSpace", to_string(layerStackSpace));
                    out.append("\n   ");
                    dumpVal(out, "framebufferSpace", to_string(framebufferSpace));
                    out.append("\n   ");
                    dumpVal(out, "orientedDisplaySpace", to_string(orientedDisplaySpace));
                    out.append("\n   ");
                    dumpVal(out, "displaySpace", to_string(displaySpace));
                    out.append("\n   ");
                    dumpVal(out, "needsFiltering", needsFiltering);
                    dumpVal(out, "colorMode", toString(colorMode), colorMode);
                    dumpVal(out, "renderIntent", toString(renderIntent), renderIntent);
                    dumpVal(out, "dataspace", toString(dataspace), dataspace);
                    dumpVal(out, "colorTransformMatrix", colorTransformMatrix);
                    dumpVal(out, "target dataspace", toString(targetDataspace), targetDataspace);
@frameworks/native/services/surfaceflinger/CompositionEngine/src/DisplayColorProfile.cpp                            
                mDisplayColorProfile->dump(out);
                    out.append("   Composition Display Color State:");
                    out.append("\n   HWC Support: ");
                    dumpVal(out, "wideColorGamut", hasWideColorGamut());
                    dumpVal(out, "hdr10plus", hasHDR10PlusSupport());
                    dumpVal(out, "hdr10", hasHDR10Support());
                    dumpVal(out, "hlg", hasHLGSupport());
                    dumpVal(out, "dv", hasDolbyVisionSupport());
                    dumpVal(out, "metadata", getSupportedPerFrameMetadata()); 
@frameworks/native/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp
@frameworks/native/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
                mRenderSurface->dump(out);
                    out.append("   Composition RenderSurface State:");
                    out.append("\n   ");
                    dumpVal(out, "size", mSize);
                    StringAppendF(&out, "ANativeWindow=%p (format %d) ", mNativeWindow.get(),
                                  ANativeWindow_getFormat(mNativeWindow.get()));
                    dumpVal(out, "flips", mPageFlipCount);
                    out.append("\n");
@frameworks/native/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp      //物理屏幕              
                    mDisplaySurface->dumpAsString(surfaceDump);
                        result.appendFormat("  FramebufferSurface: dataspace: %s(%d)\n",  dataspaceDetails(static_cast<android_dataspace>(mDataSpace)).c_str(), mDataSpace);
@frameworks/native/libs/gui/ConsumerBase.cpp                        
                        ConsumerBase::dumpLocked(result, "   ");
                            result.appendFormat("%smAbandoned=%d\n", prefix, int(mAbandoned));
@frameworks/native/libs/gui/BufferQueueConsumer.cpp                            
                            mConsumer->dumpState(String8(prefix), &consumerState);
@frameworks/native/libs/gui/BufferQueueCore.cpp
                                mCore->dumpState(prefix, outResult);   
                                    outResult->appendFormat("%s- BufferQueue ", prefix.string());
                                    outResult->appendFormat("mMaxAcquiredBufferCount=%d mMaxDequeuedBufferCount=%d\n",
                                                            mMaxAcquiredBufferCount, mMaxDequeuedBufferCount);
                                    outResult->appendFormat("%s  mDequeueBufferCannotBlock=%d mAsyncMode=%d\n", prefix.string(),
                                                            mDequeueBufferCannotBlock, mAsyncMode);
                                    outResult->appendFormat("%s  mQueueBufferCanDrop=%d mLegacyBufferDrop=%d\n", prefix.string(),
                                                            mQueueBufferCanDrop, mLegacyBufferDrop);
                                    outResult->appendFormat("%s  default-size=[%dx%d] default-format=%d ", prefix.string(),
                                                            mDefaultWidth, mDefaultHeight, mDefaultBufferFormat);
                                    outResult->appendFormat("%s  transform-hint=%02x frame-counter=%" PRIu64 "\n", prefix.string(),
                                                            mTransformHint, mFrameCounter);
                                    outResult->appendFormat("%s  mTransformHintInUse=%02x mAutoPrerotation=%d\n", prefix.string(),
                                                            mTransformHintInUse, mAutoPrerotation);                                
                                    outResult->appendFormat("%sFIFO(%zu):\n", prefix.string(), mQueue.size());                                
                                    outResult->appendFormat("%s(mConsumerName=%s, ", prefix.string(), mConsumerName.string());                                
                                    outResult->appendFormat("mConnectedApi=%d, mConsumerUsageBits=%" PRIu64 ", ", mConnectedApi,
                                                            mConsumerUsageBits);                                
                                    String8 producerProcName = String8("\?\?\?");
                                    String8 consumerProcName = String8("\?\?\?");
                                    int32_t pid = getpid();
                                    getProcessName(mConnectedPid, producerProcName);
                                    getProcessName(pid, consumerProcName);
                                    outResult->appendFormat("mId=%" PRIx64 ", producer=[%d:%s], consumer=[%d:%s])\n", mUniqueId,
                                                            mConnectedPid, producerProcName.string(), pid,
                                                            consumerProcName.string());
                                    Fifo::const_iterator current(mQueue.begin());
                                    while (current != mQueue.end()) {
                                        double timestamp = current->mTimestamp / 1e9;
                                        outResult->appendFormat("%s  %02d:%p ", prefix.string(), current->mSlot,
                                                                current->mGraphicBuffer.get());
                                        outResult->appendFormat("crop=[%d,%d,%d,%d] ", current->mCrop.left, current->mCrop.top,
                                                                current->mCrop.right, current->mCrop.bottom);
                                        outResult->appendFormat("xform=0x%02x time=%.4f scale=%s\n", current->mTransform, timestamp,
                                                                BufferItem::scalingModeName(current->mScalingMode));
                                        ++current;
                                    }                                
                                    outResult->appendFormat("%sSlots:\n", prefix.string());
                                    for (int s : mActiveBuffers) {
                                        const sp<GraphicBuffer>& buffer(mSlots[s].mGraphicBuffer);
                                        // A dequeued buffer might be null if it's still being allocated
                                        if (buffer.get()) {
                                            outResult->appendFormat("%s %s[%02d:%p] ", prefix.string(),
                                                                    (mSlots[s].mBufferState.isAcquired()) ? ">" : " ", s,
                                                                    buffer.get());
                                            outResult->appendFormat("state=%-8s %p frame=%" PRIu64, mSlots[s].mBufferState.string(),
                                                                    buffer->handle, mSlots[s].mFrameNumber);
                                            outResult->appendFormat(" [%4ux%4u:%4u,%3X]\n", buffer->width, buffer->height,
                                                                    buffer->stride, buffer->format);
                                        } else {
                                            outResult->appendFormat("%s  [%02d:%p] ", prefix.string(), s, buffer.get());
                                            outResult->appendFormat("state=%-8s frame=%" PRIu64 "\n",
                                                                    mSlots[s].mBufferState.string(), mSlots[s].mFrameNumber);
                                        }
                                    }
                                    for (int s : mFreeBuffers) {
                                        const sp<GraphicBuffer>& buffer(mSlots[s].mGraphicBuffer);
                                        outResult->appendFormat("%s  [%02d:%p] ", prefix.string(), s, buffer.get());
                                        outResult->appendFormat("state=%-8s %p frame=%" PRIu64, mSlots[s].mBufferState.string(),
                                                                buffer->handle, mSlots[s].mFrameNumber);
                                        outResult->appendFormat(" [%4ux%4u:%4u,%3X]\n", buffer->width, buffer->height,
                                                                buffer->stride, buffer->format);
                                    }                                                                                   
@frameworks/native/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp   //虚拟屏幕,两者二选一
                    mDisplaySurface->dumpAsString(surfaceDump)
                        {}
@rameworks/native/services/surfaceflinger/CompositionEngine/src/Output.cpp
            android::base::StringAppendF(&out, "\n   %zu Layers\n", getOutputLayerCount());
            for (const auto* outputLayer : getOutputLayersOrderedByZ()) {
@frameworks/native/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
                outputLayer->dump(out);
                    StringAppendF(&out, "  - Output Layer %p(%s)\n", this, getLayerFE().getDebugName());
@frameworks/native/services/surfaceflinger/CompositionEngine/src/OutputLayerCompositionState.cpp                    
                    dumpState(out);
                        out.append("      ");
                        dumpVal(out, "visibleRegion", visibleRegion);
                        out.append("      ");
                        dumpVal(out, "visibleNonTransparentRegion", visibleNonTransparentRegion);
                        out.append("      ");
                        dumpVal(out, "coveredRegion", coveredRegion);
                        out.append("      ");
                        dumpVal(out, "output visibleRegion", outputSpaceVisibleRegion);
                        out.append("      ");
                        dumpVal(out, "shadowRegion", shadowRegion);
                        out.append("      ");
                        dumpVal(out, "forceClientComposition", forceClientComposition);
                        dumpVal(out, "clearClientTarget", clearClientTarget);
                        dumpVal(out, "displayFrame", displayFrame);
                        dumpVal(out, "sourceCrop", sourceCrop);
                        dumpVal(out, "bufferTransform", toString(bufferTransform), bufferTransform);
                        dumpVal(out, "dataspace", toString(dataspace), dataspace);
                        dumpVal(out, "override buffer", overrideInfo.buffer.get());
                        dumpVal(out, "override acquire fence", overrideInfo.acquireFence.get());
                        dumpVal(out, "override display frame", overrideInfo.displayFrame);
                        dumpVal(out, "override dataspace", toString(overrideInfo.dataspace), overrideInfo.dataspace);
                        dumpVal(out, "override display space", to_string(overrideInfo.displaySpace));
                        std::string damageRegionString;
                        overrideInfo.damageRegion.dump(damageRegionString, "");
                        dumpVal(out, "override damage region", damageRegionString);
                        std::string visibleRegionString;
                        overrideInfo.visibleRegion.dump(visibleRegionString, "");
                        dumpVal(out, "override visible region", visibleRegionString);
                        dumpVal(out, "override peekThroughLayer", overrideInfo.peekThroughLayer);
                        dumpVal(out, "override disableBackgroundBlur", overrideInfo.disableBackgroundBlur);
                    
                        if (hwc) {
                            dumpHwc(*hwc, out);
                                out.append("\n      hwc: ");
                                if (hwc.hwcLayer == nullptr) {
                                    out.append("No layer ");
                                } else {
                                    dumpHex(out, "layer", hwc.hwcLayer->getId());
                                }
                                dumpVal(out, "composition", toString(hwc.hwcCompositionType), hwc.hwcCompositionType);
@frameworks/native/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
    mRefreshRateConfigs->dump(result);
        base::StringAppendF(&result, "DesiredDisplayModeSpecs (DisplayManager): %s\n\n",
                            mDisplayManagerPolicy.toString().c_str());
        scheduler::RefreshRateConfigs::Policy currentPolicy = *getCurrentPolicyLocked();
        if (mOverridePolicy && currentPolicy != mDisplayManagerPolicy) {
            base::StringAppendF(&result, "DesiredDisplayModeSpecs (Override): %s\n\n",
                                currentPolicy.toString().c_str());
        }
    
        auto mode = mCurrentRefreshRate->mode;
        base::StringAppendF(&result, "Current mode: %s\n", mCurrentRefreshRate->toString().c_str());
    
        result.append("Refresh rates:\n");
        for (const auto& [id, refreshRate] : mRefreshRates) {
            mode = refreshRate->mode;
            base::StringAppendF(&result, "\t%s\n", refreshRate->toString().c_str());
        }
    
        base::StringAppendF(&result, "Supports Frame Rate Override: %s\n",
                            mSupportsFrameRateOverride ? "yes" : "no");
        base::StringAppendF(&result, "Idle timer: (%s) %s\n",
                            mConfig.supportKernelIdleTimer ? "kernel" : "platform",
                            mIdleTimer ? mIdleTimer->dump().c_str() : "off");    

DrmHwcTwo::Dump

@hardware/rockchip/hwcomposer/drmhwc2/drmhwctwo.cpp
DrmHwcTwo::Dump
    output.appendFormat("-- HWC2 Version %s by bin.li@rock-chips.com --\n",acVersion);
    for(auto &map_disp: displays_){
@hardware/rockchip/hwcomposer/drmhwc2/drmhwctwo.cpp        
        if((map_disp.second.DumpDisplayInfo(output)) < 0)
            output.appendFormat(" DisplayId=%" PRIu64 ", Connector %u, Type = %s-%u, Connector state = %s\n",handle_,
                                    connector_->id(),
                                    isVirtual() ? "Virtual" : drm_->connector_type_str(connector_->type()),
                                    connector_->type_id(),
                                    connector_->state() == DRM_MODE_CONNECTED ? "DRM_MODE_CONNECTED" : "DRM_MODE_DISCONNECTED"); 
            output.appendFormat("  NumHwLayers=%zu, activeModeId=%u, %s%c%.2f, colorMode = %d, bStandardSwitchResolution=%d\n",      
            output.append(
                          "------+-----+-----------+-----------+--------------------+-------------+------------+--------------------------------+------------------------+------------+--------+------------\n"
                          "  id  |  z  |  sf-type  |  hwc-type |       handle       |  transform  |    blnd    |     source crop (l,t,r,b)      |          frame         | dataspace  |  mFps  | name       \n"
                          "------+-----+-----------+-----------+--------------------+-------------+------------+--------------------------------+------------------------+------------+--------+------------\n");  
                          
          for (uint32_t z_order = 0; z_order <= layers_.size(); z_order++) {
            for (auto &map_layer : layers_) {
              HwcLayer &layer = map_layer.second;
              if(layer.z_order() == z_order){
@hardware/rockchip/hwcomposer/drmhwc2/drmhwctwo.cpp                  
                layer.DumpLayerInfo(output);
                    output.appendFormat( " %04" PRIu32 " | %03" PRIu32 " | %9s | %9s | %-18.18" PRIxPTR " |"
                                           " %-11.11s | %-10.10s |%7.1f,%7.1f,%7.1f,%7.1f |%5d,%5d,%5d,%5d |"
                                           " %10x | %5.1f  | %s | 0x%" PRIx64 "\n",
                                        id_,
                                        mCurrentState.z_order_,                
                break;
              }
            }
          }       
            output.append("------+-----+-----------+-----------+--------------------+-------------+------------+--------------------------------+------------------------+------------+--------+------------\n");
            output.append("DrmHwcLayer Dump:\n");     
            for(auto &drmHwcLayer : drm_hwc_layers_)
                drmHwcLayer.DumpInfo(output);     
@hardware/rockchip/hwcomposer/drmhwc2/rockchip/common/drmlayer.cpp                
                    out.appendFormat( "DrmHwcLayer[%4u] Buffer[w/h/s/bs/format]=[%4d,%4d,%4d,%4d,%4d] Fourcc=%c%c%c%c Transform=%-8.8s(0x%x) Blend[a=%d]=%-8.8s "
                                    "source_crop[l,t,r,b]=[%5.0f,%5.0f,%5.0f,%5.0f] display_frame[l,t,r,b]=[%4d,%4d,%4d,%4d],skip=%d,afbcd=%d hdr=%d\n",
                                   uId_,iWidth_,iHeight_,iStride_,iByteStride_,iFormat_,uFourccFormat_,uFourccFormat_>>8,uFourccFormat_>>16,uFourccFormat_>>24,                

@rameworks/native/services/surfaceflinger/SurfaceFlinger.cpp SurfaceFlinger::doDump SurfaceFlinger::dumpAllLocked result.append(“Build configuration:”); colorizer.reset(result); appendSfConfigString(result); result.append("\n"); result.append("\nDisplay identification data:\n"); dumpDisplayIdentificationData(result); result.append("\nWide-Color information:\n"); dumpWideColorInfo(result); colorizer.bold(result); result.append(“Sync configuration: “); colorizer.reset(result); result.append(SyncFeatures::getInstance().toString()); result.append("\n\n”); colorizer.bold(result); result.append(“Scheduler:\n”); colorizer.reset(result); dumpVSync(result); result.append("\n”); dumpStaticScreenStats(result); result.append("\n"); StringAppendF(&result, “Total missed frame count: %u\n”, mFrameMissedCount.load()); StringAppendF(&result, “HWC missed frame count: %u\n”, mHwcFrameMissedCount.load()); StringAppendF(&result, “GPU missed frame count: %u\n\n”, mGpuFrameMissedCount.load()); dumpBufferingStats(result); colorizer.bold(result); StringAppendF(&result, “Visible layers (count = %zu)\n”, mNumLayers.load()); StringAppendF(&result, “GraphicBufferProducers: %zu, max %zu\n”, mGraphicBufferProducerList.size(), mMaxGraphicBufferProducerListSize); colorizer.reset(result); mDrawingState.traverseInZOrder([&](Layer* layer) { auto* compositionState = layer->getCompositionState(); if (!compositionState || !compositionState->isVisible) return; android::base::StringAppendF(&result, “* Layer %p (%s)\n”, layer, layer->getDebugName() ? layer->getDebugName() : “”); @frameworks/native/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp compositionState->dump(result); dumpVal(out, “isSecure”, isSecure); dumpVal(out, “geomUsesSourceCrop”, geomUsesSourceCrop); dumpVal(out, “geomBufferUsesDisplayInverseTransform”, geomBufferUsesDisplayInverseTransform); dumpVal(out, “geomLayerTransform”, geomLayerTransform); out.append("\n “); dumpVal(out, “geomBufferSize”, geomBufferSize); dumpVal(out, “geomContentCrop”, geomContentCrop); dumpVal(out, “geomCrop”, geomCrop); dumpVal(out, “geomBufferTransform”, geomBufferTransform); out.append("\n “); dumpVal(out, “transparentRegionHint”, transparentRegionHint); out.append(” “); dumpVal(out, “geomLayerBounds”, geomLayerBounds); out.append(” “); dumpVal(out, “shadowRadius”, shadowRadius); out.append("\n “); dumpVal(out, “blend”, toString(blendMode), blendMode); dumpVal(out, “alpha”, alpha); dumpVal(out, “backgroundBlurRadius”, backgroundBlurRadius); if (stretchEffect.hasEffect()) { dumpVal(out, “stretchEffect”, stretchEffect); } dumpVal(out, “composition type”, toString(compositionType), compositionType); out.append("\n buffer: “); dumpVal(out, “slot”, bufferSlot); dumpVal(out, “buffer”, buffer.get()); out.append("\n “); dumpVal(out, “sideband stream”, sidebandStream.get()); out.append("\n “); dumpVal(out, “color”, color); out.append("\n “); dumpVal(out, “isOpaque”, isOpaque); dumpVal(out, “hasProtectedContent”, hasProtectedContent); dumpVal(out, “isColorspaceAgnostic”, isColorspaceAgnostic); dumpVal(out, “dataspace”, toString(dataspace), dataspace); dumpVal(out, “hdr metadata types”, hdrMetadata.validTypes); dumpVal(out, “colorTransform”, colorTransform); }); StringAppendF(&result, “Displays (%zu entries)\n”, mDisplays.size()); for (const auto& [token, display] : mDisplays) { @frameworks/native/services/surfaceflinger/DisplayDevice.cpp display->dump(result); //看下面的 DisplayDevice::dump result.append(“SurfaceFlinger global state:\n”); @frameworks/native/libs/renderengine/skia/SkiaGLRenderEngine.cpp getRenderEngine().dump(result); StringAppendF(&result, “\n ————RE—————–\n”); StringAppendF(&result, “EGL implementation : %s\n”, extensions.getEGLVersion()); StringAppendF(&result, “%s\n”, extensions.getEGLExtensions()); StringAppendF(&result, “GLES: %s, %s, %s\n”, extensions.getVendor(), extensions.getRenderer(), extensions.getVersion()); StringAppendF(&result, “%s\n”, extensions.getExtensions()); StringAppendF(&result, “RenderEngine supports protected context: %d\n”, supportsProtectedContent()); StringAppendF(&result, “RenderEngine is in protected context: %d\n”, mInProtectedContext); StringAppendF(&result, “RenderEngine shaders cached since last dump/primeCache: %d\n”, mSkSLCacheMonitor.shadersCachedSinceLastCall()); StringAppendF(&result, “Skia CPU Caches: “); cpuReporter.logTotals(result); @frameworks/native/libs/renderengine/skia/debug/SkiaMemoryReporter.cpp StringAppendF(&log, " %.0f bytes, %.2f %s (%.2f %s is purgeable)\n”, mTotalSize.value, total.value, total.units, purgeable.value, purgeable.units); cpuReporter.logOutput(result); for (const auto& resourceCategory : mResourceMap) { const char* entry = (traceValue.count > 1) ? “entries” : “entry”; StringAppendF(&log, " %s: %.2f %s (%d %s)\n”, categoryItem->first.c_str(), traceValue.value, traceValue.units, traceValue.count, entry); SkiaMemoryReporter gpuReporter(gpuResourceMap, true); mGrContext->dumpMemoryStatistics(&gpuReporter); StringAppendF(&result, “Skia’s GPU Caches: “); gpuReporter.logTotals(result); gpuReporter.logOutput(result); StringAppendF(&result, “Skia’s Wrapped Objects:\n”); gpuReporter.logOutput(result, true); StringAppendF(&result, “RenderEngine tracked buffers: %zu\n”, mGraphicBufferExternalRefs.size()); StringAppendF(&result, “Dumping buffer ids…\n”); for (const auto& [id, refCounts] : mGraphicBufferExternalRefs) { StringAppendF(&result, “- 0x%” PRIx64 " - %d refs \n”, id, refCounts); } StringAppendF(&result, “RenderEngine AHB/BackendTexture cache size: %zu\n”, mTextureCache.size()); StringAppendF(&result, “Dumping buffer ids…\n”); // TODO(178539829): It would be nice to know which layer these are coming from and what // the texture sizes are. for (const auto& [id, unused] : mTextureCache) { StringAppendF(&result, “- 0x%” PRIx64 “\n”, id); } StringAppendF(&result, “\n”); SkiaMemoryReporter gpuProtectedReporter(gpuResourceMap, true); if (mProtectedGrContext) { mProtectedGrContext->dumpMemoryStatistics(&gpuProtectedReporter); } StringAppendF(&result, “Skia’s GPU Protected Caches: “); gpuProtectedReporter.logTotals(result); gpuProtectedReporter.logOutput(result); StringAppendF(&result, “Skia’s Protected Wrapped Objects:\n”); gpuProtectedReporter.logOutput(result, true); StringAppendF(&result, “\n”); StringAppendF(&result, “RenderEngine runtime effects: %zu\n”, mRuntimeEffects.size()); for (const auto& [linearEffect, unused] : mRuntimeEffects) { StringAppendF(&result, “- inputDataspace: %s\n”, dataspaceDetails( static_cast<android_dataspace>(linearEffect.inputDataspace)) .c_str()); StringAppendF(&result, “- outputDataspace: %s\n”, dataspaceDetails( static_cast<android_dataspace>(linearEffect.outputDataspace)) .c_str()); StringAppendF(&result, “undoPremultipliedAlpha: %s\n”, linearEffect.undoPremultipliedAlpha ? “true” : “false”); } result.append(“ClientCache state:\n”); ClientCache::getInstance().dump(result); DebugEGLImageTracker::getInstance()->dump(result); if (const auto display = getDefaultDisplayDeviceLocked()) { display->getCompositionDisplay()->getState().undefinedRegion.dump(result, “undefinedRegion”); StringAppendF(&result, " orientation=%s, isPoweredOn=%d\n”, toCString(display->getOrientation()), display->isPoweredOn()); } StringAppendF(&result, " transaction-flags : %08x\n” " gpu_to_cpu_unsupported : %d\n”, mTransactionFlags.load(), !mGpuToCpuSupported); if (const auto display = getDefaultDisplayDeviceLocked()) { std::string fps, xDpi, yDpi; if (const auto activeMode = display->getActiveMode()) { fps = to_string(activeMode->getFps()); xDpi = base::StringPrintf(”%.2f”, activeMode->getDpiX()); yDpi = base::StringPrintf(”%.2f”, activeMode->getDpiY()); } else { fps = “unknown”; xDpi = “unknown”; yDpi = “unknown”; } StringAppendF(&result, " refresh-rate : %s\n” " x-dpi : %s\n” " y-dpi : %s\n”, fps.c_str(), xDpi.c_str(), yDpi.c_str()); } StringAppendF(&result, " transaction time: %f us\n", inTransactionDuration / 1000.0); @frameworks/native/services/surfaceflinger/SurfaceTracing.cpp mTracing.dump(result); base::StringAppendF(&result, “Tracing state: %s\n”, mEnabled ? “enabled” : “disabled”); for (const auto& [token, display] : mDisplays) { StringAppendF(&result, “Display %s (%s) HWC layers:\n”, to_string(displayId).c_str(), (isDisplayActiveLocked(display) ? “active” : “inactive”)); @frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp Layer::miniDumpHeader(result); result.append(kDumpTableRowLength, ‘-’); result.append("\n"); result.append(" Layer name\n"); result.append(" Z | “); result.append(” Window Type | “); result.append(” Comp Type | “); result.append(” Transform | “); result.append(” Disp Frame (LTRB) | “); result.append(” Source Crop (LTRB) | “); result.append(” Frame Rate (Explicit) (Seamlessness) [Focused]\n"); result.append(kDumpTableRowLength, ‘-’); result.append("\n"); const DisplayDevice& ref = display; mCurrentState.traverseInZOrder([&](Layer layer) { layer->miniDump(result, ref); }); StringAppendF(&result, " %s\n", name.c_str()); const State& layerState(getDrawingState()); const auto& outputLayerState = outputLayer->getState(); if (layerState.zOrderRelativeOf != nullptr || mDrawingParent != nullptr) { StringAppendF(&result, " rel %6d | “, layerState.z); } else { StringAppendF(&result, " %10d | “, layerState.z); } StringAppendF(&result, " %10d | “, mWindowType); StringAppendF(&result, “%10s | “, toString(getCompositionType(display)).c_str()); StringAppendF(&result, “%10s | “, toString(outputLayerState.bufferTransform).c_str()); const Rect& frame = outputLayerState.displayFrame; StringAppendF(&result, “%4d %4d %4d %4d | “, frame.left, frame.top, frame.right, frame.bottom); const FloatRect& crop = outputLayerState.sourceCrop; StringAppendF(&result, “%6.1f %6.1f %6.1f %6.1f | “, crop.left, crop.top, crop.right, crop.bottom); const auto frameRate = getFrameRateForLayerTree(); if (frameRate.rate.isValid() || frameRate.type != FrameRateCompatibility::Default) { StringAppendF(&result, “%s %15s %17s”, to_string(frameRate.rate).c_str(), frameRateCompatibilityString(frameRate.type).c_str(), toString(frameRate.seamlessness).c_str()); } else { result.append(41, ’ ‘); } const auto focused = isLayerFocusedBasedOnPriority(getFrameRateSelectionPriority()); StringAppendF(&result, " [%s]\n”, focused ? “” : " “); result.append(kDumpTableRowLength, ‘-’); plannerArgs.add(String16(”–layers”)); dumpPlannerInfo(plannerArgs, result); for (const auto& [token, display] : mDisplays) { @frameworks/native/services/surfaceflinger/CompositionEngine/src/Output.cpp compositionDisplay->dumpPlannerInfo(args, result); base::StringAppendF(&out, “Planner is disabled\n”); result.append(“h/w composer state:\n”); colorizer.reset(result); bool hwcDisabled = mDebugDisableHWC || mDebugRegion; StringAppendF(&result, " h/w composer %s\n”, hwcDisabled ? “disabled” : “enabled”); @hardware/rockchip/hwcomposer/drmhwc2/drmhwctwo.cpp getHwComposer().dump(result); //看下面的DrmHwcTwo::Dump const GraphicBufferAllocator& alloc(GraphicBufferAllocator::get()); @frameworks/native/libs/ui/GraphicBufferAllocator.cpp alloc.dump(result); result.append(“GraphicBufferAllocator buffers:\n”); const size_t count = list.size(); StringAppendF(&result, “%10s | %11s | %18s | %s | %8s | %10s | %s\n”, “Handle”, “Size”, “W (Stride) x H”, “Layers”, “Format”, “Usage”, “Requestor”); for (size_t i = 0; i < count; i++) { const alloc_rec_t& rec(list.valueAt(i)); std::string sizeStr = (rec.size) ? base::StringPrintf("%7.2f KiB”, static_cast(rec.size) / 1024.0) : “unknown”; StringAppendF(&result, “%10p | %11s | %4u (%4u) x %4u | %6u | %8X | 0x%8” PRIx64 " | %s\n”, list.keyAt(i), sizeStr.c_str(), rec.width, rec.stride, rec.height, rec.layerCount, rec.format, rec.usage, rec.requestorName.c_str()); total += rec.size; } StringAppendF(&result, “Total allocated by GraphicBufferAllocator (estimate): %.2f KB\n”, static_cast(total) / 1024.0); @frameworks/native/libs/ui/Gralloc4.cpp result.append(mAllocator->dumpDebugInfo(less)); return mMapper.dumpBuffers(less); stream « “Imported gralloc buffers:\n”; for (const auto& bufferDump : bufferDumps) { uint64_t allocationSize = 0; status_t err = bufferDumpHelper(bufferDump, &stream, &allocationSize, less); status_t error = metadataDumpHelper(bufferDump, StandardMetadataType::BUFFER_ID, gralloc4::decodeBufferId, &bufferId); *outDump « “+ name:” « name « “, id:” « bufferId « “, size:” « allocationSizeKiB « “KiB, w/h:” « width « “x” « height « “, usage: 0x” « std::hex « usage « std::dec « “, req fmt:” « static_cast<int32_t>(pixelFormatRequested) « “, fourcc/mod:” « pixelFormatFourCC « “/” « pixelFormatModifier « “, dataspace: 0x” « std::hex « static_cast<uint32_t>(dataspace) « std::dec « “, compressed: “; for (const auto& planeLayout : planeLayouts) { *outDump « “\tplanes: “; outDump « " w/h:” « planeLayout.widthInSamples « “x” « planeLayout.heightInSamples « “, stride:” « planeLayout.strideInBytes « " bytes, size:” « planeLayout.totalSizeInBytes; stream « “Total imported by gralloc: " « totalAllocationSizeKiB « “KiB\n”; @frameworks/native/services/surfaceflinger/TimeStats/TimeStats.cpp result.append(mTimeStats->miniDump()); std::string result = “TimeStats miniDump:\n”; std::lock_guard lock(mMutex); android::base::StringAppendF(&result, “Number of layers currently being tracked is %zu\n”, mTimeStatsTracker.size()); android::base::StringAppendF(&result, “Number of layers in the stats pool is %zu\n”, mTimeStats.stats.size()); LayersTraceFileProto traceFileProto = SurfaceTracing::createLayersTraceFileProto(); dumpDisplayProto(layersTrace); displayProto->set_layer_stack(display->getLayerStack()); result.append(LayerProtoParser::layerTreeToString(layerTree)); for (const LayerProtoParser::Layer layer : layerTree.topLevelLayers) { @frameworks/native/services/surfaceflinger/layerproto/LayerProtoParser.cpp result.append(layerToString(layer)); result.append(layer->to_string()); StringAppendF(&result, “+ %s (%s) uid=%d\n”, type.c_str(), name.c_str(), ownerUid); result.append(transparentRegion.to_string(“TransparentRegion”).c_str()); result.append(visibleRegion.to_string(“VisibleRegion”).c_str()); result.append(damageRegion.to_string(“SurfaceDamageRegion”).c_str()); StringAppendF(&result, " layerStack=%4d, z=%9d, pos=(%g,%g), size=(%4d,%4d), “, layerStack, z, static_cast(position.x), static_cast(position.y), size.x, size.y); StringAppendF(&result, “crop=%s, “, crop.to_string().c_str()); StringAppendF(&result, “cornerRadius=%f, “, cornerRadius); StringAppendF(&result, “isProtected=%1d, “, isProtected); StringAppendF(&result, “isTrustedOverlay=%1d, “, isTrustedOverlay); StringAppendF(&result, “isOpaque=%1d, invalidate=%1d, “, isOpaque, invalidate); StringAppendF(&result, “dataspace=%s, “, dataspace.c_str()); StringAppendF(&result, “defaultPixelFormat=%s, “, pixelFormat.c_str()); StringAppendF(&result, “backgroundBlurRadius=%1d, “, backgroundBlurRadius); StringAppendF(&result, “color=(%.3f,%.3f,%.3f,%.3f), flags=0x%08x, “, static_cast(color.r), static_cast(color.g), static_cast(color.b), static_cast(color.a), flags); StringAppendF(&result, “tr=%s”, transform.to_string().c_str()); result.append("\n”); StringAppendF(&result, " parent=%s\n”, parent == nullptr ? “none” : parent->name.c_str()); StringAppendF(&result, " zOrderRelativeOf=%s\n”, zOrderRelativeOf == nullptr ? “none” : zOrderRelativeOf->name.c_str()); StringAppendF(&result, " activeBuffer=%s,”, activeBuffer.to_string().c_str()); StringAppendF(&result, " tr=%s”, bufferTransform.to_string().c_str()); StringAppendF(&result, " queued-frames=%d, mRefreshPending=%d,”, queuedFrames, refreshPending); StringAppendF(&result, " metadata={”); bool first = true; for (const auto& entry : metadata.mMap) { if (!first) result.append(”, “); first = false; result.append(metadata.itemToString(entry.first, “:”)); } result.append(”},”); StringAppendF(&result, " cornerRadiusCrop=%s, “, cornerRadiusCrop.to_string().c_str()); StringAppendF(&result, " shadowRadius=%.3f, “, shadowRadius); dumpOffscreenLayers(result); result.append(“Offscreen Layers:\n”); for (Layer offscreenLayer : mOffscreenLayers) { @frameworks/native/services/surfaceflinger/Layer.cpp layer->dumpCallingUidPid(result); StringAppendF(&result, “Layer %s (%s) callingPid:%d callingUid:%d ownerUid:%d\n”, getName().c_str(), getType(), mCallingPid, mCallingUid, mOwnerUid);