Fixed repaint issue

presentation
Andreas Butti 7 years ago
parent b708ca3755
commit 47296ea919
  1. 21
      src/control/tools/StrokeHandler.cpp
  2. 1
      src/control/tools/StrokeHandler.h
  3. 18
      src/gui/PageView.cpp
  4. 1
      src/gui/PageView.h
  5. 26
      src/gui/RepaintHandler.cpp

@ -42,7 +42,7 @@ void StrokeHandler::draw(cairo_t* cr)
view.applyColor(cr, stroke);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_mask_surface(cr, surfMask, visRect.x, visRect.y);
cairo_mask_surface(cr, surfMask, 0, 0);
}
bool StrokeHandler::onMotionNotifyEvent(const PositionInputData& pos)
@ -216,22 +216,12 @@ void StrokeHandler::onButtonPressEvent(const PositionInputData& pos)
destroySurface();
const double width = redrawable->getDisplayWidth();
const double height = redrawable->getDisplayHeight();
const double zoom = xournal->getZoom();
PageRef page = redrawable->getPage();
Rectangle *rectPtr = redrawable->getVisibleRect();
if (!rectPtr)
{
g_warning("Attempting to draw on an invisible surface");
return;
}
visRect = *(rectPtr);
delete rectPtr;
surfMask = cairo_image_surface_create(CAIRO_FORMAT_A8, visRect.width, visRect.height);
double width = page->getWidth() * zoom;
double height = page->getHeight() * zoom;
surfMask = cairo_image_surface_create(CAIRO_FORMAT_A8, width, height);
crMask = cairo_create(surfMask);
@ -242,7 +232,6 @@ void StrokeHandler::onButtonPressEvent(const PositionInputData& pos)
cairo_fill(crMask);
cairo_translate(crMask, -visRect.x, -visRect.y);
cairo_scale(crMask, zoom, zoom);
if (!stroke)

@ -62,7 +62,6 @@ private:
cairo_t* crMask;
DocumentView view;
Rectangle visRect;
ShapeRecognizer* reco;
};

@ -995,24 +995,6 @@ Text* XojPageView::getSelectedText()
return NULL;
}
Rectangle* XojPageView::getVisibleRect()
{
XOJ_CHECK_TYPE(XojPageView);
Rectangle* rect = xournal->getVisibleRect(this);
if (!rect)
{
return NULL;
}
(*rect) *= xournal->getZoom();
(*rect) = rect->translated(-getX(), -getY());
return rect;
}
Rectangle XojPageView::getRect()
{
XOJ_CHECK_TYPE(XojPageView);

@ -133,7 +133,6 @@ public:
TexImage* getSelectedTex();
Text* getSelectedText();
Rectangle* getVisibleRect();
Rectangle getRect();
public: // event handler

@ -25,30 +25,20 @@ void RepaintHandler::repaintPage(XojPageView* view)
{
XOJ_CHECK_TYPE(RepaintHandler);
// int x1 = view->getX();
// int y1 = view->getY();
// int x2 = x1 + view->getDisplayWidth();
// int y2 = y1 + view->getDisplayHeight();
// gtk_xournal_repaint_area(this->xournal->getWidget(), x1, y1, x2, y2);
// Repainting is really fast, and there are painting issues from time to time
// Therefore do always a full repaint. The stroken are cached anyway.
// Tested on a 1.8GHz Core2Duo
gtk_widget_queue_draw(this->xournal->getWidget());
int x1 = view->getX();
int y1 = view->getY();
int x2 = x1 + view->getDisplayWidth();
int y2 = y1 + view->getDisplayHeight();
gtk_xournal_repaint_area(this->xournal->getWidget(), x1, y1, x2, y2);
}
void RepaintHandler::repaintPageArea(XojPageView* view, int x1, int y1, int x2, int y2)
{
XOJ_CHECK_TYPE(RepaintHandler);
// int x = view->getX();
// int y = view->getY();
// gtk_xournal_repaint_area(this->xournal->getWidget(), x + x1, y + y1, x + x2, y + y2);
// Repainting is really fast, and there are painting issues from time to time
// Therefore do always a full repaint. The stroken are cached anyway.
// Tested on a 1.8GHz Core2Duo
gtk_widget_queue_draw(this->xournal->getWidget());
int x = view->getX();
int y = view->getY();
gtk_xournal_repaint_area(this->xournal->getWidget(), x + x1, y + y1, x + x2, y + y2);
}
void RepaintHandler::repaintPageBorder(XojPageView* view)

Loading…
Cancel
Save