diff options
| author | 2010-12-20 11:27:26 -0800 | |
|---|---|---|
| committer | 2011-01-06 13:20:47 -0800 | |
| commit | 8ba32fade11abb73f3fd47ea0953c9528eb5b91f (patch) | |
| tree | 4934397842dec6ad482d1e6bc93782840b5433eb /include/gui/SurfaceTextureClient.h | |
| parent | 495633406580685dfaa41979bbae47fc5f77fefe (diff) | |
Add the SurfaceTexture C++ implementation.
This change adds the C++ implementation of SurfaceTexture and related
classes. The goal of this is for a SurfaceTexture to be passed to
camera service or Stagefright in place of a Surface to allow camera
preview or decoded video frames to be streamed to an OpenGL ES texture
that an application can use.
Change-Id: I55c83a7017f1ecb81c9c9e3252cbd118b914296c
Diffstat (limited to 'include/gui/SurfaceTextureClient.h')
| -rw-r--r-- | include/gui/SurfaceTextureClient.h | 118 | 
1 files changed, 118 insertions, 0 deletions
diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h new file mode 100644 index 0000000000..dd1d490aeb --- /dev/null +++ b/include/gui/SurfaceTextureClient.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + *      http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_GUI_SURFACETEXTURECLIENT_H +#define ANDROID_GUI_SURFACETEXTURECLIENT_H + +#include <gui/ISurfaceTexture.h> +#include <gui/SurfaceTexture.h> + +#include <ui/egl/android_natives.h> + +#include <utils/RefBase.h> +#include <utils/threads.h> + +namespace android { + +class SurfaceTextureClient +    : public EGLNativeBase<ANativeWindow, SurfaceTextureClient, RefBase> +{ +public: +    SurfaceTextureClient(const sp<ISurfaceTexture>& surfaceTexture); + +private: + +    // can't be copied +    SurfaceTextureClient& operator = (const SurfaceTextureClient& rhs); +    SurfaceTextureClient(const SurfaceTextureClient& rhs); + +    // ANativeWindow hooks +    static int setSwapInterval(ANativeWindow* window, int interval); +    static int dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer); +    static int cancelBuffer(ANativeWindow* window, android_native_buffer_t* buffer); +    static int lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer); +    static int queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer); +    static int query(ANativeWindow* window, int what, int* value); +    static int perform(ANativeWindow* window, int operation, ...); + +    int setSwapInterval(int interval); +    int dequeueBuffer(android_native_buffer_t** buffer); +    int lockBuffer(android_native_buffer_t* buffer); +    int queueBuffer(android_native_buffer_t* buffer); +    int cancelBuffer(android_native_buffer_t* buffer); +    int query(int what, int* value); +    int perform(int operation, va_list args); + +    int dispatchSetUsage(va_list args); +    int dispatchConnect(va_list args); +    int dispatchDisconnect(va_list args); +    int dispatchSetCrop(va_list args); +    int dispatchSetBufferCount(va_list args); +    int dispatchSetBuffersGeometry(va_list args); +    int dispatchSetBuffersTransform(va_list args); + +    int connect(int api); +    int disconnect(int api); +    int setUsage(uint32_t reqUsage); +    int setCrop(Rect const* rect); +    int setBufferCount(int bufferCount); +    int setBuffersGeometry(int w, int h, int format); +    int setBuffersTransform(int transform); + +    void freeAllBuffers(); + +    enum { MIN_BUFFER_SLOTS = SurfaceTexture::MIN_BUFFER_SLOTS }; +    enum { NUM_BUFFER_SLOTS = SurfaceTexture::NUM_BUFFER_SLOTS }; +    enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 }; + +    // mSurfaceTexture is the interface to the surface texture server. All +    // operations on the surface texture client ultimately translate into +    // interactions with the server using this interface. +    sp<ISurfaceTexture> mSurfaceTexture; + +    // mSlots stores the buffers that have been allocated for each buffer slot. +    // It is initialized to null pointers, and gets filled in with the result of +    // ISurfaceTexture::requestBuffer when the client dequeues a buffer from a +    // slot that has not yet been used. The buffer allocated to a slot will also +    // be replaced if the requested buffer usage or geometry differs from that +    // of the buffer allocated to a slot. +    sp<GraphicBuffer> mSlots[NUM_BUFFER_SLOTS]; + +    // mReqWidth is the buffer width that will be requested at the next dequeue +    // operation. It is initialized to 1. +    uint32_t mReqWidth; + +    // mReqHeight is the buffer height that will be requested at the next deuque +    // operation. It is initialized to 1. +    uint32_t mReqHeight; + +    // mReqFormat is the buffer pixel format that will be requested at the next +    // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888. +    uint32_t mReqFormat; + +    // mReqUsage is the set of buffer usage flags that will be requested +    // at the next deuque operation. It is initialized to 0. +    uint32_t mReqUsage; + +    // mMutex is the mutex used to prevent concurrent access to the member +    // variables of SurfaceTexture objects. It must be locked whenever the +    // member variables are accessed. +    Mutex mMutex; +}; + +}; // namespace android + +#endif  // ANDROID_GUI_SURFACETEXTURECLIENT_H  |