Permalink
Browse files

Merge branch 'mypaint-head', up to commit before first conflicting co…

…mmit (48c4995 in MyPaint master)
  • Loading branch information...
2 parents 644cc9c + 9f8f0e0 commit ab83301a1174341d60969c762b584d44839ac5b8 davissorenson committed Aug 10, 2013
Showing with 3,610 additions and 1,005 deletions.
  1. +1 −1 README.mypaint
  2. +1 −1 SConstruct
  3. +1 −0 brushlib/libmypaint.c
  4. +4 −0 brushlib/mypaint-config.h
  5. +4 −0 brushlib/mypaint-config.h.in
  6. +5 −0 brushlib/mypaint-tiled-surface.c
  7. +1 −0 brushlib/mypaint-tiled-surface.h
  8. +18 −0 brushlib/mypaint.c
  9. +7 −74 brushlib/operationqueue.c
  10. +1 −5 brushlib/operationqueue.h
  11. +87 −0 brushlib/tilemap.c
  12. +58 −0 brushlib/tilemap.h
  13. BIN glade/icons/hicolor/16x16/actions/widget-mypaint-topbar.png
  14. BIN glade/icons/hicolor/16x16/actions/widget-mypaint-workspace.png
  15. BIN glade/icons/hicolor/22x22/actions/widget-mypaint-topbar.png
  16. BIN glade/icons/hicolor/22x22/actions/widget-mypaint-workspace.png
  17. +145 −4 glade/mypaint_widgets.xml
  18. +28 −20 gui/application.py
  19. +54 −32 gui/backgroundwindow.py
  20. +4 −4 gui/brushmanager.py
  21. +10 −10 gui/brushselectionwindow.py
  22. +3 −3 gui/buttonmap.py
  23. +3 −3 gui/canvasevent.py
  24. +1 −1 gui/colorpicker.py
  25. +408 −245 gui/colors/adjbases.py
  26. +3 −3 gui/colors/combined.py
  27. +19 −17 gui/colors/hcywheel.py
  28. +7 −7 gui/colors/hsvcube.py
  29. +1 −1 gui/colors/hsvtriangle.py
  30. +2 −2 gui/colors/hsvwheel.py
  31. +16 −16 gui/colors/paletteview.py
  32. +1 −1 gui/colors/picker.py
  33. +12 −12 gui/colors/sliders.py
  34. +3 −3 gui/colorselectionwindow.py
  35. +5 −5 gui/cursor.py
  36. +21 −41 gui/curve.py
  37. +2 −2 gui/document.py
  38. +7 −82 gui/drawwindow.py
  39. +5 −5 gui/filehandling.py
  40. +17 −9 gui/framewindow.py
  41. +11 −5 gui/{pygtkcompat.py → gtk2compat.py}
  42. +1 −1 gui/gtkexcepthook.py
  43. +2 −2 gui/historypopup.py
  44. +5 −5 gui/inputtestwindow.py
  45. +6 −6 gui/keyboard.py
  46. +4 −4 gui/layerswindow.py
  47. +8 −8 gui/layout.py
  48. +2 −2 gui/linemode.py
  49. +4 −4 gui/main.py
  50. +0 −5 gui/menu.xml
  51. +70 −0 gui/mypaint.glade
  52. +18 −5 gui/overlays.py
  53. +2 −2 gui/pixbuflist.py
  54. +3 −1 gui/previewwindow.py
  55. +25 −37 gui/{mypaint.xml → resources.xml}
  56. +2 −2 gui/stategroup.py
  57. +180 −171 gui/tileddrawwidget.py
  58. +68 −57 gui/toolbar.py
  59. +133 −0 gui/topbar.py
  60. +1,983 −0 gui/workspace.py
  61. +1 −1 lib/layer.py
  62. +18 −1 lib/pixops.hpp
  63. +2 −18 lib/surface.hpp
  64. +2 −20 lib/tiledsurface.hpp
  65. +83 −30 lib/tiledsurface.py
  66. +2 −2 mypaint-gegl.py
  67. +1 −1 mypaint.py
  68. +1 −1 tests/guicontrol.py
  69. +1 −1 tests/test_mypaintlib.py
  70. +7 −4 tests/test_performance.py
View
@@ -45,7 +45,7 @@ Debian users can fetch these dependencies by running:
# apt-get install g++ python-dev python-numpy \
libgtk-3-dev python-gi-dev gir1.2-gtk-3.0 python-gi-cairo \
- swig scons gettext libpng12-dev liblcms2-dev
+ swig scons gettext libpng12-dev liblcms2-dev libjson0-dev
Recommended: a pressure sensitive input device (graphic tablet)
View
@@ -34,7 +34,7 @@ opts.Add(BoolVariable('enable_gegl', 'enable GEGL based code in build', False))
opts.Add(BoolVariable('enable_introspection', 'enable GObject introspection support', False))
opts.Add(BoolVariable('enable_docs', 'enable documentation build', False))
opts.Add(BoolVariable('enable_gperftools', 'enable gperftools in build, for profiling', False))
-opts.Add(BoolVariable('enable_openmp', 'enable OpenMP for libmypaint', False))
+opts.Add(BoolVariable('enable_openmp', 'enable OpenMP for multithreaded processing (on by default)', True))
opts.Add('python_binary', 'python executable to build for', default_python_binary)
opts.Add('python_config', 'python-config to used', default_python_config)
View
@@ -10,6 +10,7 @@
#include "operationqueue.c"
#include "rng-double.c"
#include "utils.c"
+#include "tilemap.c"
#include "mypaint.c"
#include "mypaint-brush.c"
@@ -5,6 +5,10 @@
#define MYPAINT_TILE_SIZE 64
#endif
+#ifndef MYPAINT_MAX_THREADS
+#define MYPAINT_MAX_THREADS 16
+#endif
+
// Start generated config
#define MYPAINT_CONFIG_USE_GLIB 0
@@ -5,6 +5,10 @@
#define MYPAINT_TILE_SIZE 64
#endif
+#ifndef MYPAINT_MAX_THREADS
+#define MYPAINT_MAX_THREADS 16
+#endif
+
// Start generated config
@DEFINES@
// End generated config
@@ -139,6 +139,11 @@ mypaint_tiled_surface_tile_request_init(MyPaintTiledSurfaceTileRequestData *data
data->readonly = readonly;
data->buffer = NULL;
data->context = NULL;
+#ifdef _OPENMP
+ data->thread_id = omp_get_thread_num();
+#else
+ data->thread_id = -1;
+#endif
}
// Must be threadsafe
@@ -16,6 +16,7 @@ typedef struct {
gboolean readonly;
guint16 *buffer;
gpointer context; /* Only to be used by the surface implemenations. */
+ int thread_id;
} MyPaintTiledSurfaceTileRequestData;
void
View
@@ -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
mypaint_init()
{
+ ensure_max_threads_not_exceeded();
//bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
}
View
@@ -22,14 +22,6 @@
#include "operationqueue.h"
#include "fifo.h"
-// 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 {
- Fifo **map;
- int size;
-} TileMap;
-
struct _OperationQueue {
TileMap *tile_map;
@@ -46,73 +38,14 @@ operation_delete_func(void *user_data) {
}
-TileMap *
-tile_map_new(int size)
-{
- TileMap *self = (TileMap *)malloc(sizeof(TileMap));
-
- self->size = size;
- const int map_size = 2*self->size*2*self->size;
- self->map = (Fifo **)malloc(map_size*sizeof(Fifo *));
- 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++) {
- Fifo *op_queue = self->map[i];
- if (op_queue) {
- fifo_free(op_queue, operation_delete_func);
- }
- }
- }
- 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 */
-Fifo **
-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);
- }
+free_fifo(void *item) {
+ Fifo *op_queue = item;
+ if (op_queue) {
+ fifo_free(op_queue, operation_delete_func);
}
}
-/* Must be reentrant and lock-free on different @index */
-static 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);
-}
-
gboolean
operation_queue_resize(OperationQueue *self, int new_size)
{
@@ -128,7 +61,7 @@ operation_queue_resize(OperationQueue *self, int new_size)
}
return TRUE;
} else {
- TileMap *new_tile_map = tile_map_new(new_size);
+ TileMap *new_tile_map = tile_map_new(new_size, sizeof(Fifo *), free_fifo);
const int new_map_size = new_size*2*new_size*2;
TileIndex *new_dirty_tiles = (TileIndex *)malloc(new_map_size*sizeof(TileIndex));
@@ -245,7 +178,7 @@ operation_queue_add(OperationQueue *self, TileIndex index, OperationDataDrawDab
#endif
}
- Fifo **queue_pointer = tile_map_get(self->tile_map, index);
+ Fifo **queue_pointer = (Fifo **)tile_map_get(self->tile_map, index);
Fifo *op_queue = *queue_pointer;
if (op_queue == NULL) {
@@ -279,7 +212,7 @@ operation_queue_pop(OperationQueue *self, TileIndex index)
return NULL;
}
- Fifo **queue_pointer = tile_map_get(self->tile_map, index);
+ Fifo **queue_pointer = (Fifo **)tile_map_get(self->tile_map, index);
Fifo *op_queue = *queue_pointer;
if (!op_queue) {
@@ -2,6 +2,7 @@
#define OPERATIONQUEUE_H
#include <stdint.h>
+#include "tilemap.h"
typedef struct {
float x;
@@ -20,11 +21,6 @@ typedef struct {
float colorize;
} OperationDataDrawDab;
-typedef struct {
- int x;
- int y;
-} TileIndex;
-
typedef struct _OperationQueue OperationQueue;
OperationQueue *operation_queue_new();
View
@@ -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);
+}
+
View
@@ -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.

0 comments on commit ab83301

Please sign in to comment.