Merge branch 'blender-v2.82-release'
authorPhilipp Oeser <info@graphics-engineer.com>
Wed, 29 Jan 2020 19:25:35 +0000 (20:25 +0100)
committerPhilipp Oeser <info@graphics-engineer.com>
Wed, 29 Jan 2020 19:29:20 +0000 (20:29 +0100)
Merge conflict in source/blender/gpu/GPU_texture.h

12 files changed:
release/scripts/startup/bl_ui/properties_particle.py
source/blender/blenloader/intern/versioning_280.c
source/blender/draw/engines/gpencil/gpencil_draw_utils.c
source/blender/draw/engines/overlay/overlay_image.c
source/blender/draw/engines/overlay/overlay_paint.c
source/blender/draw/engines/workbench/workbench_forward.c
source/blender/draw/engines/workbench/workbench_materials.c
source/blender/draw/intern/draw_manager_data.c
source/blender/gpu/GPU_texture.h
source/blender/gpu/intern/gpu_draw.c
source/blender/makesdna/DNA_brush_defaults.h
source/blender/makesrna/intern/rna_image_api.c

index 34ff386893b55b8671d72608a8303a02414a2829..3384032e3328429585a68cb9460d266d006f2d07 100644 (file)
@@ -584,7 +584,7 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
 
         layout = self.layout
         layout.prop(part, "use_rotations", text="")
-        layout.enabled = particle_panel_enabled(context, psys) and part.use_rotations
+        layout.enabled = particle_panel_enabled(context, psys)
 
 
     def draw(self, context):
index 7377f6a62a15d84e71ad3f81a17e7b6f8647be59..e92ae6e73cc258bfa37808d613d97368eb463cc0 100644 (file)
@@ -4411,8 +4411,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
 
     /* Pose brush IK segments. */
-    if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "pose_ik_segments")) {
-      for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
+    for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
+      if (br->pose_ik_segments == 0) {
         br->pose_ik_segments = 1;
       }
     }
index 4c6ce896ebcfaa802bbc8480bfd88b9696c0a2b4..2c6b1315ad47ceb4a294fd4159abb2a366ecd496 100644 (file)
@@ -522,7 +522,7 @@ static DRWShadingGroup *gpencil_shgroup_fill_create(GPENCIL_e_data *e_data,
       BKE_image_release_ibuf(image, ibuf, NULL);
     }
     else {
-      GPUTexture *texture = GPU_texture_from_blender(gp_style->ima, &iuser, GL_TEXTURE_2D);
+      GPUTexture *texture = GPU_texture_from_blender(gp_style->ima, &iuser, ibuf, GL_TEXTURE_2D);
       DRW_shgroup_uniform_texture(grp, "myTexture", texture);
       DRW_shgroup_uniform_bool_copy(
           grp, "myTexturePremultiplied", (image->alpha_mode == IMA_ALPHA_PREMUL));
@@ -705,7 +705,7 @@ DRWShadingGroup *gpencil_shgroup_stroke_create(GPENCIL_e_data *e_data,
       BKE_image_release_ibuf(image, ibuf, NULL);
     }
     else {
-      GPUTexture *texture = GPU_texture_from_blender(gp_style->sima, &iuser, GL_TEXTURE_2D);
+      GPUTexture *texture = GPU_texture_from_blender(gp_style->sima, &iuser, ibuf, GL_TEXTURE_2D);
       DRW_shgroup_uniform_texture(grp, "myTexture", texture);
       DRW_shgroup_uniform_bool_copy(
           grp, "myTexturePremultiplied", (image->alpha_mode == IMA_ALPHA_PREMUL));
@@ -878,7 +878,7 @@ static DRWShadingGroup *gpencil_shgroup_point_create(GPENCIL_e_data *e_data,
       BKE_image_release_ibuf(image, ibuf, NULL);
     }
     else {
-      GPUTexture *texture = GPU_texture_from_blender(gp_style->sima, &iuser, GL_TEXTURE_2D);
+      GPUTexture *texture = GPU_texture_from_blender(gp_style->sima, &iuser, ibuf, GL_TEXTURE_2D);
       DRW_shgroup_uniform_texture(grp, "myTexture", texture);
       DRW_shgroup_uniform_bool_copy(
           grp, "myTexturePremultiplied", (image->alpha_mode == IMA_ALPHA_PREMUL));
index cda55fcfb5e00a17410cfd4ae93fea434e0724e1..cf90c12b357a028848cf488f08b4eb8d5bf4613d 100644 (file)
@@ -134,6 +134,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
                                                               float *r_aspect,
                                                               bool *r_use_alpha_premult)
 {
+  void *lock;
   Image *image = bgpic->ima;
   ImageUser *iuser = &bgpic->iuser;
   MovieClip *clip = NULL;
@@ -160,12 +161,19 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
         camera_background_images_stereo_setup(scene, draw_ctx->v3d, image, iuser);
       }
 
-      ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, NULL);
+      iuser->scene = draw_ctx->scene;
+      ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, &lock);
       if (ibuf == NULL) {
+        BKE_image_release_ibuf(image, ibuf, lock);
+        iuser->scene = NULL;
         return NULL;
       }
+      width = ibuf->x;
+      height = ibuf->y;
+      tex = GPU_texture_from_blender(image, iuser, ibuf, GL_TEXTURE_2D);
+      BKE_image_release_ibuf(image, ibuf, lock);
+      iuser->scene = NULL;
 
-      tex = GPU_texture_from_blender(image, iuser, GL_TEXTURE_2D);
       if (tex == NULL) {
         return NULL;
       }
@@ -173,10 +181,6 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
       aspect_x = bgpic->ima->aspx;
       aspect_y = bgpic->ima->aspy;
 
-      width = ibuf->x;
-      height = ibuf->y;
-
-      BKE_image_release_ibuf(image, ibuf, NULL);
       break;
 
     case CAM_BGIMG_SOURCE_MOVIE:
@@ -376,7 +380,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
      * see: T59347 */
     int size[2] = {0};
     if (ima != NULL) {
-      tex = GPU_texture_from_blender(ima, ob->iuser, GL_TEXTURE_2D);
+      tex = GPU_texture_from_blender(ima, ob->iuser, NULL, GL_TEXTURE_2D);
       if (tex) {
         size[0] = GPU_texture_orig_width(tex);
         size[1] = GPU_texture_orig_height(tex);
index 047659fbeee089da26ddf3d850e3329ca0970b82..e88a69b695ea7694ca8422d30fb6d59fb66a7041 100644 (file)
@@ -85,7 +85,7 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata)
         state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA;
         DRW_PASS_CREATE(psl->paint_color_ps, state | pd->clipping_state);
 
-        GPUTexture *tex = GPU_texture_from_blender(imapaint->stencil, NULL, GL_TEXTURE_2D);
+        GPUTexture *tex = GPU_texture_from_blender(imapaint->stencil, NULL, NULL, GL_TEXTURE_2D);
 
         const bool mask_premult = (imapaint->stencil->alpha_mode == IMA_ALPHA_PREMUL);
         const bool mask_inverted = (imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL_INV) != 0;
index e5f121a690d9e0a750d30dce4f46a832b7d1f76b..97bea58f31b7d03e77fbabde1b174bf66c41ed61 100644 (file)
@@ -210,7 +210,8 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_
     if (color_type == V3D_SHADING_TEXTURE_COLOR) {
       material->shgrp_object_outline = DRW_shgroup_create(sh_data->object_outline_texture_sh,
                                                           psl->object_outline_pass);
-      GPUTexture *tex = GPU_texture_from_blender(material->ima, material->iuser, GL_TEXTURE_2D);
+      GPUTexture *tex = GPU_texture_from_blender(
+          material->ima, material->iuser, NULL, GL_TEXTURE_2D);
       DRW_shgroup_uniform_texture(material->shgrp_object_outline, "image", tex);
     }
     else {
index 2219f5cf2dd75b3ee8618e269d215ae94ac312d1..fc054b11d5557212c17483e286dc721e0cc7722b 100644 (file)
@@ -376,14 +376,15 @@ void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd,
   if (use_texture) {
     if (is_tiled) {
       GPUTexture *array_tex = GPU_texture_from_blender(
-          material->ima, material->iuser, GL_TEXTURE_2D_ARRAY);
+          material->ima, material->iuser, NULL, GL_TEXTURE_2D_ARRAY);
       GPUTexture *data_tex = GPU_texture_from_blender(
-          material->ima, material->iuser, GL_TEXTURE_1D_ARRAY);
+          material->ima, material->iuser, NULL, GL_TEXTURE_1D_ARRAY);
       DRW_shgroup_uniform_texture(grp, "image_tile_array", array_tex);
       DRW_shgroup_uniform_texture(grp, "image_tile_data", data_tex);
     }
     else {
-      GPUTexture *tex = GPU_texture_from_blender(material->ima, material->iuser, GL_TEXTURE_2D);
+      GPUTexture *tex = GPU_texture_from_blender(
+          material->ima, material->iuser, NULL, GL_TEXTURE_2D);
       DRW_shgroup_uniform_texture(grp, "image", tex);
     }
     DRW_shgroup_uniform_bool_copy(
index c6fc244121cdabec62167bb9ac8113a8f5ed77e9..f9a6b663900c62062727810904714f829e16d6cc 100644 (file)
@@ -1226,7 +1226,7 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp,
         else {
           textarget = GL_TEXTURE_2D;
         }
-        *tex_ref = tex = GPU_texture_from_blender(input->ima, input->iuser, textarget);
+        *tex_ref = tex = GPU_texture_from_blender(input->ima, input->iuser, NULL, textarget);
 
         GPU_texture_ref(tex);
       }
index 19c7386ad6dba49db14ec93a2389e8dfa2dd1043..bb6af2273697819d22e9b9d8b00425c5f133fd8d 100644 (file)
@@ -36,6 +36,7 @@ struct ImageUser;
 struct MovieClip;
 struct MovieClipUser;
 struct PreviewImage;
+struct ImBuf;
 
 struct GPUFrameBuffer;
 typedef struct GPUTexture GPUTexture;
@@ -187,7 +188,11 @@ GPUTexture *GPU_texture_create_from_vertbuf(struct GPUVertBuf *vert);
 GPUTexture *GPU_texture_create_buffer(eGPUTextureFormat data_type, const uint buffer);
 
 GPUTexture *GPU_texture_from_bindcode(int textarget, int bindcode);
-GPUTexture *GPU_texture_from_blender(struct Image *ima, struct ImageUser *iuser, int textarget);
+GPUTexture *GPU_texture_from_blender(struct Image *ima,
+                                     struct ImageUser *iuser,
+                                     struct ImBuf *ibuf,
+                                     int textarget);
+GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap);
 
 /* movie clip drawing */
 GPUTexture *GPU_texture_from_movieclip(struct MovieClip *clip,
index d200868009874f12d93fd43165a6faab67bc005e..cfeb7f6bedb72bb7dad36c5480275cab9a62d78f 100644 (file)
@@ -851,7 +851,11 @@ static void gpu_texture_update_from_ibuf(
   GPU_texture_unbind(tex);
 }
 
-GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget)
+/* Get the GPUTexture for a given `Image`.
+ *
+ * `iuser` and `ibuf` are mutual exclusive parameters. The caller can pass the `ibuf` when already
+ * available. It is also required when requesting the GPUTexture for a render result. */
+GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf, int textarget)
 {
   if (ima == NULL) {
     return NULL;
@@ -882,27 +886,33 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget
   }
 
   /* check if we have a valid image buffer */
-  ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
-  if (ibuf == NULL) {
-    *tex = GPU_texture_from_bindcode(textarget, bindcode);
-    return *tex;
+  ImBuf *ibuf_intern = ibuf;
+  if (ibuf_intern == NULL) {
+    ibuf_intern = BKE_image_acquire_ibuf(ima, iuser, NULL);
+    if (ibuf_intern == NULL) {
+      *tex = GPU_texture_from_bindcode(textarget, bindcode);
+      return *tex;
+    }
   }
 
   if (textarget == GL_TEXTURE_2D_ARRAY) {
-    bindcode = gpu_texture_create_tile_array(ima, ibuf);
+    bindcode = gpu_texture_create_tile_array(ima, ibuf_intern);
   }
   else if (textarget == GL_TEXTURE_1D_ARRAY) {
     bindcode = gpu_texture_create_tile_mapping(ima);
   }
   else {
-    bindcode = gpu_texture_create_from_ibuf(ima, ibuf, textarget);
+    bindcode = gpu_texture_create_from_ibuf(ima, ibuf_intern, textarget);
   }
 
-  BKE_image_release_ibuf(ima, ibuf, NULL);
+  /* if `ibuf` was given, we don't own the `ibuf_intern` */
+  if (ibuf == NULL) {
+    BKE_image_release_ibuf(ima, ibuf_intern, NULL);
+  }
 
   *tex = GPU_texture_from_bindcode(textarget, bindcode);
 
-  GPU_texture_orig_size_set(*tex, ibuf->x, ibuf->y);
+  GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
 
   return *tex;
 }
index f7998fab8db110d7c9066862f86544c316aed1e6..eec154ea09d9c84568ef7e3f3e182a4423c4b8ce 100644 (file)
@@ -96,6 +96,7 @@
     /* sculpting defaults to the draw tool for new brushes */ \
     .sculpt_tool = SCULPT_TOOL_DRAW, \
     .pose_smooth_iterations = 4, \
+    .pose_ik_segments = 1, \
  \
     /* A kernel radius of 1 has almost no effect (T63233). */ \
     .blur_kernel_radius = 2, \
index cc1a0cff08bf0506686d89e9027e7b0f2ba5145c..7b5612ef8e72d083384e3ec94b41c8f3f15b4610 100644 (file)
@@ -222,7 +222,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame)
   BKE_imageuser_default(&iuser);
   iuser.framenr = frame;
 
-  GPUTexture *tex = GPU_texture_from_blender(image, &iuser, GL_TEXTURE_2D);
+  GPUTexture *tex = GPU_texture_from_blender(image, &iuser, NULL, GL_TEXTURE_2D);
 
   if (tex == NULL) {
     BKE_reportf(reports, RPT_ERROR, "Failed to load image texture '%s'", image->id.name + 2);