Commit Graph

82 Commits

Author SHA1 Message Date
David Capello 3c4d012210 [ci] Fix slow tests 2025-04-10 09:56:46 -03:00
David Capello 7fb8cfc8fa Avoid including image impl details as much as possible (image_impl/bits/iterator.h)
Including doc/image.h should be enough to access/iterate the image
pixels.
2024-12-19 09:44:37 -03:00
David Capello 09538f9a1a clang-format all files 2024-12-16 14:52:19 -03:00
David Capello 731e982a53 Update benchmark library
1) In benchmark docs it says that a range-based loop is preferred
instead of KeepRunning() call:

  https://github.com/google/benchmark/blob/main/docs/user_guide.md#a-faster-keeprunning-loop

2) Now we call benchmark::Shutdown() in editor/view benchmarks exit
2024-12-05 20:13:37 -03:00
Martín Capello ca75a98679 Add support to TilemapMode::Tiles mode
When transforming slices in a tilemap layer while Tiles mode is active
2024-08-29 15:24:48 -03:00
David Capello 577f50b713 Fix crashes using flood fill algorithm in a large canvas (fix #4481) 2024-05-23 10:56:05 -03:00
David Capello eafb779ef0 Possible fix to some RotSprite crashes (#2780) 2023-11-21 12:58:31 -03:00
David Capello 2406e2b197 Add FlipDiagonal algorithm 2023-08-09 16:12:02 -03:00
David Capello aeeef8e255 Add suppor for doc::Image row stride size > width size
This patch solves several problems introducing the possibility to
specify a row stride bigger than the width (visible pixels) on each
image row. Useful in case that we want to align the initial pixel
address of each row (if DOC_USE_ALIGNED_PIXELS is defined).

This allows us to use some SIMD intrinsics (e.g. SSE2) for some image
functions in the future (right now implemented only in the new
is_same_image_simd_templ() for is_same_image()).

Anyway to avoid breaking some existing code, by default we'll still
keep the old behavior: row stride bytes = width bytes (so
DOC_USE_ALIGNED_PIXELS is undefined).
2023-08-07 15:27:39 -03:00
David Capello 413288a014 Improve flip_image() performance (x10 from old impl, x2 from new slow impl)
The old impl was using get/put_pixel(), the new slow one is using the
get/put_pixel_fast(), and the new default flip_image() is using just
raw pointers.

Added some utilites like random_image() for testing purposes, and
DOC_DISPATCH_BY_COLOR_MODE() macros to avoid switch/case for each
color mode. In a future these might use generic lambdas.
2023-08-02 17:35:20 -03:00
Gaspar Capello 8f515da9f0 Fix 8 Connected Fill escapes grid with "Stop At Grid" checked (fix #3564) 2023-03-28 13:45:33 -03:00
David Capello 810aefaeab Add TODO note to improve shrink_bounds_templ() performance 2022-12-19 12:26:41 -03:00
David Capello a5ac9ada27 Merge branch 'main' into beta 2022-10-11 18:50:09 -03:00
Jeremy Behreandt 1133f4cc0f Floor Mod in Shift Image Mask
Changed shift image with mask routine to use floor modulo (or Euclidean remainder). Switched from two nested for loops to one for loop.

In response to bug report at https://community.aseprite.org/t/app-command-movemask-error-when-wrapping-with-a-value-higher-than-sprite-width/10437 .
2022-09-30 11:11:02 -03:00
David Capello 71b91cf6ed Merge branch 'main' into beta 2022-08-09 16:26:52 -03:00
Gaspar Capello add1128248 Fix RotSprite transparency bug (fix #3444) 2022-08-08 10:37:32 -03:00
David Capello b83f2953f9 Merge branch 'main' into beta 2021-06-11 16:36:57 -03:00
Gaspar Capello 1eace24891 Improve aspect of ellipses for 16x16 or bigger sizes (fix #2217)
Now algo_ellipse() function supports additional parameters to create
rounded squares in the future.
2021-06-11 14:47:23 -03:00
David Capello 0bca1de5c1 Add support to fill with tiles 2020-10-09 17:22:57 -03:00
David Capello b1c0d80356 Add support to clear/fill/stroke selections in tiles mode 2020-08-27 20:32:22 -03:00
David Capello 48d9e4c289 Fix compilation error in shrink_benchmark.cpp 2020-08-25 15:33:11 -03:00
David Capello 18759b1198 Avoid crash when shift a tilemap pixels (still not working, but at doesn't crash) 2020-08-24 12:24:08 -03:00
David Capello 2ffac6803c Merge branch 'beta' into tilemap-editor 2020-08-06 10:47:06 -03:00
David Capello cd21d33fe7 Add missing #includes 2020-08-03 17:19:23 -03:00
David Capello d0c95cf46f Add possibility to paint with tiles 2020-06-25 19:21:35 -03:00
David Capello a10efb187b Merge branch 'master' into tilemap-editor 2020-06-01 16:21:32 -03:00
David Capello 3163d00e1e Avoid multi-line comment warning 2020-05-22 11:14:48 -03:00
David Capello a80af2b304 Merge branch 'master' into tilemap-editor 2020-05-18 20:24:22 -03:00
David Capello 3b370c2ff5 Minor formatting changes 2020-04-22 20:20:04 -03:00
David Capello b628e21e76 Replace MIN/MAX() macros with std::min/max() functions 2020-04-08 12:20:53 -03:00
David Capello 53cabc3a1d Add minor asserts/comments 2020-02-17 09:06:01 -03:00
David Capello 26139c4ae2 Add tilemap layers (#977)
This is the first commit with a simple tilemap editor. Still buggy but
functional in several ways. Several changes were made:

* NewLayer command can receive a tilemap=true to create a new tilemap
  layer
* New ToggleTilesMode command added to switch between the palette and
  the tileset in the ColorBar (the ColorBar was expanded to show
  colors or tilesets with a generic AbstractPaletteViewAdapter)
* All commands to create new layers were moved to Layer >
  New... submenu
* There are a new tileset chunk to save tilesets in .aseprite files,
  and a new kind of cels to save tilemaps
* Added doc::LayerTilemap, doc::Tileset, etc. and several other types
  to handle tilesets/tilemaps in the doc layer.
* Added doc::Grid class with grid specifications that indicates how a
  tilemap <-> tileset must be drawn
* Added and expanded cel operations to work with tilemaps and
  conversions between regular LayerImage cels <-> LayerTilemap cels
  (e.g. copy cels in the timeline between layer types)
2020-02-17 09:06:00 -03:00
David Capello 8efb11915f Fix usage of freed memory after check_flood_line() returns true when 8-connectivity is used 2020-01-02 18:39:23 -03:00
David Capello 9c81ed46f2 Use threads in shrink_bounds() when it's possible
Improves the performance when we edit big images (shrink + crop +
image allocations are the performance issues we have when we're
editing big images).

The real solution for image allocations would be to change the
internal representation of images to a tile-based images with a cache
of tiles. But that is not planned in the short-term.
2019-08-21 20:21:57 -03:00
David Capello ad1a39714e [lua] Add Image:resize() function
Closes: https://community.aseprite.org/t/3633
2019-08-13 18:16:30 -03:00
Gaspar Capello 33dd70f89d Fix contour tool cannot draw only one pixel
The purpose of this fix is enable drawing of one pixel with contour
tool is active and we drag the cursor inside of the same
pixel (https://community.aseprite.org/t/3509).

Added 3 tests in polygon_tests.cpp to test polygon function when the
expected results is a simple pixel.
2019-07-12 14:41:48 -03:00
David Capello 3cd6fa2f08 Add missing #include <vector> for doc::algorithm::createUnion() 2019-06-06 10:14:12 -03:00
Gaspar Capello 2366bee6d4 Fix createUnion function and added createUnion tests
The purpose of this fix is that createUnion handles situations
which union results in contiguous segment collapses.
Added some treatments of eventual illogical inputs arguments like:
- pairs.size() < ints
- ints is 1
- ints is a odd number
Fixed treatment of some union cases like:
- x == pairs[i+1] + 1
- x == pairs[i+1]
Simplification of some vector::insert execution.
Added a bool return type to know if the function was
successfully executed when is called (used in tests).
We change the “static void createUnion(…)” to
“bool algorithm::createUnion(…)” to conditioning it to
future tests.
Added some comments modifications.
Added tests to polygon_tests.cpp
2019-06-05 15:19:32 -03:00
Gaspar Capello 81a355133d Add polygon tests 2019-06-04 12:14:20 -03:00
Gaspar Capello 8ae289d7e6 Fix createUnion internal function of polygon.cpp
Added special treatment in cases of horizontal lines which input
argument to createUnion is “ints == 0”.  Conditionals were sorted, it
was being generate extra scan segment pair next to pair in analysis,
instead of an augmentation of it.
2019-06-04 12:13:33 -03:00
David Capello 8aaf679406 Add missing <algorithm> header to use std::sort() 2019-05-31 14:10:56 -03:00
Gaspar Capello 8c55d34e32 Fix polygon rasterization
This fix is intended to create a polygon that matches with its preview
in one drawing step (needed when we want to draw with Contour or
Polygon tool with custom brushes with alpha content). Before this fix,
the polygon was being created in a first step, and then a second step
that patches the contour (over writing the Image with an extra
joinStroke execution of the entire contour).

- Added createUnion function in polygon.cpp to force drawing of the
  input points in each scan line render.
- Added algo_line_continuous inside polygon function to interpolate
  holes between input vertices.
- Deleted extra joinStroke execution in fillStroke function in class
  IntertwineAsLines and  class IntertwineAsPixelPerfect inside
  intertwines.h
- Added Stroke::erase function to Stroke class. It is needed inside
  IntertwineAsPixelPerfect class to get a clear m_pts (without the
  extra points due to mini L shapes, due to pixel perfect process). In
  fillStroke function in class  IntertwineAsPixelPerfect inside
  intertwiners.h, when it  executed, m_pts is delivered to polygon
  function instead of stroke argument in order to pass a pixel perfect
  processed vector instead of stroke vector which is a raw vector of
  vertices.
2019-05-31 13:02:22 -03:00
rscotchmer a08cfa9e13 Added support for 4 and 8 connected pixel fill method in paint bucket 2019-04-29 23:29:17 -03:00
David Capello 7d8e493dca Fix crash undoing Edit > Shift (regression from 1c05ea10bb) 2019-03-23 11:44:38 -03:00
Gaspar Capello 1c05ea10bb Fix shift after flip throws error (fix #1873) 2019-02-15 11:18:14 -03:00
David Capello f2ed45e795 Replace base::UniquePtr -> std::unique_ptr 2018-08-08 17:27:26 -03:00
David Capello 96ca735ed5 Add command to Stroke the selection bounds w/the foreground color 2018-05-30 18:05:18 -03:00
David Capello 0f51467768 Fix my common typo "completelly" instead of "completely" 2018-05-24 14:21:00 -03:00
David Capello 288b9aa8f9 Pass srcColor as argument to floodfill() 2017-06-15 15:24:27 -03:00
David Capello cc7bde6cd1 Fix some compiler warnings (implicit casts & unused vars) 2017-04-19 19:26:23 -03:00