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> |
Peiyong Lin | cbc184f | 2018-08-22 13:24:10 -0700 | [diff] [blame] | 24 | #include <renderengine/RenderEngine.h> |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 25 | #include <renderengine/private/Description.h> |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 26 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 27 | namespace android { |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 28 | |
| 29 | class String8; |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 30 | |
| 31 | namespace renderengine { |
| 32 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 33 | class Mesh; |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 34 | class Texture; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 35 | |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 36 | namespace gl { |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 37 | |
Peiyong Lin | f1bada9 | 2018-08-29 09:39:31 -0700 | [diff] [blame] | 38 | class GLImage; |
| 39 | class GLSurface; |
| 40 | |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 41 | class GLES20RenderEngine : public impl::RenderEngine { |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 42 | public: |
Kalle Raita | bbdcf1f | 2017-05-22 15:47:46 -0700 | [diff] [blame] | 43 | GLES20RenderEngine(uint32_t featureFlags); // See RenderEngine::FeatureFlag |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame^] | 44 | ~GLES20RenderEngine() override; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 45 | |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame^] | 46 | std::unique_ptr<Framebuffer> createFramebuffer() override; |
| 47 | std::unique_ptr<Surface> createSurface() override; |
| 48 | std::unique_ptr<Image> createImage() override; |
Peiyong Lin | f1bada9 | 2018-08-29 09:39:31 -0700 | [diff] [blame] | 49 | |
| 50 | void primeCache() const override; |
| 51 | |
| 52 | bool isCurrent() const; |
| 53 | bool setCurrentSurface(const Surface& surface) override; |
| 54 | void resetCurrentSurface() override; |
| 55 | |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame^] | 56 | void bindExternalTextureImage(uint32_t texName, const Image& image) override; |
| 57 | status_t bindFrameBuffer(Framebuffer* framebuffer) override; |
| 58 | void unbindFrameBuffer(Framebuffer* framebuffer) override; |
Peiyong Lin | f1bada9 | 2018-08-29 09:39:31 -0700 | [diff] [blame] | 59 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 60 | protected: |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame^] | 61 | void dump(String8& result) override; |
| 62 | void setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop, |
| 63 | ui::Transform::orientation_flags rotation) override; |
| 64 | void setupLayerBlending(bool premultipliedAlpha, bool opaque, bool disableTexture, |
| 65 | const half4& color) override; |
Courtney Goeltzenleuchter | 5d94389 | 2017-03-22 13:46:46 -0600 | [diff] [blame] | 66 | |
| 67 | // Color management related functions and state |
Chia-I Wu | 69bf10f | 2018-02-20 13:04:50 -0800 | [diff] [blame] | 68 | void setSourceY410BT2020(bool enable) override; |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 69 | void setSourceDataSpace(ui::Dataspace source) override; |
| 70 | void setOutputDataSpace(ui::Dataspace dataspace) override; |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 71 | void setDisplayMaxLuminance(const float maxLuminance) override; |
Kalle Raita | bbdcf1f | 2017-05-22 15:47:46 -0700 | [diff] [blame] | 72 | |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame^] | 73 | void setupLayerTexturing(const Texture& texture) override; |
| 74 | void setupLayerBlackedOut() override; |
| 75 | void setupFillWithColor(float r, float g, float b, float a) override; |
| 76 | void setupColorTransform(const mat4& colorTransform) override; |
| 77 | void disableTexturing() override; |
| 78 | void disableBlending() override; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 79 | |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame^] | 80 | void drawMesh(const Mesh& mesh) override; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 81 | |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame^] | 82 | size_t getMaxTextureSize() const override; |
| 83 | size_t getMaxViewportDims() const override; |
| 84 | |
| 85 | private: |
| 86 | // A data space is considered HDR data space if it has BT2020 color space |
| 87 | // with PQ or HLG transfer function. |
| 88 | bool isHdrDataSpace(const ui::Dataspace dataSpace) const; |
| 89 | bool needsXYZTransformMatrix() const; |
| 90 | |
| 91 | GLuint mProtectedTexName; |
| 92 | GLint mMaxViewportDims[2]; |
| 93 | GLint mMaxTextureSize; |
| 94 | GLuint mVpWidth; |
| 95 | GLuint mVpHeight; |
| 96 | Description mState; |
| 97 | |
| 98 | mat4 mSrgbToDisplayP3; |
| 99 | mat4 mDisplayP3ToSrgb; |
| 100 | mat3 mSrgbToXyz; |
| 101 | mat3 mBt2020ToXyz; |
| 102 | mat3 mDisplayP3ToXyz; |
| 103 | mat4 mXyzToSrgb; |
| 104 | mat4 mXyzToDisplayP3; |
| 105 | mat4 mXyzToBt2020; |
| 106 | |
| 107 | bool mRenderToFbo = false; |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 108 | |
| 109 | // Current dataspace of layer being rendered |
| 110 | ui::Dataspace mDataSpace = ui::Dataspace::UNKNOWN; |
| 111 | |
| 112 | // Current output dataspace of the render engine |
| 113 | ui::Dataspace mOutputDataSpace = ui::Dataspace::UNKNOWN; |
| 114 | |
Peiyong Lin | 13effd1 | 2018-07-24 17:01:47 -0700 | [diff] [blame] | 115 | // Whether device supports color management, currently color management |
| 116 | // supports sRGB, DisplayP3 color spaces. |
| 117 | const bool mUseColorManagement = false; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 118 | }; |
| 119 | |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 120 | } // namespace gl |
| 121 | } // namespace renderengine |
| 122 | } // namespace android |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 123 | |
| 124 | #endif /* SF_GLES20RENDERENGINE_H_ */ |