static GeglBuffer * gimp_projection_get_buffer (GimpPickable *pickable) { GimpProjection *proj = GIMP_PROJECTION (pickable); if (! proj->buffer) { TileManager *tiles = gimp_projection_get_tiles_at_level (proj, 0, NULL); const Babl *format = gimp_projection_get_format (pickable); proj->buffer = gimp_tile_manager_create_buffer (tiles, format); if (proj->sink_node) { gegl_node_set (proj->sink_node, "buffer", proj->buffer, NULL); } } return proj->buffer; }
void gimp_display_shell_render (GimpDisplayShell *shell, gint x, gint y, gint w, gint h, GdkRectangle *highlight) { GimpProjection *projection; GimpImage *image; RenderInfo info; GimpImageType type; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); g_return_if_fail (w > 0 && h > 0); image = shell->display->image; projection = image->projection; /* Initialize RenderInfo with values that don't change during the * call of this function. */ info.shell = shell; info.x = x + shell->offset_x; info.y = y + shell->offset_y; info.w = w; info.h = h; info.dest_bpp = 3; info.dest_bpl = info.dest_bpp * GIMP_RENDER_BUF_WIDTH; info.dest_width = info.dest_bpp * info.w; switch (GIMP_DISPLAY_CONFIG (image->gimp->config)->zoom_quality) { case GIMP_ZOOM_QUALITY_LOW: info.zoom_quality = GIMP_DISPLAY_ZOOM_FAST; break; case GIMP_ZOOM_QUALITY_HIGH: info.zoom_quality = GIMP_DISPLAY_ZOOM_PIXEL_AA; break; } if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_projection_get_image_type (projection))) { gdouble opacity = gimp_projection_get_opacity (projection); info.alpha = render_image_init_alpha (opacity * 255.999); } /* Setup RenderInfo for rendering a GimpProjection level. */ { TileManager *src_tiles; gint level; level = gimp_projection_get_level (projection, shell->scale_x, shell->scale_y); src_tiles = gimp_projection_get_tiles_at_level (projection, level); gimp_display_shell_render_info_scale (&info, shell, src_tiles, level); } /* Currently, only RGBA and GRAYA projection types are used. */ type = gimp_projection_get_image_type (projection); switch (type) { case GIMP_RGBA_IMAGE: render_image_rgb_a (&info); break; case GIMP_GRAYA_IMAGE: render_image_gray_a (&info); break; default: g_warning ("%s: unsupported projection type (%d)", G_STRFUNC, type); g_assert_not_reached (); } /* apply filters to the rendered projection */ if (shell->filter_stack) gimp_color_display_stack_convert (shell->filter_stack, shell->render_buf, w, h, 3, 3 * GIMP_RENDER_BUF_WIDTH); /* dim pixels outside the highlighted rectangle */ if (highlight) { gimp_display_shell_render_highlight (shell, x, y, w, h, highlight); } else if (shell->mask) { TileManager *src_tiles = gimp_drawable_get_tiles (shell->mask); /* The mask does not (yet) have an image pyramid, use 0 as level, */ gimp_display_shell_render_info_scale (&info, shell, src_tiles, 0); gimp_display_shell_render_mask (shell, &info); } /* put it to the screen */ gimp_canvas_draw_rgb (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_RENDER, x + shell->disp_xoffset, y + shell->disp_yoffset, w, h, shell->render_buf, 3 * GIMP_RENDER_BUF_WIDTH, shell->offset_x, shell->offset_y); }