| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 1 | /* |
| 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 Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame^] | 22 | #include <ui/Fence.h> |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 23 | #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 | |
| 30 | namespace android { |
| 31 | namespace renderengine { |
| 32 | |
| 33 | // Metadata describing the input buffer to render from. |
| 34 | struct 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 Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 38 | sp<GraphicBuffer> buffer = nullptr; |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 39 | |
| Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame^] | 40 | // Fence that will fire when the buffer is ready to be bound. |
| 41 | sp<Fence> fence = nullptr; |
| 42 | |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 43 | // Texture identifier to bind the external texture to. |
| 44 | // TODO(alecmouri): This is GL-specific...make the type backend-agnostic. |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 45 | uint32_t textureName = 0; |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 46 | |
| 47 | // Whether to use filtering when rendering the texture. |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 48 | bool useTextureFiltering = false; |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 49 | |
| 50 | // Transform matrix to apply to texture coordinates. |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 51 | mat4 textureTransform = mat4(); |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 52 | |
| 53 | // Wheteher to use pre-multiplied alpha |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 54 | bool usePremultipliedAlpha = true; |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 55 | |
| Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame^] | 56 | // 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 Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 61 | // HDR color-space setting for Y410. |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 62 | bool isY410BT2020 = false; |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | // Metadata describing the layer geometry. |
| 66 | struct Geometry { |
| 67 | // Boundaries of the layer. |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 68 | FloatRect boundaries = FloatRect(); |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 69 | |
| 70 | // Transform matrix to apply to mesh coordinates. |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 71 | mat4 positionTransform = mat4(); |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | // Descriptor of the source pixels for this layer. |
| 75 | struct PixelSource { |
| 76 | // Source buffer |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 77 | Buffer buffer = Buffer(); |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 78 | |
| 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 Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 82 | half3 solidColor = half3(0.0f, 0.0f, 0.0f); |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | // The settings that RenderEngine requires for correctly rendering a Layer. |
| 86 | struct LayerSettings { |
| 87 | // Geometry information |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 88 | Geometry geometry = Geometry(); |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 89 | |
| 90 | // Source pixels for this layer. |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 91 | PixelSource source = PixelSource(); |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 92 | |
| Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame^] | 93 | // Alpha option to blend with the source pixels |
| Alec Mouri | 1441bf7 | 2018-12-03 19:55:28 -0800 | [diff] [blame] | 94 | half alpha = half(0.0); |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 95 | |
| 96 | // Color space describing how the source pixels should be interpreted. |
| Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 97 | ui::Dataspace sourceDataspace; |
| 98 | |
| 99 | // Additional layer-specific color transform to be applied before the global |
| 100 | // transform. |
| 101 | mat4 colorTransform; |
| Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | } // namespace renderengine |
| 105 | } // namespace android |