41889bfa2bb7c9906d6f9b3d00bf7a6cb8860e05
[platform/framework/web/web-provider.git] / src / Core / Buffer / RenderBuffer.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Flora License, Version 1.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://floralicense.org/license/
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  * @file    RenderBuffer.h
18  * @author  Yunchan Cho (yunchan.cho@samsung.com)
19  */
20 #ifndef RENDER_BUFFER_H
21 #define RENDER_BUFFER_H
22
23 #include <memory>
24 #include <Evas.h>
25 #include "IRenderBuffer.h"
26
27 // forward declaration
28 struct livebox_buffer;
29
30 // type definition
31 typedef struct livebox_buffer* BufferInfoPtr;
32 typedef void* BufferAddrPtr;
33
34 #define EXPORT_CLASS    __attribute__ ((visibility("default"))
35
36 class EXPORT_CLASS RenderBuffer: public IRenderBuffer {
37     public:
38         // IRenderBuffer Implementation
39         bool allocate();  
40         bool reallocate(int width, int height);
41         bool free();  
42         Evas_Object* getWindow();
43
44         static void preRenderCallback(void* data, Evas* canvas, void* eventInfo);
45         static void postRenderCallback(void* data, Evas* canvas, void* eventInfo);
46
47         virtual ~RenderBuffer();
48
49     protected:
50         void startCanvasUpdate();
51         void stopCanvasUpdate();
52         void paintColor(unsigned int color);
53         Evas* getCanvas();
54         Evas_Object* getSnapshot();
55
56         // provided by derived class
57         virtual int getWidth() = 0;
58         virtual int getHeight() = 0;
59         virtual void setWidth(int width) = 0;
60         virtual void setHeight(int height) = 0;
61         virtual BufferInfoPtr acquireBuffer() = 0;
62         virtual void updateBuffer() = 0;
63
64         RenderBuffer();
65
66     private:
67         // callbacks
68         static void* allocateCallback(void* data, int size);
69         static void freeCallback(void* data, void *pix);
70
71         // members
72         Evas* m_canvas;
73         Evas_Object* m_win;
74         BufferAddrPtr m_bufferAddr;
75         BufferInfoPtr m_bufferInfo;
76 };
77
78 #endif