Revision: 40867
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40867
Author:   psy-fi
Date:     2011-10-09 01:12:08 +0000 (Sun, 09 Oct 2011)
Log Message:
-----------
Optimize away the conversion and copy of float images in texture paint if the 
buffer is already in color corrected space and using high resolution images.

Modified Paths:
--------------
    branches/soc-2011-onion-uv-tools/source/blender/gpu/intern/gpu_draw.c

Modified: branches/soc-2011-onion-uv-tools/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/gpu/intern/gpu_draw.c       
2011-10-09 01:11:07 UTC (rev 40866)
+++ branches/soc-2011-onion-uv-tools/source/blender/gpu/intern/gpu_draw.c       
2011-10-09 01:12:08 UTC (rev 40867)
@@ -779,23 +779,18 @@
                glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels);
                glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows);
 
-               if (ibuf->rect_float){
-                       /*This case needs a whole new buffer*/
-                       if(ibuf->rect==NULL) {
-                               IMB_rect_from_float(ibuf);
-                       }
-                       else {
-                               /* Do partial drawing. 'buffer' holds only the 
changed part. Needed for color corrected result */
-                               float *buffer = (float 
*)MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf");
-                               IMB_partial_rect_from_float(ibuf, buffer, x, y, 
w, h);
-                               glBindTexture(GL_TEXTURE_2D, ima->bindcode);
-                               glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, 
GL_RGBA,
+               /* if color correction is needed, we must update the part that 
needs updating.
+                * If using high bit depth textures, no dithering is needed, 
same as on initialization */
+               if (ibuf->rect_float && (!U.high_bit_depth_tex || 
(ibuf->profile == IB_PROFILE_LINEAR_RGB))){
+                       float *buffer = (float 
*)MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf");
+                       IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h);
+                       glBindTexture(GL_TEXTURE_2D, ima->bindcode);
+                       glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
                                        GL_FLOAT, buffer);
-                               MEM_freeN(buffer);
-                               if(ima->tpageflag & IMA_MIPMAP_COMPLETE)
-                                       ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
-                               return;
-                       }
+                       MEM_freeN(buffer);
+                       if(ima->tpageflag & IMA_MIPMAP_COMPLETE)
+                               ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+                       return;
                }
 
                glBindTexture(GL_TEXTURE_2D, ima->bindcode);
@@ -804,8 +799,13 @@
                glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
                glPixelStorei(GL_UNPACK_SKIP_ROWS, y);
 
-               glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
-                       GL_UNSIGNED_BYTE, ibuf->rect);
+               if (ibuf->rect_float){
+                       glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
+                               GL_FLOAT, ibuf->rect_float);
+               }else{
+                       glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
+                                       GL_UNSIGNED_BYTE, ibuf->rect);
+               }
 
                glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
                glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to