Commit: 5396e284f7dabc6d63466967abc6d103965ec0ef
Author: Antonio Vazquez
Date:   Tue Apr 24 19:14:07 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB5396e284f7dabc6d63466967abc6d103965ec0ef

WIP: First step to remove Palettes from Draw Manager

Still is not working.

===================================================================

M       source/blender/blenkernel/BKE_material.h
M       source/blender/blenkernel/intern/material.c
M       source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M       source/blender/draw/engines/gpencil/gpencil_engine.c
M       source/blender/draw/engines/gpencil/gpencil_engine.h
M       source/blender/draw/engines/gpencil/gpencil_geom.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_material.h 
b/source/blender/blenkernel/BKE_material.h
index 43f36618c19..71b07618db1 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -79,6 +79,7 @@ enum {
 };
 
 struct Material *give_current_material(struct Object *ob, short act);
+struct GpencilColorData *give_material_gpencil_settings(struct Object *ob, 
short act);
 void assign_material_id(struct ID *id, struct Material *ma, short act);
 void assign_material(struct Object *ob, struct Material *ma, short act, int 
assign_type);
 void assign_matarar(struct Object *ob, struct Material ***matar, short totcol);
diff --git a/source/blender/blenkernel/intern/material.c 
b/source/blender/blenkernel/intern/material.c
index e06cb082715..27b5d02ad86 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -523,6 +523,17 @@ Material *give_current_material(Object *ob, short act)
        return ma;
 }
 
+GpencilColorData *give_material_gpencil_settings(Object *ob, short act)
+{
+       Material *ma = give_current_material(ob, act);
+       if (ma != NULL) {
+               return &ma->gpcolor;
+       }
+       else {
+               return NULL;
+       }
+}
+
 Material *give_node_material(Material *ma)
 {
        if (ma && ma->use_nodes && ma->nodetree) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 10a956abea6..f72ee41dd0f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -31,12 +31,14 @@
 #include "BKE_gpencil.h"
 #include "BKE_image.h"
 #include "BKE_lattice.h"
+#include "BKE_material.h"
 #include "BKE_paint.h"
 
 #include "ED_gpencil.h"
 #include "ED_view3d.h"
 
 #include "DNA_gpencil_types.h"
+#include "DNA_material_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_modifier_types.h"
 
@@ -54,7 +56,7 @@
 
 /* create shading group for filling */
 static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(GPENCIL_e_data 
*e_data, GPENCIL_Data *vedata, DRWPass *pass, 
-       GPUShader *shader, bGPdata *gpd, PaletteColor *palcolor, int id)
+       GPUShader *shader, bGPdata *gpd, GpencilColorData *palcolor, int id)
 {
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
 
@@ -79,15 +81,15 @@ static DRWShadingGroup 
*DRW_gpencil_shgroup_fill_create(GPENCIL_e_data *e_data,
        DRW_shgroup_uniform_vec2(grp, "t_offset", palcolor->t_offset, 1);
        DRW_shgroup_uniform_float(grp, "t_opacity", &palcolor->t_opacity, 1);
 
-       stl->shgroups[id].t_mix = palcolor->flag & PAC_COLOR_TEX_MIX ? 1 : 0;
+       stl->shgroups[id].t_mix = palcolor->flag & GPC_COLOR_TEX_MIX ? 1 : 0;
        DRW_shgroup_uniform_int(grp, "t_mix", &stl->shgroups[id].t_mix, 1);
 
-       stl->shgroups[id].t_flip = palcolor->flag & PAC_COLOR_FLIP_FILL ? 1 : 0;
+       stl->shgroups[id].t_flip = palcolor->flag & GPC_COLOR_FLIP_FILL ? 1 : 0;
        DRW_shgroup_uniform_int(grp, "t_flip", &stl->shgroups[id].t_flip, 1);
 
        DRW_shgroup_uniform_int(grp, "xraymode", (const int *) &gpd->xray_mode, 
1);
        /* image texture */
-       if ((palcolor->fill_style == FILL_STYLE_TEXTURE) || 
(palcolor->fill_style == FILL_STYLE_PATTERN) || (palcolor->flag & 
PAC_COLOR_TEX_MIX)) {
+       if ((palcolor->fill_style == GPC_FILL_STYLE_TEXTURE) || 
(palcolor->fill_style == GPC_FILL_STYLE_PATTERN) || (palcolor->flag & 
GPC_COLOR_TEX_MIX)) {
                ImBuf *ibuf;
                Image *image = palcolor->ima;
                ImageUser iuser = { NULL };
@@ -104,7 +106,7 @@ static DRWShadingGroup 
*DRW_gpencil_shgroup_fill_create(GPENCIL_e_data *e_data,
                        GPUTexture *texture = 
GPU_texture_from_blender(palcolor->ima, &iuser, GL_TEXTURE_2D, true, 0.0, 0);
                        DRW_shgroup_uniform_texture(grp, "myTexture", texture);
 
-                       stl->shgroups[id].t_clamp = palcolor->flag & 
PAC_COLOR_TEX_CLAMP ? 1 : 0;
+                       stl->shgroups[id].t_clamp = palcolor->flag & 
GPC_COLOR_TEX_CLAMP ? 1 : 0;
                        DRW_shgroup_uniform_int(grp, "t_clamp", 
&stl->shgroups[id].t_clamp, 1);
 
                        BKE_image_release_ibuf(image, ibuf, NULL);
@@ -122,7 +124,7 @@ static DRWShadingGroup 
*DRW_gpencil_shgroup_fill_create(GPENCIL_e_data *e_data,
 
 /* create shading group for strokes */
 DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(GPENCIL_e_data *e_data, 
GPENCIL_Data *vedata, DRWPass *pass, GPUShader *shader, Object *ob,
-       bGPdata *gpd, PaletteColor *palcolor, int id, bool onion)
+       bGPdata *gpd, GpencilColorData *palcolor, int id, bool onion)
 {
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
        const float *viewport_size = DRW_viewport_size_get();
@@ -153,9 +155,9 @@ DRWShadingGroup 
*DRW_gpencil_shgroup_stroke_create(GPENCIL_e_data *e_data, GPENC
 
                stl->shgroups[id].stroke_style = palcolor->stroke_style;
                stl->shgroups[id].color_type = GPENCIL_COLOR_SOLID;
-               if ((palcolor->stroke_style == STROKE_STYLE_TEXTURE) && 
(!onion)) {
+               if ((palcolor->stroke_style == GPC_STROKE_STYLE_TEXTURE) && 
(!onion)) {
                        stl->shgroups[id].color_type = GPENCIL_COLOR_TEXTURE;
-                       if (palcolor->flag & PAC_COLOR_PATTERN) {
+                       if (palcolor->flag & GPC_COLOR_PATTERN) {
                                stl->shgroups[id].color_type = 
GPENCIL_COLOR_PATTERN;
                        }
                }
@@ -186,7 +188,7 @@ DRWShadingGroup 
*DRW_gpencil_shgroup_stroke_create(GPENCIL_e_data *e_data, GPENC
        }
 
        /* image texture for pattern */
-       if ((palcolor) && (palcolor->stroke_style == STROKE_STYLE_TEXTURE) && 
(!onion)) {
+       if ((palcolor) && (palcolor->stroke_style == GPC_STROKE_STYLE_TEXTURE) 
&& (!onion)) {
                ImBuf *ibuf;
                Image *image = palcolor->sima;
                ImageUser iuser = { NULL };
@@ -217,7 +219,7 @@ DRWShadingGroup 
*DRW_gpencil_shgroup_stroke_create(GPENCIL_e_data *e_data, GPENC
 
 /* create shading group for volumetrics */
 static DRWShadingGroup *DRW_gpencil_shgroup_point_create(GPENCIL_e_data 
*e_data, GPENCIL_Data *vedata, DRWPass *pass, GPUShader *shader, Object *ob,
-       bGPdata *gpd, PaletteColor *palcolor, int id, bool onion)
+       bGPdata *gpd, GpencilColorData *palcolor, int id, bool onion)
 {
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
        const float *viewport_size = DRW_viewport_size_get();
@@ -246,9 +248,9 @@ static DRWShadingGroup 
*DRW_gpencil_shgroup_point_create(GPENCIL_e_data *e_data,
                stl->shgroups[id].mode = palcolor->mode;
                stl->shgroups[id].stroke_style = palcolor->stroke_style;
                stl->shgroups[id].color_type = GPENCIL_COLOR_SOLID;
-               if ((palcolor->stroke_style == STROKE_STYLE_TEXTURE) && 
(!onion)) {
+               if ((palcolor->stroke_style == GPC_STROKE_STYLE_TEXTURE) && 
(!onion)) {
                        stl->shgroups[id].color_type = GPENCIL_COLOR_TEXTURE;
-                       if (palcolor->flag & PAC_COLOR_PATTERN) {
+                       if (palcolor->flag & GPC_COLOR_PATTERN) {
                                stl->shgroups[id].color_type = 
GPENCIL_COLOR_PATTERN;
                        }
                }
@@ -282,7 +284,7 @@ static DRWShadingGroup 
*DRW_gpencil_shgroup_point_create(GPENCIL_e_data *e_data,
        }
 
        /* image texture */
-       if ((palcolor) && (palcolor->stroke_style == STROKE_STYLE_TEXTURE) && 
(!onion)) {
+       if ((palcolor) && (palcolor->stroke_style == GPC_STROKE_STYLE_TEXTURE) 
&& (!onion)) {
                ImBuf *ibuf;
                Image *image = palcolor->sima;
                ImageUser iuser = { NULL };
@@ -315,7 +317,7 @@ static void gpencil_add_fill_shgroup(GpencilBatchCache 
*cache, DRWShadingGroup *
        Object *ob, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps,
        const float tintcolor[4], const bool onion, const bool custonion)
 {
-       PaletteColor *gps_palcolor = BKE_palette_color_getbyname(gps->palette, 
gps->colorname);
+       GpencilColorData *gps_palcolor = give_material_gpencil_settings(ob, 
gps->mat_nr + 1);
        if (gps->totpoints >= 3) {
                float tfill[4];
                /* set color using palette, tint color and opacity */
@@ -352,9 +354,9 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache 
*cache, DRWShadingGroup
        float tcolor[4];
        float ink[4];
        short sthickness;
-       PaletteColor *gps_palcolor = BKE_palette_color_getbyname(gps->palette, 
gps->colorname);
+       GpencilColorData *gps_palcolor = give_material_gpencil_settings(ob, 
gps->mat_nr + 1);
 
-       /* set color using palette, tint color and opacity */
+       /* set color using base color, tint color and opacity */
        if (!onion) {
                /* if special stroke, use fill color as stroke color */
                if (gps->flag & GP_STROKE_NOFILL) {
@@ -381,7 +383,7 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache 
*cache, DRWShadingGroup
        CLAMP_MIN(sthickness, 1);
        if (cache->is_dirty) {
                gpencil_batch_cache_check_free_slots(ob);
-               if ((gps->totpoints > 1) && (gps_palcolor->mode  == 
PAC_MODE_LINE)) {
+               if ((gps->totpoints > 1) && (gps_palcolor->mode  == 
GPC_MODE_LINE)) {
                        cache->batch_stroke[cache->cache_idx] = 
DRW_gpencil_get_stroke_geom(gpf, gps, sthickness, ink);
                }
                else {
@@ -396,7 +398,7 @@ static void gpencil_add_editpoints_shgroup(
                GPENCIL_StorageList *stl, GpencilBatchCache *cache,ToolSettings 
*ts, Object *ob, 
                bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps)
 {
-       PaletteColor *gps_palcolor = BKE_palette_color_getbyname(gps->palette, 
gps->colorname);
+       GpencilColorData *gps_palcolor = give_material_gpencil_settings(ob, 
gps->mat_nr + 1);
 
        if (GPENCIL_ANY_EDIT_MODE(gpd)) {
                const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -418,7 +420,7 @@ static void gpencil_add_editpoints_shgroup(
                }
                /* edit points */
                if ((gps->flag & GP_STROKE_SELECT) || (is_weight_paint)) {
-                       if ((gpl->flag & GP_LAYER_UNLOCK_COLOR) || 
((gps_palcolor->flag & PC_COLOR_LOCKED) == 0)) {
+                       if ((gpl->flag & GP_LAYER_UNLOCK_COLOR) || 
((gps_palcolor->flag & GPC_COLOR_LOCKED) == 0)) {
                                if (cache->is_dirty) {
                                        
gpencil_batch_cache_check_free_slots(ob);
                                        cache->batch_edit[cache->cache_idx] = 
DRW_gpencil_get_edit_geom(gps, ts->gp_sculpt.alpha, gpd->flag);
@@ -448,13 +450,13 @@ static void gpencil_draw_onion_strokes(GpencilBatchCache 
*cache, GPENCIL_e_data
 
        for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
                
-               PaletteColor *gps_palcolor = 
BKE_palette_color_getbyname(gps->palette, gps->colorname);
+               GpencilColorData *gps_palcolor = 
give_material_gpencil_settings(ob, gps->mat_nr + 1);
                copy_v4_v4(gps->tmp_rgb, gps_palcolor->rgb);
                copy_v4_v4(gps->tmp_fill, gps_palcolor->fill);
 
                int id = stl->storage->shgroup_id;
                /* check if stroke can be drawn */
-               if (gpencil_can_draw_stroke(gps, true) == false) {
+               if

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to