OSDN Git Service

DO NOT MERGE. KEY_INTENT shouldn't grant permissions. am: 1f2a5d3622 -s ours am...
[android-x86/frameworks-base.git] / libs / hwui / Image.h
1 /*
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
20 #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
28 namespace android {
29 namespace uirenderer {
30
31 /**
32  * A simple wrapper that creates an EGLImage and a texture for a GraphicBuffer.
33  */
34 class Image {
35 public:
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      */
41     Image(sp<GraphicBuffer> buffer);
42     ~Image();
43
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
59 private:
60     GLuint mTexture;
61     EGLImageKHR mImage;
62 }; // class Image
63
64 }; // namespace uirenderer
65 }; // namespace android
66
67 #endif // ANDROID_HWUI_IMAGE_H