blob: ca228674fe2f195a015e8b1d731ba4b72229e2dc [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 Guy746b7402010-10-26 16:27:31 -070026#include "Extensions.h"
Romain Guy03750a02010-10-18 14:06:08 -070027#include "FontRenderer.h"
28#include "GammaFontRenderer.h"
Romain Guyfb8b7632010-08-23 21:05:08 -070029#include "TextureCache.h"
30#include "LayerCache.h"
31#include "GradientCache.h"
32#include "PatchCache.h"
Romain Guyfb8b7632010-08-23 21:05:08 -070033#include "ProgramCache.h"
34#include "PathCache.h"
35#include "TextDropShadowCache.h"
Romain Guye2d345e2010-09-24 18:39:22 -070036#include "FboCache.h"
Romain Guy29d89972010-09-22 16:10:57 -070037#include "Line.h"
Chet Haase5c13d892010-10-08 08:37:55 -070038#include "ResourceCache.h"
Romain Guyfb8b7632010-08-23 21:05:08 -070039
40namespace android {
41namespace uirenderer {
42
Romain Guy03750a02010-10-18 14:06:08 -070043///////////////////////////////////////////////////////////////////////////////
44// Globals
45///////////////////////////////////////////////////////////////////////////////
46
47#define REQUIRED_TEXTURE_UNITS_COUNT 3
48
49// Generates simple and textured vertices
50#define FV(x, y, u, v) { { x, y }, { u, v } }
51
52// This array is never used directly but used as a memcpy source in the
53// OpenGLRenderer constructor
54static const TextureVertex gMeshVertices[] = {
55 FV(0.0f, 0.0f, 0.0f, 0.0f),
56 FV(1.0f, 0.0f, 1.0f, 0.0f),
57 FV(0.0f, 1.0f, 0.0f, 1.0f),
58 FV(1.0f, 1.0f, 1.0f, 1.0f)
59};
60static const GLsizei gMeshStride = sizeof(TextureVertex);
61static const GLsizei gMeshTextureOffset = 2 * sizeof(float);
62static const GLsizei gMeshCount = 4;
63
64///////////////////////////////////////////////////////////////////////////////
65// Debug
66///////////////////////////////////////////////////////////////////////////////
67
Romain Guyfb8b7632010-08-23 21:05:08 -070068struct CacheLogger {
69 CacheLogger() {
70 LOGD("Creating caches");
71 }
72}; // struct CacheLogger
73
Romain Guy03750a02010-10-18 14:06:08 -070074///////////////////////////////////////////////////////////////////////////////
75// Caches
76///////////////////////////////////////////////////////////////////////////////
77
Romain Guyfb8b7632010-08-23 21:05:08 -070078class Caches: public Singleton<Caches> {
Chet Haasedd78cca2010-10-22 18:59:26 -070079 Caches();
Romain Guyfb8b7632010-08-23 21:05:08 -070080
81 friend class Singleton<Caches>;
82
Romain Guy9bca4792010-10-25 18:42:25 -070083 CacheLogger mlogger;
84
85 GLuint mCurrentBuffer;
Romain Guyfb8b7632010-08-23 21:05:08 -070086
87public:
Chet Haasedd78cca2010-10-22 18:59:26 -070088 void bindMeshBuffer();
89 void bindMeshBuffer(const GLuint buffer);
90 void unbindMeshBuffer();
Romain Guy03750a02010-10-18 14:06:08 -070091
Romain Guyfb8b7632010-08-23 21:05:08 -070092 bool blend;
93 GLenum lastSrcMode;
94 GLenum lastDstMode;
95 Program* currentProgram;
96
Romain Guy746b7402010-10-26 16:27:31 -070097 // VBO to draw with
Romain Guy03750a02010-10-18 14:06:08 -070098 GLuint meshBuffer;
Romain Guy03750a02010-10-18 14:06:08 -070099
Romain Guy746b7402010-10-26 16:27:31 -0700100 // GL extensions
101 Extensions extensions;
102
103 // Misc
104 GLint maxTextureSize;
105
Romain Guyfb8b7632010-08-23 21:05:08 -0700106 TextureCache textureCache;
107 LayerCache layerCache;
108 GradientCache gradientCache;
109 ProgramCache programCache;
110 PathCache pathCache;
111 PatchCache patchCache;
112 TextDropShadowCache dropShadowCache;
Romain Guye2d345e2010-09-24 18:39:22 -0700113 FboCache fboCache;
Romain Guy11fd6542010-10-04 17:10:58 -0700114 GammaFontRenderer fontRenderer;
Chet Haase5c13d892010-10-08 08:37:55 -0700115 ResourceCache resourceCache;
Romain Guy29d89972010-09-22 16:10:57 -0700116
117 Line line;
Romain Guyfb8b7632010-08-23 21:05:08 -0700118}; // class Caches
119
120}; // namespace uirenderer
121
Romain Guyfb8b7632010-08-23 21:05:08 -0700122}; // namespace android
123
124#endif // ANDROID_UI_CACHES_H