Caches.h revision 9bca4793a33d2714b306d69ceb870925a588fe71
1/*
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
20#ifndef LOG_TAG
21    #define LOG_TAG "OpenGLRenderer"
22#endif
23
24#include <utils/Singleton.h>
25
26#include "FontRenderer.h"
27#include "GammaFontRenderer.h"
28#include "TextureCache.h"
29#include "LayerCache.h"
30#include "GradientCache.h"
31#include "PatchCache.h"
32#include "ProgramCache.h"
33#include "PathCache.h"
34#include "TextDropShadowCache.h"
35#include "FboCache.h"
36#include "Line.h"
37#include "ResourceCache.h"
38
39namespace android {
40namespace uirenderer {
41
42///////////////////////////////////////////////////////////////////////////////
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
67struct CacheLogger {
68    CacheLogger() {
69        LOGD("Creating caches");
70    }
71}; // struct CacheLogger
72
73///////////////////////////////////////////////////////////////////////////////
74// Caches
75///////////////////////////////////////////////////////////////////////////////
76
77class Caches: public Singleton<Caches> {
78    Caches();
79
80    friend class Singleton<Caches>;
81
82    CacheLogger mlogger;
83
84    GLuint mCurrentBuffer;
85
86public:
87    void bindMeshBuffer();
88    void bindMeshBuffer(const GLuint buffer);
89    void unbindMeshBuffer();
90
91    bool blend;
92    GLenum lastSrcMode;
93    GLenum lastDstMode;
94    Program* currentProgram;
95
96    GLuint meshBuffer;
97
98    TextureCache textureCache;
99    LayerCache layerCache;
100    GradientCache gradientCache;
101    ProgramCache programCache;
102    PathCache pathCache;
103    PatchCache patchCache;
104    TextDropShadowCache dropShadowCache;
105    FboCache fboCache;
106    GammaFontRenderer fontRenderer;
107    ResourceCache resourceCache;
108
109    Line line;
110}; // class Caches
111
112}; // namespace uirenderer
113
114}; // namespace android
115
116#endif // ANDROID_UI_CACHES_H
117