The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 2006, The Android Open Source Project |
| 3 | ** |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 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 |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 7 | ** |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 8 | ** http://www.apache.org/licenses/LICENSE-2.0 |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 9 | ** |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 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 |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 14 | ** limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_OPENGLES_SURFACE_H |
| 18 | #define ANDROID_OPENGLES_SURFACE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <stddef.h> |
| 22 | #include <sys/types.h> |
| 23 | |
Steven Moreland | 2716e11 | 2018-02-23 14:57:20 -0800 | [diff] [blame] | 24 | #include <cutils/atomic.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | #include <utils/threads.h> |
| 26 | #include <utils/RefBase.h> |
| 27 | #include <utils/KeyedVector.h> |
| 28 | #include <utils/Errors.h> |
| 29 | |
| 30 | #include <private/pixelflinger/ggl_context.h> |
| 31 | |
| 32 | #include <GLES/gl.h> |
Mathias Agopian | 7189c00 | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 33 | #include <EGL/egl.h> |
Mathias Agopian | 8d2e83b | 2009-06-24 22:37:39 -0700 | [diff] [blame] | 34 | #include <EGL/eglext.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | |
| 36 | #include "Tokenizer.h" |
| 37 | #include "TokenManager.h" |
| 38 | |
| 39 | |
| 40 | namespace android { |
| 41 | |
| 42 | // ---------------------------------------------------------------------------- |
| 43 | |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 44 | class EGLTextureObject : public LightRefBase<EGLTextureObject> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | { |
| 46 | public: |
| 47 | EGLTextureObject(); |
| 48 | ~EGLTextureObject(); |
| 49 | |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 50 | status_t setSurface(GGLSurface const* s); |
Iliyan Malchev | 697526b | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 51 | status_t setImage(ANativeWindowBuffer* buffer); |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 52 | void setImageBits(void* vaddr) { surface.data = (GGLubyte*)vaddr; } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | status_t reallocate(GLint level, |
| 55 | int w, int h, int s, |
| 56 | int format, int compressedFormat, int bpr); |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 57 | inline size_t size() const { return mSize; } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | const GGLSurface& mip(int lod) const; |
| 59 | GGLSurface& editMip(int lod); |
| 60 | bool hasMipmaps() const { return mMipmaps!=0; } |
| 61 | bool isComplete() const { return mIsComplete; } |
| 62 | void copyParameters(const sp<EGLTextureObject>& old); |
| 63 | |
| 64 | private: |
| 65 | status_t allocateMipmaps(); |
| 66 | void freeMipmaps(); |
| 67 | void init(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | size_t mSize; |
| 69 | GGLSurface *mMipmaps; |
| 70 | int mNumExtraLod; |
| 71 | bool mIsComplete; |
| 72 | |
| 73 | public: |
| 74 | GGLSurface surface; |
| 75 | GLenum wraps; |
| 76 | GLenum wrapt; |
| 77 | GLenum min_filter; |
| 78 | GLenum mag_filter; |
| 79 | GLenum internalformat; |
| 80 | GLint crop_rect[4]; |
| 81 | GLint generate_mipmap; |
| 82 | GLint direct; |
Iliyan Malchev | 697526b | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 83 | ANativeWindowBuffer* buffer; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | // ---------------------------------------------------------------------------- |
| 87 | |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 88 | class EGLSurfaceManager : |
| 89 | public LightRefBase<EGLSurfaceManager>, |
| 90 | public TokenManager |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | { |
| 92 | public: |
| 93 | EGLSurfaceManager(); |
| 94 | ~EGLSurfaceManager(); |
| 95 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | sp<EGLTextureObject> createTexture(GLuint name); |
| 97 | sp<EGLTextureObject> removeTexture(GLuint name); |
| 98 | sp<EGLTextureObject> replaceTexture(GLuint name); |
| 99 | void deleteTextures(GLsizei n, const GLuint *tokens); |
| 100 | sp<EGLTextureObject> texture(GLuint name); |
| 101 | |
| 102 | private: |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | mutable Mutex mLock; |
| 104 | KeyedVector< GLuint, sp<EGLTextureObject> > mTextures; |
| 105 | }; |
| 106 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | // ---------------------------------------------------------------------------- |
| 108 | }; // namespace android |
| 109 | |
| 110 | #endif // ANDROID_OPENGLES_SURFACE_H |
| 111 | |