From 2d6913cf27d620b9b52990ef0889a61155479b0d Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Thu, 8 Aug 2013 20:32:06 -0400 Subject: jni: fill in Surface class --- xbmc/android/jni/Context.cpp | 2 ++ xbmc/android/jni/Surface.cpp | 59 ++++++++++++++++++++++++++++++++++++++------ xbmc/android/jni/Surface.h | 24 +++++++++++++++--- 3 files changed, 73 insertions(+), 12 deletions(-) diff --git a/xbmc/android/jni/Context.cpp b/xbmc/android/jni/Context.cpp index b0de7cc994..3a41b0c380 100644 --- a/xbmc/android/jni/Context.cpp +++ b/xbmc/android/jni/Context.cpp @@ -36,6 +36,7 @@ #include "Cursor.h" #include "ConnectivityManager.h" #include "AudioManager.h" +#include "Surface.h" #include @@ -70,6 +71,7 @@ void CJNIContext::PopulateStaticFields() CJNIContentResolver::PopulateStaticFields(); CJNIConnectivityManager::PopulateStaticFields(); CJNIAudioManager::PopulateStaticFields(); + CJNISurface::PopulateStaticFields(); } CJNIPackageManager CJNIContext::GetPackageManager() diff --git a/xbmc/android/jni/Surface.cpp b/xbmc/android/jni/Surface.cpp index 07fef75a72..5e49e629ce 100644 --- a/xbmc/android/jni/Surface.cpp +++ b/xbmc/android/jni/Surface.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2013 Team XBMC - * http://xbmc.org + * http://www.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 @@ -18,27 +18,70 @@ * */ +#include "JNIBase.h" #include "Surface.h" #include "SurfaceTexture.h" + #include "jutils/jutils-details.hpp" using namespace jni; -CJNISurface::CJNISurface(CJNISurfaceTexture *surf_texture) : CJNIBase("android/view/Surface") +int CJNISurface::ROTATION_0; +int CJNISurface::ROTATION_90; +int CJNISurface::ROTATION_180; +int CJNISurface::ROTATION_270; +const char* CJNISurface::m_classname = "android/view/Surface"; + +void CJNISurface::PopulateStaticFields() +{ + jhclass clazz = find_class(m_classname); + ROTATION_0 = get_static_field(clazz, "ROTATION_0"); + ROTATION_90 = get_static_field(clazz, "ROTATION_90"); + ROTATION_180= get_static_field(clazz, "ROTATION_180"); + ROTATION_270= get_static_field(clazz, "ROTATION_270"); +} + + +CJNISurface::CJNISurface(const CJNISurfaceTexture &surfaceTexture) : CJNIBase(m_classname) { - m_object = new_object(GetClassName(), - "", "(Landroid/graphics/SurfaceTexture;)V", - surf_texture->get_raw()); + m_object = new_object(m_classname, "", "(Landroid/graphics/SurfaceTexture;)V", surfaceTexture.get_raw()); m_object.setGlobal(); } -CJNISurface::~CJNISurface() +bool CJNISurface::isValid() { - release(); + return call_method(m_object, + "isValid", "()Z"); } void CJNISurface::release() { - call_method(m_object, + call_method(m_object, "release", "()V"); } + +/* +CJNICanvas CJNISurface::lockCanvas(const CJNIRect &rect) +{ +} + +void CJNISurface::unlockCanvasAndPost(const CJNICanvas &canvas) +{ +} + +void CJNISurface::unlockCanvas(const CJNICanvas &canvas) +{ +} +*/ + +std::string CJNISurface::toString() +{ + return jcast(call_method(m_object, + "toString", "()Ljava/lang/String;")); +} + +int CJNISurface::describeContents() +{ + return call_method(m_object, + "describeContents", "()I"); +} diff --git a/xbmc/android/jni/Surface.h b/xbmc/android/jni/Surface.h index af514c91f2..bddd57afe0 100644 --- a/xbmc/android/jni/Surface.h +++ b/xbmc/android/jni/Surface.h @@ -1,7 +1,7 @@ #pragma once /* * Copyright (C) 2013 Team XBMC - * http://xbmc.org + * http://www.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 @@ -25,8 +25,24 @@ class CJNISurfaceTexture; class CJNISurface : public CJNIBase { public: - CJNISurface(CJNISurfaceTexture *surf_texture); - ~CJNISurface(); + CJNISurface(const CJNISurfaceTexture &surfaceTexture); + CJNISurface(const jni::jhobject &object) : CJNIBase(object) {}; + ~CJNISurface() {}; - void release(); + bool isValid(); + void release(); +//CJNICanvas lockCanvas(CJNIRect); +//void unlockCanvasAndPost(const CJNICanvas &canvas); +//void unlockCanvas(const CJNICanvas &canvas); + std::string toString(); + + int describeContents(); + static void PopulateStaticFields(); + static int ROTATION_0; + static int ROTATION_90; + static int ROTATION_180; + static int ROTATION_270; + +private: + static const char *m_classname; }; -- cgit v1.2.3