[g3dvl] move compositor creation and handling directly into the state trackers
[mesa.git] / src / gallium / state_trackers / vega / vg_context.h
index 804e9e76d77e2799a33732f348cc7dd3eefb07ed..d91ee9797f158251da7fee99277d4764b36e79bd 100644 (file)
@@ -33,6 +33,7 @@
 #include "pipe/p_state.h"
 #include "util/u_pointer.h"
 #include "util/u_math.h"
+#include "state_tracker/st_api.h"
 
 #include "cso_cache/cso_hash.h"
 #include "cso_cache/cso_context.h"
@@ -41,11 +42,12 @@ struct renderer;
 struct shaders_cache;
 struct shader;
 struct vg_shader;
+struct mapi_table;
 
 struct st_renderbuffer {
    enum pipe_format   format;
    struct pipe_surface *surface;
-   struct pipe_texture *texture;
+   struct pipe_resource *texture;
    VGint width, height;
 };
 
@@ -54,11 +56,17 @@ struct st_framebuffer {
    struct st_renderbuffer *strb;
    struct st_renderbuffer *dsrb;
 
-   struct pipe_texture *alpha_mask;
+   struct pipe_sampler_view *surface_mask_view;
 
-   struct pipe_texture *blend_texture;
+   struct pipe_sampler_view *blend_texture_view;
+
+
+   struct st_framebuffer_iface *iface;
+   enum st_attachment_type strb_att;
 
    void *privateData;
+   int32_t stamp;
+   int32_t iface_stamp;
 };
 
 enum vg_object_type {
@@ -72,29 +80,27 @@ enum vg_object_type {
    VG_OBJECT_LAST
 };
 enum dirty_state {
-   NONE_DIRTY          = 0<<0,
-   BLEND_DIRTY         = 1<<1,
-   RASTERIZER_DIRTY    = 1<<2,
-   VIEWPORT_DIRTY      = 1<<3,
-   VS_DIRTY            = 1<<4,
-   DEPTH_STENCIL_DIRTY = 1<<5,
-   ALL_DIRTY           = BLEND_DIRTY | RASTERIZER_DIRTY |
-   VIEWPORT_DIRTY | VS_DIRTY | DEPTH_STENCIL_DIRTY
+   BLEND_DIRTY         = 1 << 0,
+   FRAMEBUFFER_DIRTY   = 1 << 1,
+   DEPTH_STENCIL_DIRTY = 1 << 2,
+   PAINT_DIRTY         = 1 << 3,
+
+   ALL_DIRTY           = BLEND_DIRTY |
+                         FRAMEBUFFER_DIRTY |
+                         DEPTH_STENCIL_DIRTY |
+                         PAINT_DIRTY
 };
 
 struct vg_context
 {
+   struct st_context_iface iface;
+   struct mapi_table *dispatch;
+
    struct pipe_context *pipe;
+   enum pipe_format ds_format;
 
    struct {
       struct vg_state vg;
-      struct {
-         struct pipe_blend_state blend;
-         struct pipe_rasterizer_state rasterizer;
-         struct pipe_shader_state vs_state;
-         struct pipe_depth_stencil_alpha_state dsa;
-         struct pipe_framebuffer_state fb;
-      } g3d;
       VGbitfield dirty;
    } state;
 
@@ -105,15 +111,7 @@ struct vg_context
    struct cso_hash *owned_objects[VG_OBJECT_LAST];
 
    struct {
-      struct pipe_shader_state vert_shader;
-      struct pipe_shader_state frag_shader;
-      struct pipe_rasterizer_state raster;
-      void *fs;
-      float vertices[4][2][4];  /**< vertex pos + color */
-   } clear;
-
-   struct {
-      struct pipe_buffer *cbuf;
+      struct pipe_resource *cbuf;
       struct pipe_sampler_state sampler;
 
       struct vg_shader *union_fs;
@@ -122,39 +120,35 @@ struct vg_context
       struct vg_shader *set_fs;
    } mask;
 
-   struct vg_shader *pass_through_depth_fs;
-
    struct cso_context *cso_context;
 
-   struct pipe_buffer *stencil_quad;
-   VGfloat stencil_vertices[4][2][4];
-
    struct renderer *renderer;
    struct shaders_cache *sc;
    struct shader *shader;
 
    struct pipe_sampler_state blend_sampler;
-   struct {
-      struct pipe_buffer *buffer;
-      void *color_matrix_fs;
-   } filter;
    struct vg_paint *default_paint;
 
    struct blit_state *blit;
 
-   struct vg_shader *plain_vs;
-   struct vg_shader *clear_vs;
-   struct vg_shader *texture_vs;
-   struct pipe_buffer *vs_const_buffer;
-   struct pipe_vertex_element velems[2];
+   int32_t draw_stamp;
 };
 
+
+/**
+ *  Base class for VG objects like paths, images, fonts.
+ */
 struct vg_object {
    enum vg_object_type type;
+   VGHandle handle;
    struct vg_context *ctx;
 };
+
+
 void vg_init_object(struct vg_object *obj, struct vg_context *ctx, enum vg_object_type type);
-VGboolean vg_object_is_valid(void *ptr, enum vg_object_type type);
+void vg_free_object(struct vg_object *obj);
+
+VGboolean vg_object_is_valid(VGHandle object, enum vg_object_type type);
 
 struct vg_context *vg_create_context(struct pipe_context *pipe,
                                      const void *visual,
@@ -165,7 +159,7 @@ void vg_set_current_context(struct vg_context *ctx);
 
 VGboolean vg_context_is_object_valid(struct vg_context *ctx,
                                      enum vg_object_type type,
-                                     void *ptr);
+                                     VGHandle object);
 void vg_context_add_object(struct vg_context *ctx,
                            enum vg_object_type type,
                            void *ptr);
@@ -178,9 +172,15 @@ void vg_validate_state(struct vg_context *ctx);
 void vg_set_error(struct vg_context *ctx,
                   VGErrorCode code);
 
-void vg_prepare_blend_surface(struct vg_context *ctx);
-void vg_prepare_blend_surface_from_mask(struct vg_context *ctx);
+struct pipe_sampler_view *vg_prepare_blend_surface(struct vg_context *ctx);
+struct pipe_sampler_view *vg_prepare_blend_surface_from_mask(struct vg_context *ctx);
+
+struct pipe_sampler_view *vg_get_surface_mask(struct vg_context *ctx);
 
+VGboolean vg_get_paint_matrix(struct vg_context *ctx,
+                              const struct matrix *paint_to_user,
+                              const struct matrix *user_to_surface,
+                              struct matrix *mat);
 
 static INLINE VGboolean is_aligned_to(const void *ptr, VGbyte alignment)
 {
@@ -281,13 +281,4 @@ static INLINE void vg_bound_rect(VGfloat coords[4],
    }
 }
 
-void *vg_plain_vs(struct vg_context *ctx);
-void *vg_clear_vs(struct vg_context *ctx);
-void *vg_texture_vs(struct vg_context *ctx);
-typedef enum {
-   VEGA_Y0_TOP,
-   VEGA_Y0_BOTTOM
-} VegaOrientation;
-void vg_set_viewport(struct vg_context *ctx, VegaOrientation orientation);
-
 #endif