blob: 8b67fccdc0426440cb50fd4856f4ba16e984fdeb [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>
25
26#include "RenderEngine.h"
27#include "ProgramCache.h"
28#include "Description.h"
29
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
38class GLES20RenderEngine : public RenderEngine {
39 GLuint mProtectedTexName;
40 GLint mMaxViewportDims[2];
41 GLint mMaxTextureSize;
Mathias Agopianff2ed702013-09-01 21:36:12 -070042 GLuint mVpWidth;
43 GLuint mVpHeight;
44
45 struct Group {
46 GLuint texture;
47 GLuint fbo;
48 GLuint width;
49 GLuint height;
50 mat4 colorTransform;
51 };
Mathias Agopian3f844832013-08-07 21:24:32 -070052
53 Description mState;
Mathias Agopianff2ed702013-09-01 21:36:12 -070054 Vector<Group> mGroupStack;
Mathias Agopian3f844832013-08-07 21:24:32 -070055
Mathias Agopian458197d2013-08-15 14:56:51 -070056 virtual void bindImageAsFramebuffer(EGLImageKHR image,
57 uint32_t* texName, uint32_t* fbName, uint32_t* status);
58 virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName);
59
Mathias Agopian3f844832013-08-07 21:24:32 -070060public:
61 GLES20RenderEngine();
62
63protected:
64 virtual ~GLES20RenderEngine();
65
66 virtual void dump(String8& result);
67 virtual void setViewportAndProjection(size_t vpw, size_t vph, size_t w, size_t h, bool yswap);
68 virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha);
69 virtual void setupDimLayerBlending(int alpha);
Mathias Agopian49457ac2013-08-14 18:20:17 -070070 virtual void setupLayerTexturing(const Texture& texture);
Mathias Agopian3f844832013-08-07 21:24:32 -070071 virtual void setupLayerBlackedOut();
Mathias Agopian19733a32013-08-28 18:13:56 -070072 virtual void setupFillWithColor(float r, float g, float b, float a);
Mathias Agopian3f844832013-08-07 21:24:32 -070073 virtual void disableTexturing();
74 virtual void disableBlending();
75
Mathias Agopian3f844832013-08-07 21:24:32 -070076 virtual void drawMesh(const Mesh& mesh);
77
Mathias Agopianff2ed702013-09-01 21:36:12 -070078 virtual void beginGroup(const mat4& colorTransform);
79 virtual void endGroup();
80
Mathias Agopian3f844832013-08-07 21:24:32 -070081 virtual size_t getMaxTextureSize() const;
82 virtual size_t getMaxViewportDims() const;
83};
84
85// ---------------------------------------------------------------------------
86}; // namespace android
87// ---------------------------------------------------------------------------
88
89#endif /* SF_GLES20RENDERENGINE_H_ */