IMEditCoreContext.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * ImageMeter confidential
  3. *
  4. * Copyright (C) 2018-2019 by Dirk Farin, Kronenstr. 49b, 70174 Stuttgart, Germany
  5. * All Rights Reserved.
  6. *
  7. * NOTICE: All information contained herein is, and remains the property
  8. * of Dirk Farin. The intellectual and technical concepts contained
  9. * herein are proprietary to Dirk Farin and are protected by trade secret
  10. * and copyright law.
  11. * Dissemination of this information or reproduction of this material
  12. * is strictly forbidden unless prior written permission is obtained
  13. * from Dirk Farin.
  14. */
  15. #ifndef IMAGEMETER_IMEDITCORECONTEXT_H
  16. #define IMAGEMETER_IMEDITCORECONTEXT_H
  17. #include "IMError.h"
  18. #include "IMEditCore.h"
  19. #include <stdbool.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. struct IM_EditCoreContext;
  24. // from Geometry.h
  25. enum IM_ImageFitMode
  26. {
  27. IM_ImageFitMode_Fit = 0, // fit image into screen to be completely visible
  28. IM_ImageFitMode_Fill = 1, // fill screen completely (extending beyond borders)
  29. IM_ImageFitMode_GeometricMean = 2 // compromise between Fit and Fill (neither too small, nor too big)
  30. };
  31. // If nRenderingThreads==0, rendering has to be carried out manually
  32. struct IM_EditCoreContext* IM_EditCoreContext_alloc(bool interactive,
  33. int nRenderingThreads);
  34. void IM_EditCoreContext_release(struct IM_EditCoreContext*);
  35. void IM_EditCoreContext_add_font(struct IM_EditCoreContext*, const char* fontFile);
  36. //void add_font(const std::vector<uint8_t>& fontData);
  37. void IM_EditCoreContext_set_EditCoreUIControl(struct IM_EditCoreContext*, struct IM_EditCoreUIControl*);
  38. //struct IM_Result* load_from_bundle(const std::shared_ptr<DataBundleCPP>& bundle);
  39. struct IM_Error* IM_EditCoreContext_load_from_bundle_directory(struct IM_EditCoreContext*,
  40. const char* bundleDirectory);
  41. //IMResult<void> load_from_imm_file(Path bundleDirectory,
  42. // const std::shared_ptr<IMMFile>& imm);
  43. enum IM_IMMLoadingState
  44. {
  45. IM_IMMLoadingState_NotLoaded = 0,
  46. IM_IMMLoadingState_LoadingError = 1,
  47. IM_IMMLoadingState_LoadedIncompletely = 2, // some GElements could not be loaded. Ok for read-only, but do not overwrite.
  48. IM_IMMLoadingState_Loaded = 3
  49. };
  50. enum IM_IMMLoadingState IM_EditCoreContext_get_imm_loading_state(struct IM_EditCoreContext*);
  51. bool IM_EditCoreContext_ready_to_initialize_openGL(struct IM_EditCoreContext*);
  52. // returns true if the IMM has changed
  53. //bool prepare_imm_for_saving();
  54. //IMResult<void> restore_imm_to_stored_state();
  55. // result.throws<IMError_DataBundle_CannotWriteIMM>();
  56. //IMResult<void> save_to_bundle_directory();
  57. // TODO: set a state whether loading the IMM failed / failed a bit / succeeded
  58. // --- access to objects managed by the context
  59. //std::shared_ptr<IMMFile> get_IMM_file();
  60. struct IM_EditCore* IM_EditCoreContext_get_EditCore(struct IM_EditCoreContext*);
  61. //std::shared_ptr<GLBackgroundImage> get_BackgroundImage() { return mBkgImage; }
  62. //std::shared_ptr<EditCoreGraphics_OpenGLES2> get_EditCoreGraphics()
  63. //std::shared_ptr<DataBundleCPP> get_data_bundle() { return mDataBundle; }
  64. // --- drawing
  65. // These functions (except render()) have to be called on the OpenGL thread
  66. struct IM_Error* IM_EditCoreContext_load_auxiliary_files(struct IM_EditCoreContext*);
  67. struct IM_Error* IM_EditCoreContext_init_OpenGL_resources(struct IM_EditCoreContext*);
  68. void IM_EditCoreContext_set_OpenGL_viewport(struct IM_EditCoreContext*,
  69. int viewport_width,
  70. int viewport_height,
  71. float density_dpi);
  72. void IM_EditCoreContext_set_displayTransform(struct IM_EditCoreContext*,
  73. enum IM_ImageFitMode mode, bool flipV);
  74. //void set_displayTransform(AffineTransform transform);
  75. //bool is_display_transform_set() const { return mDisplayTransformSet; }
  76. void IM_EditCoreContext_free_OpenGL_resources(struct IM_EditCoreContext*);
  77. // Manually render the scene before drawing. Only needed when there are no rendering threads.
  78. //void render();
  79. //void wait_until_rendering_is_finished();
  80. void IM_EditCoreContext_draw_to_OpenGL(struct IM_EditCoreContext*);
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif //IMAGEMETER_IMEDITCORECONTEXT_H