blob: 25145354a4f0d8afc740d797d6a93a18c214581e [file] [log] [blame]
Romain Guy877cfe02013-05-02 17:36:28 -07001/*
2 * Copyright (C) 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#ifndef ANDROID_HWUI_IMAGE_H
18#define ANDROID_HWUI_IMAGE_H
19
Romain Guy877cfe02013-05-02 17:36:28 -070020#include <EGL/egl.h>
21#include <EGL/eglext.h>
22
23#include <GLES2/gl2.h>
24#include <GLES2/gl2ext.h>
25
26#include <ui/GraphicBuffer.h>
27
Romain Guy877cfe02013-05-02 17:36:28 -070028namespace android {
29namespace uirenderer {
30
31/**
32 * A simple wrapper that creates an EGLImage and a texture for a GraphicBuffer.
33 */
34class Image {
35public:
36 /**
37 * Creates a new image from the specified graphic buffer. If the image
38 * cannot be created, getTexture() will return 0 and getImage() will
39 * return EGL_NO_IMAGE_KHR.
40 */
Romain Guy1212c9d2013-05-02 17:50:23 -070041 Image(sp<GraphicBuffer> buffer);
42 ~Image();
Romain Guy877cfe02013-05-02 17:36:28 -070043
44 /**
45 * Returns the name of the GL texture that can be used to sample
46 * from this image.
47 */
48 GLuint getTexture() const {
49 return mTexture;
50 }
51
52 /**
53 * Returns the name of the EGL image represented by this object.
54 */
55 EGLImageKHR getImage() const {
56 return mImage;
57 }
58
59private:
60 GLuint mTexture;
61 EGLImageKHR mImage;
62}; // class Image
63
64}; // namespace uirenderer
65}; // namespace android
66
67#endif // ANDROID_HWUI_IMAGE_H