13f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian/* 23f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * Copyright 2013 The Android Open Source Project 33f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * 43f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 53f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * you may not use this file except in compliance with the License. 63f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * You may obtain a copy of the License at 73f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * 83f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 93f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * 103f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * Unless required by applicable law or agreed to in writing, software 113f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 123f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * See the License for the specific language governing permissions and 143f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * limitations under the License. 153f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian */ 163f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 173f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian#include <GLES2/gl2.h> 1849457ac092071a8f964f7f69156093657ccdc3d0Mathias Agopian#include "Texture.h" 193f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 203f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian#ifndef SF_RENDER_ENGINE_DESCRIPTION_H_ 213f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian#define SF_RENDER_ENGINE_DESCRIPTION_H_ 223f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 233f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopiannamespace android { 243f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 253f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopianclass Program; 263f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 273f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian/* 283f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * This holds the state of the rendering engine. This class is used 293f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * to generate a corresponding GLSL program and set the appropriate 303f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * uniform. 313f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * 323f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian * Program and ProgramCache are friends and access the state directly 333f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian */ 343f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopianclass Description { 357e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wupublic: 367e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu Description() = default; 377e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu ~Description() = default; 387e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu 397e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu void setPremultipliedAlpha(bool premultipliedAlpha); 407e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu void setOpaque(bool opaque); 417e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu void setTexture(const Texture& texture); 427e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu void disableTexture(); 437e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu void setColor(const half4& color); 447e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu void setProjectionMatrix(const mat4& mtx); 4576dd77a6f5298bf0e7cb89ec570ab1578e3947fbPeiyong Lin void setSaturationMatrix(const mat4& mtx); 467e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu void setColorMatrix(const mat4& mtx); 47a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin void setInputTransformMatrix(const mat3& matrix); 48a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin void setOutputTransformMatrix(const mat4& matrix); 49a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin bool hasInputTransformMatrix() const; 50a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin bool hasOutputTransformMatrix() const; 51a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin bool hasColorMatrix() const; 5276dd77a6f5298bf0e7cb89ec570ab1578e3947fbPeiyong Lin bool hasSaturationMatrix() const; 537e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu const mat4& getColorMatrix() const; 547e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu 55131d3760a0437fac08ff4cc384640b7ca1802d17Chia-I Wu void setY410BT2020(bool enable); 56131d3760a0437fac08ff4cc384640b7ca1802d17Chia-I Wu 577e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu enum class TransferFunction : int { 587e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu LINEAR, 597e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu SRGB, 60131d3760a0437fac08ff4cc384640b7ca1802d17Chia-I Wu ST2084, 61a3fb7d6b631c9ecab70ff68443cbdee872ed649fPeiyong Lin HLG, // Hybrid Log-Gamma for HDR. 627e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu }; 637e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu void setInputTransferFunction(TransferFunction transferFunction); 647e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu void setOutputTransferFunction(TransferFunction transferFunction); 65fb069305e90947aeb76b72527f23aa24564f3c87Peiyong Lin void setDisplayMaxLuminance(const float maxLuminance); 667e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu 677e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wuprivate: 683f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian friend class Program; 693f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian friend class ProgramCache; 703f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 713f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian // whether textures are premultiplied 7225429cb71cf91d217e2002325ad9f3e6d9be806fGreg Kaiser bool mPremultipliedAlpha = false; 733f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian // whether this layer is marked as opaque 7425429cb71cf91d217e2002325ad9f3e6d9be806fGreg Kaiser bool mOpaque = true; 753f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 7649457ac092071a8f964f7f69156093657ccdc3d0Mathias Agopian // Texture this layer uses 7749457ac092071a8f964f7f69156093657ccdc3d0Mathias Agopian Texture mTexture; 7825429cb71cf91d217e2002325ad9f3e6d9be806fGreg Kaiser bool mTextureEnabled = false; 7949457ac092071a8f964f7f69156093657ccdc3d0Mathias Agopian 8013fdc49516d17f41e64e62e73c313b0928bf13ccchaviw // color used when texturing is disabled or when setting alpha. 8113fdc49516d17f41e64e62e73c313b0928bf13ccchaviw half4 mColor; 82ff2ed70fa30f04b90dd1a2c06ec2319e157152d7Mathias Agopian 83131d3760a0437fac08ff4cc384640b7ca1802d17Chia-I Wu // true if the sampled pixel values are in Y410/BT2020 rather than RGBA 84131d3760a0437fac08ff4cc384640b7ca1802d17Chia-I Wu bool mY410BT2020 = false; 85131d3760a0437fac08ff4cc384640b7ca1802d17Chia-I Wu 867e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu // transfer functions for the input/output 877e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu TransferFunction mInputTransferFunction = TransferFunction::LINEAR; 887e65bc00e46fbae2820fa52c997d72ab69ecd916Chia-I Wu TransferFunction mOutputTransferFunction = TransferFunction::LINEAR; 89fb069305e90947aeb76b72527f23aa24564f3c87Peiyong Lin 90fb069305e90947aeb76b72527f23aa24564f3c87Peiyong Lin float mDisplayMaxLuminance; 91a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin 92a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin // projection matrix 93a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin mat4 mProjectionMatrix; 94a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin mat4 mColorMatrix; 9576dd77a6f5298bf0e7cb89ec570ab1578e3947fbPeiyong Lin mat4 mSaturationMatrix; 96a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin mat3 mInputTransformMatrix; 97a296b0c232483ff2d80a814a1a39d02397ba559ePeiyong Lin mat4 mOutputTransformMatrix; 983f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian}; 993f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 1003f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} /* namespace android */ 1013f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 1023f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian#endif /* SF_RENDER_ENGINE_DESCRIPTION_H_ */ 103