blob: 7c3f9b5d4a5ad5946dae17c13f8909aa52006d9c [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
17
18#ifndef SF_GLES20RENDERENGINE_H_
19#define SF_GLES20RENDERENGINE_H_
20
21#include <stdint.h>
22#include <sys/types.h>
23
24#include <GLES2/gl2.h>
Riley Andrewsc3ebe662014-09-04 16:20:31 -070025#include <Transform.h>
Mathias Agopian3f844832013-08-07 21:24:32 -070026
27#include "RenderEngine.h"
28#include "ProgramCache.h"
29#include "Description.h"
30
31// ---------------------------------------------------------------------------
32namespace android {
33// ---------------------------------------------------------------------------
34
35class String8;
36class Mesh;
Mathias Agopian49457ac2013-08-14 18:20:17 -070037class Texture;
Mathias Agopian3f844832013-08-07 21:24:32 -070038
39class GLES20RenderEngine : public RenderEngine {
40 GLuint mProtectedTexName;
41 GLint mMaxViewportDims[2];
42 GLint mMaxTextureSize;
Mathias Agopianff2ed702013-09-01 21:36:12 -070043 GLuint mVpWidth;
44 GLuint mVpHeight;
45
46 struct Group {
47 GLuint texture;
48 GLuint fbo;
49 GLuint width;
50 GLuint height;
51 mat4 colorTransform;
52 };
Mathias Agopian3f844832013-08-07 21:24:32 -070053
54 Description mState;
Mathias Agopianff2ed702013-09-01 21:36:12 -070055 Vector<Group> mGroupStack;
Mathias Agopian3f844832013-08-07 21:24:32 -070056
Mathias Agopian458197d2013-08-15 14:56:51 -070057 virtual void bindImageAsFramebuffer(EGLImageKHR image,
58 uint32_t* texName, uint32_t* fbName, uint32_t* status);
59 virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName);
60
Mathias Agopian3f844832013-08-07 21:24:32 -070061public:
62 GLES20RenderEngine();
63
64protected:
65 virtual ~GLES20RenderEngine();
66
67 virtual void dump(String8& result);
Dan Stozac1879002014-05-22 15:59:05 -070068 virtual void setViewportAndProjection(size_t vpw, size_t vph,
Dan Stoza9e56aa02015-11-02 13:00:03 -080069 Rect sourceCrop, size_t hwh, bool yswap,
70 Transform::orientation_flags rotation);
71#ifdef USE_HWC2
72 virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque,
73 float alpha) override;
74 virtual void setupDimLayerBlending(float alpha) override;
75#else
76 virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque,
77 int alpha);
Mathias Agopian3f844832013-08-07 21:24:32 -070078 virtual void setupDimLayerBlending(int alpha);
Dan Stoza9e56aa02015-11-02 13:00:03 -080079#endif
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;
91};
92
93// ---------------------------------------------------------------------------
94}; // namespace android
95// ---------------------------------------------------------------------------
96
97#endif /* SF_GLES20RENDERENGINE_H_ */