| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 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 |
|
| 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 |
}; |
| 63 |
|
| 64 |
#endif |