2009-03-04 03:31:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 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.
|
|
|
|
*/
|
|
|
|
|
2014-11-11 18:32:31 +00:00
|
|
|
#ifndef INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP
|
|
|
|
#warning "FramebufferNativeWindow is deprecated"
|
|
|
|
#endif
|
|
|
|
|
2009-05-04 21:17:04 +00:00
|
|
|
#ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
|
|
|
|
#define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
2009-04-10 21:24:30 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
#include <EGL/egl.h>
|
2009-04-10 21:24:30 +00:00
|
|
|
|
|
|
|
#include <utils/threads.h>
|
2010-12-02 00:38:01 +00:00
|
|
|
#include <utils/String8.h>
|
2009-04-10 21:24:30 +00:00
|
|
|
|
2012-02-25 02:25:41 +00:00
|
|
|
#include <ui/ANativeObjectBase.h>
|
|
|
|
#include <ui/Rect.h>
|
2009-05-06 01:11:11 +00:00
|
|
|
|
2012-06-29 19:02:32 +00:00
|
|
|
#define MIN_NUM_FRAME_BUFFERS 2
|
|
|
|
#define MAX_NUM_FRAME_BUFFERS 3
|
2009-04-10 21:24:30 +00:00
|
|
|
|
|
|
|
extern "C" EGLNativeWindowType android_createDisplaySurface(void);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
namespace android {
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class Surface;
|
2009-05-06 01:11:11 +00:00
|
|
|
class NativeBuffer;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FramebufferNativeWindow
|
2012-02-25 02:25:41 +00:00
|
|
|
: public ANativeObjectBase<
|
2010-06-30 20:56:17 +00:00
|
|
|
ANativeWindow,
|
2009-04-10 21:24:30 +00:00
|
|
|
FramebufferNativeWindow,
|
|
|
|
LightRefBase<FramebufferNativeWindow> >
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FramebufferNativeWindow();
|
|
|
|
|
|
|
|
framebuffer_device_t const * getDevice() const { return fbDev; }
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2009-05-08 00:40:23 +00:00
|
|
|
bool isUpdateOnDemand() const { return mUpdateOnDemand; }
|
|
|
|
status_t setUpdateRectangle(const Rect& updateRect);
|
2009-09-17 23:18:16 +00:00
|
|
|
status_t compositionComplete();
|
2010-12-02 00:38:01 +00:00
|
|
|
|
|
|
|
void dump(String8& result);
|
|
|
|
|
2010-09-14 05:57:58 +00:00
|
|
|
// for debugging only
|
|
|
|
int getCurrentBufferIndex() const;
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
private:
|
2009-04-10 21:24:30 +00:00
|
|
|
friend class LightRefBase<FramebufferNativeWindow>;
|
|
|
|
~FramebufferNativeWindow(); // this class cannot be overloaded
|
2010-06-30 20:56:17 +00:00
|
|
|
static int setSwapInterval(ANativeWindow* window, int interval);
|
2012-06-13 23:32:25 +00:00
|
|
|
static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd);
|
|
|
|
static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd);
|
2011-04-14 23:54:38 +00:00
|
|
|
static int query(const ANativeWindow* window, int what, int* value);
|
2010-06-30 20:56:17 +00:00
|
|
|
static int perform(ANativeWindow* window, int operation, ...);
|
2012-06-13 23:32:25 +00:00
|
|
|
|
|
|
|
static int dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer);
|
|
|
|
static int queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
|
|
|
|
static int lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
framebuffer_device_t* fbDev;
|
|
|
|
alloc_device_t* grDev;
|
|
|
|
|
2012-06-29 19:02:32 +00:00
|
|
|
sp<NativeBuffer> buffers[MAX_NUM_FRAME_BUFFERS];
|
2009-04-10 21:24:30 +00:00
|
|
|
sp<NativeBuffer> front;
|
|
|
|
|
|
|
|
mutable Mutex mutex;
|
|
|
|
Condition mCondition;
|
|
|
|
int32_t mNumBuffers;
|
|
|
|
int32_t mNumFreeBuffers;
|
|
|
|
int32_t mBufferHead;
|
2010-09-14 05:57:58 +00:00
|
|
|
int32_t mCurrentBufferIndex;
|
2009-05-08 00:40:23 +00:00
|
|
|
bool mUpdateOnDemand;
|
2009-06-24 04:11:43 +00:00
|
|
|
};
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
}; // namespace android
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2009-05-04 21:17:04 +00:00
|
|
|
#endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
|
2009-03-04 03:31:44 +00:00
|
|
|
|