Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40b4e23a authored by Dan Stoza's avatar Dan Stoza Committed by Android (Google) Code Review
Browse files

Merge "resolved conflicts for merge of 1665c8e1 to lmp-mr1-dev-plus-aosp" into...

Merge "resolved conflicts for merge of 1665c8e1 to lmp-mr1-dev-plus-aosp" into lmp-mr1-dev-plus-aosp
parents 39d890d9 22d0bdf3
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -90,7 +90,7 @@ else
endif
endif


LOCAL_CFLAGS += -fvisibility=hidden -Werror=format
LOCAL_CFLAGS += -fvisibility=hidden -Werror=format
LOCAL_CPPFLAGS := -std=c++1y
LOCAL_CFLAGS += -std=c++11


LOCAL_SHARED_LIBRARIES := \
LOCAL_SHARED_LIBRARIES := \
    libcutils \
    libcutils \
@@ -110,8 +110,6 @@ LOCAL_MODULE := libsurfaceflinger


LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code


include external/libcxx/libcxx.mk

include $(BUILD_SHARED_LIBRARY)
include $(BUILD_SHARED_LIBRARY)


###############################################################
###############################################################
+0 −95
Original line number Original line Diff line number Diff line
@@ -78,12 +78,6 @@
#include "RenderEngine/RenderEngine.h"
#include "RenderEngine/RenderEngine.h"
#include <cutils/compiler.h>
#include <cutils/compiler.h>


#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#define DISPLAY_COUNT       1
#define DISPLAY_COUNT       1


/*
/*
@@ -1813,17 +1807,6 @@ void SurfaceFlinger::doDisplayComposition(const sp<const DisplayDevice>& hw,
    hw->swapBuffers(getHwComposer());
    hw->swapBuffers(getHwComposer());
}
}


static std::set<int> getOpenFds()
{
    std::set<int> fds;
    for (int fd = 0; fd < 1024; ++fd) {
        if (fcntl(fd, F_GETFD) != -1 || errno != EBADF) {
            fds.insert(fd);
        }
    }
    return fds;
}

bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty)
bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty)
{
{
    RenderEngine& engine(getRenderEngine());
    RenderEngine& engine(getRenderEngine());
@@ -1898,8 +1881,6 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const
     * and then, render the layers targeted at the framebuffer
     * and then, render the layers targeted at the framebuffer
     */
     */


    static std::set<std::string> previousLayers;
    std::set<std::string> currentLayers;
    const Vector< sp<Layer> >& layers(hw->getVisibleLayersSortedByZ());
    const Vector< sp<Layer> >& layers(hw->getVisibleLayersSortedByZ());
    const size_t count = layers.size();
    const size_t count = layers.size();
    const Transform& tr = hw->getTransform();
    const Transform& tr = hw->getTransform();
@@ -1909,7 +1890,6 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const
            const sp<Layer>& layer(layers[i]);
            const sp<Layer>& layer(layers[i]);
            const Region clip(dirty.intersect(tr.transform(layer->visibleRegion)));
            const Region clip(dirty.intersect(tr.transform(layer->visibleRegion)));
            if (!clip.isEmpty()) {
            if (!clip.isEmpty()) {
                currentLayers.insert(layer->getName().string());
                switch (cur->getCompositionType()) {
                switch (cur->getCompositionType()) {
                    case HWC_CURSOR_OVERLAY:
                    case HWC_CURSOR_OVERLAY:
                    case HWC_OVERLAY: {
                    case HWC_OVERLAY: {
@@ -1945,86 +1925,11 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const
            const Region clip(dirty.intersect(
            const Region clip(dirty.intersect(
                    tr.transform(layer->visibleRegion)));
                    tr.transform(layer->visibleRegion)));
            if (!clip.isEmpty()) {
            if (!clip.isEmpty()) {
                currentLayers.insert(layer->getName().string());
                layer->draw(hw, clip);
                layer->draw(hw, clip);
            }
            }
        }
        }
    }
    }


    std::set<std::string> newLayers;
    for (auto layer : currentLayers) {
        if (previousLayers.count(layer) == 0) {
            newLayers.insert(layer);
        }
    }
    std::set<std::string> deletedLayers;
    for (auto layer : previousLayers) {
        if (currentLayers.count(layer) == 0) {
            deletedLayers.insert(layer);
        }
    }
    previousLayers = std::move(currentLayers);

    static std::set<int> previousFds;
    static std::unordered_map<std::string, std::set<int>> initialFds;

    for (auto layer : newLayers) {
        initialFds[layer] = previousFds;
    }

    std::set<int> currentFds = getOpenFds();

    if (!deletedLayers.empty()) {
        std::unordered_map<int, std::set<std::string>> currentBlame;
        static std::map<int, std::set<std::string>> persistentBlame;
        for (auto layer : deletedLayers) {
            std::vector<int> newFds;
            auto& layerInitialFds = initialFds[layer];
            std::set_difference(
                    currentFds.cbegin(), currentFds.cend(),
                    layerInitialFds.cbegin(), layerInitialFds.cend(),
                    std::back_inserter(newFds));

            for (auto fd : newFds) {
                currentBlame[fd].insert(layer);
            }

            initialFds.erase(layer);
        }

        for (auto blame : currentBlame) {
            persistentBlame[blame.first] = blame.second;
        }

        auto iter = persistentBlame.cbegin();
        while (iter != persistentBlame.cend()) {
            if (currentFds.count(iter->first) == 0) {
                iter = persistentBlame.erase(iter);
            } else {
                ++iter;
            }
        }

        std::map<std::set<std::string>, int> blameCounts;
        for (auto blame : persistentBlame) {
            ++blameCounts[blame.second];
        }

        ALOGI("FD Blame: %zu open fds", currentFds.size());
        for (auto blame : blameCounts) {
            std::string layers;
            for (auto layer : blame.first) {
                if (!layers.empty()) {
                    layers += ", ";
                }
                layers += layer;
            }
            ALOGI("  %s: %d", layers.c_str(), blame.second);
        }
    }

    previousFds = std::move(currentFds);

    // disable scissor at the end of the frame
    // disable scissor at the end of the frame
    engine.disableScissor();
    engine.disableScissor();
    return true;
    return true;