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

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

SF: Move LayerBE into it's own file

Move LayerBE related structures into a separate file, as prep
work for changes that will come in later and allow for sharing
structures between LayerBE and SurfaceFlingerBE

Test: Compiles
Change-Id: I36684d0e25e150a2dca6843073aa86991553e4f9
parent db1422bb
Loading
Loading
Loading
Loading
+1 −62
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include "MonitoredProducer.h"
#include "SurfaceFlinger.h"
#include "Transform.h"
#include "LayerBE.h"

#include <layerproto/LayerProtoHeader.h>
#include "DisplayHardware/HWComposer.h"
@@ -68,68 +69,6 @@ class LayerBE;

// ---------------------------------------------------------------------------

struct CompositionInfo {
    HWC2::Composition compositionType;
    sp<GraphicBuffer> mBuffer = nullptr;
    int mBufferSlot = BufferQueue::INVALID_BUFFER_SLOT;
    struct {
        HWComposer* hwc;
        sp<Fence> fence;
        HWC2::BlendMode blendMode;
        Rect displayFrame;
        float alpha;
        FloatRect sourceCrop;
        HWC2::Transform transform;
        int z;
        int type;
        int appId;
        Region visibleRegion;
        Region surfaceDamage;
        sp<NativeHandle> sidebandStream;
        android_dataspace dataspace;
        hwc_color_t color;
    } hwc;
    struct {
        RE::RenderEngine* renderEngine;
        Mesh* mesh;
    } renderEngine;
};

class LayerBE {
public:
    LayerBE();

    // The mesh used to draw the layer in GLES composition mode
    Mesh mMesh;

    // HWC items, accessed from the main thread
    struct HWCInfo {
        HWCInfo()
              : hwc(nullptr),
                layer(nullptr),
                forceClientComposition(false),
                compositionType(HWC2::Composition::Invalid),
                clearClientTarget(false) {}

        HWComposer* hwc;
        HWC2::Layer* layer;
        bool forceClientComposition;
        HWC2::Composition compositionType;
        bool clearClientTarget;
        Rect displayFrame;
        FloatRect sourceCrop;
        HWComposerBufferCache bufferCache;
    };

    // A layer can be attached to multiple displays when operating in mirror mode
    // (a.k.a: when several displays are attached with equal layerStack). In this
    // case we need to keep track. In non-mirror mode, a layer will have only one
    // HWCInfo. This map key is a display layerStack.
    std::unordered_map<int32_t, HWCInfo> mHwcLayers;

    CompositionInfo compositionInfo;
};

class Layer : public virtual RefBase {
    static int32_t sSequence;

+96 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.
 */

#pragma once

#include <stdint.h>
#include <sys/types.h>

#include <ui/Region.h>

#include "SurfaceFlinger.h"

#include "DisplayHardware/HWComposer.h"
#include "DisplayHardware/HWComposerBufferCache.h"
#include "RenderEngine/Mesh.h"

namespace android {

struct CompositionInfo {
    HWC2::Composition compositionType;
    sp<GraphicBuffer> mBuffer = nullptr;
    int mBufferSlot = BufferQueue::INVALID_BUFFER_SLOT;
    struct {
        HWC2::Layer* hwcLayer;
        int32_t hwid = -1;
        sp<Fence> fence;
        HWC2::BlendMode blendMode = HWC2::BlendMode::Invalid;
        Rect displayFrame;
        float alpha;
        FloatRect sourceCrop;
        HWC2::Transform transform = HWC2::Transform::None;
        int z;
        int type;
        int appId;
        Region visibleRegion;
        Region surfaceDamage;
        sp<NativeHandle> sidebandStream;
        android_dataspace dataspace;
        hwc_color_t color;
    } hwc;
    struct {
        Mesh* mesh;
    } renderEngine;
};

class LayerBE {
public:
    LayerBE();

    // The mesh used to draw the layer in GLES composition mode
    Mesh mMesh;

    // HWC items, accessed from the main thread
    struct HWCInfo {
        HWCInfo()
              : hwc(nullptr),
                layer(nullptr),
                forceClientComposition(false),
                compositionType(HWC2::Composition::Invalid),
                clearClientTarget(false) {}

        HWComposer* hwc;
        HWC2::Layer* layer;
        bool forceClientComposition;
        HWC2::Composition compositionType;
        bool clearClientTarget;
        Rect displayFrame;
        FloatRect sourceCrop;
        HWComposerBufferCache bufferCache;
    };


    // A layer can be attached to multiple displays when operating in mirror mode
    // (a.k.a: when several displays are attached with equal layerStack). In this
    // case we need to keep track. In non-mirror mode, a layer will have only one
    // HWCInfo. This map key is a display layerStack.
    std::unordered_map<int32_t, HWCInfo> mHwcLayers;

    CompositionInfo compositionInfo;
};

}; // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include <gui/LayerState.h>

#include <gui/OccupancyTracker.h>
#include <gui/BufferQueue.h>

#include <hardware/hwcomposer_defs.h>

@@ -60,6 +61,7 @@
#include "SurfaceInterceptor.h"
#include "SurfaceTracing.h"
#include "StartPropertySetThread.h"
#include "LayerBE.h"

#include "DisplayHardware/HWC2.h"
#include "DisplayHardware/HWComposer.h"