[Bf-blender-cvs] [a514fea932] blender2.8: OpenGL: remove old DrawPixels util functions

Mike Erwin noreply at git.blender.org
Sat Mar 4 00:19:04 CET 2017


Commit: a514fea93248756b4319a5f661a2f292bb9125ae
Author: Mike Erwin
Date:   Fri Mar 3 18:18:21 2017 -0500
Branches: blender2.8
https://developer.blender.org/rBa514fea93248756b4319a5f661a2f292bb9125ae

OpenGL: remove old DrawPixels util functions

a little bit of T49043, mostly related to T49165

Thx to @fclem for marking these as unused & making shader-based replacements.

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

M	source/blender/editors/include/BIF_glutil.h
M	source/blender/editors/screen/glutil.c

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

diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index 74c96f46cc..e67094027f 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -136,45 +136,6 @@ int glaGetOneInt(int param);
  */
 void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y);
 
-#if 0 /* Obsolete / unused */
-/**
- * Functions like a limited glDrawPixels, except ensures that
- * the image is displayed onscreen even if the \a x and \a y
- * coordinates for would be clipped. The routine respects the
- * glPixelZoom values, pixel unpacking parameters are _not_
- * respected.
- *
- * \attention This routine makes many assumptions: the rect data
- * is expected to be in RGBA unsigned byte format, the coordinate
- * (GLA_PIXEL_OFS, GLA_PIXEL_OFS) is assumed to be within the view frustum,
- * and the modelview and projection matrices are assumed to define a
- * 1-to-1 mapping to screen space.
- * \attention Furthermore, in the case of zoomed or unpixel aligned
- * images extending outside the view frustum, but still within the
- * window, some portion of the image may be visible left and/or
- * below of the given \a x and \a y coordinates. It is recommended
- * to use the glScissor functionality if images are to be drawn
- * with an inset view matrix.
- */
-void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int format, int type, void *rect);
-
-/**
- * glaDrawPixelsTex - Functions like a limited glDrawPixels, but actually draws the
- * image using textures, which can be tremendously faster on low-end
- * cards, and also avoids problems with the raster position being
- * clipped when offscreen. The routine respects the glPixelZoom values,
- * pixel unpacking parameters are _not_ respected.
- *
- * \attention This routine makes many assumptions: the rect data
- * is expected to be in RGBA byte or float format, and the
- * modelview and projection matrices are assumed to define a
- * 1-to-1 mapping to screen space.
- */
-void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect);
-void glaDrawPixelsTex_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect,
-                               float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y);
-#endif
-
 /* To be used before calling immDrawPixelsTex
  * Default shader is GPU_SHADER_2D_IMAGE_COLOR
  * Returns a shader to be able to set uniforms */
@@ -199,22 +160,6 @@ void immDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int ty
 void immDrawPixelsTex_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect,
                                float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y,
                                float xzoom, float yzoom, float color[4]);
-#if 0 /* Obsolete / unused */
-/**
- * glaDrawPixelsAuto - Switches between texture or pixel drawing using UserDef.
- * only RGBA
- * needs glaDefine2DArea to be set.
- */
-void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect);
-void glaDrawPixelsAuto_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect,
-                                float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y);
-
-
-void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY);
-void glaDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY,
-                                     float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y);
-#endif
-
 void immDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY,
                            float xzoom, float yzoom, float color[4]);
 void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY,
@@ -234,6 +179,9 @@ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, int
  * \param screen_rect The screen rectangle to be defined for 2D drawing.
  */
 void glaDefine2DArea(struct rcti *screen_rect);
+
+/* TODO(merwin): put the following 2D code to use, or build new 2D code inspired & informd by it */
+
 #if 0  /* UNUSED */
 
 typedef struct gla2DDrawInfo gla2DDrawInfo;
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index dcf7b1ba20..14fdcb1f72 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -286,274 +286,6 @@ static int get_cached_work_texture(int *r_w, int *r_h)
 	return texid;
 }
 
-#if 0 /* Obsolete / unused */
-/* DEPRECATED: use immDrawPixelsTexScaled_clipping instead */
-void glaDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h,
-                                     int format, int type, int zoomfilter, void *rect,
-                                     float scaleX, float scaleY,
-                                     float clip_min_x, float clip_min_y,
-                                     float clip_max_x, float clip_max_y)
-{
-	unsigned char *uc_rect = (unsigned char *) rect;
-	const float *f_rect = (float *)rect;
-	float xzoom = glaGetOneFloat(GL_ZOOM_X), yzoom = glaGetOneFloat(GL_ZOOM_Y);
-	int subpart_x, subpart_y, tex_w, tex_h;
-	int seamless, offset_x, offset_y, nsubparts_x, nsubparts_y;
-	int texid = get_cached_work_texture(&tex_w, &tex_h);
-	int components;
-	const bool use_clipping = ((clip_min_x < clip_max_x) && (clip_min_y < clip_max_y));
-
-	/* Specify the color outside this function, and tex will modulate it.
-	 * This is useful for changing alpha without using glPixelTransferf()
-	 */
-	glPixelStorei(GL_UNPACK_ROW_LENGTH, img_w);
-	glBindTexture(GL_TEXTURE_2D, texid);
-
-	/* don't want nasty border artifacts */
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, zoomfilter);
-
-	/* setup seamless 2=on, 0=off */
-	seamless = ((tex_w < img_w || tex_h < img_h) && tex_w > 2 && tex_h > 2) ? 2 : 0;
-	
-	offset_x = tex_w - seamless;
-	offset_y = tex_h - seamless;
-	
-	nsubparts_x = (img_w + (offset_x - 1)) / (offset_x);
-	nsubparts_y = (img_h + (offset_y - 1)) / (offset_y);
-
-	if (format == GL_RGBA)
-		components = 4;
-	else if (format == GL_RGB)
-		components = 3;
-	else if (ELEM(format, GL_LUMINANCE, GL_ALPHA))
-		components = 1;
-	else {
-		BLI_assert(!"Incompatible format passed to glaDrawPixelsTexScaled");
-		return;
-	}
-
-	if (type == GL_FLOAT) {
-		/* need to set internal format to higher range float */
-
-		/* NOTE: this could fail on some drivers, like mesa,
-		 *       but currently this code is only used by color
-		 *       management stuff which already checks on whether
-		 *       it's possible to use GL_RGBA16F_ARB
-		 */
-
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, tex_w, tex_h, 0, format, GL_FLOAT, NULL);
-	}
-	else {
-		/* switch to 8bit RGBA for byte buffer */
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, format, GL_UNSIGNED_BYTE, NULL);
-	}
-
-	for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) {
-		for (subpart_x = 0; subpart_x < nsubparts_x; subpart_x++) {
-			int remainder_x = img_w - subpart_x * offset_x;
-			int remainder_y = img_h - subpart_y * offset_y;
-			int subpart_w = (remainder_x < tex_w) ? remainder_x : tex_w;
-			int subpart_h = (remainder_y < tex_h) ? remainder_y : tex_h;
-			int offset_left = (seamless && subpart_x != 0) ? 1 : 0;
-			int offset_bot = (seamless && subpart_y != 0) ? 1 : 0;
-			int offset_right = (seamless && remainder_x > tex_w) ? 1 : 0;
-			int offset_top = (seamless && remainder_y > tex_h) ? 1 : 0;
-			float rast_x = x + subpart_x * offset_x * xzoom;
-			float rast_y = y + subpart_y * offset_y * yzoom;
-			/* check if we already got these because we always get 2 more when doing seamless */
-			if (subpart_w <= seamless || subpart_h <= seamless)
-				continue;
-
-			if (use_clipping) {
-				if (rast_x + (float)(subpart_w - offset_right) * xzoom * scaleX < clip_min_x ||
-				    rast_y + (float)(subpart_h - offset_top) * yzoom * scaleY < clip_min_y)
-				{
-					continue;
-				}
-				if (rast_x + (float)offset_left * xzoom > clip_max_x ||
-				    rast_y + (float)offset_bot * yzoom > clip_max_y)
-				{
-					continue;
-				}
-			}
-
-			if (type == GL_FLOAT) {
-				glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, format, GL_FLOAT, &f_rect[((size_t)subpart_y) * offset_y * img_w * components + subpart_x * offset_x * components]);
-				
-				/* add an extra border of pixels so linear looks ok at edges of full image */
-				if (subpart_w < tex_w)
-					glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, format, GL_FLOAT, &f_rect[((size_t)subpart_y) * offset_y * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
-				if (subpart_h < tex_h)
-					glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, format, GL_FLOAT, &f_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components + subpart_x * offset_x * components]);
-				if (subpart_w < tex_w && subpart_h < tex_h)
-					glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, format, GL_FLOAT, &f_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
-			}
-			else {
-				glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, format, GL_UNSIGNED_BYTE, &uc_rect[((size_t)subpart_y) * offset_y * img_w * components + subpart_x * offset_x * components]);
-				
-				if (subpart_w < tex_w)
-					glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, format, GL_UNSIGNED_BYTE, &uc_rect[((size_t)subpart_y) * offset_y * img_w * components + (subpart_x * offset

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list