rasterizer_canvas_gles2.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*************************************************************************/
  2. /* rasterizer_canvas_gles2.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef RASTERIZERCANVASGLES2_H
  31. #define RASTERIZERCANVASGLES2_H
  32. #include "drivers/gles_common/rasterizer_canvas_batcher.h"
  33. #include "rasterizer_canvas_base_gles2.h"
  34. class RasterizerSceneGLES2;
  35. class RasterizerCanvasGLES2 : public RasterizerCanvasBaseGLES2, public RasterizerCanvasBatcher<RasterizerCanvasGLES2, RasterizerStorageGLES2> {
  36. friend class RasterizerCanvasBatcher<RasterizerCanvasGLES2, RasterizerStorageGLES2>;
  37. public:
  38. virtual void canvas_render_items_begin(const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform);
  39. virtual void canvas_render_items_end();
  40. virtual void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform);
  41. virtual void canvas_begin();
  42. virtual void canvas_end();
  43. private:
  44. // legacy codepath .. to remove after testing
  45. void _legacy_canvas_render_item(Item *p_ci, RenderItemState &r_ris);
  46. // high level batch funcs
  47. void canvas_render_items_implementation(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform);
  48. void render_joined_item(const BItemJoined &p_bij, RenderItemState &r_ris);
  49. bool try_join_item(Item *p_ci, RenderItemState &r_ris, bool &r_batch_break);
  50. void render_batches(Item *p_current_clip, bool &r_reclip, RasterizerStorageGLES2::Material *p_material);
  51. // low level batch funcs
  52. void _batch_upload_buffers();
  53. void _batch_render_generic(const Batch &p_batch, RasterizerStorageGLES2::Material *p_material);
  54. void _batch_render_lines(const Batch &p_batch, RasterizerStorageGLES2::Material *p_material, bool p_anti_alias);
  55. // funcs used from rasterizer_canvas_batcher template
  56. void gl_enable_scissor(int p_x, int p_y, int p_width, int p_height) const;
  57. void gl_disable_scissor() const;
  58. public:
  59. void initialize();
  60. RasterizerCanvasGLES2();
  61. };
  62. #endif // RASTERIZERCANVASGLES2_H