*/}}

ourpaint.h 8.5 KB

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