From 43665505e7f75cbacb303e542771507b58f1a12e Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 23 Nov 2017 16:07:25 +0100 Subject: First attempt at supporting HiDPI on canvas. Rendering seems to work but has not been fully tested. Editting does not work. --- src/display/drawing-item.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/display/drawing-item.cpp') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 43db4f259..a9408e4b0 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -667,7 +667,7 @@ struct MaskLuminanceToAlpha { /** * Rasterize items. - * This method submits the drawing opeartions required to draw this item + * This method submits the drawing operations required to draw this item * to the supplied DrawingContext, restricting drawing the specified area. * * This method does some common tasks and calls the item-specific rendering @@ -678,6 +678,15 @@ struct MaskLuminanceToAlpha { unsigned DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { + std::cout << "\nDrawingItem::render:" << std::endl; + std::cout << " area: " << area << std::endl; + if (_drawbox) + std::cout << " _drawbox: " << *_drawbox << std::endl; + else + std::cout << " No _drawbox" << std::endl; + std::cout << " Surface: width: " << cairo_image_surface_get_width(dc.rawTarget()) + << " height: " << cairo_image_surface_get_height(dc.rawTarget()) << std::endl; + bool outline = _drawing.outline(); bool render_filters = _drawing.renderFilters(); @@ -698,6 +707,11 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag // carea is the area to paint Geom::OptIntRect carea = Geom::intersect(area, _drawbox); if (!carea) return RENDER_OK; + std::cout << " carea: " << *carea << std::endl; + + // Device scale for HiDPI screens (either 1 or 2) + int device_scale = dc.surface()->device_scale(); + std::cout << "DrawingItem::render: device_scale: " << device_scale << std::endl; switch(_antialias){ case 0: @@ -731,7 +745,7 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag Geom::OptIntRect cl = _drawing.cacheLimit(); cl.intersectWith(_drawbox); if (cl) { - _cache = new DrawingCache(*cl); + _cache = new DrawingCache(*cl, device_scale); } } } else { @@ -770,6 +784,7 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag // filters and opacity do not apply when rendering the ancestors of the filtered // element if ((flags & RENDER_FILTER_BACKGROUND) || !needs_intermediate_rendering) { + std::cout << " short-circuit!" << std::endl; return _renderItem(dc, *carea, flags & ~RENDER_FILTER_BACKGROUND, stop_at); } @@ -785,7 +800,8 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag iarea.intersectWith(_drawbox); } - DrawingSurface intermediate(*iarea); + std::cout << " intermediate area required! Device scale: " << device_scale << std::endl; + DrawingSurface intermediate(*iarea, device_scale); DrawingContext ict(intermediate); unsigned render_result = RENDER_OK; @@ -832,7 +848,7 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag if (bg_root->_background_new) break; } if (bg_root) { - DrawingSurface bg(*iarea); + DrawingSurface bg(*iarea, device_scale); DrawingContext bgdc(bg); bg_root->render(bgdc, *iarea, flags | RENDER_FILTER_BACKGROUND, this); _filter->render(this, ict, &bgdc); @@ -854,6 +870,7 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag // 6. Paint the completed rendering onto the base context (or into cache) if (_cached && _cache) { + std::cout << " cache!!!!!!!!!!!!!!" << std::endl; DrawingContext cachect(*_cache); cachect.rectangle(*carea); cachect.setOperator(CAIRO_OPERATOR_SOURCE); -- cgit v1.2.3 From 2a6647cad9a24ed63e53a2d1ca12edaae5449b8a Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 24 Nov 2017 13:23:54 +0100 Subject: Remove debugging code and other cleanup. --- src/display/drawing-item.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src/display/drawing-item.cpp') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index a9408e4b0..cc4673bc8 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -678,15 +678,6 @@ struct MaskLuminanceToAlpha { unsigned DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { - std::cout << "\nDrawingItem::render:" << std::endl; - std::cout << " area: " << area << std::endl; - if (_drawbox) - std::cout << " _drawbox: " << *_drawbox << std::endl; - else - std::cout << " No _drawbox" << std::endl; - std::cout << " Surface: width: " << cairo_image_surface_get_width(dc.rawTarget()) - << " height: " << cairo_image_surface_get_height(dc.rawTarget()) << std::endl; - bool outline = _drawing.outline(); bool render_filters = _drawing.renderFilters(); @@ -707,11 +698,9 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag // carea is the area to paint Geom::OptIntRect carea = Geom::intersect(area, _drawbox); if (!carea) return RENDER_OK; - std::cout << " carea: " << *carea << std::endl; - // Device scale for HiDPI screens (either 1 or 2) + // Device scale for HiDPI screens (typically 1 or 2) int device_scale = dc.surface()->device_scale(); - std::cout << "DrawingItem::render: device_scale: " << device_scale << std::endl; switch(_antialias){ case 0: @@ -784,7 +773,6 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag // filters and opacity do not apply when rendering the ancestors of the filtered // element if ((flags & RENDER_FILTER_BACKGROUND) || !needs_intermediate_rendering) { - std::cout << " short-circuit!" << std::endl; return _renderItem(dc, *carea, flags & ~RENDER_FILTER_BACKGROUND, stop_at); } @@ -800,7 +788,6 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag iarea.intersectWith(_drawbox); } - std::cout << " intermediate area required! Device scale: " << device_scale << std::endl; DrawingSurface intermediate(*iarea, device_scale); DrawingContext ict(intermediate); unsigned render_result = RENDER_OK; @@ -870,7 +857,6 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag // 6. Paint the completed rendering onto the base context (or into cache) if (_cached && _cache) { - std::cout << " cache!!!!!!!!!!!!!!" << std::endl; DrawingContext cachect(*_cache); cachect.rectangle(*carea); cachect.setOperator(CAIRO_OPERATOR_SOURCE); -- cgit v1.2.3