• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 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_FRAMEBUFFER_NATIVE_WINDOW_H
18 #define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
19 
20 #warning "FramebufferNativeWindow is deprecated"
21 
22 #include <stdint.h>
23 #include <sys/types.h>
24 
25 #include <EGL/egl.h>
26 
27 #include <utils/threads.h>
28 #include <utils/String8.h>
29 
30 #include <ui/ANativeObjectBase.h>
31 #include <ui/Rect.h>
32 
33 #define MIN_NUM_FRAME_BUFFERS  2
34 #define MAX_NUM_FRAME_BUFFERS  3
35 
36 extern "C" EGLNativeWindowType android_createDisplaySurface(void);
37 
38 // ---------------------------------------------------------------------------
39 namespace android {
40 // ---------------------------------------------------------------------------
41 
42 class Surface;
43 class NativeBuffer;
44 
45 // ---------------------------------------------------------------------------
46 
47 class FramebufferNativeWindow
48     : public ANativeObjectBase<
49         ANativeWindow,
50         FramebufferNativeWindow,
51         LightRefBase<FramebufferNativeWindow> >
52 {
53 public:
54     FramebufferNativeWindow();
55 
getDevice()56     framebuffer_device_t const * getDevice() const { return fbDev; }
57 
isUpdateOnDemand()58     bool isUpdateOnDemand() const { return mUpdateOnDemand; }
59     status_t setUpdateRectangle(const Rect& updateRect);
60     status_t compositionComplete();
61 
62     void dump(String8& result);
63 
64     // for debugging only
65     int getCurrentBufferIndex() const;
66 
67 private:
68     friend class LightRefBase<FramebufferNativeWindow>;
69     ~FramebufferNativeWindow(); // this class cannot be overloaded
70     static int setSwapInterval(ANativeWindow* window, int interval);
71     static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd);
72     static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd);
73     static int query(const ANativeWindow* window, int what, int* value);
74     static int perform(ANativeWindow* window, int operation, ...);
75 
76     static int dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer);
77     static int queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
78     static int lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
79 
80     framebuffer_device_t* fbDev;
81     alloc_device_t* grDev;
82 
83     sp<NativeBuffer> buffers[MAX_NUM_FRAME_BUFFERS];
84     sp<NativeBuffer> front;
85 
86     mutable Mutex mutex;
87     Condition mCondition;
88     int32_t mNumBuffers;
89     int32_t mNumFreeBuffers;
90     int32_t mBufferHead;
91     int32_t mCurrentBufferIndex;
92     bool mUpdateOnDemand;
93 };
94 
95 // ---------------------------------------------------------------------------
96 }; // namespace android
97 // ---------------------------------------------------------------------------
98 
99 #endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
100 
101