📄 visualsurface2d_draw.c
字号:
/* * GPAC - Multimedia Framework C SDK * * Copyright (c) Jean Le Feuvre 2000-2005 * All rights reserved * * This file is part of GPAC / 2D rendering module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */#include "visualsurface2d.h"#include "drawable.h"#include "stacks2d.h"#include <gpac/options.h>//#define SKIP_DRAWGF_Err VS2D_InitSurface(VisualSurface2D *surf){ GF_Raster2D *r2d = surf->render->compositor->r2d; if (!surf->the_surface) { surf->the_surface = r2d->surface_new(r2d, surf->center_coords); if (!surf->the_surface) return GF_IO_ERR; } if (!surf->the_brush) { surf->the_brush = r2d->stencil_new(r2d, GF_STENCIL_SOLID); if (!surf->the_brush) return GF_IO_ERR; } if (!surf->the_pen) { surf->the_pen = r2d->stencil_new(r2d, GF_STENCIL_SOLID); if (!surf->the_pen) return GF_IO_ERR; } return surf->GetSurfaceAccess(surf);}void VS2D_TerminateSurface(VisualSurface2D *surf){ if (surf->the_surface) { if (surf->render->compositor->r2d->surface_flush) surf->render->compositor->r2d->surface_flush(surf->the_surface); surf->ReleaseSurfaceAccess(surf); }}void VS2D_ResetGraphics(VisualSurface2D *surf){ GF_Raster2D *r2d = surf->render->compositor->r2d; if (surf->the_surface) r2d->surface_delete(surf->the_surface); surf->the_surface = NULL; if (surf->the_brush) r2d->stencil_delete(surf->the_brush); surf->the_brush = NULL; if (surf->the_pen) r2d->stencil_delete(surf->the_pen); surf->the_pen = NULL;}void VS2D_Clear(VisualSurface2D *surf, GF_IRect *rc, u32 BackColor){#ifdef SKIP_DRAW return;#endif if (!surf->the_surface) return; if (!BackColor && !surf->composite) BackColor = surf->render->compositor->back_color; surf->render->compositor->r2d->surface_clear(surf->the_surface, rc, BackColor);}static void draw_clipper(VisualSurface2D *surf, struct _drawable_context *ctx){ GF_PenSettings clipset; GF_Path *clippath, *cliper; GF_Raster2D *r2d = surf->render->compositor->r2d; if (ctx->flags & CTX_IS_BACKGROUND) return; memset(&clipset, 0, sizeof(GF_PenSettings)); clipset.width = 2*FIX_ONE; clippath = gf_path_new(); gf_path_add_rect_center(clippath, ctx->bi->unclip.x + ctx->bi->unclip.width/2, ctx->bi->unclip.y - ctx->bi->unclip.height/2, ctx->bi->unclip.width, ctx->bi->unclip.height); cliper = gf_path_get_outline(clippath, clipset); gf_path_del(clippath); r2d->surface_set_matrix(surf->the_surface, NULL); r2d->surface_set_clipper(surf->the_surface, NULL); r2d->surface_set_path(surf->the_surface, cliper); r2d->stencil_set_brush_color(surf->the_pen, 0xFF000000); r2d->surface_fill(surf->the_surface, surf->the_pen); gf_path_del(cliper);}static void VS2D_DoFill(VisualSurface2D *surf, DrawableContext *ctx, GF_STENCIL stencil){ GF_IRect clip; GF_Raster2D *r2d = surf->render->compositor->r2d; /*background rendering - direct rendering: use ctx clip*/ if ((ctx->flags & CTX_IS_BACKGROUND) || (surf->render->top_effect->trav_flags & TF_RENDER_DIRECT)) { if (ctx->bi->clip.width && ctx->bi->clip.height) { r2d->surface_set_clipper(surf->the_surface, &ctx->bi->clip); r2d->surface_fill(surf->the_surface, stencil); } } /*indirect rendering, draw path in all dirty areas*/ else { u32 i; for (i=0; i<surf->to_redraw.count; i++) { /*there's an opaque region above, don't draw*/#ifdef TRACK_OPAQUE_REGIONS if (surf->draw_node_index<surf->to_redraw.opaque_node_index[i]) continue;#endif clip = ctx->bi->clip; gf_irect_intersect(&clip, &surf->to_redraw.list[i]); if (clip.width && clip.height) { r2d->surface_set_clipper(surf->the_surface, &clip); r2d->surface_fill(surf->the_surface, stencil);// } else {// fprintf(stdout, "node outside clipper\n"); } } }}void VS2D_SetOptions(Render2D *sr, GF_SURFACE rend, Bool forText, Bool no_antialias){ GF_Raster2D *r2d = sr->compositor->r2d; if (no_antialias) { r2d->surface_set_raster_level(rend, sr->compositor->high_speed ? GF_RASTER_HIGH_SPEED : GF_RASTER_MID); } else { switch (sr->compositor->antiAlias) { case GF_ANTIALIAS_NONE: r2d->surface_set_raster_level(rend, GF_RASTER_HIGH_SPEED); break; case GF_ANTIALIAS_TEXT: if (forText) { r2d->surface_set_raster_level(rend, GF_RASTER_HIGH_QUALITY); } else { r2d->surface_set_raster_level(rend, sr->compositor->high_speed ? GF_RASTER_HIGH_QUALITY : GF_RASTER_MID); } break; case GF_ANTIALIAS_FULL: default: r2d->surface_set_raster_level(rend, GF_RASTER_HIGH_QUALITY); break; } }}void get_gf_sr_texture_transform(GF_Node *__appear, GF_TextureHandler *txh, GF_Matrix2D *mat, Bool line_texture, Fixed final_width, Fixed final_height){ u32 node_tag; M_Appearance *appear; GF_Node *txtrans = NULL; gf_mx2d_init(*mat); if (!__appear || !txh) return; appear = (M_Appearance *)__appear; if (!line_texture) { if (!appear->textureTransform) return; txtrans = appear->textureTransform; } else { if (gf_node_get_tag(appear->material) != TAG_MPEG4_Material2D) return; if (gf_node_get_tag(((M_Material2D *)appear->material)->lineProps) != TAG_MPEG4_XLineProperties) return; txtrans = ((M_XLineProperties *) ((M_Material2D *)appear->material)->lineProps)->textureTransform; } if (!txtrans) return; /*gradient doesn't need bounds info in texture transform*/ if (txh->compute_gradient_matrix) { final_width = final_height = FIX_ONE; } node_tag = gf_node_get_tag(txtrans); if (node_tag==TAG_MPEG4_TextureTransform) { /*VRML: Tc' = -C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -