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

Commit b8af792f authored by David Sodman's avatar David Sodman
Browse files

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
parent 8725e81d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ filegroup {
        "FrameTracker.cpp",
        "GpuService.cpp",
        "Layer.cpp",
	"LayerBE.cpp",
        "LayerProtoHelper.cpp",
        "LayerRejecter.cpp",
        "LayerStats.cpp",
+2 −6
Original line number Diff line number Diff line
@@ -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 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& n
        mQueueItems(),
        mLastFrameNumberReceived(0),
        mAutoRefresh(false),
        mFreezeGeometryUpdates(false) {
        mFreezeGeometryUpdates(false),
        mBE{this} {

    mCurrentCrop.makeInvalid();

+81 −0
Original line number Diff line number Diff line
/*
 * 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
+19 −1
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@

namespace android {

class LayerBE;

class LayerContainer
{
    public:
@@ -56,9 +58,11 @@ class LayerContainer
};

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 @@ struct CompositionInfo {
        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;

+2 −2
Original line number Diff line number Diff line
@@ -2034,7 +2034,7 @@ void SurfaceFlinger::postFramebuffer()
                        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 @@ void SurfaceFlinger::postFramebuffer()
        if (!displayDevice->getLayersNeedingFences().isEmpty()) {
            sp<Fence> presentFence = getBE().mHwc->getPresentFence(hwcId);
            for (auto& layer : displayDevice->getLayersNeedingFences()) {
                layer->onLayerDisplayed(presentFence);
                layer->getBE().onLayerDisplayed(presentFence);
            }
        }