Tizen 2.1 base
[framework/osp/uifw.git] / src / graphics / opengl / FGrp_VideoTextureImpl.cpp
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_VideoTextureImpl.cpp
20  * @brief       This is the implementation file for internal VideoTextureImpl class.
21  *
22  */
23
24 #include <new>
25
26 #include <FBaseSysLog.h>
27 #include <FGrpVideoTexture.h>
28 #include "FGrp_VideoTextureImpl.h"
29 #include "FGrp_VideoTexture.h"
30
31 namespace Tizen { namespace Graphics { namespace Opengl
32 {
33
34 _VideoTextureImpl::_VideoTextureImpl(void)
35         : __pNativeVideoTexture(new (std::nothrow)_VideoTexture)
36 {
37 }
38
39 _VideoTextureImpl::~_VideoTextureImpl(void)
40 {
41         delete this->__pNativeVideoTexture;
42 }
43
44 result
45 _VideoTextureImpl::Construct(int textureId, int width, int height)
46 {
47         SysTryReturnResult(NID_GRP, this->__pNativeVideoTexture != null, E_OUT_OF_MEMORY, "Fails to allocate memory.\n");
48
49         return this->__pNativeVideoTexture->Construct(textureId, width, height);
50 }
51
52 result
53 _VideoTextureImpl::BindTexture(void)
54 {
55         return this->__pNativeVideoTexture->BindTexture();
56 }
57
58 void
59 _VideoTextureImpl::AddVideoTextureUpdateListener(IVideoTextureUpdateListener& listener, VideoTexture* pVideoTexture)
60 {
61         this->__pNativeVideoTexture->AddVideoTextureUpdateListener(listener, pVideoTexture);
62 }
63
64 void
65 _VideoTextureImpl::RemoveVideoTextureUpdateListener(IVideoTextureUpdateListener& listener)
66 {
67         this->__pNativeVideoTexture->RemoveVideoTextureUpdateListener(listener);
68 }
69
70 _VideoTextureImpl*
71 _VideoTextureImpl::GetInstance(VideoTexture& videoTexture)
72 {
73         return (&videoTexture != null) ? videoTexture.__pImpl : null;
74 }
75
76 const _VideoTextureImpl*
77 _VideoTextureImpl::GetInstance(const VideoTexture& videoTexture)
78 {
79         return (&videoTexture != null) ? videoTexture.__pImpl : null;
80 }
81
82 unsigned int
83 _VideoTextureImpl::GetPixmap(void* pData)
84 {
85         _VideoTextureImpl* pVideoTextureImpl = dynamic_cast<_VideoTextureImpl*> ((_VideoTextureImpl*)pData);
86         if (pVideoTextureImpl == null)
87         {
88                 SysLog(NID_GRP, "pData is null.");
89                 return 0;
90         }
91
92         return (unsigned int)pVideoTextureImpl->__pNativeVideoTexture->GetPixmap();
93 }
94
95 }}} // Tizen::Graphics