Commits

Christian Fischer  committed 316b451

adapted latest changes to android projects

  • Participants
  • Parent commits 5f72d5d

Comments (0)

Files changed (11)

File libraries/android-native/wiesel-common/Android.mk

 LOCAL_MODULE_FILENAME      := libwieselcommon
 LOCAL_CFLAGS               := -Werror
 LOCAL_LDLIBS               := 
-LOCAL_STATIC_LIBRARIES     := wiesel-base libpng-static libxml2-static android_native_app_glue
+LOCAL_STATIC_LIBRARIES     := libpng-static wiesel-base wiesel-core
 LOCAL_SRC_FILES            := $(MY_FILES)
 LOCAL_C_INCLUDES           := $(MY_LOCAL_FOLDERS)
 LOCAL_EXPORT_C_INCLUDES    := $(MY_LOCAL_FOLDERS)
-LOCAL_EXPORT_LDLIBS        := -landroid -llog -lEGL -lGLESv2
+LOCAL_EXPORT_LDLIBS        := 
 
 # Build the static library
 include $(BUILD_STATIC_LIBRARY)
 
+# import all required modules
+$(call import-module,wiesel-base)
+$(call import-module,wiesel-core)
+
 # External third-party modules
 $(call import-module,third-party/libpng)
-$(call import-module,third-party/libxml)
-
-# NativeActivity stuff
-$(call import-module,android/native_app_glue)

File libraries/android-native/wiesel-common/src/wiesel/wiesel-common-config.h

+/**
+ * Copyright (C) 2012
+ * Christian Fischer
+ *
+ * https://bitbucket.org/baldur/wiesel/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+#ifndef __WIESEL_COMMON_CONFIG_H__
+#define __WIESEL_COMMON_CONFIG_H__
+
+
+// enables support for libpng
+#define WIESEL_SUPPORTS_LIBPNG 1
+
+
+#endif // __WIESEL_COMMON_CONFIG_H__

File libraries/android-native/wiesel-core/Android.mk

+# wiesel-core
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+# define source folders of this library
+MY_LOCAL_FOLDERS := \
+				$(LOCAL_PATH)/src								\
+				$(LOCAL_PATH)/../../../src/core					\
+
+MY_SUBFOLDERS := \
+				$(foreach dir,$(MY_LOCAL_FOLDERS),$(shell /usr/bin/find $(dir) -type d -print))
+
+MY_FILES := \
+				$(subst $(LOCAL_PATH), ,$(foreach dir,$(MY_SUBFOLDERS),$(wildcard $(dir)/*.cpp)))
+
+# configure the module
+LOCAL_MODULE               := wiesel-core
+LOCAL_MODULE_FILENAME      := libwieselcore
+LOCAL_CFLAGS               := -Werror
+LOCAL_LDLIBS               := 
+LOCAL_STATIC_LIBRARIES     := wiesel-base libxml2-static android_native_app_glue
+LOCAL_SRC_FILES            := $(MY_FILES)
+LOCAL_C_INCLUDES           := $(MY_LOCAL_FOLDERS)
+LOCAL_EXPORT_C_INCLUDES    := $(MY_LOCAL_FOLDERS)
+LOCAL_EXPORT_LDLIBS        := -landroid -llog -lEGL -lGLESv2
+
+# Build the static library
+include $(BUILD_STATIC_LIBRARY)
+
+# External third-party modules
+$(call import-module,third-party/libxml)
+
+# NativeActivity stuff
+$(call import-module,android/native_app_glue)

File samples/HelloWiesel/android/jni/Android.mk

 
 # add the path to the libraries into search path
 WIESEL_PATH := $(LOCAL_PATH)/../$(WIESEL_DIR)/libraries/android-native
+WIESEL_SRC_PATH := $(WIESEL_PATH)/../../src
 $(call import-add-path,$(WIESEL_PATH))
 
 # define the source folders of this project
 MY_FILES := \
 				$(subst $(LOCAL_PATH), ,$(foreach dir,$(MY_SUBFOLDERS),$(wildcard $(dir)/*.cpp)))
 
+
 # configure the application's build
 LOCAL_MODULE               := main
 LOCAL_SRC_FILES            := $(MY_FILES)
 LOCAL_LDLIBS               :=
-LOCAL_STATIC_LIBRARIES     := wiesel-common
+LOCAL_STATIC_LIBRARIES     := wiesel-common wiesel-core
 
 # build the shared library
 include $(BUILD_SHARED_LIBRARY)
 
 # import all required modules
 $(call import-module,wiesel-base)
+$(call import-module,wiesel-core)
 $(call import-module,wiesel-common)

File samples/HelloWiesel/android/jni/module_registry.cpp

+
+#include "wiesel/resources/graphics/image_loader_libpng.loadable_module"
+

File src/base/wiesel/math/utils.cpp

 			bInt = 0x80000000 - bInt;
 		}
 
-		uint64_t diff = std::abs(aInt - bInt);
+		// FIXME: casting to int32 to fix "call of overloaded 'abs(int64_t)' is ambiguous" on android
+		uint64_t diff = std::abs(static_cast<int32_t>(aInt - bInt));
 		if (diff <= max_ulp) {
 			return true;
 		}

File src/core/wiesel/platform/android/android_engine.cpp

 	return touch_handler;
 }
 
-
-bool AndroidEngine::decodeImage(
-		DataSource *data,
-		unsigned char **pBuffer, size_t *pSize,
-		unsigned int *pWidth, unsigned int *pHeight,
-		unsigned int *pOriginalWidth, unsigned int *pOriginalHeight,
-		int *pRbits, int *pGbits, int *pBbits, int *pAbits,
-		bool as_texture
-) {
-	FileDataSource *filedata = dynamic_cast<FileDataSource*>(data);
-	if (filedata) {
-		string file_ext = filedata->getFile()->getExtension();
-		// TODO: convert to lower case
-
-		if (file_ext == "png") {
-			return decodeImage_PNG(
-					data, pBuffer, pSize,
-					pWidth, pHeight, pOriginalWidth, pOriginalHeight,
-					pRbits, pGbits, pBbits, pAbits, as_texture
-			);
-		}
-	}
-	else {
-		DataBuffer *buffer = data->getDataBuffer();
-
-		// check first bytes
-		if (buffer->getSize() >= 4) {
-			uint32_t header_32 = *(reinterpret_cast<const int32_t*>(buffer->getData()));
-
-			// when a format was recognized, we create a new BufferDataSource, to re-use the created data-buffer,
-			// because passing the original 'data' object could cause the buffer will be re-loaded from a storage.
-
-			if (header_32 == 0x474e5089U) {
-				return decodeImage_PNG(
-						new BufferDataSource(buffer), pBuffer, pSize,
-						pWidth, pHeight, pOriginalWidth, pOriginalHeight,
-						pRbits, pGbits, pBbits, pAbits, as_texture
-				);
-			}
-		}
-	}
-
-	return false;
-}
-
 #endif // __ANDROID__

File src/core/wiesel/platform/android/android_engine.h

 #ifndef __WIESEL_PLATFORM_ANDROID_ENGINE_H__
 #define __WIESEL_PLATFORM_ANDROID_ENGINE_H__
 
-#include <wiesel/wiesel-common.def>
+#include <wiesel/wiesel-core.def>
 
 #ifdef __ANDROID__
 
 
 		virtual TouchHandler *getTouchHandler();
 
-	public:
-		virtual bool decodeImage(
-				DataSource *data,
-				unsigned char **pBuffer, size_t *pSize,
-				unsigned int *pWidth, unsigned int *pHeight,
-				unsigned int *pOriginalWidth, unsigned int *pOriginalHeight,
-				int *pRbits, int *pGbits, int *pBbits, int *pAbits,
-				bool as_texture
-		);
-
-	private:
-		virtual bool decodeImage_PNG(
-				DataSource *data,
-				unsigned char **pBuffer, size_t *pSize,
-				unsigned int *pWidth, unsigned int *pHeight,
-				unsigned int *pOriginalWidth, unsigned int *pOriginalHeight,
-				int *pRbits, int *pGbits, int *pBbits, int *pAbits,
-				bool as_texture
-		);
-
 	protected:
 		struct android_app*			app;
 		GenericFileSystem*			root_fs;

File src/core/wiesel/platform/android/android_screen.h

 #ifndef __WIESEL_PLATFORM_ANDROID_SCREEN_H__
 #define __WIESEL_PLATFORM_ANDROID_SCREEN_H__
 
-#include <wiesel/wiesel-common.def>
+#include <wiesel/wiesel-core.def>
 
 #ifdef __ANDROID__
 

File src/core/wiesel/platform/android/file_support/android_asset_fs.h

 #ifndef __WIESEL_PLATFORM_ANDROID_FILESUPPORT_ANDROID_ASSET_FS_H__
 #define __WIESEL_PLATFORM_ANDROID_FILESUPPORT_ANDROID_ASSET_FS_H__
 
-#include <wiesel/wiesel-common.def>
+#include <wiesel/wiesel-core.def>
 
 #include "wiesel/io/filesystem.h"
 

File src/core/wiesel/platform/android/platform_main.h

 #ifndef __WIESEL_PLATFORM_ANDROID_PLATFORM_MAIN_H__
 #define __WIESEL_PLATFORM_ANDROID_PLATFORM_MAIN_H__
 
-#include <wiesel/wiesel-common.def>
+#include <wiesel/wiesel-core.def>
 
 #include "../../application.h"