📄 cairo-directfb-surface.c
字号:
D_DEBUG_AT (Cairo_DirectFB, "Running TileBlit().\n"); RUN_CLIPPED( dst, &clip, dst->buffer->TileBlit (dst->buffer, src->buffer, &sr, dst_x, dst_y)); ret = CAIRO_STATUS_SUCCESS; } } else if (src_attr.extend == CAIRO_EXTEND_NONE && cairo_matrix_invert (m) == CAIRO_STATUS_SUCCESS) { DFBAccelerationMask accel; /* Yet I don't fully understand what these src_x/src_y mean. * It seems they are X11 specific, so I ignore them for now. */ src_x = src_y = 0; dst->buffer->GetAccelerationMask (dst->buffer, src->buffer, &accel); if (m->xy != 0.0 || m->yx != 0.0) { if (accel & DFXL_TEXTRIANGLES) { DFBVertex v[4]; float w, h; float x1, y1, x2, y2; int i; w = MAX (src->width, 8); h = MAX (src->height, 8); x1 = src_x + src_attr.x_offset; y1 = src_y + src_attr.y_offset; x2 = src->width - x1; y2 = src->height - y1; v[0].x = x1; v[0].y = y1; v[0].s = x1/w; v[0].t = y1/h; v[1].x = x2; v[1].y = y1; v[1].s = x2/w; v[1].t = y1/h; v[2].x = x2; v[2].y = y2; v[2].s = x2/w; v[2].t = y2/h; v[3].x = x1; v[3].y = y2; v[3].s = x1/w; v[3].t = y2/h; for (i = 0; i < 4; i++) { TRANSFORM_POINT (m, v[i].x, v[i].y, v[i].x, v[i].y); v[i].z = 0; v[i].w = 1; } D_DEBUG_AT (Cairo_DirectFB, "Running TextureTriangles().\n"); RUN_CLIPPED (dst, NULL, dst->buffer->TextureTriangles (dst->buffer, src->buffer, v, NULL, 4, DTTF_FAN)); ret = CAIRO_STATUS_SUCCESS; } } else { if (accel & DFXL_STRETCHBLIT || src_attr.filter == CAIRO_FILTER_NEAREST) { DFBRectangle sr, dr; double x1, y1, x2, y2; sr.x = src_x + src_attr.x_offset; sr.y = src_y + src_attr.y_offset; sr.w = src->width - sr.x; sr.h = src->height - sr.y; TRANSFORM_POINT (m, sr.x, sr.y, x1, y1); TRANSFORM_POINT (m, sr.x+sr.w, sr.y+sr.h, x2, y2); dr.x = floor (x1+.5); dr.y = floor (y1+.5); dr.w = floor (x2-x1+.5); dr.h = floor (y2-y1+.5); D_DEBUG_AT (Cairo_DirectFB, "Running StretchBlit().\n"); RUN_CLIPPED (dst, NULL, dst->buffer->StretchBlit (dst->buffer, src->buffer, &sr, &dr)); ret = CAIRO_STATUS_SUCCESS; } } } _directfb_finish_composite (dst, src_pattern, &src->base, &src_attr); return ret;}#endif /* DFB_COMPOSITE */static cairo_int_status_t_cairo_directfb_surface_fill_rectangles (void *abstract_surface, cairo_operator_t op, const cairo_color_t *color, cairo_rectangle_int16_t *rects, int n_rects){ cairo_directfb_surface_t *dst = abstract_surface; cairo_status_t ret; DFBSurfaceDrawingFlags flags; DFBSurfaceBlendFunction sblend; DFBSurfaceBlendFunction dblend; DFBRectangle r[n_rects]; int i; D_DEBUG_AT (Cairo_DirectFB, "%s( dst=%p, op=%d, color=%p, rects=%p, n_rects=%d ).\n", __FUNCTION__, dst, op, color, rects, n_rects); if (_directfb_get_operator (op, &flags, NULL, &sblend, &dblend)) return CAIRO_INT_STATUS_UNSUPPORTED; ret = _directfb_acquire_surface (dst, 0); if (ret) return ret; dst->buffer->SetDrawingFlags (dst->buffer, flags); if (flags & DSDRAW_BLEND) { dst->buffer->SetSrcBlendFunction (dst->buffer, sblend); dst->buffer->SetDstBlendFunction (dst->buffer, dblend); } dst->buffer->SetColor (dst->buffer, color->red_short >> 8, color->green_short >> 8, color->blue_short >> 8, color->alpha_short >> 8 ); for (i = 0; i < n_rects; i++) { r[i].x = rects[i].x; r[i].y = rects[i].y; r[i].w = rects[i].width; r[i].h = rects[i].height; } RUN_CLIPPED (dst, NULL, dst->buffer->FillRectangles (dst->buffer, r, n_rects)); return CAIRO_STATUS_SUCCESS;}#if DFB_COMPOSITE_TRAPEZOIDSstatic cairo_int_status_t_cairo_directfb_surface_composite_trapezoids (cairo_operator_t op, cairo_pattern_t *pattern, void *abstract_dst, cairo_antialias_t antialias, int src_x, int src_y, int dst_x, int dst_y, unsigned int width, unsigned int height, cairo_trapezoid_t *traps, int num_traps ){ cairo_directfb_surface_t *dst = abstract_dst; cairo_directfb_surface_t *src; cairo_surface_attributes_t src_attr; cairo_status_t ret; DFBAccelerationMask accel; D_DEBUG_AT (Cairo_DirectFB, "%s( op=%d, pattern=%p, dst=%p, antialias=%d," " src_x=%d, src_y=%d, dst_x=%d, dst_y=%d," " width=%u, height=%u, traps=%p, num_traps=%d ).\n", __FUNCTION__, op, pattern, dst, antialias, src_x, src_y, dst_x, dst_y, width, height, traps, num_traps); if (antialias != CAIRO_ANTIALIAS_NONE) return CAIRO_INT_STATUS_UNSUPPORTED; /* Textures are not supported yet. */ if (pattern->type != CAIRO_PATTERN_TYPE_SOLID) return CAIRO_INT_STATUS_UNSUPPORTED; ret = _directfb_prepare_composite (dst, pattern, NULL, op, &src_x, &src_y, NULL, NULL, width, height, &src, &src_attr); if (ret) return ret; dst->buffer->GetAccelerationMask (dst->buffer, src->buffer, &accel); ret = CAIRO_INT_STATUS_UNSUPPORTED; if (accel & DFXL_TEXTRIANGLES) { DFBVertex vertex[6*num_traps]; DFBVertex *v = &vertex[0]; int n; #define ADD_TRI(id, x1, y1, s1, t1, x2, y2, s2, t2, x3, y3, s3, t3) {\ const int p = (id)*3;\ v[p+0].x=(x1); v[p+0].y=(y1); v[p+0].z=0; v[p+0].w=1; v[p+0].s=(s1); v[p+0].t=(t1);\ v[p+1].x=(x2); v[p+1].y=(y2); v[p+1].z=0; v[p+1].w=1; v[p+1].s=(s2); v[p+1].t=(t2);\ v[p+2].x=(x3); v[p+2].y=(y3); v[p+2].z=0; v[p+2].w=1; v[p+2].s=(s3); v[p+2].t=(t3);\} for (n = 0; num_traps; num_traps--) { float lx1, ly1, lx2, ly2; float rx1, ry1, rx2, ry2; /* XXX: Do we need to validate the trapezoid? */ lx1 = traps->left.p1.x/65536.0; ly1 = traps->left.p1.y/65536.0; lx2 = traps->left.p2.x/65536.0; ly2 = traps->left.p2.y/65536.0; rx1 = traps->right.p1.x/65536.0; ry1 = traps->right.p1.y/65536.0; rx2 = traps->right.p2.x/65536.0; ry2 = traps->right.p2.y/65536.0; if (traps->left.p1.y < traps->top) { float y = traps->top/65536.0; if (lx2 != lx1) lx1 = (y - ly1) * (lx2 - lx1) / (ly2 - ly1) + lx1; ly1 = y; } if (traps->left.p2.y > traps->bottom) { float y = traps->bottom/65536.0; if (lx2 != lx1) lx2 = (y - ly1) * (lx2 - lx1) / (ly2 - ly1) + lx1; ly2 = y; } if (traps->right.p1.y < traps->top) { float y = traps->top/65536.0; if (rx2 != rx1) rx1 = (y - ry1) * (rx2 - rx1) / (ry2 - ry1) + rx1; ry1 = y; } if (traps->right.p2.y > traps->bottom) { float y = traps->bottom/65536.0; if (rx2 != rx1) rx2 = (y - ry1) * (rx2 - rx1) / (ry2 - ry1) + rx1; ry2 = y; } if (lx1 == rx1 && ly1 == ry1) { ADD_TRI (0, lx2, ly2, 0, 0, lx1, ly1, 0, 0, rx2, ry2, 0, 0 ); v += 3; n += 3; } else if (lx2 == rx2 && ly2 == ry2) { ADD_TRI (0, lx1, ly1, 0, 0, lx2, ly2, 0, 0, rx1, ry1, 0, 0 ); v += 3; n += 3; } else { ADD_TRI (0, lx1, ly1, 0, 0, rx1, ry1, 0, 0, lx2, ly2, 0, 0); ADD_TRI (1, lx2, ly2, 0, 0, rx1, ry1, 0, 0, rx2, ry2, 0, 0); v += 6; n += 6; } traps++; } #undef ADD_TRI D_DEBUG_AT (Cairo_DirectFB, "Running TextureTriangles().\n"); RUN_CLIPPED (dst, NULL, dst->buffer->TextureTriangles (dst->buffer, src->buffer, vertex, NULL, n, DTTF_LIST)); ret = CAIRO_STATUS_SUCCESS; } _directfb_finish_composite (dst, pattern, &src->base, &src_attr); return ret;}#endif /* DFB_COMPOSITE_TRAPEZOIDS */static cairo_int_status_t_cairo_directfb_surface_set_clip_region (void *abstract_surface, pixman_region16_t *region){ cairo_directfb_surface_t *surface = abstract_surface; D_DEBUG_AT (Cairo_DirectFB, "%s( surface=%p, region=%p ).\n", __FUNCTION__, surface, region); if (region) { pixman_box16_t *boxes = pixman_region_rects (region); int n_boxes = pixman_region_num_rects (region); int i; if (surface->n_clips != n_boxes) { free (surface->clips); surface->clips = malloc (n_boxes * sizeof(DFBRegion)); if (!surface->clips) { surface->n_clips = 0; return CAIRO_STATUS_NO_MEMORY; } surface->n_clips = n_boxes; } for (i = 0; i < n_boxes; i++) { surface->clips[i].x1 = boxes[i].x1; surface->clips[i].y1 = boxes[i].y1; surface->clips[i].x2 = boxes[i].x2; surface->clips[i].y2 = boxes[i].y2; } } else { if (surface->clips) { free (surface->clips); surface->clips = NULL; surface->n_clips = 0; } } return CAIRO_STATUS_SUCCESS;}static cairo_int_status_t_cairo_directfb_abstract_surface_get_extents (void *abstract_surface, cairo_rectangle_int16_t *rectangle){ cairo_directfb_surface_t *surface = abstract_surface; D_DEBUG_AT (Cairo_DirectFB, "%s( surface=%p, rectangle=%p ).\n", __FUNCTION__, surface, rectangle); if (rectangle) { rectangle->x = 0; rectangle->y = 0; rectangle->width = surface->width; rectangle->height = surface->height; } return CAIRO_STATUS_SUCCESS;}static cairo_status_t_cairo_directfb_surface_mark_dirty_rectangle (void *abstract_surface, int x, int y, int width, int height){ cairo_directfb_surface_t *surface = abstract_surface; D_DEBUG_AT (Cairo_DirectFB, "%s( surface=%p, x=%d, y=%d, width=%d, height=%d ).\n", __FUNCTION__, surface, x, y, width, height); if (surface->surface != surface->buffer) { DFBRegion region = { x1:x, y1:y, x2:x+width-1, y2:y+height-1 }; surface->buffer->SetClip (surface->buffer, ®ion); surface->buffer->SetBlittingFlags (surface->buffer, DSBLIT_NOFX); surface->buffer->Blit (surface->buffer, surface->surface, NULL, 0, 0); } return CAIRO_STATUS_SUCCESS;}static cairo_status_t _cairo_directfb_surface_flush (void *abstract_surface){ cairo_directfb_surface_t *surface = abstract_surface; D_DEBUG_AT (Cairo_DirectFB, "%s( surface=%p ).\n", __FUNCTION__, surface); if (surface->surface != surface->buffer) { surface->surface->SetClip (surface->surface, NULL); surface->surface->SetBlittingFlags (surface->surface, DSBLIT_NOFX); surface->surface->Blit (surface->surface, surface->buffer, NULL, 0, 0); } return CAIRO_STATUS_SUCCESS;}#if DFB_SHOW_GLYPHSstatic cairo_directfb_font_cache_t*_directfb_allocate_font_cache (IDirectFB *dfb, int width, int height){ cairo_directfb_font_cache_t *cache; cache = calloc (1, sizeof(cairo_directfb_font_cache_t)); if (!cache) return NULL; cache->buffer = _directfb_buffer_surface_create( dfb, DSPF_A8, width, height); if (!cache->buffer) { free (cache); return NULL; } dfb->AddRef (dfb);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -