1edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project/*
2e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * Copyright (C) 2010 The Android Open Source Project
3edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
4edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
5edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * you may not use this file except in compliance with the License.
6edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * You may obtain a copy of the License at
7edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
8edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
9edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
10edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
11edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
12edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * See the License for the specific language governing permissions and
14edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * limitations under the License.
15edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project */
16edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
1790ac799241f077a7b7e6c1875fd933864c8dd2a7Mathias Agopian#ifndef ANDROID_GUI_SURFACE_H
1890ac799241f077a7b7e6c1875fd933864c8dd2a7Mathias Agopian#define ANDROID_GUI_SURFACE_H
19edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
20e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian#include <gui/IGraphicBufferProducer.h>
21e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian#include <gui/BufferQueue.h>
22e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
23e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian#include <ui/ANativeObjectBase.h>
24e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian#include <ui/Region.h>
25edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
2688612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala#include <binder/Parcelable.h>
2788612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
28edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <utils/RefBase.h>
29edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <utils/threads.h>
30e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian#include <utils/KeyedVector.h>
31edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
32e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopianstruct ANativeWindow_Buffer;
339cce325fae8adcf7560a28eef394489f09bad74dMathias Agopian
34edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectnamespace android {
35edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
360273adbf0bc202eda2ca579ae0773464ea9c701fAndy McFadden/*
37e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * An implementation of ANativeWindow that feeds graphics buffers into a
38e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * BufferQueue.
390273adbf0bc202eda2ca579ae0773464ea9c701fAndy McFadden *
40e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * This is typically used by programs that want to render frames through
41e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * some means (maybe OpenGL, a software renderer, or a hardware decoder)
42e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * and have the frames they create forwarded to SurfaceFlinger for
43e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * compositing.  For example, a video decoder could render a frame and call
44e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * eglSwapBuffers(), which invokes ANativeWindow callbacks defined by
45e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * Surface.  Surface then forwards the buffers through Binder IPC
46e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * to the BufferQueue's producer interface, providing the new frame to a
47e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian * consumer such as GLConsumer.
480273adbf0bc202eda2ca579ae0773464ea9c701fAndy McFadden */
49e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopianclass Surface
50e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    : public ANativeObjectBase<ANativeWindow, Surface, RefBase>
51076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian{
52edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectpublic:
53edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
54cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian    /*
55cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * creates a Surface from the given IGraphicBufferProducer (which concrete
56cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * implementation is a BufferQueue).
57cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     *
58cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * Surface is mainly state-less while it's disconnected, it can be
59cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * viewed as a glorified IGraphicBufferProducer holder. It's therefore
60cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * safe to create other Surfaces from the same IGraphicBufferProducer.
61cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     *
62cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * However, once a Surface is connected, it'll prevent other Surfaces
63cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * referring to the same IGraphicBufferProducer to become connected and
64cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * therefore prevent them to be used as actual producers of buffers.
65595264f1af12e25dce57d7c5b1d52ed86ac0d0c9Mathias Agopian     *
66595264f1af12e25dce57d7c5b1d52ed86ac0d0c9Mathias Agopian     * the controlledByApp flag indicates that this Surface (producer) is
67595264f1af12e25dce57d7c5b1d52ed86ac0d0c9Mathias Agopian     * controlled by the application. This flag is used at connect time.
68cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     */
69595264f1af12e25dce57d7c5b1d52ed86ac0d0c9Mathias Agopian    Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp = false);
70bd050ab2af1421d527d1a80ce59dd8d9940a838cTed Bonkenburg
71cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian    /* getIGraphicBufferProducer() returns the IGraphicBufferProducer this
72cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * Surface was created with. Usually it's an error to use the
73cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * IGraphicBufferProducer while the Surface is connected.
74cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     */
75e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    sp<IGraphicBufferProducer> getIGraphicBufferProducer() const;
76bd050ab2af1421d527d1a80ce59dd8d9940a838cTed Bonkenburg
77cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian    /* convenience function to check that the given surface is non NULL as
78cf0b8c85fb0106751256dba7821f86b5ad03126cMathias Agopian     * well as its IGraphicBufferProducer */
79c4905eb49d20667381f3cda7c6f6894234404bd3Mathias Agopian    static bool isValid(const sp<Surface>& surface) {
80f25c5086cf46eb029d887f34f25a09220e44958cMathias Agopian        return surface != NULL && surface->getIGraphicBufferProducer() != NULL;
81f25c5086cf46eb029d887f34f25a09220e44958cMathias Agopian    }
82f25c5086cf46eb029d887f34f25a09220e44958cMathias Agopian
83399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    /* Attaches a sideband buffer stream to the Surface's IGraphicBufferProducer.
84399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     *
85399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     * A sideband stream is a device-specific mechanism for passing buffers
86399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     * from the producer to the consumer without using dequeueBuffer/
87399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     * queueBuffer. If a sideband stream is present, the consumer can choose
88399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     * whether to acquire buffers from the sideband stream or from the queued
89399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     * buffers.
90399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     *
91399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     * Passing NULL or a different stream handle will detach the previous
92399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     * handle if any.
93399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall     */
94399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    void setSidebandStream(const sp<NativeHandle>& stream);
95399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall
9629a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza    /* Allocates buffers based on the current dimensions/format.
9729a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza     *
9829a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza     * This function will allocate up to the maximum number of buffers
9929a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza     * permitted by the current BufferQueue configuration. It will use the
10029a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza     * default format and dimensions. This is most useful to avoid an allocation
10129a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza     * delay during dequeueBuffer. If there are already the maximum number of
10229a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza     * buffers allocated, this function has no effect.
10329a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza     */
10429a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza    void allocateBuffers();
10529a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza
106812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza    /* Sets the generation number on the IGraphicBufferProducer and updates the
107812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza     * generation number on any buffers attached to the Surface after this call.
108812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza     * See IGBP::setGenerationNumber for more information. */
109812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza    status_t setGenerationNumber(uint32_t generationNumber);
110812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza
111c6f30bdee1f634eb90d68cb76efe935b6535a1e8Dan Stoza    // See IGraphicBufferProducer::getConsumerName
112c6f30bdee1f634eb90d68cb76efe935b6535a1e8Dan Stoza    String8 getConsumerName() const;
113c6f30bdee1f634eb90d68cb76efe935b6535a1e8Dan Stoza
1147dde599bf1a0dbef7390d91c2689d506371cdbd7Dan Stoza    // See IGraphicBufferProducer::getNextFrameNumber
1157dde599bf1a0dbef7390d91c2689d506371cdbd7Dan Stoza    uint64_t getNextFrameNumber() const;
1167dde599bf1a0dbef7390d91c2689d506371cdbd7Dan Stoza
117c2e7788721489c5a2ef681fd0bfa591d2ce41175Robert Carr    /* Set the scaling mode to be used with a Surface.
118c2e7788721489c5a2ef681fd0bfa591d2ce41175Robert Carr     * See NATIVE_WINDOW_SET_SCALING_MODE and its parameters
119c2e7788721489c5a2ef681fd0bfa591d2ce41175Robert Carr     * in <system/window.h>. */
120c2e7788721489c5a2ef681fd0bfa591d2ce41175Robert Carr    int setScalingMode(int mode);
121c2e7788721489c5a2ef681fd0bfa591d2ce41175Robert Carr
122127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza    // See IGraphicBufferProducer::setDequeueTimeout
123127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza    status_t setDequeueTimeout(nsecs_t timeout);
124127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza
1259f31e299b3ec93b7bac969846105e7e926e3efcdRobert Carr    /*
1269f31e299b3ec93b7bac969846105e7e926e3efcdRobert Carr     * Wait for frame number to increase past lastFrame for at most
1279f31e299b3ec93b7bac969846105e7e926e3efcdRobert Carr     * timeoutNs. Useful for one thread to wait for another unknown
1289f31e299b3ec93b7bac969846105e7e926e3efcdRobert Carr     * thread to queue a buffer.
1299f31e299b3ec93b7bac969846105e7e926e3efcdRobert Carr     */
1309f31e299b3ec93b7bac969846105e7e926e3efcdRobert Carr    bool waitForNextFrame(uint64_t lastFrame, nsecs_t timeout);
1319f31e299b3ec93b7bac969846105e7e926e3efcdRobert Carr
13250101d02a8eae555887282a5f761fdec57bdaf30Dan Stoza    // See IGraphicBufferProducer::getLastQueuedBuffer
1331a61da5e28fa16ad556a58193c8bbeb32a5f636dJohn Reck    // See GLConsumer::getTransformMatrix for outTransformMatrix format
13450101d02a8eae555887282a5f761fdec57bdaf30Dan Stoza    status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer,
1351a61da5e28fa16ad556a58193c8bbeb32a5f636dJohn Reck            sp<Fence>* outFence, float outTransformMatrix[16]);
13650101d02a8eae555887282a5f761fdec57bdaf30Dan Stoza
137ce796e78a57018f186b062199c75d94545318acaPablo Ceballos    // See IGraphicBufferProducer::getFrameTimestamps
138ce796e78a57018f186b062199c75d94545318acaPablo Ceballos    bool getFrameTimestamps(uint64_t frameNumber, nsecs_t* outPostedTime,
139ce796e78a57018f186b062199c75d94545318acaPablo Ceballos            nsecs_t* outAcquireTime, nsecs_t* outRefreshStartTime,
140ce796e78a57018f186b062199c75d94545318acaPablo Ceballos            nsecs_t* outGlCompositionDoneTime, nsecs_t* outDisplayRetireTime,
141ce796e78a57018f186b062199c75d94545318acaPablo Ceballos            nsecs_t* outReleaseTime);
142ce796e78a57018f186b062199c75d94545318acaPablo Ceballos
1438e3e92b906db431c4fa822f21242977d4ee99942Pablo Ceballos    status_t getUniqueId(uint64_t* outId) const;
1448e3e92b906db431c4fa822f21242977d4ee99942Pablo Ceballos
145e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopianprotected:
146e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual ~Surface();
147edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
148b296533607232357597b255679db29470ab5925dMathias Agopianprivate:
149b296533607232357597b255679db29470ab5925dMathias Agopian    // can't be copied
150e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    Surface& operator = (const Surface& rhs);
151b296533607232357597b255679db29470ab5925dMathias Agopian    Surface(const Surface& rhs);
152e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
153e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // ANativeWindow hooks
154e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_cancelBuffer(ANativeWindow* window,
155e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian            ANativeWindowBuffer* buffer, int fenceFd);
156e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_dequeueBuffer(ANativeWindow* window,
157e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian            ANativeWindowBuffer** buffer, int* fenceFd);
158e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_perform(ANativeWindow* window, int operation, ...);
159e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_query(const ANativeWindow* window, int what, int* value);
160e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_queueBuffer(ANativeWindow* window,
161e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian            ANativeWindowBuffer* buffer, int fenceFd);
162e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_setSwapInterval(ANativeWindow* window, int interval);
163e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
164e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_cancelBuffer_DEPRECATED(ANativeWindow* window,
165e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian            ANativeWindowBuffer* buffer);
166e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_dequeueBuffer_DEPRECATED(ANativeWindow* window,
167e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian            ANativeWindowBuffer** buffer);
168e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_lockBuffer_DEPRECATED(ANativeWindow* window,
169e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian            ANativeWindowBuffer* buffer);
170e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    static int hook_queueBuffer_DEPRECATED(ANativeWindow* window,
171e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian            ANativeWindowBuffer* buffer);
172e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
173e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchConnect(va_list args);
174e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchDisconnect(va_list args);
175e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetBufferCount(va_list args);
176e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetBuffersGeometry(va_list args);
177e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetBuffersDimensions(va_list args);
178e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetBuffersUserDimensions(va_list args);
179e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetBuffersFormat(va_list args);
180e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetScalingMode(va_list args);
181e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetBuffersTransform(va_list args);
1821681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk    int dispatchSetBuffersStickyTransform(va_list args);
183e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetBuffersTimestamp(va_list args);
184e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetCrop(va_list args);
185e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetPostTransformCrop(va_list args);
186e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchSetUsage(va_list args);
187e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchLock(va_list args);
188e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int dispatchUnlockAndPost(va_list args);
1897cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad    int dispatchSetSidebandStream(va_list args);
19082c6bcc9705eabcaf5b9e45bc81867b0e2d61a02Eino-Ville Talvala    int dispatchSetBuffersDataSpace(va_list args);
1915065a55291b67f584d7b0be3fa3cfc4e29a3cd1cDan Stoza    int dispatchSetSurfaceDamage(va_list args);
1923559fbf93801e2c0d9d8fb246fb9b867a361b464Pablo Ceballos    int dispatchSetSharedBufferMode(va_list args);
193ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    int dispatchSetAutoRefresh(va_list args);
194ce796e78a57018f186b062199c75d94545318acaPablo Ceballos    int dispatchGetFrameTimestamps(va_list args);
195e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
196e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopianprotected:
197e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
198e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int cancelBuffer(ANativeWindowBuffer* buffer, int fenceFd);
199e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int queueBuffer(ANativeWindowBuffer* buffer, int fenceFd);
200e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int perform(int operation, va_list args);
201e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int setSwapInterval(int interval);
202e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
203e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int lockBuffer_DEPRECATED(ANativeWindowBuffer* buffer);
204e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
205e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int connect(int api);
206e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int setBufferCount(int bufferCount);
2073be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    virtual int setBuffersDimensions(uint32_t width, uint32_t height);
2083be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    virtual int setBuffersUserDimensions(uint32_t width, uint32_t height);
2093be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    virtual int setBuffersFormat(PixelFormat format);
2103be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    virtual int setBuffersTransform(uint32_t transform);
2113be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    virtual int setBuffersStickyTransform(uint32_t transform);
212e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int setBuffersTimestamp(int64_t timestamp);
21382c6bcc9705eabcaf5b9e45bc81867b0e2d61a02Eino-Ville Talvala    virtual int setBuffersDataSpace(android_dataspace dataSpace);
214e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int setCrop(Rect const* rect);
215e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int setUsage(uint32_t reqUsage);
2165065a55291b67f584d7b0be3fa3cfc4e29a3cd1cDan Stoza    virtual void setSurfaceDamage(android_native_rect_t* rects, size_t numRects);
217076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian
218e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopianpublic:
21997b9c86338e2d364d47ea7522c2d81a8014f0e07Robert Carr    virtual int disconnect(int api,
22097b9c86338e2d364d47ea7522c2d81a8014f0e07Robert Carr            IGraphicBufferProducer::DisconnectMode mode =
22197b9c86338e2d364d47ea7522c2d81a8014f0e07Robert Carr                    IGraphicBufferProducer::DisconnectMode::Api);
22297b9c86338e2d364d47ea7522c2d81a8014f0e07Robert Carr
22319e3e06e3c65a7c001a6fe0971744ba5ff536515Pablo Ceballos    virtual int setMaxDequeuedBufferCount(int maxDequeuedBuffers);
22419e3e06e3c65a7c001a6fe0971744ba5ff536515Pablo Ceballos    virtual int setAsyncMode(bool async);
2253559fbf93801e2c0d9d8fb246fb9b867a361b464Pablo Ceballos    virtual int setSharedBufferMode(bool sharedBufferMode);
226ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    virtual int setAutoRefresh(bool autoRefresh);
227e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds);
228e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    virtual int unlockAndPost();
22970ccba596c586b7effde1ff99d36c911873b4ed4Dan Stoza    virtual int query(int what, int* value) const;
230b296533607232357597b255679db29470ab5925dMathias Agopian
231231832eb27107fb561467f5f4a9be2c577c61ea8Dan Stoza    virtual int connect(int api, const sp<IProducerListener>& listener);
232d9c4971da2f2c4f980a748006bd40469c3332a13Dan Stoza    virtual int detachNextBuffer(sp<GraphicBuffer>* outBuffer,
233231832eb27107fb561467f5f4a9be2c577c61ea8Dan Stoza            sp<Fence>* outFence);
234231832eb27107fb561467f5f4a9be2c577c61ea8Dan Stoza    virtual int attachBuffer(ANativeWindowBuffer*);
235231832eb27107fb561467f5f4a9be2c577c61ea8Dan Stoza
236e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopianprotected:
237e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    enum { NUM_BUFFER_SLOTS = BufferQueue::NUM_BUFFER_SLOTS };
238e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
239aca4e2287939b4ce3d9e9aced64c5c9641333503Jamie Gennis
240e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopianprivate:
241e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    void freeAllBuffers();
242e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int getSlotFromBufferLocked(android_native_buffer_t* buffer) const;
2438f9dbf9e13b927de2524116c30544f7dfbbbf56cMathias Agopian
244e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    struct BufferSlot {
245e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian        sp<GraphicBuffer> buffer;
246e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian        Region dirtyRegion;
247e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    };
248ba5972ffdc7179dd9a387f22032eb18666d97917Mathias Agopian
249e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mSurfaceTexture is the interface to the surface texture server. All
250e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // operations on the surface texture client ultimately translate into
251e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // interactions with the server using this interface.
252e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // TODO: rename to mBufferProducer
253e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    sp<IGraphicBufferProducer> mGraphicBufferProducer;
254e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
255e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mSlots stores the buffers that have been allocated for each buffer slot.
256e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // It is initialized to null pointers, and gets filled in with the result of
257e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // IGraphicBufferProducer::requestBuffer when the client dequeues a buffer from a
258e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // slot that has not yet been used. The buffer allocated to a slot will also
259e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // be replaced if the requested buffer usage or geometry differs from that
260e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // of the buffer allocated to a slot.
261e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    BufferSlot mSlots[NUM_BUFFER_SLOTS];
262e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
263e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mReqWidth is the buffer width that will be requested at the next dequeue
264e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // operation. It is initialized to 1.
265e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    uint32_t mReqWidth;
266e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
267e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mReqHeight is the buffer height that will be requested at the next
268e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // dequeue operation. It is initialized to 1.
269e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    uint32_t mReqHeight;
270e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
271e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mReqFormat is the buffer pixel format that will be requested at the next
272e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888.
2733be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    PixelFormat mReqFormat;
274e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
275e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mReqUsage is the set of buffer usage flags that will be requested
276e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // at the next deuque operation. It is initialized to 0.
277e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    uint32_t mReqUsage;
278e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
279e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mTimestamp is the timestamp that will be used for the next buffer queue
280e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // operation. It defaults to NATIVE_WINDOW_TIMESTAMP_AUTO, which means that
281e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // a timestamp is auto-generated when queueBuffer is called.
282e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int64_t mTimestamp;
283e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
28482c6bcc9705eabcaf5b9e45bc81867b0e2d61a02Eino-Ville Talvala    // mDataSpace is the buffer dataSpace that will be used for the next buffer
28582c6bcc9705eabcaf5b9e45bc81867b0e2d61a02Eino-Ville Talvala    // queue operation. It defaults to HAL_DATASPACE_UNKNOWN, which
28682c6bcc9705eabcaf5b9e45bc81867b0e2d61a02Eino-Ville Talvala    // means that the buffer contains some type of color data.
28782c6bcc9705eabcaf5b9e45bc81867b0e2d61a02Eino-Ville Talvala    android_dataspace mDataSpace;
28882c6bcc9705eabcaf5b9e45bc81867b0e2d61a02Eino-Ville Talvala
289e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mCrop is the crop rectangle that will be used for the next buffer
290e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // that gets queued. It is set by calling setCrop.
291e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    Rect mCrop;
292e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
293e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mScalingMode is the scaling mode that will be used for the next
294e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // buffers that get queued. It is set by calling setScalingMode.
295e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    int mScalingMode;
296e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
297e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mTransform is the transform identifier that will be used for the next
298e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // buffer that gets queued. It is set by calling setTransform.
299e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    uint32_t mTransform;
300e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
3011681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk    // mStickyTransform is a transform that is applied on top of mTransform
3021681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk    // in each buffer that is queued.  This is typically used to force the
3031681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk    // compositor to apply a transform, and will prevent the transform hint
3041681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk    // from being set by the compositor.
3051681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk    uint32_t mStickyTransform;
3061681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk
3073be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // mDefaultWidth is default width of the buffers, regardless of the
3083be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // native_window_set_buffers_dimensions call.
3093be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    uint32_t mDefaultWidth;
310e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
3113be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // mDefaultHeight is default height of the buffers, regardless of the
3123be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // native_window_set_buffers_dimensions call.
3133be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    uint32_t mDefaultHeight;
314e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
3153be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // mUserWidth, if non-zero, is an application-specified override
3163be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // of mDefaultWidth.  This is lower priority than the width set by
3173be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // native_window_set_buffers_dimensions.
3183be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    uint32_t mUserWidth;
319e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
3203be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // mUserHeight, if non-zero, is an application-specified override
3213be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // of mDefaultHeight.  This is lower priority than the height set
3223be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    // by native_window_set_buffers_dimensions.
3233be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza    uint32_t mUserHeight;
324e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
325e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mTransformHint is the transform probably applied to buffers of this
326e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // window. this is only a hint, actual transform may differ.
327e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    uint32_t mTransformHint;
328e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
329595264f1af12e25dce57d7c5b1d52ed86ac0d0c9Mathias Agopian    // mProducerControlledByApp whether this buffer producer is controlled
330595264f1af12e25dce57d7c5b1d52ed86ac0d0c9Mathias Agopian    // by the application
331595264f1af12e25dce57d7c5b1d52ed86ac0d0c9Mathias Agopian    bool mProducerControlledByApp;
332595264f1af12e25dce57d7c5b1d52ed86ac0d0c9Mathias Agopian
3337cdd786fa80cf03551291ae8feca7b77583be1c5Mathias Agopian    // mSwapIntervalZero set if we should drop buffers at queue() time to
3347cdd786fa80cf03551291ae8feca7b77583be1c5Mathias Agopian    // achieve an asynchronous swap interval
3357cdd786fa80cf03551291ae8feca7b77583be1c5Mathias Agopian    bool mSwapIntervalZero;
3367cdd786fa80cf03551291ae8feca7b77583be1c5Mathias Agopian
337e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mConsumerRunningBehind whether the consumer is running more than
338e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // one buffer behind the producer.
339e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    mutable bool mConsumerRunningBehind;
340e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
341e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // mMutex is the mutex used to prevent concurrent access to the member
342e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // variables of Surface objects. It must be locked whenever the
343e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // member variables are accessed.
344e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    mutable Mutex mMutex;
345e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
346e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    // must be used from the lock/unlock thread
347e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    sp<GraphicBuffer>           mLockedBuffer;
348e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    sp<GraphicBuffer>           mPostedBuffer;
349e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    bool                        mConnectedToCpu;
350e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian
351c62acbd12711ee6cff1ef94c146316dfe5169045Dan Stoza    // When a CPU producer is attached, this reflects the region that the
352c62acbd12711ee6cff1ef94c146316dfe5169045Dan Stoza    // producer wished to update as well as whether the Surface was able to copy
353c62acbd12711ee6cff1ef94c146316dfe5169045Dan Stoza    // the previous buffer back to allow a partial update.
3545065a55291b67f584d7b0be3fa3cfc4e29a3cd1cDan Stoza    //
355c62acbd12711ee6cff1ef94c146316dfe5169045Dan Stoza    // When a non-CPU producer is attached, this reflects the surface damage
356c62acbd12711ee6cff1ef94c146316dfe5169045Dan Stoza    // (the change since the previous frame) passed in by the producer.
357e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian    Region mDirtyRegion;
358812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza
359812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza    // Stores the current generation number. See setGenerationNumber and
360812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza    // IGraphicBufferProducer::setGenerationNumber for more information.
361812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza    uint32_t mGenerationNumber;
362ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos
363ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    // Caches the values that have been passed to the producer.
3643559fbf93801e2c0d9d8fb246fb9b867a361b464Pablo Ceballos    bool mSharedBufferMode;
365ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    bool mAutoRefresh;
366ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos
3673559fbf93801e2c0d9d8fb246fb9b867a361b464Pablo Ceballos    // If in shared buffer mode and auto refresh is enabled, store the shared
368ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    // buffer slot and return it for all calls to queue/dequeue without going
369ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    // over Binder.
370ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    int mSharedBufferSlot;
371ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos
372ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    // This is true if the shared buffer has already been queued/canceled. It's
373ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    // used to prevent a mismatch between the number of queue/dequeue calls.
374ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos    bool mSharedBufferHasBeenQueued;
3759f31e299b3ec93b7bac969846105e7e926e3efcdRobert Carr
37670ccba596c586b7effde1ff99d36c911873b4ed4Dan Stoza    // These are used to satisfy the NATIVE_WINDOW_LAST_*_DURATION queries
37770ccba596c586b7effde1ff99d36c911873b4ed4Dan Stoza    nsecs_t mLastDequeueDuration = 0;
37870ccba596c586b7effde1ff99d36c911873b4ed4Dan Stoza    nsecs_t mLastQueueDuration = 0;
37970ccba596c586b7effde1ff99d36c911873b4ed4Dan Stoza
3809f31e299b3ec93b7bac969846105e7e926e3efcdRobert Carr    Condition mQueueBufferCondition;
381bc8c1928e1dbdaf6a2820f6e426c96ed61284043Pablo Ceballos
382bc8c1928e1dbdaf6a2820f6e426c96ed61284043Pablo Ceballos    uint64_t mNextFrameNumber;
383edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
384edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
38588612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvalanamespace view {
38688612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
38788612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala/**
38888612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala * A simple holder for an IGraphicBufferProducer, to match the managed-side
38988612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala * android.view.Surface parcelable behavior.
39088612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala *
39188612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala * This implements android/view/Surface.aidl
39288612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala *
39388612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala * TODO: Convert IGraphicBufferProducer into AIDL so that it can be directly
39488612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala * used in managed Binder calls.
39588612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala */
39688612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvalaclass Surface : public Parcelable {
39788612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala  public:
39888612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
39988612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    String16 name;
40088612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    sp<IGraphicBufferProducer> graphicBufferProducer;
40188612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
40288612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    virtual status_t writeToParcel(Parcel* parcel) const override;
40388612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    virtual status_t readFromParcel(const Parcel* parcel) override;
40488612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
40588612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    // nameAlreadyWritten set to true by Surface.java, because it splits
40688612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    // Parceling itself between managed and native code, so it only wants a part
40788612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    // of the full parceling to happen on its native side.
40888612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    status_t writeToParcel(Parcel* parcel, bool nameAlreadyWritten) const;
40988612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
41088612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    // nameAlreadyRead set to true by Surface.java, because it splits
41188612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    // Parceling itself between managed and native code, so it only wants a part
41288612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    // of the full parceling to happen on its native side.
41388612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    status_t readFromParcel(const Parcel* parcel, bool nameAlreadyRead);
41488612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
41588612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala  private:
41688612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
41788612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala    static String16 readMaybeEmptyString16(const Parcel* parcel);
41888612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala};
41988612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
42088612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala} // namespace view
42188612912ac8406f2be0eeff97892274f98509017Eino-Ville Talvala
422edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project}; // namespace android
423edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
424e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopian#endif  // ANDROID_GUI_SURFACE_H
425