Path: blob/21.2-virgl/src/gallium/auxiliary/vl/vl_compositor.h
4565 views
/**************************************************************************1*2* Copyright 2009 Younes Manton.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef vl_compositor_h28#define vl_compositor_h2930#include "pipe/p_state.h"31#include "pipe/p_video_codec.h"32#include "pipe/p_video_state.h"3334#include "util/u_rect.h"3536#include "vl_types.h"37#include "vl_csc.h"3839struct pipe_context;4041/**42* composing and displaying of image data43*/4445#define VL_COMPOSITOR_MAX_LAYERS 1646#define VL_COMPOSITOR_MIN_DIRTY (0)47#define VL_COMPOSITOR_MAX_DIRTY (1 << 15)4849/* deinterlace allgorithem */50enum vl_compositor_deinterlace51{52VL_COMPOSITOR_NONE,53VL_COMPOSITOR_WEAVE,54VL_COMPOSITOR_BOB_TOP,55VL_COMPOSITOR_BOB_BOTTOM,56VL_COMPOSITOR_MOTION_ADAPTIVE57};5859/* clockwise degree */60enum vl_compositor_rotation61{62VL_COMPOSITOR_ROTATE_0,63VL_COMPOSITOR_ROTATE_90,64VL_COMPOSITOR_ROTATE_180,65VL_COMPOSITOR_ROTATE_27066};6768struct vl_compositor_layer69{70bool clearing;7172bool viewport_valid;73struct pipe_viewport_state viewport;7475void *fs;76void *cs;77void *samplers[3];78void *blend;7980struct pipe_sampler_view *sampler_views[3];81struct {82struct vertex2f tl, br;83} src, dst;84struct vertex2f zw;85struct vertex4f colors[4];86enum vl_compositor_rotation rotate;87};8889struct vl_compositor_state90{91struct pipe_context *pipe;9293bool scissor_valid;94struct pipe_scissor_state scissor;95struct pipe_resource *shader_params;9697union pipe_color_union clear_color;9899unsigned used_layers:VL_COMPOSITOR_MAX_LAYERS;100struct vl_compositor_layer layers[VL_COMPOSITOR_MAX_LAYERS];101bool interlaced;102};103104struct vl_compositor105{106struct pipe_context *pipe;107108struct pipe_framebuffer_state fb_state;109struct pipe_vertex_buffer vertex_buf;110111void *sampler_linear;112void *sampler_nearest;113void *blend_clear, *blend_add;114void *rast;115void *dsa;116void *vertex_elems_state;117118void *vs;119void *fs_video_buffer;120void *fs_weave_rgb;121void *fs_rgba;122void *cs_video_buffer;123void *cs_weave_rgb;124void *cs_rgba;125126bool pipe_cs_composit_supported;127bool pipe_gfx_supported;128129enum vl_compositor_deinterlace deinterlace;130131struct {132struct {133void *y;134void *uv;135} weave;136struct {137void *y;138void *uv;139} bob;140} fs_yuv;141142struct {143struct {144void *y;145void *uv;146} weave;147struct {148void *y;149void *uv;150} bob;151} cs_yuv;152153struct {154void *rgb;155void *yuv;156} fs_palette;157158struct {159void *y;160void *uv;161} fs_rgb_yuv;162};163164/**165* initialize this compositor166*/167bool168vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe);169170/**171* init state bag172*/173bool174vl_compositor_init_state(struct vl_compositor_state *state, struct pipe_context *pipe);175176/**177* set yuv -> rgba conversion matrix178*/179bool180vl_compositor_set_csc_matrix(struct vl_compositor_state *settings,181const vl_csc_matrix *matrix,182float luma_min, float luma_max);183184/**185* reset dirty area, so it's cleared with the clear colour186*/187void188vl_compositor_reset_dirty_area(struct u_rect *dirty);189190/**191* set the clear color192*/193void194vl_compositor_set_clear_color(struct vl_compositor_state *settings, union pipe_color_union *color);195196/**197* get the clear color198*/199void200vl_compositor_get_clear_color(struct vl_compositor_state *settings, union pipe_color_union *color);201202/**203* set the destination clipping204*/205void206vl_compositor_set_dst_clip(struct vl_compositor_state *settings, struct u_rect *dst_clip);207208/**209* set overlay samplers210*/211/*@{*/212213/**214* reset all currently set layers215*/216void217vl_compositor_clear_layers(struct vl_compositor_state *state);218219/**220* set the blender used to render a layer221*/222void223vl_compositor_set_layer_blend(struct vl_compositor_state *state,224unsigned layer, void *blend, bool is_clearing);225226/**227* set the layer destination area228*/229void230vl_compositor_set_layer_dst_area(struct vl_compositor_state *settings,231unsigned layer, struct u_rect *dst_area);232233/**234* set a video buffer as a layer to render235*/236void237vl_compositor_set_buffer_layer(struct vl_compositor_state *state,238struct vl_compositor *compositor,239unsigned layer,240struct pipe_video_buffer *buffer,241struct u_rect *src_rect,242struct u_rect *dst_rect,243enum vl_compositor_deinterlace deinterlace);244245/**246* set a paletted sampler as a layer to render247*/248void249vl_compositor_set_palette_layer(struct vl_compositor_state *state,250struct vl_compositor *compositor,251unsigned layer,252struct pipe_sampler_view *indexes,253struct pipe_sampler_view *palette,254struct u_rect *src_rect,255struct u_rect *dst_rect,256bool include_color_conversion);257258/**259* set a rgba sampler as a layer to render260*/261void262vl_compositor_set_rgba_layer(struct vl_compositor_state *state,263struct vl_compositor *compositor,264unsigned layer,265struct pipe_sampler_view *rgba,266struct u_rect *src_rect,267struct u_rect *dst_rect,268struct vertex4f *colors);269270/**271* set the layer rotation272*/273void274vl_compositor_set_layer_rotation(struct vl_compositor_state *state,275unsigned layer,276enum vl_compositor_rotation rotate);277278/**279* deinterlace yuv buffer with full abilities280*/281void282vl_compositor_yuv_deint_full(struct vl_compositor_state *state,283struct vl_compositor *compositor,284struct pipe_video_buffer *src,285struct pipe_video_buffer *dst,286struct u_rect *src_rect,287struct u_rect *dst_rect,288enum vl_compositor_deinterlace deinterlace);289290/**291+ * convert rgb to yuv292+ */293void294vl_compositor_convert_rgb_to_yuv(struct vl_compositor_state *state,295struct vl_compositor *compositor,296unsigned layer,297struct pipe_resource *src_res,298struct pipe_video_buffer *dst,299struct u_rect *src_rect,300struct u_rect *dst_rect);301302/*@}*/303304/**305* render the layers to the frontbuffer306*/307void308vl_compositor_render(struct vl_compositor_state *state,309struct vl_compositor *compositor,310struct pipe_surface *dst_surface,311struct u_rect *dirty_area,312bool clear_dirty);313314/**315* destroy this compositor316*/317void318vl_compositor_cleanup(struct vl_compositor *compositor);319320/**321* destroy this state bag322*/323void324vl_compositor_cleanup_state(struct vl_compositor_state *state);325326#endif /* vl_compositor_h */327328329