Commit: 302a5b56df1937986e54ef4600cca6f6a70d8066
Author: Jason Wilkins
Date:   Fri Jul 4 15:15:16 2014 -0500
https://developer.blender.org/rB302a5b56df1937986e54ef4600cca6f6a70d8066

[OpenGL Policy] BlendFuncSeparate defaults to GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 
GL_ONE, GL_ZERO

Only set the blend func if the coefficients are different.  Return them to the 
defaults when done.

Note: Fairly confident that Blender and the standalone Cycles renderer are 
correct, but that both the embedded and standalone game engine will need more 
testing.

Note: Do we actually want the default to be: GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 
GL_ONE, GL_ONE_MINUS_SRC_ALPHA?

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

M       intern/cycles/device/device.cpp
M       intern/cycles/device/device_cuda.cpp
M       intern/cycles/util/util_view.cpp
M       source/blender/blenfont/intern/blf.c
M       source/blender/editors/animation/anim_channels_defines.c
M       source/blender/editors/animation/anim_draw.c
M       source/blender/editors/animation/anim_markers.c
M       source/blender/editors/armature/editarmature_sketch.c
M       source/blender/editors/gpencil/drawgpencil.c
M       source/blender/editors/interface/interface.c
M       source/blender/editors/interface/interface_draw.c
M       source/blender/editors/interface/interface_icons.c
M       source/blender/editors/interface/interface_widgets.c
M       source/blender/editors/mask/mask_draw.c
M       source/blender/editors/mesh/editmesh_knife.c
M       source/blender/editors/screen/area.c
M       source/blender/editors/screen/screen_edit.c
M       source/blender/editors/space_clip/clip_draw.c
M       source/blender/editors/space_clip/clip_utils.c
M       source/blender/editors/space_file/file_draw.c
M       source/blender/editors/space_graph/graph_draw.c
M       source/blender/editors/space_image/image_draw.c
M       source/blender/editors/space_info/textview.c
M       source/blender/editors/space_nla/nla_draw.c
M       source/blender/editors/space_node/drawnode.c
M       source/blender/editors/space_node/node_draw.c
M       source/blender/editors/space_outliner/outliner_draw.c
M       source/blender/editors/space_sequencer/sequencer_draw.c
M       source/blender/editors/space_text/text_draw.c
M       source/blender/editors/space_time/space_time.c
M       source/blender/editors/space_view3d/drawmesh.c
M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/editors/space_view3d/drawvolume.c
M       source/blender/editors/space_view3d/view3d_draw.c
M       source/blender/editors/transform/transform.c
M       source/blender/editors/transform/transform_manipulator.c
M       source/blender/editors/uvedit/uvedit_draw.c
M       source/blender/gpu/intern/gpu_draw.c
M       source/blender/windowmanager/intern/wm_playanim.c

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

diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 7fd1b79..97ec242 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -127,8 +127,10 @@ void Device::draw_pixels(device_memory& rgba, int y, int 
w, int h, int dy, int w
                glPixelZoom(1.0f, 1.0f);
        }
 
-       if(transparent)
+       if (transparent) {
                glDisable(GL_BLEND);
+               glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       }
 }
 
 Device *Device::create(DeviceInfo& info, Stats &stats, bool background)
diff --git a/intern/cycles/device/device_cuda.cpp 
b/intern/cycles/device/device_cuda.cpp
index 3bb16c7..db90120 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -1008,9 +1008,11 @@ public:
                                draw_params.unbind_display_space_shader_cb();
                        }
 
-                       if(transparent)
+                       if (transparent) {
                                glDisable(GL_BLEND);
-                       
+                               glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+                       }
+
                        glBindTexture(GL_TEXTURE_2D, 0);
                        glDisable(GL_TEXTURE_2D);
 
diff --git a/intern/cycles/util/util_view.cpp b/intern/cycles/util/util_view.cpp
index 62e73a2..0fab98b 100644
--- a/intern/cycles/util/util_view.cpp
+++ b/intern/cycles/util/util_view.cpp
@@ -66,7 +66,6 @@ void view_display_info(const char *info)
        const int height = 20;
 
        glEnable(GL_BLEND);
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glColor4f(0.1f, 0.1f, 0.1f, 0.8f);
        glRectf(0.0f, V.height - height, V.width, V.height);
        glDisable(GL_BLEND);
@@ -90,7 +89,6 @@ void view_display_help()
        const int y2 = y1 + h;
 
        glEnable(GL_BLEND);
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glColor4f(0.5f, 0.5f, 0.5f, 0.8f);
        glRectf(x1, y1, x2, y2);
        glDisable(GL_BLEND);
@@ -253,6 +251,8 @@ void view_main_loop(const char *title, int width, int 
height,
 
        view_reshape(width, height);
 
+       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
        glutDisplayFunc(view_display);
        glutIdleFunc(view_idle);
        glutReshapeFunc(view_reshape);
diff --git a/source/blender/blenfont/intern/blf.c 
b/source/blender/blenfont/intern/blf.c
index cdccbe0..3944255 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -514,7 +514,6 @@ static void blf_draw__start(FontBLF *font, GLint *mode, 
GLint *param)
 
        glEnable(GL_BLEND);
        glEnable(GL_TEXTURE_2D);
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
        /* Save the current matrix mode. */
        glGetIntegerv(GL_MATRIX_MODE, mode);
diff --git a/source/blender/editors/animation/anim_channels_defines.c 
b/source/blender/editors/animation/anim_channels_defines.c
index 3530857..b47e096 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -3382,7 +3382,6 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem 
*ale, float yminc, float
                selected = 0;
                
        /* set blending again, as may not be set in previous step */
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_BLEND);
        
        /* step 1) draw backdrop ...........................................  */
diff --git a/source/blender/editors/animation/anim_draw.c 
b/source/blender/editors/animation/anim_draw.c
index 9c3f310..029c3b6 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -140,7 +140,6 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, 
int end_frame_width)
        
        /* only draw this if preview range is set */
        if (PRVRANGEON) {
-               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                glEnable(GL_BLEND);
                glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
                
diff --git a/source/blender/editors/animation/anim_markers.c 
b/source/blender/editors/animation/anim_markers.c
index e519fc8..da3d17b 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -330,7 +330,6 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, 
int cfra, int flag)
        glScalef(1.0f / xscale, 1.0f, 1.0f);
        
        glEnable(GL_BLEND);
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        
        /* vertical line - dotted */
 #ifdef DURIAN_CAMERA_SWITCH
diff --git a/source/blender/editors/armature/editarmature_sketch.c 
b/source/blender/editors/armature/editarmature_sketch.c
index 475ffd2..ec139b9 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -2067,7 +2067,6 @@ static void sk_drawSketch(Scene *scene, View3D 
*UNUSED(v3d), SK_Sketch *sketch,
                                glPushMatrix();
 
                                glEnable(GL_BLEND);
-                               glBlendFunc(GL_SRC_ALPHA, 
GL_ONE_MINUS_SRC_ALPHA);
 
                                switch (sketch->next_point.mode) {
                                        case PT_SNAP:
diff --git a/source/blender/editors/gpencil/drawgpencil.c 
b/source/blender/editors/gpencil/drawgpencil.c
index a69c020..6c73cc1 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -556,7 +556,6 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int 
offsy, int winx, int winy,
        glEnable(GL_LINE_SMOOTH);
        
        /* turn on alpha-blending */
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_BLEND);
                
        /* loop over layers, drawing them */
diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index c857150..c059b16 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1257,9 +1257,6 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
        if (multisample_enabled)
                glDisable(GL_MULTISAMPLE_ARB);
 
-       /* we set this only once */
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-       
        /* scale fonts */
        ui_fontscale(&style.paneltitle.points, block->aspect);
        ui_fontscale(&style.grouplabel.points, block->aspect);
diff --git a/source/blender/editors/interface/interface_draw.c 
b/source/blender/editors/interface/interface_draw.c
index f821aab..29da19a 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -446,8 +446,6 @@ static void draw_scope_end(const rctf *rect, GLint *scissor)
        /* restore scissortest */
        glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
 
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
        /* outline */
        glColor4f(0.f, 0.f, 0.f, 0.5f);
        uiSetRoundBox(UI_CNR_ALL);
@@ -460,14 +458,13 @@ static void histogram_draw_one(float r, float g, float b, 
float alpha,
        int i;
        
        if (is_line) {
+               glBlendFunc(GL_SRC_ALPHA, GL_ONE);
 
                glLineWidth(1.5);
-               glBlendFunc(GL_SRC_ALPHA, GL_ONE);
                glColor4f(r, g, b, alpha);
 
                /* curve outline */
 
-               glBlendFunc(GL_SRC_ALPHA, GL_ONE);
                glEnable(GL_LINE_SMOOTH);
                glBegin(GL_LINE_STRIP);
                for (i = 0; i < res; i++) {
@@ -477,14 +474,19 @@ static void histogram_draw_one(float r, float g, float b, 
float alpha,
                glEnd();
                glDisable(GL_LINE_SMOOTH);
 
+               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
                glLineWidth(1.0);
        }
        else {
                /* under the curve */
+
                glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+
                glColor4f(r, g, b, alpha);
 
                glShadeModel(GL_FLAT);
+
                glBegin(GL_QUAD_STRIP);
                glVertex2f(x, y);
                glVertex2f(x, y + (data[0] * h));
@@ -496,9 +498,11 @@ static void histogram_draw_one(float r, float g, float b, 
float alpha,
                glEnd();
 
                /* curve outline */
+
                glColor4f(0.f, 0.f, 0.f, 0.25f);
 
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
                glEnable(GL_LINE_SMOOTH);
                glBegin(GL_LINE_STRIP);
                for (i = 0; i < res; i++) {
@@ -532,7 +536,6 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wcol)
        h = BLI_rctf_size_y(&rect) * hist->ymax;
        
        glEnable(GL_BLEND);
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        
        glColor4f(0.f, 0.f, 0.f, 0.3f);
        uiSetRoundBox(UI_CNR_ALL);
@@ -619,8 +622,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wcol),
        }
 
        glEnable(GL_BLEND);
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-       
+
        glColor4f(0.f, 0.f, 0.f, 0.3f);
        uiSetRoundBox(UI_CNR_ALL);
        uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, 
rect.ymax + 1, 3.0f);
@@ -642,7 +644,6 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wcol),
                BLF_draw_default(rect.xmin + 1, yofs - 5 + (i / 5.f) * h, 0, 
str, sizeof(str) - 1);
                /* in the loop because blf_draw reset it */
                glEnable(GL_BLEND);
-               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        }
        /* 3 vertical separation */
        if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
@@ -665,15 +666,14 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wcol),
        if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA)
                fdrawline(rect.xmin, yofs + h * 0.075f, rect.xmax + 1, yofs + h 
* 0.075f);
 
+       glBlendFunc(GL_ONE, GL_ONE);
+
        if (scopes->ok && scopes->waveform_1 != NULL) {
                
                /* LUMA (1 channel) */
-               glBlendFunc(GL_ONE, GL_ONE);
                glColor3f(alpha, alpha, alpha);
                if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
 
-                       glBlendFunc(GL_ONE, GL_ONE);
-                       
                        glPushMatrix();
                        glEnableClientState(GL_VERTEX_ARRAY);
                        
@@ -702,9 +702,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wcol),
                               SCOPES_WAVEFRM_YCC_JPEG))
                {
                        int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB);
-                       
-                       glBlendFunc(GL_ONE, GL_ONE);
-                       
+
                        glPushMatrix();
                        glEnableClientState(GL_VERTEX_ARRAY);
                        
@@ -743,7 +741,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wcol),
                        }
                }
        }
-       
+
+       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
        /* outline */
        draw_scope_end(&rect, scissor);
 }
@@ -838,7 +838,6 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wco
        alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * 
scopes->vecscope_alpha;
 
        glEnable(GL_BLEND);
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        
        glColor4f(0.f, 0.f, 0.f, 0.3f);
        uiSetRoundBox(UI_CNR_ALL);
@@ -890,6 +889,8 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wco
                
                glDisableClientState(GL_VERTEX_ARRAY);
                glPopMatrix();
+
+               glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        }
 
        /* outline */
@@ -1334,7 +1335,6

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to