blob: e43bfa490c6a6a7498dac3852d621c8ac9c5cfc3 [file] [log] [blame]
Mathias Agopian875d8e12013-06-07 15:35:48 -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_RENDERENGINE_H_
19#define SF_RENDERENGINE_H_
20
21#include <stdint.h>
22#include <sys/types.h>
23
24#include <EGL/egl.h>
25
26// ---------------------------------------------------------------------------
27namespace android {
28// ---------------------------------------------------------------------------
29
30class String8;
31
32class RenderEngine {
33 enum GlesVersion {
34 GLES_VERSION_1_0 = 0x10000,
35 GLES_VERSION_1_1 = 0x10001,
36 GLES_VERSION_2_0 = 0x20000,
37 GLES_VERSION_3_0 = 0x30000,
38 };
39 static GlesVersion parseGlesVersion(const char* str);
40
41 EGLContext mEGLContext;
42 void setEGLContext(EGLContext ctxt);
43
44protected:
45 RenderEngine();
46 virtual ~RenderEngine() = 0;
47
48public:
49 static RenderEngine* create(EGLDisplay display, EGLConfig config);
50
51 virtual void checkErrors() const;
52
53 virtual void dump(String8& result) = 0;
54 virtual void setViewportAndProjection(size_t w, size_t h) = 0;
55 virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha) = 0;
56 virtual void setupDimLayerBlending(int alpha) = 0;
57 virtual void setupLayerTexturing(size_t textureName, bool useFiltering, const float* textureMatrix) = 0;
58 virtual void setupLayerBlackedOut() = 0;
59
60 virtual void disableTexturing() = 0;
61 virtual void disableBlending() = 0;
62
63 virtual void clearWithColor(const float vertices[][2], size_t count,
64 float red, float green, float blue, float alpha) = 0;
65
66 virtual void drawMesh2D(const float vertices[][2], const float texCoords[][2], size_t count) = 0;
67
68 virtual size_t getMaxTextureSize() const = 0;
69 virtual size_t getMaxViewportDims() const = 0;
70
71 EGLContext getEGLContext() const;
72};
73
74// ---------------------------------------------------------------------------
75}; // namespace android
76// ---------------------------------------------------------------------------
77
78#endif /* SF_RENDERENGINE_H_ */