graphic_buffer_impl.h revision c5cde8c18df853e11d1ec528508fd0fe2e742d5c
1/*
2 * Copyright (C) 2013 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// Provides the implementation of the GraphicBuffer interface in
18// renderer compostior
19
20#ifndef ANDROID_GRAPHIC_BUFFER_IMPL_H
21#define ANDROID_GRAPHIC_BUFFER_IMPL_H
22
23#include <ui/GraphicBuffer.h>
24
25namespace android {
26
27class GraphicBufferImpl {
28 public:
29  ~GraphicBufferImpl();
30
31  static int Create(int w, int h);
32  static void Release(int buffer_id);
33  static int LockStatic(int buffer_id, int mode, void** vaddr);
34  static int UnlockStatic(int buffer_id);
35  static void* GetNativeBufferStatic(int buffer_id);
36  static uint32_t GetStrideStatic(int buffer_id);
37
38 private:
39  status_t Lock(int mode, void** vaddr);
40  status_t Unlock();
41  status_t InitCheck() const;
42  void* GetNativeBuffer() const;
43  uint32_t GetStride() const;
44  GraphicBufferImpl(uint32_t w, uint32_t h);
45
46  sp<android::GraphicBuffer> mBuffer;
47};
48
49} // namespace android
50
51#endif // ANDROID_GRAPHIC_BUFFER_IMPL_H
52