blob: 90cb62b292f6add58f71871dff58b8346296e32f [file] [log] [blame]
Mathias Agopiand606de62010-05-10 20:06:11 -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_TEXTURE_MANAGER_H
18#define ANDROID_TEXTURE_MANAGER_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <EGL/egl.h>
24#include <EGL/eglext.h>
25#include <GLES/gl.h>
26
27#include <ui/Region.h>
28
29#include <pixelflinger/pixelflinger.h>
30
31namespace android {
32
33// ---------------------------------------------------------------------------
34
35class GraphicBuffer;
36
37// ---------------------------------------------------------------------------
38
39struct Texture {
40 Texture() : name(-1U), width(0), height(0),
41 image(EGL_NO_IMAGE_KHR), transform(0),
42 NPOTAdjust(false), dirty(true) { }
43 GLuint name;
44 GLuint width;
45 GLuint height;
46 GLuint potWidth;
47 GLuint potHeight;
48 GLfloat wScale;
49 GLfloat hScale;
50 EGLImageKHR image;
51 uint32_t transform;
52 bool NPOTAdjust;
53 bool dirty;
54};
55
56// ---------------------------------------------------------------------------
57
58class TextureManager {
59 uint32_t mFlags;
60 GLuint createTexture();
61 static bool isSupportedYuvFormat(int format);
62public:
63
64 TextureManager(uint32_t flags);
65
66 // load bitmap data into the active buffer
67 status_t loadTexture(Texture* texture,
68 const Region& dirty, const GGLSurface& t);
69
70 // make active buffer an EGLImage if needed
71 status_t initEglImage(Texture* texture,
72 EGLDisplay dpy, const sp<GraphicBuffer>& buffer);
73};
74
75// ---------------------------------------------------------------------------
76
77}; // namespace android
78
79#endif // ANDROID_TEXTURE_MANAGER_H