[gtk+/wip/otte/vulkan: 46/62] vulkan: Make the GskVulkanRender struct private



commit 96355981248bcf6e9cf6bc0f1a8add9f4a03e794
Author: Benjamin Otte <otte redhat com>
Date:   Thu Dec 8 17:55:32 2016 +0100

    vulkan: Make the GskVulkanRender struct private

 gsk/gskvulkanrender.c            |   27 +++++++++++++++++++++++++--
 gsk/gskvulkanrenderpass.c        |   22 +++++++++++++---------
 gsk/gskvulkanrenderpassprivate.h |    6 ++++--
 gsk/gskvulkanrenderprivate.h     |   20 ++------------------
 4 files changed, 44 insertions(+), 31 deletions(-)
---
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c
index 2cf99ac..571ed29 100644
--- a/gsk/gskvulkanrender.c
+++ b/gsk/gskvulkanrender.c
@@ -10,6 +10,23 @@
 #define ORTHO_NEAR_PLANE        -10000
 #define ORTHO_FAR_PLANE          10000
 
+struct _GskVulkanRender
+{
+  GskRenderer *renderer;
+  GdkVulkanContext *vulkan;
+
+  graphene_matrix_t mvp;
+  int scale_factor;
+  VkExtent2D size;
+  VkRect2D scissor;
+
+  VkCommandPool command_pool;
+  VkCommandBuffer command_buffer;
+
+  GSList *render_passes;
+  GSList *cleanup_images;
+};
+
 static void
 gsk_vulkan_render_compute_mvp (GskVulkanRender *self)
 {
@@ -95,7 +112,7 @@ gsk_vulkan_render_upload (GskVulkanRender *self)
 
   for (l = self->render_passes; l; l = l->next)
     {
-      gsk_vulkan_render_pass_upload (l->data, self);
+      gsk_vulkan_render_pass_upload (l->data, self, self->command_buffer);
     }
 }
 
@@ -219,7 +236,7 @@ gsk_vulkan_render_draw (GskVulkanRender   *self,
 
   for (l = self->render_passes; l; l = l->next)
     {
-      gsk_vulkan_render_pass_draw (l->data, self);
+      gsk_vulkan_render_pass_draw (l->data, self, self->command_buffer);
     }
 
   vkCmdEndRenderPass (self->command_buffer);
@@ -275,3 +292,9 @@ gsk_vulkan_render_free (GskVulkanRender *self)
 
   g_slice_free (GskVulkanRender, self);
 }
+
+GskRenderer *
+gsk_vulkan_render_get_renderer (GskVulkanRender *self)
+{
+  return self->renderer;
+}
diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c
index 373bc6c..731498b 100644
--- a/gsk/gskvulkanrenderpass.c
+++ b/gsk/gskvulkanrenderpass.c
@@ -64,8 +64,10 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
 }
 
 static void
-gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderOp *op,
-                                        GskVulkanRender   *render)
+gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass *self,
+                                        GskVulkanRenderOp   *op,
+                                        GskVulkanRender     *render,
+                                        VkCommandBuffer      command_buffer)
 {
   graphene_rect_t bounds;
   GskRenderer *fallback;
@@ -80,7 +82,7 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderOp *op,
   cr = cairo_create (surface);
   cairo_translate (cr, bounds.origin.x, bounds.origin.y);
 
-  fallback = gsk_renderer_create_fallback (render->renderer,
+  fallback = gsk_renderer_create_fallback (gsk_vulkan_render_get_renderer (render),
                                            &bounds,
                                            cr);
   gsk_renderer_render (fallback, op->node, NULL);
@@ -88,8 +90,8 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderOp *op,
   
   cairo_destroy (cr);
 
-  op->source = gsk_vulkan_image_new_from_data (render->vulkan,
-                                               render->command_buffer,
+  op->source = gsk_vulkan_image_new_from_data (self->vulkan,
+                                               command_buffer,
                                                cairo_image_surface_get_data (surface),
                                                cairo_image_surface_get_width (surface),
                                                cairo_image_surface_get_height (surface),
@@ -102,7 +104,8 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderOp *op,
 
 void
 gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
-                               GskVulkanRender     *render)
+                               GskVulkanRender     *render,
+                               VkCommandBuffer      command_buffer)
 {
   GskVulkanRenderOp *op;
   guint i;
@@ -114,7 +117,7 @@ gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
       switch (op->type)
         {
         case GSK_VULKAN_OP_FALLBACK:
-          gsk_vulkan_render_pass_upload_fallback (op, render);
+          gsk_vulkan_render_pass_upload_fallback (self, op, render, command_buffer);
           break;
 
         default:
@@ -217,7 +220,8 @@ gsk_vulkan_render_pass_update_descriptor_sets (GskVulkanRenderPass *self,
 
 void
 gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
-                             GskVulkanRender     *render)
+                             GskVulkanRender     *render,
+                             VkCommandBuffer      command_buffer)
 {
   GskVulkanRenderOp *op;
   guint i;
@@ -226,7 +230,7 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
     {
       op = &g_array_index (self->render_ops, GskVulkanRenderOp, i);
 
-      vkCmdDraw (render->command_buffer,
+      vkCmdDraw (command_buffer,
                  op->vertex_count, 1,
                  op->vertex_offset, 0);
     }
diff --git a/gsk/gskvulkanrenderpassprivate.h b/gsk/gskvulkanrenderpassprivate.h
index eb22761..886e7c2 100644
--- a/gsk/gskvulkanrenderpassprivate.h
+++ b/gsk/gskvulkanrenderpassprivate.h
@@ -18,7 +18,8 @@ void                    gsk_vulkan_render_pass_add_node                 (GskVulk
                                                                          GskRenderNode          *node);
 
 void                    gsk_vulkan_render_pass_upload                   (GskVulkanRenderPass    *self,
-                                                                         GskVulkanRender        *render);
+                                                                         GskVulkanRender        *render,
+                                                                         VkCommandBuffer         
command_buffer);
 
 gsize                   gsk_vulkan_render_pass_count_vertices           (GskVulkanRenderPass    *self);
 gsize                   gsk_vulkan_render_pass_collect_vertices         (GskVulkanRenderPass    *self,
@@ -30,7 +31,8 @@ void                    gsk_vulkan_render_pass_update_descriptor_sets   (GskVulk
                                                                          VkDescriptorSet         
descriptor_set,
                                                                          VkSampler               sampler);
 void                    gsk_vulkan_render_pass_draw                     (GskVulkanRenderPass    *self,
-                                                                         GskVulkanRender        *render);
+                                                                         GskVulkanRender        *render,
+                                                                         VkCommandBuffer         
command_buffer);
 
 G_END_DECLS
 
diff --git a/gsk/gskvulkanrenderprivate.h b/gsk/gskvulkanrenderprivate.h
index de4dc80..55c454e 100644
--- a/gsk/gskvulkanrenderprivate.h
+++ b/gsk/gskvulkanrenderprivate.h
@@ -12,24 +12,6 @@ G_BEGIN_DECLS
 typedef struct _GskVulkanRender GskVulkanRender;
 typedef struct _GskVulkanVertex GskVulkanVertex;
 
-struct _GskVulkanRender
-{
-  GskRenderer *renderer;
-  GdkVulkanContext *vulkan;
-
-  graphene_matrix_t mvp;
-  int scale_factor;
-  VkExtent2D size;
-  VkRect2D scissor;
-
-
-  VkCommandPool command_pool;
-  VkCommandBuffer command_buffer;
-
-  GSList *render_passes;
-  GSList *cleanup_images;
-};
-
 struct _GskVulkanVertex
 {
   float x;
@@ -43,6 +25,8 @@ GskVulkanRender *       gsk_vulkan_render_new                           (GskRend
                                                                          VkCommandPool           
command_pool);
 void                    gsk_vulkan_render_free                          (GskVulkanRender        *self);
 
+GskRenderer *           gsk_vulkan_render_get_renderer                  (GskVulkanRender        *self);
+
 void                    gsk_vulkan_render_add_cleanup_image             (GskVulkanRender        *self,
                                                                          GskVulkanImage         *image);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]