*/}}

ourpaint.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. /*
  2. * Our Paint: A light weight GPU powered painting program.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "la_5.h"
  19. #ifndef OURPAINT_GIT_BRANCH
  20. #define OURPAINT_GIT_BRANCH "Release 1"
  21. #endif
  22. // No need to show hash when not compiled from git repo.
  23. //#ifndef OURPAINT_GIT_HASH
  24. //#define OURPAINT_GIT_HASH "?"
  25. //#endif
  26. extern unsigned char DATA_SPLASH[];
  27. extern unsigned char DATA_SPLASH_HIGHDPI[];
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. extern const char OUR_CANVAS_SHADER[];
  32. extern const char OUR_COMPOSITION_SHADER[];
  33. #ifdef __cplusplus
  34. } // extern "C"
  35. #endif
  36. #define OUR_AT_CROP_CENTER 0
  37. #define OUR_AT_CROP_L 1
  38. #define OUR_AT_CROP_R 2
  39. #define OUR_AT_CROP_U 3
  40. #define OUR_AT_CROP_B 4
  41. #define OUR_AT_CROP_UL 5
  42. #define OUR_AT_CROP_UR 6
  43. #define OUR_AT_CROP_BL 7
  44. #define OUR_AT_CROP_BR 8
  45. #define OUR_VERSION_MAJOR 0
  46. #define OUR_VERSION_MINOR 2
  47. #define OUR_VERSION_SUB 1
  48. #define OUR_PAINT_NAME_STRING "Our Paint v0.2"
  49. #define OUR_SIGNAL_PICK 1
  50. #define OUR_SIGNAL_MOVE 2
  51. #define OUR_SIGNAL_PICK 3
  52. #define OUR_SIGNAL_TOGGLE_ERASING 4
  53. #define OUR_SIGNAL_ZOOM_IN 5
  54. #define OUR_SIGNAL_ZOOM_OUT 6
  55. #define OUR_SIGNAL_BRUSH_BIGGER 7
  56. #define OUR_SIGNAL_BRUSH_SMALLER 8
  57. #define OUR_SIGNAL_TOGGLE_SKETCH 9
  58. STRUCTURE(OurCanvasDraw){
  59. laCanvasExtra Base;
  60. int HideBrushCircle;
  61. int AtCrop;
  62. real CanvasLastX,CanvasLastY;
  63. real CanvasDownX,CanvasDownY;
  64. real PointerX,PointerY,DownTilt;
  65. real LastPressure;
  66. real LastTilt[2];
  67. real LastTwist;
  68. int MovedX,MovedY;
  69. };
  70. #define OUR_DPC (600*0.3937007874)
  71. #define OUR_TILE_W 1024
  72. #define OUR_TILES_PER_ROW 100
  73. #define OUR_TILE_CTR (OUR_TILES_PER_ROW/2)
  74. #define OUR_TILE_SEAM 12
  75. #define OUR_TILE_W_USE (OUR_TILE_W-OUR_TILE_SEAM*2)
  76. STRUCTURE(OurTexTile){
  77. tnsTexture* Texture;
  78. uint16_t* Data;
  79. int l,r,u,b;
  80. uint16_t* FullData;
  81. uint16_t* CopyBuffer;
  82. int cl,cr,cu,cb;
  83. };
  84. #define OUR_BLEND_NORMAL 0
  85. #define OUR_BLEND_ADD 1
  86. STRUCTURE(OurLayer){
  87. laListItem Item;
  88. laSafeString* Name;
  89. int OffsetX,OffsetY;
  90. real Transparency;
  91. int Lock;
  92. int Hide;
  93. int BlendMode;
  94. int AsSketch;
  95. OurTexTile** TexTiles[OUR_TILES_PER_ROW];
  96. };
  97. STRUCTURE(OurLayerWrite){
  98. unsigned char* data;
  99. size_t NextData, MaxData;
  100. };
  101. STRUCTURE(OurLayerRead){
  102. unsigned char* data;
  103. size_t NextData;
  104. };
  105. STRUCTURE(OurBrushSettingsNode){
  106. laBaseNode Base;
  107. laNodeOutSocket* CanvasScale; real rCanvasScale;
  108. laNodeOutSocket* Size; real rSize;
  109. laNodeOutSocket* Transparency; real rTransparency;
  110. laNodeOutSocket* Hardness; real rHardness;
  111. laNodeOutSocket* Smudge; real rSmudge;
  112. laNodeOutSocket* DabsPerSize; real rDabsPerSize;
  113. laNodeOutSocket* SmudgeLength; real rSmudgeLength;
  114. laNodeOutSocket* Slender; real rSlender;
  115. laNodeOutSocket* Angle; real rAngle;
  116. laNodeOutSocket* Gunkyness; real rGunkyness;
  117. laNodeOutSocket* Force; real rForce;
  118. laNodeOutSocket* Color;
  119. laNodeOutSocket* Iteration; int rIteration;
  120. laNodeOutSocket* Custom1; real rCustom1;
  121. laNodeOutSocket* Custom2; real rCustom2;
  122. };
  123. STRUCTURE(OurBrushOutputsNode){
  124. laBaseNode Base;
  125. laNodeInSocket* Offset;
  126. laNodeInSocket* Size;
  127. laNodeInSocket* Transparency;
  128. laNodeInSocket* Hardness;
  129. laNodeInSocket* Smudge;
  130. laNodeInSocket* DabsPerSize;
  131. laNodeInSocket* SmudgeLength;
  132. laNodeInSocket* Slender;
  133. laNodeInSocket* Angle;
  134. laNodeInSocket* Color;
  135. laNodeInSocket* Gunkyness;
  136. laNodeInSocket* Force;
  137. laNodeInSocket* Repeats;
  138. laNodeInSocket* Discard;
  139. };
  140. STRUCTURE(OurBrushDeviceNode){
  141. laBaseNode Base;
  142. laNodeOutSocket* Pressure; real rPressure;
  143. laNodeOutSocket* Position; real rPosition[2];
  144. laNodeOutSocket* Tilt; real rTilt[2];
  145. laNodeOutSocket* Twist; real rTwist;
  146. laNodeOutSocket* IsEraser; int rIsEraser;
  147. laNodeOutSocket* Speed; real rSpeed;
  148. laNodeOutSocket* Angle; real rAngle;
  149. laNodeOutSocket* Length; real rLength;
  150. laNodeOutSocket* LengthAccum; real rLengthAccum;
  151. };
  152. STRUCTURE(OurBrush){
  153. laListItem Item;
  154. laSafeString* Name;
  155. real Size;
  156. real DabsPerSize;
  157. real Hardness;
  158. real Transparency;
  159. real Smudge;
  160. real SmudgeResampleLength; real SmudgeAccum; int SmudgeRestart; real BrushRemainingDist;
  161. real Slender;
  162. real Angle;
  163. real Force, Gunkyness;
  164. real Smoothness;
  165. real MaxStrokeLength;
  166. real Custom1,Custom2; laSafeString *Custom1Name,*Custom2Name;
  167. int Iteration;
  168. int PressureSize,PressureHardness,PressureTransparency,PressureSmudge,PressureForce,TwistAngle; // the simple way
  169. int Binding,DefaultAsEraser;
  170. int ShowInPages;
  171. real VisualOffset;
  172. real VisualOffsetAngle;
  173. int16_t OffsetFollowPenTilt;
  174. int16_t UseNodes; // the flexible way
  175. laRackPage* Rack;
  176. real LastX,LastY,LastAngle;
  177. real EvalColor[3];
  178. real EvalOffset[2];
  179. real EvalSize;
  180. real EvalDabsPerSize;
  181. real EvalHardness;
  182. real EvalTransparency;
  183. real EvalSmudge;
  184. real EvalSmudgeLength;
  185. real EvalSlender;
  186. real EvalAngle;
  187. real EvalForce, EvalGunkyness;
  188. real EvalSpeed;
  189. real EvalStrokeLength;
  190. real EvalStrokeLengthAccum;
  191. real EvalPressure;
  192. real EvalPosition[2];
  193. real EvalTilt[2];
  194. real EvalTwist;
  195. real EvalStrokeAngle;
  196. int EvalIsEraser;
  197. int EvalRepeats;
  198. int EvalDiscard;
  199. };
  200. STRUCTURE(OurDab){
  201. float X,Y;
  202. float Size;
  203. float Hardness;
  204. float Smudge; int ResampleSmudge;
  205. float Color[4];
  206. float Slender;
  207. float Angle;
  208. float Direction[2];
  209. float Force;
  210. float Gunkyness;
  211. float Recentness;
  212. };
  213. NEED_STRUCTURE(OurColorPallette);
  214. STRUCTURE(OurColorItem){
  215. laListItem Item;
  216. tnsVector3d Color;
  217. OurColorPallette* Parent;
  218. };
  219. STRUCTURE(OurColorPallette){
  220. laListItem Item;
  221. laSafeString* Name;
  222. laListHandle Colors;
  223. };
  224. STRUCTURE(OurUndoTile){
  225. laListItem Item;
  226. int col,row;
  227. uint16_t* CopyData;
  228. int l,r,u,b;
  229. };
  230. STRUCTURE(OurUndo){
  231. OurLayer* Layer;
  232. laListHandle Tiles;
  233. };
  234. STRUCTURE(OurMoveUndo){
  235. OurLayer* Layer;
  236. int dx,dy;
  237. };
  238. #define OUR_TOOL_PAINT 0
  239. #define OUR_TOOL_CROP 1
  240. #define OUR_TOOL_MOVE 2
  241. #define OUR_PNG_READ_INPUT_FLAT 0
  242. #define OUR_PNG_READ_INPUT_ICC 1
  243. #define OUR_PNG_READ_INPUT_SRGB 2
  244. #define OUR_PNG_READ_INPUT_LINEAR_SRGB 3
  245. #define OUR_PNG_READ_INPUT_CLAY 4
  246. #define OUR_PNG_READ_INPUT_LINEAR_CLAY 5
  247. #define OUR_PNG_READ_OUTPUT_CANVAS 0
  248. #define OUR_PNG_READ_OUTPUT_LINEAR_SRGB OUR_PNG_READ_INPUT_LINEAR_SRGB
  249. #define OUR_PNG_READ_OUTPUT_LINEAR_CLAY OUR_PNG_READ_INPUT_LINEAR_CLAY
  250. #define OUR_CANVAS_INTERPRETATION_SRGB 0
  251. #define OUR_CANVAS_INTERPRETATION_CLAY 1
  252. #define OUR_EXPORT_BIT_DEPTH_8 0
  253. #define OUR_EXPORT_BIT_DEPTH_16 1
  254. #define OUR_EXPORT_COLOR_MODE_SRGB 0
  255. #define OUR_EXPORT_COLOR_MODE_CLAY 1
  256. #define OUR_EXPORT_COLOR_MODE_FLAT 2
  257. #define OUR_BRUSH_PAGE_LIST 128
  258. STRUCTURE(OurPNGReadExtra){
  259. int Confirming;
  260. laSafeString* FilePath;
  261. laSafeString* iccName;
  262. int HassRGB;
  263. int HasProfile;
  264. int InputMode;
  265. int OutputMode;
  266. int Offsets[2];
  267. };
  268. STRUCTURE(OurPNGWriteExtra){
  269. int Confirming;
  270. laSafeString* FilePath;
  271. int BitDepth;
  272. int ColorProfile;
  273. };
  274. STRUCTURE(OurPaint){
  275. real pad;
  276. laListHandle CanvasSaverDummyList;
  277. laProp* CanvasSaverDummyProp;
  278. laListHandle BadEvents;
  279. tnsImage* SplashImage;
  280. tnsImage* SplashImageHigh;
  281. laListHandle Pallettes;
  282. OurColorPallette* CurrentPallette;
  283. laListHandle Layers;
  284. OurLayer* CurrentLayer;
  285. laListHandle Brushes;
  286. OurBrush* CurrentBrush;
  287. real SaveBrushSize,SaveEraserSize;
  288. OurDab* Dabs; int NextDab,MaxDab;
  289. float LastBrushCenter[2];
  290. int CanvasVersion;
  291. laSafeString* Notes;
  292. real Smoothness;
  293. real LastX, LastY;
  294. real CurrentScale;
  295. real DefaultScale;
  296. int BrushPage;
  297. int Tool,ActiveTool,Erasing,EventErasing;
  298. int LockBackground;
  299. int BackgroundType;
  300. int BackgroundRandom;
  301. real BackgroundFactor;
  302. int PenID,EraserID;
  303. int X,Y,W,H; //border
  304. int ColorInterpretation;
  305. int ShowBorder,UseBorder;
  306. int ShowTiles;
  307. int AllowNonPressure,PaintProcessedEvents;
  308. int BadEventsLimit,BadEventCount,BadEventsGiveUp;
  309. int LockRadius;
  310. int EnableBrushCircle,ShowBrushName; int EventHasTwist; real EventTwistAngle;
  311. int DefaultBitDepth;
  312. int DefaultColorProfile;
  313. int PaintUndoLimit;
  314. int SpectralMode;
  315. int SketchMode;
  316. tnsTexture* SmudgeTexture;
  317. GLuint CanvasShader; GLuint CanvasProgram;
  318. GLuint CompositionShader; GLuint CompositionProgram;
  319. GLint uCanvasType;
  320. GLint uCanvasRandom;
  321. GLint uCanvasFactor;
  322. GLint uImageOffset;
  323. GLint uBrushCorner;
  324. GLint uBrushCenter;
  325. GLint uBrushSize;
  326. GLint uBrushHardness;
  327. GLint uBrushSmudge;
  328. GLint uBrushRecentness;
  329. GLint uBrushColor;
  330. GLint uBrushSlender;
  331. GLint uBrushAngle;
  332. GLint uBrushDirection;
  333. GLint uBrushForce;
  334. GLint uBrushGunkyness;
  335. GLint uBrushRoutineSelection;
  336. GLint uMixRoutineSelection;
  337. GLint uBrushErasing;
  338. GLint RoutineDoDabs;
  339. GLint RoutineDoSample;
  340. GLint RoutineDoMixNormal;
  341. GLint RoutineDoMixSpectral;
  342. GLint uBlendMode;
  343. GLint uAlphaTop;
  344. GLint uAlphaBottom;
  345. real CurrentColor[3];
  346. real BackgroundColor[3];
  347. uint16_t BColorU16[4];
  348. uint8_t BColorU8[4];
  349. real BorderAlpha;
  350. int ShowStripes;
  351. int ShowRef;
  352. int RefSize;
  353. int RefCategory;
  354. int RefOrientation;
  355. real RefMargins[3],RefPaddings[2];
  356. int RefBiases[2];
  357. real RefAlpha;
  358. real xmin,xmax,ymin,ymax; // stroke bbox for undo region
  359. int ResetBrush;
  360. uint16_t *ImageBuffer;
  361. int ImageW,ImageH,ImageX,ImageY,LoadX,LoadY,TempLoadX,TempLoadY;
  362. uint8_t* ThumbnailBuffer;
  363. void* icc_LinearsRGB; int iccsize_LinearsRGB;
  364. void* icc_LinearClay; int iccsize_LinearClay;
  365. void* icc_sRGB; int iccsize_sRGB;
  366. void* icc_Clay; int iccsize_Clay;
  367. };
  368. int ourProcessInitArgs(int argc, char* argv[]);
  369. int ourInit();
  370. void ourRegisterNodes();
  371. int ourRebuildBrushEval();
  372. int ourEvalBrush();
  373. void ourMakeTranslations();
  374. void our_EnableSplashPanel();