From ddff7455e7b19f16db6626c2610f17cd7eb6800a Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 16 Nov 2019 15:15:19 +0100 Subject: [PATCH] fix mixer clear residual data, reduce brush preview updates especially on gesture --- src/canvas.cpp | 2 +- src/canvas.h | 1 - src/canvas_modes.cpp | 4 ++-- src/node_panel_stroke.cpp | 14 +++++++------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/canvas.cpp b/src/canvas.cpp index ae19e80..59012c8 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -1259,6 +1259,7 @@ void Canvas::stroke_start(glm::vec3 point, float pressure) m_tmp_dual[i].unbindFramebuffer(); } } + m_mixer.clear(); m_show_tmp = true; } void Canvas::layer_add(std::string name, std::shared_ptr layer /*= nullptr*/, int index /*= 0*/) @@ -1670,7 +1671,6 @@ bool Canvas::create(int width, int height) m_plane.create<1>(1, 1); m_plane_brush.create<1>(1, 1); m_brush_shape.create(); - m_brush_mix.create(8, 8); for (auto& l : m_layers) l->create(width, height, ""); m_smask.create(width, height, "mask"); diff --git a/src/canvas.h b/src/canvas.h index a8d44a1..9a913cf 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -131,7 +131,6 @@ public: RTT m_tmp_dual[6]; RTT m_mixer; float m_mixer_scale = 1; - Texture2D m_brush_mix; Texture2D m_tex[6]; Texture2D m_tex2[6]; RTT m_merge_rtt; diff --git a/src/canvas_modes.cpp b/src/canvas_modes.cpp index 1a0fa72..63cfeb2 100644 --- a/src/canvas_modes.cpp +++ b/src/canvas_modes.cpp @@ -83,7 +83,7 @@ void CanvasModeBasicCamera::on_MouseEvent(MouseEvent* me, glm::vec2& loc) m_zoom_canvas += me->m_scroll_delta * 0.1f; Canvas::I->m_cam_fov = glm::clamp(Canvas::I->m_cam_fov - me->m_scroll_delta * 2.0f, Canvas::I->m_cam_fov_min, Canvas::I->m_cam_fov_max); - App::I->brush_update(true, true); + //App::I->brush_update(true, true); break; case kEventType::MouseCancel: m_draggingR = false; @@ -110,7 +110,7 @@ void CanvasModeBasicCamera::on_GestureEvent(GestureEvent* ge) Canvas::I->m_cam_fov_min, Canvas::I->m_cam_fov_max); auto angle = Canvas::I->m_pan * 0.003f; Canvas::I->m_cam_rot = glm::eulerAngleXY(angle.y, angle.x); - App::I->brush_update(true, true); + //App::I->brush_update(true, true); break; } default: diff --git a/src/node_panel_stroke.cpp b/src/node_panel_stroke.cpp index 84c8eb9..4febb70 100644 --- a/src/node_panel_stroke.cpp +++ b/src/node_panel_stroke.cpp @@ -206,7 +206,7 @@ void NodePanelStroke::init_controls() *Canvas::I->m_current_brush = *b; Canvas::I->m_current_brush->m_tip_color = old_color; Canvas::I->m_current_brush->load(); - m_preview->draw_stroke(); + //m_preview->draw_stroke(); m_brush_thumb->set_image(b->m_brush_thumb_path); m_dual_brush_thumb->set_image(b->m_dual_thumb_path); m_pattern_thumb->set_image(b->m_pattern_thumb_path); @@ -330,7 +330,7 @@ void NodePanelStroke::init_controls() m_blend_mode = find("blend-mode"); m_blend_mode->on_select = [this](Node*, int index) { Canvas::I->m_current_brush->m_blend_mode = index; - m_preview->draw_stroke(); + //m_preview->draw_stroke(); if (on_stroke_change) on_stroke_change(this); }; @@ -464,7 +464,7 @@ void NodePanelStroke::init_controls() m_tip_aspect_reset->on_click = [this](Node*) { m_tip_aspect->set_value(0.5); Canvas::I->m_current_brush->m_tip_aspect = 0.5f; - m_preview->draw_stroke(); + //m_preview->draw_stroke(); if (on_stroke_change) on_stroke_change(this); }; @@ -472,7 +472,7 @@ void NodePanelStroke::init_controls() m_dual_blend_mode = find("dual-blend-mode"); m_dual_blend_mode->on_select = [this](Node*, int index) { Canvas::I->m_current_brush->m_dual_blend_mode = index; - m_preview->draw_stroke(); + //m_preview->draw_stroke(); if (on_stroke_change) on_stroke_change(this); }; @@ -480,7 +480,7 @@ void NodePanelStroke::init_controls() m_pattern_blend_mode = find("pattern-blend-mode"); m_pattern_blend_mode->on_select = [this](Node*, int index) { Canvas::I->m_current_brush->m_pattern_blend_mode = index; - m_preview->draw_stroke(); + //m_preview->draw_stroke(); if (on_stroke_change) on_stroke_change(this); }; @@ -540,7 +540,7 @@ void NodePanelStroke::handle_slide(float Brush::* prop, Node* target, float valu { auto curve = m_curves.find((NodeSliderH*)target); Canvas::I->m_current_brush.get()->*prop = curve != m_curves.end() ? curve->second.to_value(value) : value; - m_preview->draw_stroke(); + //m_preview->draw_stroke(); if (on_stroke_change) on_stroke_change(this); } @@ -556,7 +556,7 @@ void NodePanelStroke::init_checkbox(NodeCheckBox*& target, const char* id, bool void NodePanelStroke::handle_checkbox(bool Brush::* prop, Node *target, bool value) { Canvas::I->m_current_brush.get()->*prop = value; - m_preview->draw_stroke(); + //m_preview->draw_stroke(); if (on_stroke_change) on_stroke_change(this); }