*/}}

ourpaint.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. #define OUR_AT_CROP_CENTER 0
  29. #define OUR_AT_CROP_L 1
  30. #define OUR_AT_CROP_R 2
  31. #define OUR_AT_CROP_U 3
  32. #define OUR_AT_CROP_B 4
  33. #define OUR_AT_CROP_UL 5
  34. #define OUR_AT_CROP_UR 6
  35. #define OUR_AT_CROP_BL 7
  36. #define OUR_AT_CROP_BR 8
  37. #define OUR_VERSION_MAJOR 0
  38. #define OUR_VERSION_MINOR 1
  39. STRUCTURE(OurCanvasDraw){
  40. laCanvasExtra Base;
  41. int HideBrushCircle;
  42. int AtCrop;
  43. real CanvasLastX,CanvasLastY;
  44. real CanvasDownX,CanvasDownY;
  45. real LastPressure;
  46. real LastTilt[2];
  47. };
  48. #define OUR_TILE_W 1024
  49. #define OUR_TILES_PER_ROW 100
  50. #define OUR_TILE_CTR (OUR_TILES_PER_ROW/2)
  51. #define OUR_TILE_SEAM 12
  52. #define OUR_TILE_W_USE (OUR_TILE_W-OUR_TILE_SEAM*2)
  53. STRUCTURE(OurTexTile){
  54. tnsTexture* Texture;
  55. uint16_t* Data;
  56. int l,r,u,b;
  57. uint16_t* FullData;
  58. uint16_t* CopyBuffer;
  59. int cl,cr,cu,cb;
  60. };
  61. #define OUR_BLEND_NORMAL 0
  62. #define OUR_BLEND_ADD 1
  63. STRUCTURE(OurLayer){
  64. laListItem Item;
  65. laSafeString Name;
  66. int OffsetX,OffsetY;
  67. real Transparency;
  68. int Lock;
  69. int Hide;
  70. int BlendMode;
  71. OurTexTile** TexTiles[OUR_TILES_PER_ROW];
  72. };
  73. STRUCTURE(OurLayerWrite){
  74. unsigned char* data;
  75. size_t NextData, MaxData;
  76. };
  77. STRUCTURE(OurLayerRead){
  78. unsigned char* data;
  79. size_t NextData;
  80. };
  81. STRUCTURE(OurBrushSettingsNode){
  82. laBaseNode Base;
  83. laNodeOutSocket* CanvasScale; real rCanvasScale;
  84. laNodeOutSocket* Size; real rSize;
  85. laNodeOutSocket* Transparency; real rTransparency;
  86. laNodeOutSocket* Hardness; real rHardness;
  87. laNodeOutSocket* Smudge; real rSmudge;
  88. laNodeOutSocket* DabsPerSize; real rDabsPerSize;
  89. laNodeOutSocket* SmudgeLength; real rSmudgeLength;
  90. laNodeOutSocket* Slender; real rSlender;
  91. laNodeOutSocket* Angle; real rAngle;
  92. laNodeOutSocket* Color;
  93. };
  94. STRUCTURE(OurBrushOutputsNode){
  95. laBaseNode Base;
  96. laNodeInSocket* Offset;
  97. laNodeInSocket* Size;
  98. laNodeInSocket* Transparency;
  99. laNodeInSocket* Hardness;
  100. laNodeInSocket* Smudge;
  101. laNodeInSocket* DabsPerSize;
  102. laNodeInSocket* SmudgeLength;
  103. laNodeInSocket* Slender;
  104. laNodeInSocket* Angle;
  105. laNodeInSocket* Color;
  106. };
  107. STRUCTURE(OurBrushDeviceNode){
  108. laBaseNode Base;
  109. laNodeOutSocket* Pressure; real rPressure;
  110. laNodeOutSocket* Position; real rPosition[2];
  111. laNodeOutSocket* Tilt; real rTilt[2];
  112. laNodeOutSocket* IsEraser; int rIsEraser;
  113. laNodeOutSocket* Speed; real rSpeed;
  114. laNodeOutSocket* Angle; real rAngle;
  115. laNodeOutSocket* Length; real rLength;
  116. laNodeOutSocket* LengthAccum; real rLengthAccum;
  117. };
  118. STRUCTURE(OurBrush){
  119. laListItem Item;
  120. laSafeString Name;
  121. real Size;
  122. real DabsPerSize;
  123. real Hardness;
  124. real Transparency;
  125. real Smudge;
  126. real SmudgeResampleLength; real SmudgeAccum; int SmudgeRestart; real BrushRemainingDist;
  127. real Slender;
  128. real Angle;
  129. real Smoothness;
  130. real MaxStrokeLength;
  131. int PressureSize,PressureHardness,PressureTransparency,PressureSmudge; // the simple way
  132. int Binding,DefaultAsEraser;
  133. int UseNodes; // the flexible way
  134. laRackPage* Rack;
  135. real LastX,LastY,LastAngle;
  136. real EvalColor[3];
  137. real EvalOffset[2];
  138. real EvalSize;
  139. real EvalDabsPerSize;
  140. real EvalHardness;
  141. real EvalTransparency;
  142. real EvalSmudge;
  143. real EvalSmudgeLength;
  144. real EvalSlender;
  145. real EvalAngle;
  146. real EvalSpeed;
  147. real EvalStrokeLength;
  148. real EvalStrokeLengthAccum;
  149. real EvalPressure;
  150. real EvalPosition[2];
  151. real EvalTilt[2];
  152. real EvalStrokeAngle;
  153. int EvalIsEraser;
  154. };
  155. STRUCTURE(OurDab){
  156. float X,Y;
  157. float Size;
  158. float Hardness;
  159. float Smudge; int ResampleSmudge;
  160. float Color[4];
  161. float Slender;
  162. float Angle;
  163. float Recentness;
  164. };
  165. STRUCTURE(OurUndoTile){
  166. laListItem Item;
  167. int col,row;
  168. uint16_t* CopyData;
  169. int l,r,u,b;
  170. };
  171. STRUCTURE(OurUndo){
  172. OurLayer* Layer;
  173. laListHandle Tiles;
  174. };
  175. #define OUR_TOOL_PAINT 0
  176. #define OUR_TOOL_CROP 1
  177. #define OUR_PNG_READ_INPUT_FLAT 0
  178. #define OUR_PNG_READ_INPUT_ICC 1
  179. #define OUR_PNG_READ_INPUT_SRGB 2
  180. #define OUR_PNG_READ_INPUT_LINEAR_SRGB 3
  181. #define OUR_PNG_READ_INPUT_CLAY 4
  182. #define OUR_PNG_READ_INPUT_LINEAR_CLAY 5
  183. #define OUR_PNG_READ_OUTPUT_CANVAS 0
  184. #define OUR_PNG_READ_OUTPUT_LINEAR_SRGB OUR_PNG_READ_INPUT_LINEAR_SRGB
  185. #define OUR_PNG_READ_OUTPUT_LINEAR_CLAY OUR_PNG_READ_INPUT_LINEAR_CLAY
  186. #define OUR_CANVAS_INTERPRETATION_SRGB 0
  187. #define OUR_CANVAS_INTERPRETATION_CLAY 1
  188. #define OUR_EXPORT_BIT_DEPTH_8 0
  189. #define OUR_EXPORT_BIT_DEPTH_16 1
  190. #define OUR_EXPORT_COLOR_MODE_SRGB 0
  191. #define OUR_EXPORT_COLOR_MODE_CLAY 1
  192. #define OUR_EXPORT_COLOR_MODE_FLAT 2
  193. STRUCTURE(OurPNGReadExtra){
  194. int Confirming;
  195. laSafeString* FilePath;
  196. laSafeString* iccName;
  197. int HassRGB;
  198. int HasProfile;
  199. int InputMode;
  200. int OutputMode;
  201. };
  202. STRUCTURE(OurPNGWriteExtra){
  203. int Confirming;
  204. laSafeString* FilePath;
  205. int BitDepth;
  206. int ColorProfile;
  207. };
  208. STRUCTURE(OurPaint){
  209. real pad;
  210. laListHandle CanvasSaverDummyList;
  211. laProp* CanvasSaverDummyProp;
  212. tnsImage* SplashImage;
  213. tnsImage* SplashImageHigh;
  214. laListHandle Layers;
  215. OurLayer* CurrentLayer;
  216. laListHandle Brushes;
  217. OurBrush* CurrentBrush;
  218. OurDab* Dabs; int NextDab,MaxDab;
  219. laListHandle BrushEval;
  220. real CurrentScale;
  221. int Tool,ActiveTool,Erasing,EventErasing;
  222. int LockBackground;
  223. int PenID,EraserID;
  224. int X,Y,W,H; //border
  225. int ColorInterpretation;
  226. int ShowBorder,UseBorder;
  227. int ShowTiles;
  228. int LockRadius;
  229. int EnableBrushCircle;
  230. int DefaultBitDepth;
  231. int DefaultColorProfile;
  232. int PaintUndoLimit;
  233. tnsTexture* SmudgeTexture;
  234. GLuint CanvasShader; GLuint CanvasProgram;
  235. GLuint CompositionShader; GLuint CompositionProgram;
  236. GLint uBrushCorner;
  237. GLint uBrushCenter;
  238. GLint uBrushSize;
  239. GLint uBrushHardness;
  240. GLint uBrushSmudge;
  241. GLint uBrushRecentness;
  242. GLint uBrushColor;
  243. GLint uBrushSlender;
  244. GLint uBrushAngle;
  245. GLint uBrushRoutineSelection;
  246. GLint uBrushErasing;
  247. GLint RoutineDoDabs;
  248. GLint RoutineDoSample;
  249. GLint uBlendMode;
  250. GLint uAlphaTop;
  251. GLint uAlphaBottom;
  252. real CurrentColor[3];
  253. real BackgroundColor[3];
  254. uint16_t BColorU16[4];
  255. real BorderAlpha;
  256. real xmin,xmax,ymin,ymax; // stroke bbox for undo region
  257. int ResetBrush;
  258. uint16_t *ImageBuffer;
  259. int ImageW,ImageH,ImageX,ImageY,LoadX,LoadY,TempLoadX,TempLoadY;
  260. void* icc_LinearsRGB; int iccsize_LinearsRGB;
  261. void* icc_LinearClay; int iccsize_LinearClay;
  262. void* icc_sRGB; int iccsize_sRGB;
  263. void* icc_Clay; int iccsize_Clay;
  264. };
  265. int ourInit();
  266. void ourRegisterNodes();
  267. int ourRebuildBrushEval();
  268. int ourEvalBrush();
  269. void ourMakeTranslations();
  270. void our_EnableSplashPanel();