No way to construct a SkM44
Describe the bug
SkM44 constructor takes no inputs. So I cannot construct 4x4 matrix to use in canvas.concat or canvas.setMatrix. The normal Matrix class is 3x3, but the Matrix state held by Skia is 4x4, so this design choice does not make much sense.
To Reproduce Steps to reproduce the behavior:
- Try constructing your own M44
Expected behavior I expect to make my own M44 given a 4x4 matrix
Both concat and setMatrix are overloaded and can take 3x3 or 4x4, I agree not having any 4x4 method is an oversight, though.
So how do I concat a 4x4 with the current bindings then?
I agree you cannot at the moment (i.e. next release). That said, as I said, both concat and setMatrix takes 3x3's and the 3x3 API is quite complete? Is there anything with 4x4 you can't do with 3x3 at the moment? If you have something specific in mind, I'll make sure to include it in the next update.
I am using skia-python to test out certain skia api level optimizations. This involves trying to redraw optimized skps using skia-python's api for testing correctness. At the skp level, all matrix operations reduce to concat44 and set44, so I atleast need to be able to construct 4x4 matrices and set them.
@bhargavkulk #339 should get you started - grab the wheel from the bottom of https://github.com/kyamagu/skia-python/actions/runs/15481893521 when it finishes building. The Rows/Cols methods take 4 V4 instances, the RowMajor/ColMajor method take a single tuple of 16 values, I think. (I have not bound a constructor taking 16 separate values, nor a coercion constructor from numpy arrays, for example - the former a bit tedious, the latter takes a bit of effort...) This is substantially incomplete, however (there is no viewer / getter methods, nor partial setters, nor tests) - you could work on a complete pull, if you want (a fair amount of somewhat tedious work...). I'd really think @pavpanchekha should commission / sponsor some of the work...
Thanks for getting started on this! I was going to try and add the constructor myself, but I was not able to get the wheel build to work.
The wheel building finished. You can cross reference the addition in #339 with https://api.skia.org/classSkM44.html - the pull currently have all the static member functions (including the Rows/Cols methods take 4 V4 instances, the RowMajor/ColMajor method take a single tuple of 16, that should be all you need) . I haven't bound any of the getters, getColMajor (we probably wants a different calling convention - where the results are returned, instead of we passing in an array to be filled as in the c++ case). Partial setters like setRC and setRow . And getter like rc . And tests and examples too. Add what you need.
@bhargavkulk I have added single element set/get https://github.com/kyamagu/skia-python/pull/339/commits/7338f0466bad582ab901bd907c75d6473c4a3a8c , and the tests to go with it https://github.com/kyamagu/skia-python/pull/339/commits/6d6bd1f57525265f665b4ad0e4303a72fed1062a . I think the corresponding older Matrix.rc method is probably lacking - SK_DEBUG is not defined, so it does not do bound checks.
The more "in front of you" way of building and testing skia-python is starting this line: https://github.com/kyamagu/skia-python/blob/17a97a0e547c42acac6d9d6e0ec91960685d89a9/.github/workflows/ci.yml#L201
(Replace the checkout action with git clone / git submodule update --init)
Add what you need to #339 for your work. It needs another 400 lines of tests before it can be merged. It is a good first issue to have a go yourself.