2010-12-20 19:27:26 +00:00
|
|
|
/*
|
|
|
|
* 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 {
|
|
|
|
|
2011-04-12 04:19:55 +00:00
|
|
|
class Surface;
|
|
|
|
|
2010-12-20 19:27:26 +00:00
|
|
|
class SurfaceTextureClient
|
|
|
|
: public EGLNativeBase<ANativeWindow, SurfaceTextureClient, RefBase>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SurfaceTextureClient(const sp<ISurfaceTexture>& surfaceTexture);
|
|
|
|
|
2011-03-14 22:08:53 +00:00
|
|
|
sp<ISurfaceTexture> getISurfaceTexture() const;
|
|
|
|
|
2010-12-20 19:27:26 +00:00
|
|
|
private:
|
2011-04-12 04:19:55 +00:00
|
|
|
friend class Surface;
|
2010-12-20 19:27:26 +00:00
|
|
|
|
|
|
|
// can't be copied
|
|
|
|
SurfaceTextureClient& operator = (const SurfaceTextureClient& rhs);
|
|
|
|
SurfaceTextureClient(const SurfaceTextureClient& rhs);
|
|
|
|
|
|
|
|
// ANativeWindow hooks
|
|
|
|
static int cancelBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
|
2011-02-27 22:10:20 +00:00
|
|
|
static int dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer);
|
2010-12-20 19:27:26 +00:00
|
|
|
static int lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
|
|
|
|
static int perform(ANativeWindow* window, int operation, ...);
|
2011-02-27 22:10:20 +00:00
|
|
|
static int query(ANativeWindow* window, int what, int* value);
|
|
|
|
static int queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
|
|
|
|
static int setSwapInterval(ANativeWindow* window, int interval);
|
2010-12-20 19:27:26 +00:00
|
|
|
|
2011-02-27 22:10:20 +00:00
|
|
|
int cancelBuffer(android_native_buffer_t* buffer);
|
2010-12-20 19:27:26 +00:00
|
|
|
int dequeueBuffer(android_native_buffer_t** buffer);
|
|
|
|
int lockBuffer(android_native_buffer_t* buffer);
|
|
|
|
int perform(int operation, va_list args);
|
2011-02-27 22:10:20 +00:00
|
|
|
int query(int what, int* value);
|
|
|
|
int queueBuffer(android_native_buffer_t* buffer);
|
|
|
|
int setSwapInterval(int interval);
|
2010-12-20 19:27:26 +00:00
|
|
|
|
|
|
|
int dispatchConnect(va_list args);
|
|
|
|
int dispatchDisconnect(va_list args);
|
|
|
|
int dispatchSetBufferCount(va_list args);
|
|
|
|
int dispatchSetBuffersGeometry(va_list args);
|
|
|
|
int dispatchSetBuffersTransform(va_list args);
|
2011-02-18 19:02:42 +00:00
|
|
|
int dispatchSetBuffersTimestamp(va_list args);
|
2011-02-27 22:10:20 +00:00
|
|
|
int dispatchSetCrop(va_list args);
|
|
|
|
int dispatchSetUsage(va_list args);
|
2010-12-20 19:27:26 +00:00
|
|
|
|
|
|
|
int connect(int api);
|
|
|
|
int disconnect(int api);
|
|
|
|
int setBufferCount(int bufferCount);
|
|
|
|
int setBuffersGeometry(int w, int h, int format);
|
|
|
|
int setBuffersTransform(int transform);
|
2011-02-18 19:02:42 +00:00
|
|
|
int setBuffersTimestamp(int64_t timestamp);
|
2011-02-27 22:10:20 +00:00
|
|
|
int setCrop(Rect const* rect);
|
|
|
|
int setUsage(uint32_t reqUsage);
|
2010-12-20 19:27:26 +00:00
|
|
|
|
|
|
|
void freeAllBuffers();
|
|
|
|
|
2011-04-12 04:19:55 +00:00
|
|
|
int getConnectedApi() const;
|
|
|
|
|
2011-02-27 22:10:20 +00:00
|
|
|
enum { MIN_UNDEQUEUED_BUFFERS = SurfaceTexture::MIN_UNDEQUEUED_BUFFERS };
|
2010-12-20 19:27:26 +00:00
|
|
|
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;
|
|
|
|
|
2011-02-02 23:31:47 +00:00
|
|
|
// mAllocator is the binder object that is referenced to prevent the
|
|
|
|
// dequeued buffers from being freed prematurely.
|
|
|
|
sp<IBinder> mAllocator;
|
|
|
|
|
2010-12-20 19:27:26 +00:00
|
|
|
// 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;
|
|
|
|
|
2011-02-18 19:02:42 +00:00
|
|
|
// mTimestamp is the timestamp that will be used for the next buffer queue
|
|
|
|
// operation. It defaults to NATIVE_WINDOW_TIMESTAMP_AUTO, which means that
|
|
|
|
// a timestamp is auto-generated when queueBuffer is called.
|
|
|
|
int64_t mTimestamp;
|
|
|
|
|
2011-04-12 04:19:55 +00:00
|
|
|
// mConnectedApi holds the currently connected API to this surface
|
|
|
|
int mConnectedApi;
|
|
|
|
|
|
|
|
// mQueryWidth is the width returned by query(). It is set to width
|
|
|
|
// of the last dequeued buffer or to mReqWidth if no buffer was dequeued.
|
|
|
|
uint32_t mQueryWidth;
|
|
|
|
|
|
|
|
// mQueryHeight is the height returned by query(). It is set to height
|
|
|
|
// of the last dequeued buffer or to mReqHeight if no buffer was dequeued.
|
|
|
|
uint32_t mQueryHeight;
|
|
|
|
|
|
|
|
// mQueryFormat is the format returned by query(). It is set to the last
|
|
|
|
// dequeued format or to mReqFormat if no buffer was dequeued.
|
|
|
|
uint32_t mQueryFormat;
|
|
|
|
|
2010-12-20 19:27:26 +00:00
|
|
|
// 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.
|
2011-04-12 04:19:55 +00:00
|
|
|
mutable Mutex mMutex;
|
2010-12-20 19:27:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace android
|
|
|
|
|
|
|
|
#endif // ANDROID_GUI_SURFACETEXTURECLIENT_H
|