*/}}

ourpaint.h 7.5 KB

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