blob: a37a16340c340cde8e954e72860465ba8af889ca [file] [log] [blame]
Alec Mouri6e57f682018-09-29 20:45:08 -07001/*
2 * Copyright 2018 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 <math/mat4.h>
20#include <math/vec3.h>
21#include <renderengine/Texture.h>
Alec Mouri0d5e1eb2018-11-10 20:40:12 -080022#include <ui/Fence.h>
Alec Mouri6e57f682018-09-29 20:45:08 -070023#include <ui/FloatRect.h>
24#include <ui/GraphicBuffer.h>
25#include <ui/GraphicTypes.h>
26#include <ui/Rect.h>
27#include <ui/Region.h>
28#include <ui/Transform.h>
29
30namespace android {
31namespace renderengine {
32
33// Metadata describing the input buffer to render from.
34struct Buffer {
35 // Buffer containing the image that we will render.
36 // If buffer == nullptr, then the rest of the fields in this struct will be
37 // ignored.
Alec Mouri1441bf72018-12-03 19:55:28 -080038 sp<GraphicBuffer> buffer = nullptr;
Alec Mouri6e57f682018-09-29 20:45:08 -070039
Alec Mouri0d5e1eb2018-11-10 20:40:12 -080040 // Fence that will fire when the buffer is ready to be bound.
41 sp<Fence> fence = nullptr;
42
Alec Mouri6e57f682018-09-29 20:45:08 -070043 // Texture identifier to bind the external texture to.
44 // TODO(alecmouri): This is GL-specific...make the type backend-agnostic.
Alec Mouri1441bf72018-12-03 19:55:28 -080045 uint32_t textureName = 0;
Alec Mouri6e57f682018-09-29 20:45:08 -070046
47 // Whether to use filtering when rendering the texture.
Alec Mouri1441bf72018-12-03 19:55:28 -080048 bool useTextureFiltering = false;
Alec Mouri6e57f682018-09-29 20:45:08 -070049
50 // Transform matrix to apply to texture coordinates.
Alec Mouri1441bf72018-12-03 19:55:28 -080051 mat4 textureTransform = mat4();
Alec Mouri6e57f682018-09-29 20:45:08 -070052
53 // Wheteher to use pre-multiplied alpha
Alec Mouri1441bf72018-12-03 19:55:28 -080054 bool usePremultipliedAlpha = true;
Alec Mouri6e57f682018-09-29 20:45:08 -070055
Alec Mouri0d5e1eb2018-11-10 20:40:12 -080056 // Override flag that alpha for each pixel in the buffer *must* be 1.0.
57 // LayerSettings::alpha is still used if isOpaque==true - this flag only
58 // overrides the alpha channel of the buffer.
59 bool isOpaque = false;
60
Alec Mouri6e57f682018-09-29 20:45:08 -070061 // HDR color-space setting for Y410.
Alec Mouri1441bf72018-12-03 19:55:28 -080062 bool isY410BT2020 = false;
Alec Mouri6e57f682018-09-29 20:45:08 -070063};
64
65// Metadata describing the layer geometry.
66struct Geometry {
67 // Boundaries of the layer.
Alec Mouri1441bf72018-12-03 19:55:28 -080068 FloatRect boundaries = FloatRect();
Alec Mouri6e57f682018-09-29 20:45:08 -070069
70 // Transform matrix to apply to mesh coordinates.
Alec Mouri1441bf72018-12-03 19:55:28 -080071 mat4 positionTransform = mat4();
Alec Mouri6e57f682018-09-29 20:45:08 -070072};
73
74// Descriptor of the source pixels for this layer.
75struct PixelSource {
76 // Source buffer
Alec Mouri1441bf72018-12-03 19:55:28 -080077 Buffer buffer = Buffer();
Alec Mouri6e57f682018-09-29 20:45:08 -070078
79 // The solid color with which to fill the layer.
80 // This should only be populated if we don't render from an application
81 // buffer.
Alec Mouri1441bf72018-12-03 19:55:28 -080082 half3 solidColor = half3(0.0f, 0.0f, 0.0f);
Alec Mouri6e57f682018-09-29 20:45:08 -070083};
84
85// The settings that RenderEngine requires for correctly rendering a Layer.
86struct LayerSettings {
87 // Geometry information
Alec Mouri1441bf72018-12-03 19:55:28 -080088 Geometry geometry = Geometry();
Alec Mouri6e57f682018-09-29 20:45:08 -070089
90 // Source pixels for this layer.
Alec Mouri1441bf72018-12-03 19:55:28 -080091 PixelSource source = PixelSource();
Alec Mouri6e57f682018-09-29 20:45:08 -070092
Alec Mouri0d5e1eb2018-11-10 20:40:12 -080093 // Alpha option to blend with the source pixels
Alec Mouri1441bf72018-12-03 19:55:28 -080094 half alpha = half(0.0);
Alec Mouri6e57f682018-09-29 20:45:08 -070095
96 // Color space describing how the source pixels should be interpreted.
Alec Mouri1089aed2018-10-25 21:33:57 -070097 ui::Dataspace sourceDataspace;
98
99 // Additional layer-specific color transform to be applied before the global
100 // transform.
101 mat4 colorTransform;
Alec Mouri6e57f682018-09-29 20:45:08 -0700102};
103
104} // namespace renderengine
105} // namespace android