1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/gonk/nativewindow/GonkNativeWindowClientICS.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,136 @@ 1.4 +/* 1.5 + * Copyright (C) 2010 The Android Open Source Project 1.6 + * Copyright (C) 2012 Mozilla Foundation 1.7 + * 1.8 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.9 + * you may not use this file except in compliance with the License. 1.10 + * You may obtain a copy of the License at 1.11 + * 1.12 + * http://www.apache.org/licenses/LICENSE-2.0 1.13 + * 1.14 + * Unless required by applicable law or agreed to in writing, software 1.15 + * distributed under the License is distributed on an "AS IS" BASIS, 1.16 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.17 + * See the License for the specific language governing permissions and 1.18 + * limitations under the License. 1.19 + */ 1.20 + 1.21 +#ifndef NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_ICS_H 1.22 +#define NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_ICS_H 1.23 + 1.24 +#include <ui/egl/android_natives.h> 1.25 + 1.26 +#include "GonkNativeWindow.h" 1.27 + 1.28 +namespace android { 1.29 + 1.30 +class GonkNativeWindowClient : public EGLNativeBase<ANativeWindow, GonkNativeWindowClient, RefBase> 1.31 +{ 1.32 +public: 1.33 + GonkNativeWindowClient(const sp<GonkNativeWindow>& window); 1.34 + ~GonkNativeWindowClient(); // this class cannot be overloaded 1.35 + 1.36 +private: 1.37 + void init(); 1.38 + 1.39 + // ANativeWindow hooks 1.40 + static int hook_cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer); 1.41 + static int hook_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer); 1.42 + static int hook_lockBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer); 1.43 + static int hook_perform(ANativeWindow* window, int operation, ...); 1.44 + static int hook_query(const ANativeWindow* window, int what, int* value); 1.45 + static int hook_queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer); 1.46 + static int hook_setSwapInterval(ANativeWindow* window, int interval); 1.47 + 1.48 + int dispatchConnect(va_list args); 1.49 + int dispatchDisconnect(va_list args); 1.50 + int dispatchSetBufferCount(va_list args); 1.51 + int dispatchSetBuffersGeometry(va_list args); 1.52 + int dispatchSetBuffersDimensions(va_list args); 1.53 + int dispatchSetBuffersFormat(va_list args); 1.54 + int dispatchSetBuffersTimestamp(va_list args); 1.55 + int dispatchSetUsage(va_list args); 1.56 + 1.57 +protected: 1.58 + virtual int cancelBuffer(ANativeWindowBuffer* buffer); 1.59 + virtual int dequeueBuffer(ANativeWindowBuffer** buffer); 1.60 + virtual int lockBuffer(ANativeWindowBuffer* buffer); 1.61 + virtual int perform(int operation, va_list args); 1.62 + virtual int query(int what, int* value) const; 1.63 + virtual int queueBuffer(ANativeWindowBuffer* buffer); 1.64 + virtual int setSwapInterval(int interval); 1.65 + 1.66 + virtual int connect(int api); 1.67 + virtual int disconnect(int api); 1.68 + virtual int setBufferCount(int bufferCount); 1.69 + virtual int setBuffersDimensions(int w, int h); 1.70 + virtual int setBuffersFormat(int format); 1.71 + virtual int setBuffersTimestamp(int64_t timestamp); 1.72 + virtual int setUsage(uint32_t reqUsage); 1.73 + 1.74 + int getNumberOfArgsForOperation(int operation); 1.75 + 1.76 + enum { MIN_UNDEQUEUED_BUFFERS = GonkNativeWindow::MIN_UNDEQUEUED_BUFFERS }; 1.77 + enum { NUM_BUFFER_SLOTS = GonkNativeWindow::NUM_BUFFER_SLOTS }; 1.78 + enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 }; 1.79 + enum { NATIVE_WINDOW_SET_BUFFERS_SIZE = 0x10000000 }; 1.80 + 1.81 +private: 1.82 + void freeAllBuffers(); 1.83 + int getSlotFromBufferLocked(android_native_buffer_t* buffer) const; 1.84 + 1.85 + sp<GonkNativeWindow> mNativeWindow; 1.86 + 1.87 + // mSlots stores the buffers that have been allocated for each buffer slot. 1.88 + // It is initialized to null pointers, and gets filled in with the result of 1.89 + // ISurfaceTexture::requestBuffer when the client dequeues a buffer from a 1.90 + // slot that has not yet been used. The buffer allocated to a slot will also 1.91 + // be replaced if the requested buffer usage or geometry differs from that 1.92 + // of the buffer allocated to a slot. 1.93 + sp<GraphicBuffer> mSlots[NUM_BUFFER_SLOTS]; 1.94 + 1.95 + // mReqWidth is the buffer width that will be requested at the next dequeue 1.96 + // operation. It is initialized to 1. 1.97 + uint32_t mReqWidth; 1.98 + 1.99 + // mReqHeight is the buffer height that will be requested at the next deuque 1.100 + // operation. It is initialized to 1. 1.101 + uint32_t mReqHeight; 1.102 + 1.103 + // mReqFormat is the buffer pixel format that will be requested at the next 1.104 + // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888. 1.105 + uint32_t mReqFormat; 1.106 + 1.107 + // mReqUsage is the set of buffer usage flags that will be requested 1.108 + // at the next deuque operation. It is initialized to 0. 1.109 + uint32_t mReqUsage; 1.110 + 1.111 + // mTimestamp is the timestamp that will be used for the next buffer queue 1.112 + // operation. It defaults to NATIVE_WINDOW_TIMESTAMP_AUTO, which means that 1.113 + // a timestamp is auto-generated when queueBuffer is called. 1.114 + int64_t mTimestamp; 1.115 + 1.116 + // mDefaultWidth is default width of the window, regardless of the 1.117 + // native_window_set_buffers_dimensions call 1.118 + uint32_t mDefaultWidth; 1.119 + 1.120 + // mDefaultHeight is default width of the window, regardless of the 1.121 + // native_window_set_buffers_dimensions call 1.122 + uint32_t mDefaultHeight; 1.123 + 1.124 + // mTransformHint is the transform probably applied to buffers of this 1.125 + // window. this is only a hint, actual transform may differ. 1.126 + uint32_t mTransformHint; 1.127 + 1.128 + // mMutex is the mutex used to prevent concurrent access to the member 1.129 + // variables of GonkNativeWindow objects. It must be locked whenever the 1.130 + // member variables are accessed. 1.131 + mutable Mutex mMutex; 1.132 + 1.133 + bool mConnectedToCpu; 1.134 +}; 1.135 + 1.136 + 1.137 +}; // namespace android 1.138 + 1.139 +#endif // NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_ICS_H