本文整理汇总了C++中DocumentView::drawPage方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentView::drawPage方法的具体用法?C++ DocumentView::drawPage怎么用?C++ DocumentView::drawPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentView
的用法示例。
在下文中一共展示了DocumentView::drawPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rerenderRectangle
void RenderJob::rerenderRectangle(RenderJob * renderJob, Rectangle * rect) {
XOJ_CHECK_TYPE_OBJ(renderJob, RenderJob);
PageView * view = renderJob->view;
double zoom = view->xournal->getZoom();
Document * doc = view->xournal->getDocument();
doc->lock();
double pageWidth = view->page.getWidth();
double pageHeight = view->page.getHeight();
doc->unlock();
int x = rect->x * zoom;
int y = rect->y * zoom;
int width = rect->width * zoom;
int height = rect->height * zoom;
cairo_surface_t * rectBuffer = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t * crRect = cairo_create(rectBuffer);
cairo_translate(crRect, -x, -y);
cairo_scale(crRect, zoom, zoom);
DocumentView v;
v.limitArea(rect->x, rect->y, rect->width, rect->height);
if (view->page.getBackgroundType() == BACKGROUND_TYPE_PDF) {
int pgNo = view->page.getPdfPageNr();
XojPopplerPage * popplerPage = doc->getPdfPage(pgNo);
PdfCache * cache = view->xournal->getCache();
PdfView::drawPage(cache, popplerPage, crRect, zoom, pageWidth, pageHeight);
}
doc->lock();
v.drawPage(view->page, crRect, false);
doc->unlock();
cairo_destroy(crRect);
g_mutex_lock(view->drawingMutex);
cairo_t * crPageBuffer = cairo_create(view->crBuffer);
cairo_set_operator(crPageBuffer, CAIRO_OPERATOR_SOURCE);
cairo_set_source_surface(crPageBuffer, rectBuffer, x, y);
cairo_rectangle(crPageBuffer, x, y, width, height);
cairo_fill(crPageBuffer);
cairo_destroy(crPageBuffer);
cairo_surface_destroy(rectBuffer);
g_mutex_unlock(view->drawingMutex);
}
示例2: run
void PreviewJob::run() {
XOJ_CHECK_TYPE(PreviewJob);
GtkAllocation alloc;
gtk_widget_get_allocation(this->sidebarPreview->widget, &alloc);
cairo_surface_t * crBuffer = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, alloc.width, alloc.height);
double zoom = this->sidebarPreview->sidebar->getZoom();
cairo_t * cr2 = cairo_create(crBuffer);
cairo_matrix_t defaultMatrix = { 0 };
cairo_get_matrix(cr2, &defaultMatrix);
cairo_translate(cr2, Shadow::getShadowTopLeftSize() + 2, Shadow::getShadowTopLeftSize() + 2);
cairo_scale(cr2, zoom, zoom);
Document * doc = this->sidebarPreview->sidebar->getControl()->getDocument();
doc->lock();
if (this->sidebarPreview->page.getBackgroundType() == BACKGROUND_TYPE_PDF) {
int pgNo = this->sidebarPreview->page.getPdfPageNr();
XojPopplerPage * popplerPage = doc->getPdfPage(pgNo);
PdfView::drawPage(this->sidebarPreview->sidebar->getCache(), popplerPage, cr2, zoom, this->sidebarPreview->page.getWidth(), this->sidebarPreview->page.getHeight());
}
DocumentView view;
view.drawPage(this->sidebarPreview->page, cr2, true);
cairo_set_matrix(cr2, &defaultMatrix);
cairo_set_operator(cr2, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgb(cr2, 1, 1, 1);
cairo_rectangle(cr2, 0, 0, Shadow::getShadowTopLeftSize() + 2, alloc.height);
cairo_rectangle(cr2, 0, 0, alloc.height, Shadow::getShadowTopLeftSize() + 2);
cairo_rectangle(cr2, alloc.width - Shadow::getShadowBottomRightSize() - 2, 0, Shadow::getShadowBottomRightSize() + 2, alloc.height);
cairo_rectangle(cr2, 0, alloc.height - Shadow::getShadowBottomRightSize() - 2, alloc.width, Shadow::getShadowBottomRightSize() + 2);
cairo_fill(cr2);
cairo_destroy(cr2);
doc->unlock();
g_mutex_lock(this->sidebarPreview->drawingMutex);
if (this->sidebarPreview->crBuffer) {
cairo_surface_destroy(this->sidebarPreview->crBuffer);
}
this->sidebarPreview->crBuffer = crBuffer;
gdk_threads_enter();
gtk_widget_queue_draw(this->sidebarPreview->widget);
gdk_threads_leave();
g_mutex_unlock(this->sidebarPreview->drawingMutex);
}
示例3: run
void RenderJob::run() {
XOJ_CHECK_TYPE(RenderJob);
if(handler == NULL) {
handler = new RepaintWidgetHandler(this->view->getXournal()->getWidget());
}
double zoom = this->view->xournal->getZoom();
g_mutex_lock(this->view->repaintRectMutex);
bool rerenderComplete = this->view->rerenderComplete;
GList * rerenderRects = this->view->rerenderRects;
this->view->rerenderRects = NULL;
this->view->rerenderComplete = false;
g_mutex_unlock(this->view->repaintRectMutex);
if (rerenderComplete) {
Document * doc = this->view->xournal->getDocument();
int dispWidth = this->view->getDisplayWidth();
int dispHeight = this->view->getDisplayHeight();
cairo_surface_t * crBuffer = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, dispWidth, dispHeight);
cairo_t * cr2 = cairo_create(crBuffer);
cairo_scale(cr2, zoom, zoom);
XojPopplerPage * popplerPage = NULL;
doc->lock();
if (this->view->page.getBackgroundType() == BACKGROUND_TYPE_PDF) {
int pgNo = this->view->page.getPdfPageNr();
popplerPage = doc->getPdfPage(pgNo);
}
DocumentView view;
int width = this->view->page.getWidth();
int height = this->view->page.getHeight();
PdfView::drawPage(this->view->xournal->getCache(), popplerPage, cr2, zoom, width, height);
view.drawPage(this->view->page, cr2, false);
cairo_destroy(cr2);
g_mutex_lock(this->view->drawingMutex);
if (this->view->crBuffer) {
cairo_surface_destroy(this->view->crBuffer);
}
this->view->crBuffer = crBuffer;
g_mutex_unlock(this->view->drawingMutex);
doc->unlock();
handler->repaintComplete();
} else {
for (GList * l = rerenderRects; l != NULL; l = l->next) {
Rectangle * rect = (Rectangle *) l->data;
rerenderRectangle(rect);
rect = this->view->rectOnWidget(rect->x, rect->y, rect->width, rect->height);
handler->repaintRects(rect);
}
}
// delete all rectangles
for (GList * l = rerenderRects; l != NULL; l = l->next) {
Rectangle * rect = (Rectangle *) l->data;
delete rect;
}
g_list_free(rerenderRects);
}