Skip to content

Commit

Permalink
Fix memory handler
Browse files Browse the repository at this point in the history
* Add CMAKE_ASM_COMPILE_OBJECT
* Add ASM files for arch files
* Tweak rectangle to use color_set if memset16 defined
* Add LIBAROMA_CONFIG_NO_ANDROID_MEM check to disable android memory
* Disable libaroma_color_set in engines (neon&sse) if memset16 is
defined
  • Loading branch information
Ahmad Amarullah committed Jan 20, 2016
1 parent 0aaf25f commit fbb1746
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,14 @@ if("${ARCHITECTURE}" STREQUAL "arm")
endif()
endif()

# asm
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <FLAGS> <DEFINES> -fPIC -c -o <OBJECT> <SOURCE>")

# sources
file(GLOB AROMA_SRCS
${PROJECT_SOURCE_DIR}/src/contrib/platform/${LIBAROMA_PLATFORM_NAME}/*.c
src/aroma/arch/${ARCHITECTURE}/*.c
src/aroma/arch/${ARCHITECTURE}/*.S
src/aroma/aroma.c
src/aroma/version.c
src/aroma/utils/*.c
Expand Down Expand Up @@ -308,7 +312,10 @@ if (DEFINED WITHAROMART)
endif()

# libaroma_test
file(GLOB LIBAROMA_TEST_SRCS examples/*.c)
file(GLOB LIBAROMA_TEST_SRCS examples/recovery/*.c)
include_directories(
${PROJECT_SOURCE_DIR}/examples/recovery
)
add_executable(libaroma_test ${LIBAROMA_TEST_SRCS})
target_link_libraries(libaroma_test aroma)

Expand Down
9 changes: 8 additions & 1 deletion src/aroma/graph/draw/commondraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,14 @@ byte libaroma_draw_rect(
int dy;

if (alpha == 0xff) {
int w2=w*2;
wordp datapos = dst->data + x;
#ifdef libaroma_memset16
for (dy = y; dy < y2; dy++) {
wordp linepos = datapos + (dy * dst->l);
libaroma_color_set(linepos,color,w);
}
#else
int w2=w*2;
wordp firstline = datapos + (y * dst->l);
libaroma_color_set(firstline, color, w);
#ifdef LIBAROMA_CONFIG_OPENMP
Expand All @@ -326,6 +332,7 @@ byte libaroma_draw_rect(
wordp linepos = datapos + (dy * dst->l);
memcpy(linepos,firstline,w2);
}
#endif
}
else {
#ifdef LIBAROMA_CONFIG_OPENMP
Expand Down
4 changes: 3 additions & 1 deletion src/contrib/arm_neon/arm_neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
#define __engine_have_libaroma_alpha_rgba_fill_line 1
#define __engine_have_libaroma_alpha_mono 1
#define __engine_have_libaroma_alpha_multi_line 1
#define __engine_have_libaroma_color_set 1
#ifndef libaroma_memset16
#define __engine_have_libaroma_color_set 1
#endif
#define __engine_have_libaroma_color_copy32 1
#define __engine_have_libaroma_color_copy16 1
#define __engine_have_libaroma_color_copy_rgb24 1
Expand Down
2 changes: 2 additions & 0 deletions src/contrib/arm_neon/arm_neon_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/*
* memset color 16bit
*/
#ifndef libaroma_memset16
static inline void libaroma_color_set(
wordp __restrict dst,
word color,
Expand All @@ -49,6 +50,7 @@ static inline void libaroma_color_set(
}
}
}
#endif

/*
* 16 to 32bit
Expand Down
2 changes: 2 additions & 0 deletions src/contrib/x86_sse/x86_sse_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#ifndef __libaroma_x86_sse_color_h__
#define __libaroma_x86_sse_color_h__

#ifndef libaroma_memset16
#define __engine_have_libaroma_color_set 1
static inline void libaroma_color_set(wordp dst, word color, int n) {
int i,left=n%32;
Expand All @@ -44,6 +45,7 @@ static inline void libaroma_color_set(wordp dst, word color, int n) {
}
}
}
#endif

#define __engine_have_libaroma_color_24to16 1
static inline void libaroma_color_24to16(
Expand Down
5 changes: 4 additions & 1 deletion src/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#endif
#ifndef __libaroma_memory_h__
#define __libaroma_memory_h__
#ifndef LIBAROMA_CONFIG_NO_ANDROID_MEM

/*
* Function : android_memset16
Expand All @@ -41,6 +42,8 @@ void android_memset16(uint16_t* dst, uint16_t value, size_t size);
*/
void android_memset32(uint32_t* dst, uint32_t value, size_t size);

#define libaroma_memset16(s,d,n) android_memset16(s,d,n*2)
#define libaroma_memset16(s,d,n) android_memset16(s,d,n<<1)
#define libaroma_memset32(s,d,n) android_memset32(s,d,n<<2)

#endif /* LIBAROMA_CONFIG_NO_ANDROID_MEM */
#endif /* __libaroma_memory_h__ */

0 comments on commit fbb1746

Please sign in to comment.