Fix link issues and crashes with Android build

This commit is contained in:
rdb 2016-02-06 11:46:56 +01:00
parent ffaa7419ec
commit 40739c6b5f
5 changed files with 36 additions and 16 deletions

View File

@ -1171,7 +1171,7 @@ def CompileCxx(obj,src,opts):
if (opt=="ALWAYS") or (opt in opts): cmd += ' -D' + var + '=' + val
for x in ipath: cmd += ' -I' + x
if not GetLinkAllStatic():
if not GetLinkAllStatic() and 'NOHIDDEN' not in opts:
cmd += ' -fvisibility=hidden'
# Mac-specific flags.
@ -1627,7 +1627,8 @@ def CompileLink(dll, obj, opts):
cmd += ' -o ' + dll + ' -L' + GetOutputDir() + '/lib -L' + GetOutputDir() + '/tmp'
else:
cmd = cxx + ' -shared'
if ("MODULE" not in opts): cmd += " -Wl,-soname=" + os.path.basename(dll)
if "MODULE" not in opts or GetTarget() == 'android':
cmd += " -Wl,-soname=" + os.path.basename(dll)
cmd += ' -o ' + dll + ' -L' + GetOutputDir() + '/lib -L' + GetOutputDir() + '/tmp'
for x in obj:
@ -4806,7 +4807,7 @@ if (not RUNTIME and GetTarget() == 'android'):
TargetAdd('libp3android.dll', input=COMMON_PANDA_LIBS)
TargetAdd('libp3android.dll', opts=['JNIGRAPHICS'])
TargetAdd('android_native_app_glue.obj', opts=OPTS, input='android_native_app_glue.c')
TargetAdd('android_native_app_glue.obj', opts=OPTS + ['NOHIDDEN'], input='android_native_app_glue.c')
TargetAdd('android_main.obj', opts=OPTS, input='android_main.cxx')
if (not RTDIST and PkgSkip("PVIEW")==0):

View File

@ -23,10 +23,10 @@
#include <jni.h>
NotifyCategoryDeclNoExport(android);
NotifyCategoryDecl(android, EXPORT_CLASS, EXPORT_TEMPL);
extern void init_libandroid();
extern struct android_app* panda_android_app;
extern EXPORT_CLASS struct android_app* panda_android_app;
extern jclass jni_PandaActivity;
extern jmethodID jni_PandaActivity_readBitmapHeader;

View File

@ -16,13 +16,19 @@
#include <istream>
#if __GNUC__ >= 4
#define EXPORT_JNI extern "C" __attribute__((visibility("default")))
#else
#define EXPORT_JNI extern "C"
#endif
////////////////////////////////////////////////////////////////////
// Function: NativeIStream::nativeGet
// Access: Private, Static
// Description: Reads a single character from the istream.
// Should return -1 on EOF.
////////////////////////////////////////////////////////////////////
extern "C" jint
EXPORT_JNI jint
Java_org_panda3d_android_NativeIStream_nativeGet(JNIEnv *env, jclass clazz, jlong ptr) {
std::istream *stream = (std::istream *) ptr;
@ -37,7 +43,7 @@ Java_org_panda3d_android_NativeIStream_nativeGet(JNIEnv *env, jclass clazz, jlon
// the actual number of bytes that were read.
// Should return -1 on EOF.
////////////////////////////////////////////////////////////////////
extern "C" jint
EXPORT_JNI jint
Java_org_panda3d_android_NativeIStream_nativeRead(JNIEnv *env, jclass clazz, jlong ptr, jbyteArray byte_array, jint offset, jint length) {
std::istream *stream = (std::istream *) ptr;
jbyte *buffer = (jbyte *) env->GetPrimitiveArrayCritical(byte_array, NULL);
@ -63,7 +69,7 @@ Java_org_panda3d_android_NativeIStream_nativeRead(JNIEnv *env, jclass clazz, jlo
// Description: Skips ahead N bytes in the stream. Returns the
// actual number of skipped bytes.
////////////////////////////////////////////////////////////////////
extern "C" jlong
EXPORT_JNI jlong
Java_org_panda3d_android_NativeIStream_nativeIgnore(JNIEnv *env, jclass clazz, jlong ptr, jlong offset) {
std::istream *stream = (std::istream *) ptr;
stream->ignore(offset);

View File

@ -30,7 +30,7 @@
#include <android/window.h>
#include <android/log.h>
extern struct android_app* panda_android_app;
extern IMPORT_CLASS struct android_app* panda_android_app;
TypeHandle AndroidGraphicsWindow::_type_handle;

View File

@ -6583,9 +6583,12 @@ do_issue_depth_test() {
////////////////////////////////////////////////////////////////////
void CLP(GraphicsStateGuardian)::
do_issue_alpha_test() {
#ifndef OPENGLES_1
if (_target_shader->get_flag(ShaderAttrib::F_subsume_alpha_test)) {
enable_alpha_test(false);
} else {
} else
#endif
{
const AlphaTestAttrib *target_alpha_test;
_target_rs->get_attrib_def(target_alpha_test);
@ -6846,9 +6849,13 @@ do_issue_blending() {
unsigned int color_channels =
target_color_write->get_channels() & _color_write_mask;
#ifndef OPENGLES_1
if (_target_shader->get_flag(ShaderAttrib::F_disable_alpha_write)) {
color_channels &= ~(ColorWriteAttrib::C_alpha);
}
#endif
if (color_channels == ColorWriteAttrib::C_off) {
int color_write_slot = ColorWriteAttrib::get_class_slot();
enable_multisample_alpha_one(false);
@ -9875,9 +9882,12 @@ set_state_and_transform(const RenderState *target,
#ifdef SUPPORT_FIXED_FUNCTION
int alpha_test_slot = AlphaTestAttrib::get_class_slot();
if (_target_rs->get_attrib(alpha_test_slot) != _state_rs->get_attrib(alpha_test_slot) ||
!_state_mask.get_bit(alpha_test_slot) ||
(_target_shader->get_flag(ShaderAttrib::F_subsume_alpha_test) !=
_state_shader->get_flag(ShaderAttrib::F_subsume_alpha_test))) {
!_state_mask.get_bit(alpha_test_slot)
#ifndef OPENGLES_1
|| (_target_shader->get_flag(ShaderAttrib::F_subsume_alpha_test) !=
_state_shader->get_flag(ShaderAttrib::F_subsume_alpha_test))
#endif
) {
//PStatGPUTimer timer(this, _draw_set_state_alpha_test_pcollector);
do_issue_alpha_test();
_state_mask.set_bit(alpha_test_slot);
@ -9981,9 +9991,12 @@ set_state_and_transform(const RenderState *target,
_target_rs->get_attrib(color_blend_slot) != _state_rs->get_attrib(color_blend_slot) ||
!_state_mask.get_bit(transparency_slot) ||
!_state_mask.get_bit(color_write_slot) ||
!_state_mask.get_bit(color_blend_slot) ||
(_target_shader->get_flag(ShaderAttrib::F_disable_alpha_write) !=
_state_shader->get_flag(ShaderAttrib::F_disable_alpha_write))) {
!_state_mask.get_bit(color_blend_slot)
#ifndef OPENGLES_1
|| (_target_shader->get_flag(ShaderAttrib::F_disable_alpha_write) !=
_state_shader->get_flag(ShaderAttrib::F_disable_alpha_write))
#endif
) {
//PStatGPUTimer timer(this, _draw_set_state_blending_pcollector);
do_issue_blending();
_state_mask.set_bit(transparency_slot);