*/}}

ourpaint.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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. int Transparent;
  274. };
  275. STRUCTURE(OurPaint){
  276. real pad;
  277. laListHandle CanvasSaverDummyList;
  278. laProp* CanvasSaverDummyProp;
  279. laListHandle BadEvents;
  280. tnsImage* SplashImage;
  281. tnsImage* SplashImageHigh;
  282. laListHandle Pallettes;
  283. OurColorPallette* CurrentPallette;
  284. laListHandle Layers;
  285. OurLayer* CurrentLayer;
  286. laListHandle Brushes;
  287. OurBrush* CurrentBrush;
  288. real SaveBrushSize,SaveEraserSize;
  289. OurDab* Dabs; int NextDab,MaxDab;
  290. float LastBrushCenter[2];
  291. int CanvasVersion;
  292. laSafeString* Notes;
  293. real Smoothness;
  294. real LastX, LastY;
  295. real CurrentScale;
  296. real DefaultScale;
  297. int BrushPage;
  298. int Tool,ActiveTool,Erasing,EventErasing,BrushMix;
  299. int LockBackground;
  300. int BackgroundType;
  301. int BackgroundRandom;
  302. real BackgroundFactor;
  303. int PenID,EraserID;
  304. int X,Y,W,H; //border
  305. int ColorInterpretation;
  306. int ShowBorder,UseBorder;
  307. int ShowTiles;
  308. int AllowNonPressure,PaintProcessedEvents;
  309. int BadEventsLimit,BadEventCount,BadEventsGiveUp;
  310. int LockRadius;
  311. int EnableBrushCircle,ShowBrushName; int EventHasTwist; real EventTwistAngle;
  312. int DefaultBitDepth;
  313. int DefaultColorProfile;
  314. int PaintUndoLimit;
  315. int SpectralMode;
  316. int SketchMode;
  317. tnsTexture* SmudgeTexture;
  318. GLuint CanvasShader; GLuint CanvasProgram;
  319. GLuint CompositionShader; GLuint CompositionProgram;
  320. GLint uCanvasType;
  321. GLint uCanvasRandom;
  322. GLint uCanvasFactor;
  323. GLint uImageOffset;
  324. GLint uBrushCorner;
  325. GLint uBrushCenter;
  326. GLint uBrushSize;
  327. GLint uBrushHardness;
  328. GLint uBrushSmudge;
  329. GLint uBrushRecentness;
  330. GLint uBrushColor;
  331. GLint uBrushSlender;
  332. GLint uBrushAngle;
  333. GLint uBrushDirection;
  334. GLint uBrushForce;
  335. GLint uBrushGunkyness;
  336. GLint uBrushRoutineSelection;
  337. GLint uMixRoutineSelection;
  338. GLint uBrushErasing;
  339. GLint uBrushMix;
  340. GLint RoutineDoDabs;
  341. GLint RoutineDoSample;
  342. GLint RoutineDoMixNormal;
  343. GLint RoutineDoMixSpectral;
  344. GLint uBlendMode;
  345. GLint uAlphaTop;
  346. GLint uAlphaBottom;
  347. real CurrentColor[3];
  348. real BackgroundColor[3];
  349. uint16_t BColorU16[4];
  350. uint8_t BColorU8[4];
  351. real BorderAlpha;
  352. int ShowStripes;
  353. int ShowGrid;
  354. int ShowRef;
  355. int RefSize;
  356. int RefCategory;
  357. int RefOrientation;
  358. int RefCutHalf;
  359. real RefMargins[3],RefPaddings[2];
  360. int RefBiases[2];
  361. real RefAlpha;
  362. real xmin,xmax,ymin,ymax; // stroke bbox for undo region
  363. int ResetBrush;
  364. int SaveFailed;
  365. uint16_t *ImageBuffer;
  366. int ImageW,ImageH,ImageX,ImageY,LoadX,LoadY,TempLoadX,TempLoadY;
  367. uint8_t* ThumbnailBuffer;
  368. void* icc_LinearsRGB; int iccsize_LinearsRGB;
  369. void* icc_LinearClay; int iccsize_LinearClay;
  370. void* icc_sRGB; int iccsize_sRGB;
  371. void* icc_Clay; int iccsize_Clay;
  372. };
  373. int ourProcessInitArgs(int argc, char* argv[]);
  374. int ourInit();
  375. void ourRegisterNodes();
  376. int ourRebuildBrushEval();
  377. int ourEvalBrush();
  378. void ourMakeTranslations();
  379. void our_EnableSplashPanel();