blob: 79f4eeb6a9816c598e60a64bef7aac7dc222b9d4 [file] [log] [blame]
Mathias Agopiancbb288b2009-09-07 16:32:45 -07001/*
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
23#include <hardware/gralloc.h>
24
25#include <utils/Atomic.h>
26
27#include <ui/PixelFormat.h>
28#include <ui/Rect.h>
29#include <ui/Surface.h>
30
31#include <pixelflinger/pixelflinger.h>
32
33#include <private/ui/SharedBufferStack.h>
34#include <private/ui/SurfaceBuffer.h>
35
36class copybit_image_t;
37struct android_native_buffer_t;
38
39namespace android {
40
41// ===========================================================================
42// Buffer
43// ===========================================================================
44
45class NativeBuffer;
46
47class Buffer : public SurfaceBuffer
48{
49public:
50 enum {
51 DONT_CLEAR = 0x00000001,
52 SECURE = 0x00000004
53 };
54
55 Buffer();
56
57 // creates w * h buffer
58 Buffer(uint32_t w, uint32_t h, PixelFormat format,
59 uint32_t reqUsage, uint32_t flags = 0);
60
61 // return status
62 status_t initCheck() const;
63
64 uint32_t getWidth() const { return width; }
65 uint32_t getHeight() const { return height; }
66 uint32_t getStride() const { return stride; }
67 uint32_t getUsage() const { return usage; }
68 PixelFormat getPixelFormat() const { return format; }
69 Rect getBounds() const { return Rect(width, height); }
70
71 status_t lock(GGLSurface* surface, uint32_t usage);
72
73 android_native_buffer_t* getNativeBuffer() const;
74
75 status_t reallocate(uint32_t w, uint32_t h, PixelFormat f,
76 uint32_t reqUsage, uint32_t flags);
77
78private:
79 friend class LightRefBase<Buffer>;
80 Buffer(const Buffer& rhs);
81 virtual ~Buffer();
82 Buffer& operator = (const Buffer& rhs);
83 const Buffer& operator = (const Buffer& rhs) const;
84
85 status_t initSize(uint32_t w, uint32_t h, PixelFormat format,
86 uint32_t reqUsage, uint32_t flags);
87
88 ssize_t mInitCheck;
89 uint32_t mVStride;
90};
91
92}; // namespace android
93
94#endif // ANDROID_LAYER_BITMAP_H