widget/gonk/nativewindow/GonkNativeWindowClientICS.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial