2 * Copyright (C) 2011-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
22 #include "EGLNativeTypeAndroid.h"
23 #include "utils/log.h"
24 #include "guilib/gui3d.h"
25 #if defined(TARGET_ANDROID)
26 #include "android/activity/XBMCApp.h"
28 CEGLNativeTypeAndroid::CEGLNativeTypeAndroid()
32 CEGLNativeTypeAndroid::~CEGLNativeTypeAndroid()
36 bool CEGLNativeTypeAndroid::CheckCompatibility()
38 #if defined(TARGET_ANDROID)
44 void CEGLNativeTypeAndroid::Initialize()
48 void CEGLNativeTypeAndroid::Destroy()
53 bool CEGLNativeTypeAndroid::CreateNativeDisplay()
55 m_nativeDisplay = EGL_DEFAULT_DISPLAY;
59 bool CEGLNativeTypeAndroid::CreateNativeWindow()
61 #if defined(TARGET_ANDROID)
62 // Android hands us a window, we don't have to create it
69 bool CEGLNativeTypeAndroid::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const
73 *nativeDisplay = (XBNativeDisplayType*) &m_nativeDisplay;
77 bool CEGLNativeTypeAndroid::GetNativeWindow(XBNativeWindowType **nativeWindow) const
81 *nativeWindow = (XBNativeWindowType*) CXBMCApp::GetNativeWindow(30000);
82 return (*nativeWindow != NULL);
85 bool CEGLNativeTypeAndroid::DestroyNativeDisplay()
90 bool CEGLNativeTypeAndroid::DestroyNativeWindow()
95 bool CEGLNativeTypeAndroid::GetNativeResolution(RESOLUTION_INFO *res) const
97 #if defined(TARGET_ANDROID)
98 EGLNativeWindowType *nativeWindow = (EGLNativeWindowType*)CXBMCApp::GetNativeWindow(30000);
102 ANativeWindow_acquire(*nativeWindow);
103 res->iWidth = ANativeWindow_getWidth(*nativeWindow);
104 res->iHeight= ANativeWindow_getHeight(*nativeWindow);
105 ANativeWindow_release(*nativeWindow);
107 res->fRefreshRate = 60;
108 res->dwFlags= D3DPRESENTFLAG_PROGRESSIVE;
110 res->bFullScreen = true;
111 res->iSubtitles = (int)(0.965 * res->iHeight);
112 res->fPixelRatio = 1.0f;
113 res->iScreenWidth = res->iWidth;
114 res->iScreenHeight = res->iHeight;
115 res->strMode.Format("%dx%d @ %.2f%s - Full Screen", res->iScreenWidth, res->iScreenHeight, res->fRefreshRate,
116 res->dwFlags & D3DPRESENTFLAG_INTERLACED ? "i" : "");
117 CLog::Log(LOGNOTICE,"Current resolution: %s\n",res->strMode.c_str());
124 bool CEGLNativeTypeAndroid::SetNativeResolution(const RESOLUTION_INFO &res)
129 bool CEGLNativeTypeAndroid::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions)
133 ret = GetNativeResolution(&res);
134 if (ret && res.iWidth > 1 && res.iHeight > 1)
136 resolutions.push_back(res);
142 bool CEGLNativeTypeAndroid::GetPreferredResolution(RESOLUTION_INFO *res) const
147 bool CEGLNativeTypeAndroid::ShowWindow(bool show)