commit e4117b365ef85b37583879a35f7df31ac972cfbd
parent c6fbf1e852c658090891783c4994433d5817e909
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Wed, 2 Nov 2016 16:19:29 +0100
Remove device API and stuff from the lib.
A sanim node should be part of a custom data struct that provides allocator
and device.
Diffstat:
5 files changed, 0 insertions(+), 291 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -45,7 +45,6 @@ set(VERSION_PATCH 0)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(SANIM_FILES_SRC
- sanim_device.c
sanim_node.c)
set(SANIM_FILES_INC_API
@@ -53,7 +52,6 @@ set(SANIM_FILES_INC_API
set(SANIM_FILES_INC
sanim_c.h
- sanim_device_c.h
sanim_node_c.h)
set(SANIM_FILES_DOC COPYING README.md)
@@ -98,7 +96,6 @@ if(NOT NO_TEST)
rcmake_set_test_runtime_dirs(${_name} _runtime_dirs)
endfunction()
- new_test(test_sanim_device)
new_test(test_sanim_node_transform)
new_test(test_sanim_node_pivot)
endif()
diff --git a/src/sanim.h b/src/sanim.h
@@ -46,9 +46,6 @@ struct logger;
struct mem_allocator;
struct node_data;
-/* Opaque Solstice Anim types */
-struct sanim_device;
-
/* sanim_node type for building own node types */
struct sanim_node {
struct node_data* data;
@@ -118,26 +115,6 @@ struct sanim_tracking {
BEGIN_DECLS
/*******************************************************************************
- * Device API - Main entry point of the Solstice Anim library. Applications
- * use the sanim_device to create others Solstice Anim resources.
- ******************************************************************************/
-SANIM_API res_T
-sanim_device_create
-(struct logger* logger, /* May be NULL <=> use default logger */
- struct mem_allocator* allocator, /* May be NULL <=> use default allocator */
- const unsigned nthreads_hint, /* Hint on the number of threads to use */
- const int verbose, /* Make the library more verbose */
- struct sanim_device** dev);
-
-SANIM_API res_T
-sanim_device_ref_get
- (struct sanim_device* dev);
-
-SANIM_API res_T
-sanim_device_ref_put
- (struct sanim_device* dev);
-
-/*******************************************************************************
* Node API.
******************************************************************************/
SANIM_API res_T
diff --git a/src/sanim_device.c b/src/sanim_device.c
@@ -1,135 +0,0 @@
-/* Copyright (C) CNRS 2016
-*
-* 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 3 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include "sanim.h"
-#include "sanim_device_c.h"
-
-#include <rsys/logger.h>
-#include <rsys/mem_allocator.h>
-
-#include <omp.h>
-
-/*******************************************************************************
-* Helper functions
-******************************************************************************/
-static INLINE void
-log_msg
- (struct sanim_device* dev,
- const enum log_type stream,
- const char* msg,
- va_list vargs)
-{
- ASSERT(dev && msg);
- if (dev->verbose) {
- res_T res; (void) res;
- res = logger_vprint(dev->logger, stream, msg, vargs);
- ASSERT(res == RES_OK);
- }
-}
-
-static void
-device_release(ref_T* ref)
-{
- struct sanim_device* dev;
- ASSERT(ref);
- dev = CONTAINER_OF(ref, struct sanim_device, ref);
- MEM_RM(dev->allocator, dev);
-}
-
-/*******************************************************************************
-* Exported ssol_device functions
-******************************************************************************/
-res_T
-sanim_device_create
- (struct logger* logger,
- struct mem_allocator* mem_allocator,
- const unsigned nthreads_hint,
- const int verbose,
- struct sanim_device** out_dev)
-{
- struct sanim_device* dev = NULL;
- struct mem_allocator* allocator;
- res_T res = RES_OK;
-
- if (nthreads_hint == 0 || !out_dev) {
- res = RES_BAD_ARG;
- goto error;
- }
-
- allocator = mem_allocator ? mem_allocator : &mem_default_allocator;
- dev = MEM_CALLOC(allocator, 1, sizeof(struct sanim_device));
- if (!dev) {
- res = RES_MEM_ERR;
- goto error;
- }
- ref_init(&dev->ref);
- dev->logger = logger ? logger : LOGGER_DEFAULT;
- dev->allocator = allocator;
- dev->verbose = verbose;
- dev->nthreads = MMIN(nthreads_hint, (unsigned) omp_get_num_procs());
- omp_set_num_threads((int) dev->nthreads);
-
-exit:
- if (out_dev) *out_dev = dev;
- return res;
-error:
- if (dev) {
- SANIM(device_ref_put(dev));
- dev = NULL;
- }
- goto exit;
-}
-
-res_T
-sanim_device_ref_get(struct sanim_device* dev)
-{
- if (!dev) return RES_BAD_ARG;
- ref_get(&dev->ref);
- return RES_OK;
-}
-
-res_T
-sanim_device_ref_put(struct sanim_device* dev)
-{
- if (!dev) return RES_BAD_ARG;
- ref_put(&dev->ref, device_release);
- return RES_OK;
-}
-
-/*******************************************************************************
-* Local functions
-******************************************************************************/
-void
-log_error(struct sanim_device* dev, const char* msg, ...)
-{
- va_list vargs_list;
- ASSERT(dev && msg);
-
- va_start(vargs_list, msg);
- log_msg(dev, LOG_ERROR, msg, vargs_list);
- va_end(vargs_list);
-}
-
-void
-log_warning(struct sanim_device* dev, const char* msg, ...)
-{
- va_list vargs_list;
- ASSERT(dev && msg);
-
- va_start(vargs_list, msg);
- log_msg(dev, LOG_WARNING, msg, vargs_list);
- va_end(vargs_list);
-}
-
diff --git a/src/sanim_device_c.h b/src/sanim_device_c.h
@@ -1,58 +0,0 @@
-/* Copyright (C) CNRS 2016
-*
-* 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 3 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef SANIM_DEVICE_C_H
-#define SANIM_DEVICE_C_H
-
-#include <rsys/ref_count.h>
-#include <rsys/mem_allocator.h>
-
-struct logger;
-
-struct sanim_device {
- struct logger* logger;
- struct mem_allocator* allocator;
- unsigned nthreads;
- int verbose;
-
- ref_T ref;
-};
-
-/* Conditionally log a message on the LOG_ERROR stream of the device logger,
-* with respect to the device verbose flag */
-extern LOCAL_SYM void
-log_error
-(struct sanim_device* dev,
- const char* msg,
- ...)
-#ifdef COMPILER_GCC
- __attribute((format(printf, 2, 3)))
-#endif
- ;
-
-/* Conditionally log a message on the LOG_WARNING stream of the device logger,
-* with respect to the device verbose flag */
-extern LOCAL_SYM void
-log_warning
-(struct sanim_device* dev,
- const char* msg,
- ...)
-#ifdef COMPILER_GCC
- __attribute((format(printf, 2, 3)))
-#endif
- ;
-
-#endif /* SANIM_DEVICE_C_H */
-
diff --git a/src/test_sanim_device.c b/src/test_sanim_device.c
@@ -1,72 +0,0 @@
-/* Copyright (C) CNRS 2016
-*
-* 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 3 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include "sanim.h"
-#include "test_sanim_utils.h"
-
-#include <rsys/logger.h>
-
-int
-main(int argc, char** argv)
-{
- struct logger logger;
- struct mem_allocator allocator;
- struct sanim_device* dev;
- (void) argc, (void) argv;
-
- CHECK(sanim_device_create(NULL, NULL, 0, 0, NULL), RES_BAD_ARG);
- CHECK(sanim_device_create(NULL, NULL, SANIM_NTHREADS_DEFAULT, 0, &dev), RES_OK);
-
- CHECK(sanim_device_ref_get(NULL), RES_BAD_ARG);
- CHECK(sanim_device_ref_get(dev), RES_OK);
- CHECK(sanim_device_ref_put(NULL), RES_BAD_ARG);
- CHECK(sanim_device_ref_put(dev), RES_OK);
- CHECK(sanim_device_ref_put(dev), RES_OK);
-
- mem_init_proxy_allocator(&allocator, &mem_default_allocator);
-
- CHECK(MEM_ALLOCATED_SIZE(&allocator), 0);
- CHECK(sanim_device_create(NULL, &allocator, 2, 0, NULL), RES_BAD_ARG);
- CHECK(sanim_device_create
- (NULL, &allocator, SANIM_NTHREADS_DEFAULT, 0, &dev), RES_OK);
- CHECK(sanim_device_ref_put(dev), RES_OK);
- CHECK(MEM_ALLOCATED_SIZE(&allocator), 0);
-
- CHECK(logger_init(&allocator, &logger), RES_OK);
- logger_set_stream(&logger, LOG_OUTPUT, log_stream, NULL);
- logger_set_stream(&logger, LOG_ERROR, log_stream, NULL);
- logger_set_stream(&logger, LOG_WARNING, log_stream, NULL);
-
- CHECK(sanim_device_create(&logger, NULL, 4, 0, NULL), RES_BAD_ARG);
- CHECK(sanim_device_create
- (&logger, NULL, SANIM_NTHREADS_DEFAULT, 0, &dev), RES_OK);
- CHECK(sanim_device_ref_put(dev), RES_OK);
-
- CHECK(sanim_device_create(&logger, &allocator, 2, 0, NULL), RES_BAD_ARG);
- CHECK(sanim_device_create
- (&logger, &allocator, SANIM_NTHREADS_DEFAULT, 0, &dev), RES_OK);
- CHECK(sanim_device_ref_put(dev), RES_OK);
-
- CHECK(sanim_device_create(&logger, &allocator, 0, 0, &dev), RES_BAD_ARG);
- CHECK(sanim_device_create
- (&logger, &allocator, SANIM_NTHREADS_DEFAULT, 0, &dev), RES_OK);
- CHECK(sanim_device_ref_put(dev), RES_OK);
-
- logger_release(&logger);
- check_memory_allocator(&allocator);
- mem_shutdown_proxy_allocator(&allocator);
- CHECK(mem_allocated_size(), 0);
- return 0;
-}