widget/gonk/nativewindow/GonkNativeWindowClientICS.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:467fe71148e5
1 /*
2 * Copyright (C) 2010 The Android Open Source Project
3 * Copyright (C) 2012 Mozilla Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 #ifndef NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_ICS_H
19 #define NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_ICS_H
20
21 #include <ui/egl/android_natives.h>
22
23 #include "GonkNativeWindow.h"
24
25 namespace android {
26
27 class GonkNativeWindowClient : public EGLNativeBase<ANativeWindow, GonkNativeWindowClient, RefBase>
28 {
29 public:
30 GonkNativeWindowClient(const sp<GonkNativeWindow>& window);
31 ~GonkNativeWindowClient(); // this class cannot be overloaded
32
33 private:
34 void init();
35
36 // ANativeWindow hooks
37 static int hook_cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
38 static int hook_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer);
39 static int hook_lockBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
40 static int hook_perform(ANativeWindow* window, int operation, ...);
41 static int hook_query(const ANativeWindow* window, int what, int* value);
42 static int hook_queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer);
43 static int hook_setSwapInterval(ANativeWindow* window, int interval);
44
45 int dispatchConnect(va_list args);
46 int dispatchDisconnect(va_list args);
47 int dispatchSetBufferCount(va_list args);
48 int dispatchSetBuffersGeometry(va_list args);
49 int dispatchSetBuffersDimensions(va_list args);
50 int dispatchSetBuffersFormat(va_list args);
51 int dispatchSetBuffersTimestamp(va_list args);
52 int dispatchSetUsage(va_list args);
53
54 protected:
55 virtual int cancelBuffer(ANativeWindowBuffer* buffer);
56 virtual int dequeueBuffer(ANativeWindowBuffer** buffer);
57 virtual int lockBuffer(ANativeWindowBuffer* buffer);
58 virtual int perform(int operation, va_list args);
59 virtual int query(int what, int* value) const;
60 virtual int queueBuffer(ANativeWindowBuffer* buffer);
61 virtual int setSwapInterval(int interval);
62
63 virtual int connect(int api);
64 virtual int disconnect(int api);
65 virtual int setBufferCount(int bufferCount);
66 virtual int setBuffersDimensions(int w, int h);
67 virtual int setBuffersFormat(int format);
68 virtual int setBuffersTimestamp(int64_t timestamp);
69 virtual int setUsage(uint32_t reqUsage);
70
71 int getNumberOfArgsForOperation(int operation);
72
73 enum { MIN_UNDEQUEUED_BUFFERS = GonkNativeWindow::MIN_UNDEQUEUED_BUFFERS };
74 enum { NUM_BUFFER_SLOTS = GonkNativeWindow::NUM_BUFFER_SLOTS };
75 enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
76 enum { NATIVE_WINDOW_SET_BUFFERS_SIZE = 0x10000000 };
77
78 private:
79 void freeAllBuffers();
80 int getSlotFromBufferLocked(android_native_buffer_t* buffer) const;
81
82 sp<GonkNativeWindow> mNativeWindow;
83
84 // mSlots stores the buffers that have been allocated for each buffer slot.
85 // It is initialized to null pointers, and gets filled in with the result of
86 // ISurfaceTexture::requestBuffer when the client dequeues a buffer from a
87 // slot that has not yet been used. The buffer allocated to a slot will also
88 // be replaced if the requested buffer usage or geometry differs from that
89 // of the buffer allocated to a slot.
90 sp<GraphicBuffer> mSlots[NUM_BUFFER_SLOTS];
91
92 // mReqWidth is the buffer width that will be requested at the next dequeue
93 // operation. It is initialized to 1.
94 uint32_t mReqWidth;
95
96 // mReqHeight is the buffer height that will be requested at the next deuque
97 // operation. It is initialized to 1.
98 uint32_t mReqHeight;
99
100 // mReqFormat is the buffer pixel format that will be requested at the next
101 // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888.
102 uint32_t mReqFormat;
103
104 // mReqUsage is the set of buffer usage flags that will be requested
105 // at the next deuque operation. It is initialized to 0.
106 uint32_t mReqUsage;
107
108 // mTimestamp is the timestamp that will be used for the next buffer queue
109 // operation. It defaults to NATIVE_WINDOW_TIMESTAMP_AUTO, which means that
110 // a timestamp is auto-generated when queueBuffer is called.
111 int64_t mTimestamp;
112
113 // mDefaultWidth is default width of the window, regardless of the
114 // native_window_set_buffers_dimensions call
115 uint32_t mDefaultWidth;
116
117 // mDefaultHeight is default width of the window, regardless of the
118 // native_window_set_buffers_dimensions call
119 uint32_t mDefaultHeight;
120
121 // mTransformHint is the transform probably applied to buffers of this
122 // window. this is only a hint, actual transform may differ.
123 uint32_t mTransformHint;
124
125 // mMutex is the mutex used to prevent concurrent access to the member
126 // variables of GonkNativeWindow objects. It must be locked whenever the
127 // member variables are accessed.
128 mutable Mutex mMutex;
129
130 bool mConnectedToCpu;
131 };
132
133
134 }; // namespace android
135
136 #endif // NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_ICS_H

mercurial