blob: 79644a55d0bfcd1239b941e56603e75619559501 [file] [log] [blame]
Romain Guyfb8b7632010-08-23 21:05:08 -07001/*
2 * Copyright (C) 2010 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#ifndef ANDROID_UI_CACHES_H
18#define ANDROID_UI_CACHES_H
19
Romain Guya2341a92010-09-08 18:04:33 -070020#ifndef LOG_TAG
21 #define LOG_TAG "OpenGLRenderer"
22#endif
Romain Guyfb8b7632010-08-23 21:05:08 -070023
24#include <utils/Singleton.h>
25
Romain Guy03750a02010-10-18 14:06:08 -070026#include "FontRenderer.h"
27#include "GammaFontRenderer.h"
Romain Guyfb8b7632010-08-23 21:05:08 -070028#include "TextureCache.h"
29#include "LayerCache.h"
30#include "GradientCache.h"
31#include "PatchCache.h"
Romain Guyfb8b7632010-08-23 21:05:08 -070032#include "ProgramCache.h"
33#include "PathCache.h"
34#include "TextDropShadowCache.h"
Romain Guye2d345e2010-09-24 18:39:22 -070035#include "FboCache.h"
Romain Guy29d89972010-09-22 16:10:57 -070036#include "Line.h"
Chet Haase5c13d892010-10-08 08:37:55 -070037#include "ResourceCache.h"
Romain Guyfb8b7632010-08-23 21:05:08 -070038
39namespace android {
40namespace uirenderer {
41
Romain Guy03750a02010-10-18 14:06:08 -070042///////////////////////////////////////////////////////////////////////////////
43// Globals
44///////////////////////////////////////////////////////////////////////////////
45
46#define REQUIRED_TEXTURE_UNITS_COUNT 3
47
48// Generates simple and textured vertices
49#define FV(x, y, u, v) { { x, y }, { u, v } }
50
51// This array is never used directly but used as a memcpy source in the
52// OpenGLRenderer constructor
53static const TextureVertex gMeshVertices[] = {
54 FV(0.0f, 0.0f, 0.0f, 0.0f),
55 FV(1.0f, 0.0f, 1.0f, 0.0f),
56 FV(0.0f, 1.0f, 0.0f, 1.0f),
57 FV(1.0f, 1.0f, 1.0f, 1.0f)
58};
59static const GLsizei gMeshStride = sizeof(TextureVertex);
60static const GLsizei gMeshTextureOffset = 2 * sizeof(float);
61static const GLsizei gMeshCount = 4;
62
63///////////////////////////////////////////////////////////////////////////////
64// Debug
65///////////////////////////////////////////////////////////////////////////////
66
Romain Guyfb8b7632010-08-23 21:05:08 -070067struct CacheLogger {
68 CacheLogger() {
69 LOGD("Creating caches");
70 }
71}; // struct CacheLogger
72
Romain Guy03750a02010-10-18 14:06:08 -070073///////////////////////////////////////////////////////////////////////////////
74// Caches
75///////////////////////////////////////////////////////////////////////////////
76
Romain Guyfb8b7632010-08-23 21:05:08 -070077class Caches: public Singleton<Caches> {
Chet Haasedd78cca2010-10-22 18:59:26 -070078 Caches();
Romain Guyfb8b7632010-08-23 21:05:08 -070079
80 friend class Singleton<Caches>;
81
82 CacheLogger logger;
83
84public:
Chet Haasedd78cca2010-10-22 18:59:26 -070085 void bindMeshBuffer();
86 void bindMeshBuffer(const GLuint buffer);
87 void unbindMeshBuffer();
Romain Guy03750a02010-10-18 14:06:08 -070088
Romain Guyfb8b7632010-08-23 21:05:08 -070089 bool blend;
90 GLenum lastSrcMode;
91 GLenum lastDstMode;
92 Program* currentProgram;
93
Romain Guy03750a02010-10-18 14:06:08 -070094 GLuint meshBuffer;
95 GLuint currentBuffer;
96
Romain Guyfb8b7632010-08-23 21:05:08 -070097 TextureCache textureCache;
98 LayerCache layerCache;
99 GradientCache gradientCache;
100 ProgramCache programCache;
101 PathCache pathCache;
102 PatchCache patchCache;
103 TextDropShadowCache dropShadowCache;
Romain Guye2d345e2010-09-24 18:39:22 -0700104 FboCache fboCache;
Romain Guy11fd6542010-10-04 17:10:58 -0700105 GammaFontRenderer fontRenderer;
Chet Haase5c13d892010-10-08 08:37:55 -0700106 ResourceCache resourceCache;
Romain Guy29d89972010-09-22 16:10:57 -0700107
108 Line line;
Romain Guyfb8b7632010-08-23 21:05:08 -0700109}; // class Caches
110
111}; // namespace uirenderer
112
Romain Guyfb8b7632010-08-23 21:05:08 -0700113}; // namespace android
114
115#endif // ANDROID_UI_CACHES_H