1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_GUI_BUFFERITEMCONSUMER_H 18 #define ANDROID_GUI_BUFFERITEMCONSUMER_H 19 20 #include <utils/RefBase.h> 21 22 #include <gui/ConsumerBase.h> 23 #include <gui/IGraphicBufferConsumer.h> 24 25 namespace android { 26 27 class BufferItemConsumer : public ConsumerBase { 28 public: BufferItemConsumer(const sp<IGraphicBufferConsumer> & consumer,uint64_t consumerUsage,int bufferCount,bool controlledByApp)29 BufferItemConsumer( 30 const sp<IGraphicBufferConsumer>& consumer, 31 uint64_t consumerUsage, 32 int bufferCount, 33 bool controlledByApp) : mConsumer(consumer) { 34 } 35 36 status_t acquireBuffer(BufferItem *item, nsecs_t presentWhen, bool waitForFence = true) { 37 return mConsumer->acquireBuffer(item, presentWhen, 0); 38 } 39 40 status_t releaseBuffer( 41 const BufferItem &item, const sp<Fence>& releaseFence = Fence::NO_FENCE) { return OK; } 42 setName(const String8 & name)43 void setName(const String8& name) { } 44 setFrameAvailableListener(const wp<FrameAvailableListener> & listener)45 void setFrameAvailableListener(const wp<FrameAvailableListener>& listener) { } 46 setDefaultBufferSize(uint32_t width,uint32_t height)47 status_t setDefaultBufferSize(uint32_t width, uint32_t height) { 48 return mConsumer->setDefaultBufferSize(width, height); 49 } 50 setDefaultBufferFormat(PixelFormat defaultFormat)51 status_t setDefaultBufferFormat(PixelFormat defaultFormat) { 52 return mConsumer->setDefaultBufferFormat(defaultFormat); 53 } 54 setDefaultBufferDataSpace(android_dataspace defaultDataSpace)55 status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace) { 56 return mConsumer->setDefaultBufferDataSpace(defaultDataSpace); 57 } 58 abandon()59 void abandon() { } 60 detachBuffer(int slot)61 status_t detachBuffer(int slot) { return OK; } 62 discardFreeBuffers()63 status_t discardFreeBuffers() { return OK; } 64 freeBufferLocked(int slotIndex)65 void freeBufferLocked(int slotIndex) { } 66 addReleaseFenceLocked(int slot,const sp<GraphicBuffer> graphicBuffer,const sp<Fence> & fence)67 status_t addReleaseFenceLocked( 68 int slot, const sp<GraphicBuffer> graphicBuffer, const sp<Fence>& fence) { return OK; } 69 private: 70 sp<IGraphicBufferConsumer> mConsumer; 71 }; 72 73 } // namespace android 74 75 #endif // ANDROID_GUI_BUFFERITEMCONSUMER_H 76