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 
25 #include "draw_gl.h"
26 
27 namespace android {
28 
29 class GraphicBufferImpl {
30  public:
31   ~GraphicBufferImpl();
32 
33   static long Create(int w, int h);
34   static void Release(long buffer_id);
35   static int MapStatic(long buffer_id, AwMapMode mode, void** vaddr);
36   static int UnmapStatic(long buffer_id);
37   static void* GetNativeBufferStatic(long buffer_id);
38   static uint32_t GetStrideStatic(long buffer_id);
39 
40  private:
41   status_t Map(AwMapMode mode, void** vaddr);
42   status_t Unmap();
43   status_t InitCheck() const;
44   void* GetNativeBuffer() const;
45   uint32_t GetStride() const;
46   GraphicBufferImpl(uint32_t w, uint32_t h);
47 
48   sp<android::GraphicBuffer> mBuffer;
49 };
50 
51 }  // namespace android
52 
53 #endif  // ANDROID_GRAPHIC_BUFFER_IMPL_H
54