1 /* 2 * Copyright 2022 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 #pragma once 18 19 #include <gui/LayerState.h> 20 21 namespace android::fake { 22 23 // Class which exposes buffer properties from BufferData without holding on to an actual buffer 24 class BufferData : public android::BufferData { 25 public: BufferData(uint64_t bufferId,uint32_t width,uint32_t height,int32_t pixelFormat,uint64_t outUsage)26 BufferData(uint64_t bufferId, uint32_t width, uint32_t height, int32_t pixelFormat, 27 uint64_t outUsage) 28 : mBufferId(bufferId), 29 mWidth(width), 30 mHeight(height), 31 mPixelFormat(pixelFormat), 32 mOutUsage(outUsage) {} hasBuffer()33 bool hasBuffer() const override { return mBufferId != 0; } hasSameBuffer(const android::BufferData & other)34 bool hasSameBuffer(const android::BufferData& other) const override { 35 return getId() == other.getId() && frameNumber == other.frameNumber; 36 } getWidth()37 uint32_t getWidth() const override { return mWidth; } getHeight()38 uint32_t getHeight() const override { return mHeight; } getId()39 uint64_t getId() const override { return mBufferId; } getPixelFormat()40 PixelFormat getPixelFormat() const override { return mPixelFormat; } getUsage()41 uint64_t getUsage() const override { return mOutUsage; } 42 43 private: 44 uint64_t mBufferId; 45 uint32_t mWidth; 46 uint32_t mHeight; 47 int32_t mPixelFormat; 48 uint64_t mOutUsage; 49 }; 50 51 } // namespace android::fake 52