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

     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  */
    18 #ifndef NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_ICS_H
    19 #define NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_ICS_H
    21 #include <ui/egl/android_natives.h>
    23 #include "GonkNativeWindow.h"
    25 namespace android {
    27 class GonkNativeWindowClient : public EGLNativeBase<ANativeWindow, GonkNativeWindowClient, RefBase>
    28 {
    29 public:
    30     GonkNativeWindowClient(const sp<GonkNativeWindow>& window);
    31     ~GonkNativeWindowClient(); // this class cannot be overloaded
    33 private:
    34     void init();
    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);
    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);
    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);
    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);
    71     int getNumberOfArgsForOperation(int operation);
    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 };
    78 private:
    79     void freeAllBuffers();
    80     int getSlotFromBufferLocked(android_native_buffer_t* buffer) const;
    82     sp<GonkNativeWindow> mNativeWindow;
    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];
    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;
    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;
   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;
   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;
   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;
   113     // mDefaultWidth is default width of the window, regardless of the
   114     // native_window_set_buffers_dimensions call
   115     uint32_t mDefaultWidth;
   117     // mDefaultHeight is default width of the window, regardless of the
   118     // native_window_set_buffers_dimensions call
   119     uint32_t mDefaultHeight;
   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;
   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;
   130     bool mConnectedToCpu;
   131 };
   134 }; // namespace android
   136 #endif // NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_ICS_H

mercurial