1 /* 2 * Copyright 2023 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/vec4.h> 20 #include "FloatRect.h" 21 22 namespace android { 23 24 /* 25 * Contains the configuration for the shadows drawn by single layer. Shadow follows 26 * material design guidelines. 27 */ 28 struct ShadowSettings { 29 // Boundaries of the shadow. 30 FloatRect boundaries = FloatRect(); 31 32 // Color to the ambient shadow. The alpha is premultiplied. 33 vec4 ambientColor = vec4(); 34 35 // Color to the spot shadow. The alpha is premultiplied. The position of the spot shadow 36 // depends on the light position. 37 vec4 spotColor = vec4(); 38 39 // Position of the light source used to cast the spot shadow. 40 vec3 lightPos = vec3(); 41 42 // Radius of the spot light source. Smaller radius will have sharper edges, 43 // larger radius will have softer shadows 44 float lightRadius = 0.f; 45 46 // Length of the cast shadow. If length is <= 0.f no shadows will be drawn. 47 float length = 0.f; 48 49 // If true fill in the casting layer is translucent and the shadow needs to fill the bounds. 50 // Otherwise the shadow will only be drawn around the edges of the casting layer. 51 bool casterIsTranslucent = false; 52 }; 53 54 static inline bool operator==(const ShadowSettings& lhs, const ShadowSettings& rhs) { 55 return lhs.boundaries == rhs.boundaries && lhs.ambientColor == rhs.ambientColor && 56 lhs.spotColor == rhs.spotColor && lhs.lightPos == rhs.lightPos && 57 lhs.lightRadius == rhs.lightRadius && lhs.length == rhs.length && 58 lhs.casterIsTranslucent == rhs.casterIsTranslucent; 59 } 60 61 static inline bool operator!=(const ShadowSettings& lhs, const ShadowSettings& rhs) { 62 return !(operator==(lhs, rhs)); 63 } 64 65 } // namespace android