Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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_LAYER_BITMAP_H |
| 18 | #define ANDROID_LAYER_BITMAP_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 23 | #include <ui/PixelFormat.h> |
| 24 | #include <ui/Rect.h> |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 25 | #include <pixelflinger/pixelflinger.h> |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 26 | #include <private/ui/SurfaceBuffer.h> |
| 27 | |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 28 | struct android_native_buffer_t; |
| 29 | |
| 30 | namespace android { |
| 31 | |
| 32 | // =========================================================================== |
| 33 | // Buffer |
| 34 | // =========================================================================== |
| 35 | |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 36 | class Buffer : public SurfaceBuffer |
| 37 | { |
| 38 | public: |
| 39 | enum { |
| 40 | DONT_CLEAR = 0x00000001, |
| 41 | SECURE = 0x00000004 |
| 42 | }; |
| 43 | |
| 44 | Buffer(); |
| 45 | |
| 46 | // creates w * h buffer |
| 47 | Buffer(uint32_t w, uint32_t h, PixelFormat format, |
| 48 | uint32_t reqUsage, uint32_t flags = 0); |
| 49 | |
| 50 | // return status |
| 51 | status_t initCheck() const; |
| 52 | |
| 53 | uint32_t getWidth() const { return width; } |
| 54 | uint32_t getHeight() const { return height; } |
| 55 | uint32_t getStride() const { return stride; } |
| 56 | uint32_t getUsage() const { return usage; } |
| 57 | PixelFormat getPixelFormat() const { return format; } |
| 58 | Rect getBounds() const { return Rect(width, height); } |
| 59 | |
| 60 | status_t lock(GGLSurface* surface, uint32_t usage); |
| 61 | |
| 62 | android_native_buffer_t* getNativeBuffer() const; |
| 63 | |
| 64 | status_t reallocate(uint32_t w, uint32_t h, PixelFormat f, |
| 65 | uint32_t reqUsage, uint32_t flags); |
| 66 | |
| 67 | private: |
| 68 | friend class LightRefBase<Buffer>; |
| 69 | Buffer(const Buffer& rhs); |
| 70 | virtual ~Buffer(); |
| 71 | Buffer& operator = (const Buffer& rhs); |
| 72 | const Buffer& operator = (const Buffer& rhs) const; |
| 73 | |
| 74 | status_t initSize(uint32_t w, uint32_t h, PixelFormat format, |
| 75 | uint32_t reqUsage, uint32_t flags); |
| 76 | |
| 77 | ssize_t mInitCheck; |
| 78 | uint32_t mVStride; |
| 79 | }; |
| 80 | |
| 81 | }; // namespace android |
| 82 | |
| 83 | #endif // ANDROID_LAYER_BITMAP_H |