Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mypaint-head', up to commit before first conflicting co…
…mmit (48c4995 in MyPaint master)
- Loading branch information
Showing
70 changed files
with
3,610 additions
and
1,005 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,7 +1,25 @@ | |||
|
|
||
#include <mypaint-config.h> | |||
|
|||
#ifdef _OPENMP | |||
#include <omp.h> | |||
#endif | |||
|
|||
void | |||
ensure_max_threads_not_exceeded() | |||
{ | |||
#ifdef _OPENMP | |||
const int max_threads = omp_get_max_threads(); | |||
if (max_threads > MYPAINT_MAX_THREADS) { | |||
omp_set_num_threads(MYPAINT_MAX_THREADS); | |||
} | |||
#endif | |||
} | |||
|
|||
void | void | ||
mypaint_init() | mypaint_init() | ||
{ | { | ||
ensure_max_threads_not_exceeded(); | |||
//bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); | //bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); | ||
} | } | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,87 @@ | |||
/* brushlib - The MyPaint Brush Library | |||
* Copyright (C) 2012 Jon Nordby <jononor@gmail.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any | |||
* purpose with or without fee is hereby granted, provided that the above | |||
* copyright notice and this permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
|
|||
#include <stdlib.h> | |||
#include <assert.h> | |||
|
|||
#include "tilemap.h" | |||
|
|||
TileMap * | |||
tile_map_new(int size, size_t item_size, TileMapItemFreeFunc item_free_func) | |||
{ | |||
TileMap *self = (TileMap *)malloc(sizeof(TileMap)); | |||
|
|||
self->size = size; | |||
self->item_size = item_size; | |||
self->item_free_func = item_free_func; | |||
const int map_size = 2*self->size*2*self->size; | |||
self->map = malloc(map_size*self->item_size); | |||
for(int i = 0; i < map_size; i++) { | |||
self->map[i] = NULL; | |||
} | |||
|
|||
return self; | |||
} | |||
|
|||
void | |||
tile_map_free(TileMap *self, gboolean free_items) | |||
{ | |||
const int map_size = 2*self->size*2*self->size; | |||
if (free_items) { | |||
for(int i = 0; i < map_size; i++) { | |||
self->item_free_func(self->map[i]); | |||
} | |||
} | |||
free(self->map); | |||
|
|||
free(self); | |||
} | |||
|
|||
/* Get the data in the tile map for a given tile @index. | |||
* Must be reentrant and lock-free on different @index */ | |||
void ** | |||
tile_map_get(TileMap *self, TileIndex index) | |||
{ | |||
const int rowstride = self->size*2; | |||
const int offset = ((self->size + index.y) * rowstride) + self->size + index.x; | |||
assert(offset < 2*self->size*2*self->size); | |||
assert(offset >= 0); | |||
return self->map + offset; | |||
} | |||
|
|||
/* Copy | |||
* The size of @other must be equal or larger to that of @self */ | |||
void | |||
tile_map_copy_to(TileMap *self, TileMap *other) | |||
{ | |||
assert(other->size >= self->size); | |||
|
|||
for(int y = -self->size; y < self->size; y++) { | |||
for(int x = -self->size; x < self->size; x++) { | |||
TileIndex index = {x, y}; | |||
*tile_map_get(other, index) = *tile_map_get(self, index); | |||
} | |||
} | |||
} | |||
|
|||
/* Must be reentrant and lock-free on different @index */ | |||
gboolean | |||
tile_map_contains(TileMap *self, TileIndex index) | |||
{ | |||
return (index.x >= -self->size && index.x < self->size | |||
&& index.y >= -self->size && index.y < self->size); | |||
} | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,58 @@ | |||
/* brushlib - The MyPaint Brush Library | |||
* Copyright (C) 2012 Jon Nordby <jononor@gmail.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any | |||
* purpose with or without fee is hereby granted, provided that the above | |||
* copyright notice and this permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
|
|||
#ifndef TILEMAP_H | |||
#define TILEMAP_H | |||
|
|||
#include <mypaint-glib-compat.h> | |||
|
|||
G_BEGIN_DECLS | |||
|
|||
typedef struct { | |||
int x; | |||
int y; | |||
} TileIndex; | |||
|
|||
typedef void (*TileMapItemFreeFunc) (void *item_data); | |||
|
|||
// A size of 10 means the map spans x=[-10,9], y=[-10,9] | |||
// The tile with TileIndex (x,y) is stored in the map at offset | |||
// offset=((self->size + y) * rowstride) + (self->size + index.x) | |||
typedef struct { | |||
void **map; | |||
int size; | |||
size_t item_size; | |||
TileMapItemFreeFunc item_free_func; | |||
} TileMap; | |||
|
|||
TileMap * | |||
tile_map_new(int size, size_t item_size, TileMapItemFreeFunc item_free_func); | |||
|
|||
void | |||
tile_map_free(TileMap *self, gboolean free_items); | |||
|
|||
gboolean | |||
tile_map_contains(TileMap *self, TileIndex index); | |||
|
|||
void ** | |||
tile_map_get(TileMap *self, TileIndex index); | |||
|
|||
void | |||
tile_map_copy_to(TileMap *self, TileMap *other); | |||
|
|||
G_END_DECLS | |||
|
|||
#endif // TILEMAP_H |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.