Home | History | Annotate | Download | only in compositionengine
      1 /*
      2  * Copyright 2019 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #pragma once
     18 
     19 #include <cstdint>
     20 
     21 #include <gui/BufferQueue.h>
     22 #include <gui/HdrMetadata.h>
     23 #include <math/mat4.h>
     24 #include <ui/FloatRect.h>
     25 #include <ui/GraphicBuffer.h>
     26 #include <ui/GraphicTypes.h>
     27 #include <ui/Rect.h>
     28 #include <ui/Region.h>
     29 #include <ui/Transform.h>
     30 
     31 #include "DisplayHardware/ComposerHal.h"
     32 
     33 namespace android::compositionengine {
     34 
     35 /*
     36  * Used by LayerFE::getCompositionState
     37  */
     38 struct LayerFECompositionState {
     39     // TODO(lpique): b/121291683 Remove this one we are sure we don't need the
     40     // value recomputed / set every frame.
     41     Region geomVisibleRegion;
     42 
     43     /*
     44      * Geometry state
     45      */
     46 
     47     bool isSecure{false};
     48     bool geomUsesSourceCrop{false};
     49     bool geomBufferUsesDisplayInverseTransform{false};
     50     uint32_t geomBufferTransform{0};
     51     ui::Transform geomLayerTransform;
     52     ui::Transform geomInverseLayerTransform;
     53     Rect geomBufferSize;
     54     Rect geomContentCrop;
     55     Rect geomCrop;
     56     Region geomActiveTransparentRegion;
     57     FloatRect geomLayerBounds;
     58 
     59     /*
     60      * Presentation
     61      */
     62 
     63     // The blend mode for this layer
     64     Hwc2::IComposerClient::BlendMode blendMode{Hwc2::IComposerClient::BlendMode::INVALID};
     65 
     66     // The alpha value for this layer
     67     float alpha{1.f};
     68 
     69     /*
     70      * Extra metadata
     71      */
     72 
     73     // The type for this layer
     74     int type{0};
     75 
     76     // The appId for this layer
     77     int appId{0};
     78 
     79     /*
     80      * Per-frame content
     81      */
     82 
     83     // The type of composition for this layer
     84     Hwc2::IComposerClient::Composition compositionType{Hwc2::IComposerClient::Composition::INVALID};
     85 
     86     // The buffer and related state
     87     sp<GraphicBuffer> buffer;
     88     int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT};
     89     sp<Fence> acquireFence;
     90     Region surfaceDamage;
     91 
     92     // The handle to use for a sideband stream for this layer
     93     sp<NativeHandle> sidebandStream;
     94 
     95     // The color for this layer
     96     Hwc2::IComposerClient::Color color;
     97 
     98     /*
     99      * Per-frame presentation state
    100      */
    101 
    102     // The dataspace for this layer
    103     ui::Dataspace dataspace{ui::Dataspace::UNKNOWN};
    104 
    105     // The metadata for this layer
    106     HdrMetadata hdrMetadata;
    107 
    108     // The color transform
    109     mat4 colorTransform;
    110 };
    111 
    112 } // namespace android::compositionengine
    113