Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 17 | #ifndef SF_GLES20RENDERENGINE_H_ |
| 18 | #define SF_GLES20RENDERENGINE_H_ |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <GLES2/gl2.h> |
Riley Andrews | c3ebe66 | 2014-09-04 16:20:31 -0700 | [diff] [blame] | 24 | #include <Transform.h> |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 25 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 26 | #include "Description.h" |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 27 | #include "ProgramCache.h" |
| 28 | #include "RenderEngine.h" |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 29 | |
| 30 | // --------------------------------------------------------------------------- |
| 31 | namespace android { |
| 32 | // --------------------------------------------------------------------------- |
| 33 | |
| 34 | class String8; |
| 35 | class Mesh; |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 36 | class Texture; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 37 | |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame^] | 38 | namespace RE { |
| 39 | namespace impl { |
| 40 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 41 | class GLES20RenderEngine : public RenderEngine { |
| 42 | GLuint mProtectedTexName; |
| 43 | GLint mMaxViewportDims[2]; |
| 44 | GLint mMaxTextureSize; |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 45 | GLuint mVpWidth; |
| 46 | GLuint mVpHeight; |
| 47 | |
| 48 | struct Group { |
| 49 | GLuint texture; |
| 50 | GLuint fbo; |
| 51 | GLuint width; |
| 52 | GLuint height; |
| 53 | mat4 colorTransform; |
| 54 | }; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 55 | |
| 56 | Description mState; |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 57 | Vector<Group> mGroupStack; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 58 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 59 | virtual void bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName, uint32_t* fbName, |
| 60 | uint32_t* status); |
Mathias Agopian | 458197d | 2013-08-15 14:56:51 -0700 | [diff] [blame] | 61 | virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName); |
| 62 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 63 | public: |
Kalle Raita | bbdcf1f | 2017-05-22 15:47:46 -0700 | [diff] [blame] | 64 | GLES20RenderEngine(uint32_t featureFlags); // See RenderEngine::FeatureFlag |
Chia-I Wu | b2c7624 | 2017-11-09 17:17:07 -0800 | [diff] [blame] | 65 | virtual ~GLES20RenderEngine(); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 66 | |
| 67 | protected: |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 68 | virtual void dump(String8& result); |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 69 | virtual void setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop, size_t hwh, |
| 70 | bool yswap, Transform::orientation_flags rotation); |
| 71 | virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, bool disableTexture, |
| 72 | const half4& color) override; |
Courtney Goeltzenleuchter | 5d94389 | 2017-03-22 13:46:46 -0600 | [diff] [blame] | 73 | |
| 74 | // Color management related functions and state |
| 75 | void setColorMode(android_color_mode mode); |
| 76 | void setSourceDataSpace(android_dataspace source); |
Chia-I Wu | 131d376 | 2018-01-11 14:35:27 -0800 | [diff] [blame] | 77 | void setSourceY410BT2020(bool enable); |
Courtney Goeltzenleuchter | 5d94389 | 2017-03-22 13:46:46 -0600 | [diff] [blame] | 78 | void setWideColor(bool hasWideColor); |
| 79 | bool usesWideColor(); |
| 80 | |
| 81 | // Current color mode of display using the render engine |
| 82 | android_color_mode mColorMode = HAL_COLOR_MODE_NATIVE; |
| 83 | |
| 84 | // Current dataspace of layer being rendered |
| 85 | android_dataspace mDataSpace = HAL_DATASPACE_V0_SRGB; |
| 86 | |
| 87 | // Indicate if wide-color mode is needed or not |
Courtney Goeltzenleuchter | 5d94389 | 2017-03-22 13:46:46 -0600 | [diff] [blame] | 88 | bool mDisplayHasWideColor = false; |
| 89 | bool mUseWideColor = false; |
| 90 | uint64_t mWideColorFrameCount = 0; |
| 91 | |
Chia-I Wu | 131d376 | 2018-01-11 14:35:27 -0800 | [diff] [blame] | 92 | // Currently only supporting sRGB, BT2020 and DisplayP3 color spaces |
Courtney Goeltzenleuchter | 5d94389 | 2017-03-22 13:46:46 -0600 | [diff] [blame] | 93 | mat4 mSrgbToDisplayP3; |
Chia-I Wu | 131d376 | 2018-01-11 14:35:27 -0800 | [diff] [blame] | 94 | mat4 mBt2020ToDisplayP3; |
Kalle Raita | bbdcf1f | 2017-05-22 15:47:46 -0700 | [diff] [blame] | 95 | bool mPlatformHasWideColor = false; |
| 96 | |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 97 | virtual void setupLayerTexturing(const Texture& texture); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 98 | virtual void setupLayerBlackedOut(); |
Mathias Agopian | 19733a3 | 2013-08-28 18:13:56 -0700 | [diff] [blame] | 99 | virtual void setupFillWithColor(float r, float g, float b, float a); |
Dan Stoza | f008799 | 2014-10-20 15:46:09 -0700 | [diff] [blame] | 100 | virtual mat4 setupColorTransform(const mat4& colorTransform); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 101 | virtual void disableTexturing(); |
| 102 | virtual void disableBlending(); |
| 103 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 104 | virtual void drawMesh(const Mesh& mesh); |
| 105 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 106 | virtual size_t getMaxTextureSize() const; |
| 107 | virtual size_t getMaxViewportDims() const; |
| 108 | }; |
| 109 | |
| 110 | // --------------------------------------------------------------------------- |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame^] | 111 | } // namespace impl |
| 112 | } // namespace RE |
| 113 | } // namespace android |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 114 | // --------------------------------------------------------------------------- |
| 115 | |
| 116 | #endif /* SF_GLES20RENDERENGINE_H_ */ |