Fedor Kudasov | 15e58b4 | 2019-07-04 17:52:39 +0100 | [diff] [blame] | 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_GRAPHIC_BUFFER_H |
| 18 | #define ANDROID_GRAPHIC_BUFFER_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <vector> |
| 24 | |
| 25 | #include <ui/PixelFormat.h> |
| 26 | #include <ui/Rect.h> |
| 27 | |
| 28 | #include <utils/RefBase.h> |
| 29 | |
| 30 | namespace android { |
| 31 | |
| 32 | class GraphicBuffer : virtual public RefBase { |
| 33 | public: |
| 34 | GraphicBuffer(uint32_t w, uint32_t h):width(w),height(h) { |
| 35 | data.resize(w*h); |
| 36 | } |
| 37 | uint32_t getWidth() const { return static_cast<uint32_t>(width); } |
| 38 | uint32_t getHeight() const { return static_cast<uint32_t>(height); } |
| 39 | uint32_t getStride() const { return static_cast<uint32_t>(width); } |
| 40 | uint64_t getUsage() const { return 0; } |
| 41 | PixelFormat getPixelFormat() const { return PIXEL_FORMAT_RGBA_8888; } |
| 42 | //uint32_t getLayerCount() const { return static_cast<uint32_t>(layerCount); } |
| 43 | Rect getBounds() const { return Rect(width, height); } |
| 44 | |
| 45 | status_t lockAsyncYCbCr(uint32_t inUsage, const Rect& rect, |
| 46 | android_ycbcr *ycbcr, int fenceFd) { return OK; } |
| 47 | |
| 48 | status_t lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr, int fenceFd, |
| 49 | int32_t* outBytesPerPixel = nullptr, int32_t* outBytesPerStride = nullptr) { |
| 50 | *vaddr = data.data(); |
| 51 | return OK; |
| 52 | } |
| 53 | |
| 54 | status_t unlockAsync(int *fenceFd) { return OK; } |
| 55 | |
| 56 | private: |
| 57 | uint32_t width; |
| 58 | uint32_t height; |
| 59 | std::vector<uint32_t> data; |
| 60 | }; |
| 61 | |
| 62 | }; // namespace android |
| 63 | |
| 64 | #endif // ANDROID_GRAPHIC_BUFFER_H |