IGraphicBufferProducer.h revision f0bc2f1d8d37977bd3aef3d3326a70e9e69d4246
17b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar/* 2b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * Copyright (C) 2010 The Android Open Source Project 3b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * 4d911e414a989cad68befdeb554580d59ad81f04aYigit Boyar * Licensed under the Apache License, Version 2.0 (the "License"); 5b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * you may not use this file except in compliance with the License. 6b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * You may obtain a copy of the License at 7x[�I * 8b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * http://www.apache.org/licenses/LICENSE-2.0 97b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar * 10b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * Unless required by applicable law or agreed to in writing, software 11b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * distributed under the License is distributed on an "AS IS" BASIS, 12b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * See the License for the specific language governing permissions and 14b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar * limitations under the License. 15JQ? */ 16b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar 177b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar#ifndef ANDROID_GUI_ISURFACETEXTURE_H 187b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar#define ANDROID_GUI_ISURFACETEXTURE_H 197b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar 20b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar#include <stdint.h> 217b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar#include <sys/types.h> 227b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar 237b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar#include <utils/Errors.h> 24Tr|ů���F^k�����Vp��؊���ʦf�#include <utils/RefBase.h> 257b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar 267b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar#include <binder/IInterface.h> 277b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar 287b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar#include <ui/GraphicBuffer.h> 297b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar#include <ui/Rect.h> 30yhM\���Y�\���*♇�-�Ɠl#� 317b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyarnamespace android { 327b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar// ---------------------------------------------------------------------------- 337b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar 34li�e"���Bq�E� V� \'&�Q��l�)cH<���!�+�xG�class SurfaceTextureClient; 357b07818f07c28c6dec34ca2a9ab5f61e86afb493Yigit Boyar 36b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyarclass ISurfaceTexture : public IInterface 37722fe711207a37783dfa7142284b0ebe5bd503fbGeorge Mount{ 38722fe711207a37783dfa7142284b0ebe5bd503fbGeorge Mountpublic: 39b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar DECLARE_META_INTERFACE(SurfaceTexture); 40b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar 41B�.ai��I�L��X�protected: 42b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar friend class SurfaceTextureClient; 43b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar 44722fe711207a37783dfa7142284b0ebe5bd503fbGeorge Mount enum { 454m����m@�/�")� �D�i��r���I BUFFER_NEEDS_REALLOCATION = 0x1, 46b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar RELEASE_ALL_BUFFERS = 0x2, 47722fe711207a37783dfa7142284b0ebe5bd503fbGeorge Mount }; 48722fe711207a37783dfa7142284b0ebe5bd503fbGeorge Mount 49b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // requestBuffer requests a new buffer for the given index. The server (i.e. 50b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // the ISurfaceTexture implementation) assigns the newly created buffer to 51b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // the given slot index, and the client is expected to mirror the 52d911e414a989cad68befdeb554580d59ad81f04aYigit Boyar // slot->buffer mapping so that it's not necessary to transfer a 53b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // GraphicBuffer for every dequeue operation. 54b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf) = 0; 55b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar 56b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // setBufferCount sets the number of buffer slots available. Calling this 57b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // will also cause all buffer slots to be emptied. The caller should empty 58b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // its mirrored copy of the buffer slots when calling this method. 59b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar virtual status_t setBufferCount(int bufferCount) = 0; 60b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar 61b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // dequeueBuffer requests a new buffer slot for the client to use. Ownership 62b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // of the slot is transfered to the client, meaning that the server will not 63b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // use the contents of the buffer associated with that slot. The slot index 64b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // returned may or may not contain a buffer. If the slot is empty the client 65b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // should call requestBuffer to assign a new buffer to that slot. The client 66b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // is expected to either call cancelBuffer on the dequeued slot or to fill 67b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // in the contents of its associated buffer contents and call queueBuffer. 68b1356339eaa6c8e967e4fc1dc283b82909a1208dYigit Boyar // If dequeueBuffer return BUFFER_NEEDS_REALLOCATION, the client is 69 // expected to call requestBuffer immediately. 70 virtual status_t dequeueBuffer(int *slot, uint32_t w, uint32_t h, 71 uint32_t format, uint32_t usage) = 0; 72 73 // queueBuffer indicates that the client has finished filling in the 74 // contents of the buffer associated with slot and transfers ownership of 75 // that slot back to the server. It is not valid to call queueBuffer on a 76 // slot that is not owned by the client or one for which a buffer associated 77 // via requestBuffer. In addition, a timestamp must be provided by the 78 // client for this buffer. The timestamp is measured in nanoseconds, and 79 // must be monotonically increasing. Its other properties (zero point, etc) 80 // are client-dependent, and should be documented by the client. 81 // 82 // outWidth, outHeight and outTransform are filled with the default width 83 // and height of the window and current transform applied to buffers, 84 // respectively. 85 86 // QueueBufferInput must be a POD structure 87 struct QueueBufferInput { 88 inline QueueBufferInput(int64_t timestamp, 89 const Rect& crop, int scalingMode, uint32_t transform) 90 : timestamp(timestamp), crop(crop), scalingMode(scalingMode), 91 transform(transform) { } 92 inline void deflate(int64_t* outTimestamp, Rect* outCrop, 93 int* outScalingMode, uint32_t* outTransform) const { 94 *outTimestamp = timestamp; 95 *outCrop = crop; 96 *outScalingMode = scalingMode; 97 *outTransform = transform; 98 } 99 private: 100 int64_t timestamp; 101 Rect crop; 102 int scalingMode; 103 uint32_t transform; 104 }; 105 106 // QueueBufferOutput must be a POD structure 107 struct QueueBufferOutput { 108 inline QueueBufferOutput() { } 109 inline void deflate(uint32_t* outWidth, 110 uint32_t* outHeight, uint32_t* outTransformHint) const { 111 *outWidth = width; 112 *outHeight = height; 113 *outTransformHint = transformHint; 114 } 115 inline void inflate(uint32_t inWidth, uint32_t inHeight, 116 uint32_t inTransformHint) { 117 width = inWidth; 118 height = inHeight; 119 transformHint = inTransformHint; 120 } 121 private: 122 uint32_t width; 123 uint32_t height; 124 uint32_t transformHint; 125 }; 126 127 virtual status_t queueBuffer(int slot, 128 const QueueBufferInput& input, QueueBufferOutput* output) = 0; 129 130 // cancelBuffer indicates that the client does not wish to fill in the 131 // buffer associated with slot and transfers ownership of the slot back to 132 // the server. 133 virtual void cancelBuffer(int slot) = 0; 134 135 // query retrieves some information for this surface 136 // 'what' tokens allowed are that of android_natives.h 137 virtual int query(int what, int* value) = 0; 138 139 // setSynchronousMode set whether dequeueBuffer is synchronous or 140 // asynchronous. In synchronous mode, dequeueBuffer blocks until 141 // a buffer is available, the currently bound buffer can be dequeued and 142 // queued buffers will be retired in order. 143 // The default mode is asynchronous. 144 virtual status_t setSynchronousMode(bool enabled) = 0; 145 146 // connect attempts to connect a client API to the SurfaceTexture. This 147 // must be called before any other ISurfaceTexture methods are called except 148 // for getAllocator. 149 // 150 // This method will fail if the connect was previously called on the 151 // SurfaceTexture and no corresponding disconnect call was made. 152 // 153 // outWidth, outHeight and outTransform are filled with the default width 154 // and height of the window and current transform applied to buffers, 155 // respectively. 156 virtual status_t connect(int api, 157 uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) = 0; 158 159 // disconnect attempts to disconnect a client API from the SurfaceTexture. 160 // Calling this method will cause any subsequent calls to other 161 // ISurfaceTexture methods to fail except for getAllocator and connect. 162 // Successfully calling connect after this will allow the other methods to 163 // succeed again. 164 // 165 // This method will fail if the the SurfaceTexture is not currently 166 // connected to the specified client API. 167 virtual status_t disconnect(int api) = 0; 168}; 169 170// ---------------------------------------------------------------------------- 171 172class BnSurfaceTexture : public BnInterface<ISurfaceTexture> 173{ 174public: 175 virtual status_t onTransact( uint32_t code, 176 const Parcel& data, 177 Parcel* reply, 178 uint32_t flags = 0); 179}; 180 181// ---------------------------------------------------------------------------- 182}; // namespace android 183 184#endif // ANDROID_GUI_ISURFACETEXTURE_H 185