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