blob: 7177aad032ee2705487426f46e9606de08d7657a [file] [log] [blame]
Mathias Agopian3f844832013-08-07 21:24:32 -07001/*
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 Agopian3f844832013-08-07 21:24:32 -070017#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 Andrewsc3ebe662014-09-04 16:20:31 -070024#include <Transform.h>
Mathias Agopian3f844832013-08-07 21:24:32 -070025
Mathias Agopian3f844832013-08-07 21:24:32 -070026#include "Description.h"
Chia-I Wub027f802017-11-29 14:00:52 -080027#include "ProgramCache.h"
28#include "RenderEngine.h"
Mathias Agopian3f844832013-08-07 21:24:32 -070029
30// ---------------------------------------------------------------------------
31namespace android {
32// ---------------------------------------------------------------------------
33
34class String8;
35class Mesh;
Mathias Agopian49457ac2013-08-14 18:20:17 -070036class Texture;
Mathias Agopian3f844832013-08-07 21:24:32 -070037
Lloyd Pique144e1162017-12-20 16:44:52 -080038namespace RE {
39namespace impl {
40
Mathias Agopian3f844832013-08-07 21:24:32 -070041class GLES20RenderEngine : public RenderEngine {
42 GLuint mProtectedTexName;
43 GLint mMaxViewportDims[2];
44 GLint mMaxTextureSize;
Mathias Agopianff2ed702013-09-01 21:36:12 -070045 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 Agopian3f844832013-08-07 21:24:32 -070055
56 Description mState;
Mathias Agopianff2ed702013-09-01 21:36:12 -070057 Vector<Group> mGroupStack;
Mathias Agopian3f844832013-08-07 21:24:32 -070058
Chia-I Wub027f802017-11-29 14:00:52 -080059 virtual void bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName, uint32_t* fbName,
60 uint32_t* status);
Mathias Agopian458197d2013-08-15 14:56:51 -070061 virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName);
62
Mathias Agopian3f844832013-08-07 21:24:32 -070063public:
Kalle Raitabbdcf1f2017-05-22 15:47:46 -070064 GLES20RenderEngine(uint32_t featureFlags); // See RenderEngine::FeatureFlag
Chia-I Wub2c76242017-11-09 17:17:07 -080065 virtual ~GLES20RenderEngine();
Mathias Agopian3f844832013-08-07 21:24:32 -070066
67protected:
Mathias Agopian3f844832013-08-07 21:24:32 -070068 virtual void dump(String8& result);
Chia-I Wub027f802017-11-29 14:00:52 -080069 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 Goeltzenleuchter5d943892017-03-22 13:46:46 -060073
74 // Color management related functions and state
Chia-I Wu69bf10f2018-02-20 13:04:50 -080075 void setSourceY410BT2020(bool enable) override;
Peiyong Lin34beb7a2018-03-28 11:57:12 -070076 void setSourceDataSpace(ui::Dataspace source) override;
77 void setOutputDataSpace(ui::Dataspace dataspace) override;
Peiyong Linfb069302018-04-25 14:34:31 -070078 void setDisplayMaxLuminance(const float maxLuminance) override;
Kalle Raitabbdcf1f2017-05-22 15:47:46 -070079
Mathias Agopian49457ac2013-08-14 18:20:17 -070080 virtual void setupLayerTexturing(const Texture& texture);
Mathias Agopian3f844832013-08-07 21:24:32 -070081 virtual void setupLayerBlackedOut();
Mathias Agopian19733a32013-08-28 18:13:56 -070082 virtual void setupFillWithColor(float r, float g, float b, float a);
Dan Stozaf0087992014-10-20 15:46:09 -070083 virtual mat4 setupColorTransform(const mat4& colorTransform);
Mathias Agopian3f844832013-08-07 21:24:32 -070084 virtual void disableTexturing();
85 virtual void disableBlending();
86
Mathias Agopian3f844832013-08-07 21:24:32 -070087 virtual void drawMesh(const Mesh& mesh);
88
Mathias Agopian3f844832013-08-07 21:24:32 -070089 virtual size_t getMaxTextureSize() const;
90 virtual size_t getMaxViewportDims() const;
Peiyong Linfb069302018-04-25 14:34:31 -070091
92 // Current dataspace of layer being rendered
93 ui::Dataspace mDataSpace = ui::Dataspace::UNKNOWN;
94
95 // Current output dataspace of the render engine
96 ui::Dataspace mOutputDataSpace = ui::Dataspace::UNKNOWN;
97
98 // Currently only supporting sRGB, BT2020 and DisplayP3 color spaces
99 const bool mPlatformHasWideColor = false;
100 mat4 mSrgbToDisplayP3;
101 mat4 mBt2020ToDisplayP3;
Mathias Agopian3f844832013-08-07 21:24:32 -0700102};
103
104// ---------------------------------------------------------------------------
Lloyd Pique144e1162017-12-20 16:44:52 -0800105} // namespace impl
106} // namespace RE
107} // namespace android
Mathias Agopian3f844832013-08-07 21:24:32 -0700108// ---------------------------------------------------------------------------
109
110#endif /* SF_GLES20RENDERENGINE_H_ */