Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: [droid] generically use hdmi resolution (4K) #7240

Merged
merged 2 commits into from Jun 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions xbmc/android/jni/Makefile.in
Expand Up @@ -51,6 +51,7 @@ SRCS += Window.cpp
SRCS += Build.cpp
SRCS += KeyCharacterMap.cpp
SRCS += Activity.cpp
SRCS += SystemProperties.cpp

LIB = jni.a

Expand Down
32 changes: 32 additions & 0 deletions xbmc/android/jni/SystemProperties.cpp
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2013 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/

#include "SystemProperties.h"
#include "jutils/jutils-details.hpp"

using namespace jni;
const char *CJNISystemProperties::m_classname = "android/os/SystemProperties";

std::string CJNISystemProperties::get(const std::string& property, const std::string& defaultValue)
{
return jcast<std::string>(call_static_method<jhstring>(m_classname,
"get", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
jcast<jhstring>(property), jcast<jhstring>(defaultValue)));
}
33 changes: 33 additions & 0 deletions xbmc/android/jni/SystemProperties.h
@@ -0,0 +1,33 @@
#pragma once
/*
* Copyright (C) 2013 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/

#include "JNIBase.h"

class CJNISystemProperties
{
public:
static std::string get(const std::string& property, const std::string& defaultValue);

private:
CJNISystemProperties();
~CJNISystemProperties() {};
static const char *m_classname;
};
46 changes: 40 additions & 6 deletions xbmc/windowing/egl/EGLNativeTypeAndroid.cpp
Expand Up @@ -17,6 +17,7 @@
* <http://www.gnu.org/licenses/>.
*
*/
#include <stdlib.h>

#include "system.h"
#include <EGL/egl.h>
Expand All @@ -25,8 +26,10 @@
#include "guilib/gui3d.h"
#include "android/activity/XBMCApp.h"
#include "utils/StringUtils.h"
#include "android/jni/SystemProperties.h"

CEGLNativeTypeAndroid::CEGLNativeTypeAndroid()
: m_width(0), m_height(0)
{
}

Expand All @@ -41,6 +44,22 @@ bool CEGLNativeTypeAndroid::CheckCompatibility()

void CEGLNativeTypeAndroid::Initialize()
{
m_width = m_height = 0;

// FIXME: Temporary shield specific hack to obtain HDMI resolution
// Remove and use New Android M API
std::string displaySize = CJNISystemProperties::get("sys.display-size", "");
CLog::Log(LOGDEBUG, "CEGLNativeTypeAndroid: display-size: %s", displaySize.c_str());
if (!displaySize.empty())
{
std::vector<std::string> aSize = StringUtils::Split(displaySize, "x");
if (aSize.size() == 2)
{
m_width = StringUtils::IsInteger(aSize[0]) ? atoi(aSize[0].c_str()) : 0;
m_height = StringUtils::IsInteger(aSize[1]) ? atoi(aSize[1].c_str()) : 0;
}
}

return;
}
void CEGLNativeTypeAndroid::Destroy()
Expand All @@ -58,7 +77,7 @@ bool CEGLNativeTypeAndroid::CreateNativeWindow()
{
// Android hands us a window, we don't have to create it
return true;
}
}

bool CEGLNativeTypeAndroid::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const
{
Expand Down Expand Up @@ -92,10 +111,18 @@ bool CEGLNativeTypeAndroid::GetNativeResolution(RESOLUTION_INFO *res) const
if (!nativeWindow)
return false;

ANativeWindow_acquire(*nativeWindow);
res->iWidth = ANativeWindow_getWidth(*nativeWindow);
res->iHeight= ANativeWindow_getHeight(*nativeWindow);
ANativeWindow_release(*nativeWindow);
if (!m_width || !m_height)
{
ANativeWindow_acquire(*nativeWindow);
res->iWidth = ANativeWindow_getWidth(*nativeWindow);
res->iHeight= ANativeWindow_getHeight(*nativeWindow);
ANativeWindow_release(*nativeWindow);
}
else
{
res->iWidth = m_width;
res->iHeight = m_height;
}

res->fRefreshRate = 60;
res->dwFlags= D3DPRESENTFLAG_PROGRESSIVE;
Expand All @@ -113,7 +140,14 @@ bool CEGLNativeTypeAndroid::GetNativeResolution(RESOLUTION_INFO *res) const

bool CEGLNativeTypeAndroid::SetNativeResolution(const RESOLUTION_INFO &res)
{
return false;
CLog::Log(LOGDEBUG, "CEGLNativeTypeAndroid: SetNativeResolution: %dx%d", m_width, m_height);
if (m_width && m_height)
{
if (!CXBMCApp::SetBuffersGeometry(m_width, m_height, 0))
return false;
}

return true;
}

bool CEGLNativeTypeAndroid::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions)
Expand Down
4 changes: 4 additions & 0 deletions xbmc/windowing/egl/EGLNativeTypeAndroid.h
Expand Up @@ -46,4 +46,8 @@ class CEGLNativeTypeAndroid : public CEGLNativeType
virtual bool GetPreferredResolution(RESOLUTION_INFO *res) const;

virtual bool ShowWindow(bool show);

protected:
int m_width;
int m_height;
};