Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / inc / FGrp_GlPlayerImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /*
19  * @file        FGrp_GlPlayerImpl.h
20  * @brief       This is the header file for the _GlPlayerImpl class.
21  *
22  */
23
24 #ifndef _FGRP_GLPLAYERIMPL_H_
25 #define _FGRP_GLPLAYERIMPL_H_
26
27 #include <FBase.h>
28 #include <FGrpIGlRenderer.h>
29 #include <FGrpGlPlayer.h>
30
31 #include <egl.h>
32
33 namespace Tizen { namespace Ui
34 {
35 class Control;
36 }}
37
38 namespace Tizen { namespace Graphics { namespace Opengl
39 {
40
41 class IGlRenderer;
42 class GlPlayer;
43
44 class _OSP_EXPORT_ _GlPlayerImpl
45         : public Tizen::Base::Object
46         , public Tizen::Base::Runtime::ITimerEventListener
47 {
48 public:
49         _GlPlayerImpl(void);
50         virtual ~_GlPlayerImpl(void);
51
52         result Construct(EglContextClientVersion version, Tizen::Ui::Control* pControl);
53         result Start(void);
54         result Pause(void);
55         result Resume(void);
56         result Stop(void);
57
58         result Redraw(void);
59
60         result SetFps(int fps);
61         result SetIGlRenderer(IGlRenderer* pRenderer);
62
63         result SetEglAttributeList(const EGLint* pEglConfigList);
64         result SetEglAttributePreset(EglAttributesPreset preset);
65         result SetEglAttribute(EGLint key, EGLint value);
66
67         bool IsValid(void) const;
68
69         //// function for ITimerEventListener
70         void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
71
72 public:
73         static _GlPlayerImpl* GetInstance(GlPlayer& plyaer);
74         static const _GlPlayerImpl* GetInstance(const GlPlayer& player);
75
76 private:
77         _GlPlayerImpl(const _GlPlayerImpl& rhs);
78         _GlPlayerImpl& operator =(const _GlPlayerImpl& rhs);
79
80         bool __CheckReadyToStart(void);
81         bool __DestroyGl(void);
82
83         result __Terminate(void);
84
85 private:
86         IGlRenderer* __pRenderer;
87
88         Tizen::Base::Runtime::Timer* __pTimer;
89         Tizen::Ui::Control* __pTargetControl;
90
91         EGLDisplay __eglDisplay;
92         EGLSurface __eglSurface;
93         EGLConfig __eglConfig;
94         EGLContext __eglContext;
95
96         /*
97         * EGL frame buffer configuration attributes are,
98         *   EGL_BUFFER_SIZE, EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, EGL_ALPHA_SIZE,
99         *   EGL_CONFIG_CAVEAT, EGL_CONFIG_ID, EGL_DEPTH_SIZE, EGL_LEVEL, EGL_NATIVE_RENDERABLE,
100         *   EGL_NATIVE_VISUAL_TYPE, EGL_SAMPLE_BUFFERS, EGL_SAMPLES, EGL_STENCIL_SIZE, EGL_SURFACE_TYPE,
101         *   EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_RED_VALUE, EGL_TRANSPARENT_GREEN_VALUE, EGL_TRANSPARENT_BLUE_VALUE
102         */
103         EGLint __eglConfigList[40];
104
105         int __fps;
106         int __renderTimeInterval; // time interval between consecutive frames in microsecond units.
107
108         EglContextClientVersion __eglContextClientVersion;
109
110         enum
111         {
112                 PLAYER_STATE_NOT_INITIALIZED = 0,
113                 PLAYER_STATE_START = 1,
114                 PLAYER_STATE_PAUSE = 2,
115                 PLAYER_STATE_STOP = 3
116         } __playerState;
117
118 }; // _GlPlayerImpl
119
120 }}} // Tizen::Graphics::Opengl
121
122 #endif //_FGRP_GLPLAYERIMPL_H_