Merge lp:~3v1n0/compiz/move-lowgfx-fixes into lp:compiz

Proposed by Marco Trevisan (Treviño) on 2017-06-28
Status: Merged
Approved by: Andrea Azzarone on 2017-06-29
Approved revision: 4129
Merged at revision: 4122
Proposed branch: lp:~3v1n0/compiz/move-lowgfx-fixes
Merge into: lp:compiz
Diff against target: 315 lines (+87/-86)
3 files modified
debian/unity-lowgfx.ini (+1/-0)
plugins/move/src/move.cpp (+82/-86)
plugins/move/src/move.h (+4/-0)
To merge this branch: bzr merge lp:~3v1n0/compiz/move-lowgfx-fixes
Reviewer Review Type Date Requested Status
Andrea Azzarone 2017-06-28 Approve on 2017-06-29
Review via email: mp+326451@code.launchpad.net

Commit Message

move: damage all the border area in outline mode and ignore transparent colors

Also we don't really need to damage at every X event. It's just about doing it
right the firs time, by including the exceeding space.
Also optimize damanging in outline-mode, by only touching such regions

Plus add some optimizations when not blending, as we don't care about the alpha channel

To post a comment you must log in.
lp:~3v1n0/compiz/move-lowgfx-fixes updated on 2017-06-29
4129. By Marco Trevisan (Treviño) on 2017-06-29

move: properly use the blending if enabled

Andrea Azzarone (azzar1) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/unity-lowgfx.ini'
--- debian/unity-lowgfx.ini 2017-01-09 15:08:47 +0000
+++ debian/unity-lowgfx.ini 2017-06-29 01:58:44 +0000
@@ -50,3 +50,4 @@
50[move]50[move]
51s0_mode = 151s0_mode = 1
52s0_blend = false52s0_blend = false
53s0_lazy_positioning = true
5354
=== modified file 'plugins/move/src/move.cpp'
--- plugins/move/src/move.cpp 2017-04-20 08:03:29 +0000
+++ plugins/move/src/move.cpp 2017-06-29 01:58:44 +0000
@@ -34,9 +34,6 @@
3434
35COMPIZ_PLUGIN_20090315 (move, MovePluginVTable)35COMPIZ_PLUGIN_20090315 (move, MovePluginVTable)
3636
37static float pos_x, pos_y;
38static bool paint_rectangle;
39
40static bool37static bool
41moveInitiate (CompAction *action,38moveInitiate (CompAction *action,
42 CompAction::State state,39 CompAction::State state,
@@ -49,13 +46,9 @@
49 if (ms->optionGetMode () != MoveOptions::ModeNormal)46 if (ms->optionGetMode () != MoveOptions::ModeNormal)
50 {47 {
51 ms->gScreen->glPaintOutputSetEnabled (ms, true);48 ms->gScreen->glPaintOutputSetEnabled (ms, true);
52 paint_rectangle = true;49 ms->paintRect = true;
53 pos_x = pos_y = 0;50 ms->rectX = 0;
54 }51 ms->rectY = 0;
55 else
56 {
57 ms->gScreen->glPaintOutputSetEnabled (ms, false);
58 paint_rectangle = false;
59 }52 }
6053
61 Window xid = CompOption::getIntOptionNamed (options, "window");54 Window xid = CompOption::getIntOptionNamed (options, "window");
@@ -188,26 +181,15 @@
188{181{
189 MOVE_SCREEN (screen);182 MOVE_SCREEN (screen);
190183
191 if (ms->optionGetMode () != MoveOptions::ModeNormal)
192 {
193 ms->gScreen->glPaintOutputSetEnabled (ms, true);
194 paint_rectangle = true;
195 }
196 else
197 {
198 ms->gScreen->glPaintOutputSetEnabled (ms, false);
199 paint_rectangle = false;
200 }
201
202 if (ms->w)184 if (ms->w)
203 {185 {
204 MOVE_WINDOW (ms->w);186 MOVE_WINDOW (ms->w);
205187
206 if (ms->optionGetMode () != MoveOptions::ModeNormal) {188 if (ms->paintRect)
189 {
190 ms->paintRect = false;
207 ms->gScreen->glPaintOutputSetEnabled (ms, false);191 ms->gScreen->glPaintOutputSetEnabled (ms, false);
208 paint_rectangle = false;192 mw->window->move (ms->rectX, ms->rectY, true);
209
210 mw->window->move (pos_x, pos_y, true);
211 }193 }
212194
213 if (state & CompAction::StateCancel)195 if (state & CompAction::StateCancel)
@@ -564,8 +546,8 @@
564 }546 }
565 else547 else
566 {548 {
567 pos_x += wX + dx - w->geometry ().x ();549 ms->rectX += wX + dx - w->geometry ().x ();
568 pos_y += wY + dy - w->geometry ().y ();550 ms->rectY += wY + dy - w->geometry ().y ();
569 }551 }
570552
571 ms->x -= dx;553 ms->x -= dx;
@@ -577,10 +559,6 @@
577void559void
578MoveScreen::handleEvent (XEvent *event)560MoveScreen::handleEvent (XEvent *event)
579{561{
580 Box box;
581 if (getMovingRectangle (&box))
582 damageMovingRectangle (&box);
583
584 switch (event->type)562 switch (event->type)
585 {563 {
586 case ButtonPress:564 case ButtonPress:
@@ -757,6 +735,9 @@
757 status (RectangleOut),735 status (RectangleOut),
758 releaseButton (0),736 releaseButton (0),
759 grab (NULL),737 grab (NULL),
738 paintRect(false),
739 rectX(0),
740 rectY(0),
760 hasCompositing (false),741 hasCompositing (false),
761 yConstrained (false)742 yConstrained (false)
762{743{
@@ -784,16 +765,7 @@
784 ScreenInterface::setHandler (screen);765 ScreenInterface::setHandler (screen);
785 GLScreenInterface::setHandler (gScreen);766 GLScreenInterface::setHandler (gScreen);
786767
787 if (optionGetMode () != MoveOptions::ModeNormal)768 gScreen->glPaintOutputSetEnabled (this, false);
788 {
789 paint_rectangle = true;
790 gScreen->glPaintOutputSetEnabled (this, true);
791 }
792 else
793 {
794 paint_rectangle = false;
795 gScreen->glPaintOutputSetEnabled (this, false);
796 }
797}769}
798770
799MoveScreen::~MoveScreen ()771MoveScreen::~MoveScreen ()
@@ -805,12 +777,7 @@
805bool777bool
806MoveScreen::getMovingRectangle (BoxPtr pBox)778MoveScreen::getMovingRectangle (BoxPtr pBox)
807{779{
808 if (optionGetMode () == MoveOptions::ModeNormal)
809 return false;
810
811 MOVE_SCREEN (screen);780 MOVE_SCREEN (screen);
812 if (!ms)
813 return false;
814781
815 CompWindow *w = ms->w;782 CompWindow *w = ms->w;
816 if (!w)783 if (!w)
@@ -821,8 +788,8 @@
821 int wWidth = w->geometry ().widthIncBorders () + w->border ().left + w->border ().right;788 int wWidth = w->geometry ().widthIncBorders () + w->border ().left + w->border ().right;
822 int wHeight = w->geometry ().heightIncBorders () + w->border ().top + w->border ().bottom;789 int wHeight = w->geometry ().heightIncBorders () + w->border ().top + w->border ().bottom;
823790
824 pBox->x1 = wX + pos_x;791 pBox->x1 = wX + ms->rectX;
825 pBox->y1 = wY + pos_y;792 pBox->y1 = wY + ms->rectY;
826793
827 pBox->x2 = pBox->x1 + wWidth;794 pBox->x2 = pBox->x1 + wWidth;
828 pBox->y2 = pBox->y1 + wHeight;795 pBox->y2 = pBox->y1 + wHeight;
@@ -838,30 +805,20 @@
838{805{
839 bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);806 bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
840807
841 if (status && paint_rectangle)808 if (status && paintRect)
842 {809 {
843 unsigned short *borderColor = optionGetBorderColor ();810 unsigned short *borderColor = optionGetBorderColor ();
844 unsigned short *fillColor = optionGetFillColor ();811 unsigned short *fillColor = NULL;
845812
846 return glPaintMovingRectangle (transform, output, borderColor, (optionGetMode() == MoveOptions::ModeRectangle) ? fillColor : NULL);813 if (optionGetMode() == MoveOptions::ModeRectangle)
814 fillColor = optionGetFillColor ();
815
816 return glPaintMovingRectangle (transform, output, borderColor, fillColor);
847 }817 }
818
848 return status;819 return status;
849}820}
850821
851void
852MoveScreen::damageMovingRectangle (BoxPtr pBox)
853{
854 int x1, x2, y1, y2;
855
856 x1 = pBox->x1 - 1;
857 y1 = pBox->y1 - 1;
858 x2 = pBox->x2 + 1;
859 y2 = pBox->y2 + 1;
860
861 if (cScreen)
862 cScreen->damageRegion (CompRect (x1, y1, x2 - x1, y2 - y1));
863}
864
865bool822bool
866MoveScreen::glPaintMovingRectangle (const GLMatrix &transform,823MoveScreen::glPaintMovingRectangle (const GLMatrix &transform,
867 CompOutput *output,824 CompOutput *output,
@@ -872,6 +829,8 @@
872 if (!getMovingRectangle(&box))829 if (!getMovingRectangle(&box))
873 return false;830 return false;
874831
832 const unsigned short MaxUShort = std::numeric_limits <unsigned short>::max ();
833 const float MaxUShortFloat = MaxUShort;
875 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();834 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
876 GLMatrix sTransform (transform);835 GLMatrix sTransform (transform);
877836
@@ -881,6 +840,13 @@
881 GLint origSrc, origDst;840 GLint origSrc, origDst;
882841
883 bool blend = optionGetBlend ();842 bool blend = optionGetBlend ();
843
844 if (blend && borderColor[3] == MaxUShort)
845 {
846 if (optionGetMode () == MoveOptions::ModeOutline || fillColor[3] == MaxUShort)
847 blend = false;
848 }
849
884 if (blend)850 if (blend)
885 {851 {
886#ifdef USE_GLES852#ifdef USE_GLES
@@ -895,12 +861,10 @@
895#endif861#endif
896 }862 }
897863
898 bc[3] = (float) borderColor[3] / (float) 65535.0f;864 bc[3] = blend ? ((float) borderColor[3] / MaxUShortFloat) : MaxUShortFloat;
899 bc[0] = ((float) borderColor[0] / 65535.0f) * bc[3];865 bc[0] = ((float) borderColor[0] / MaxUShortFloat) * bc[3];
900 bc[1] = ((float) borderColor[1] / 65535.0f) * bc[3];866 bc[1] = ((float) borderColor[1] / MaxUShortFloat) * bc[3];
901 bc[2] = ((float) borderColor[2] / 65535.0f) * bc[3];867 bc[2] = ((float) borderColor[2] / MaxUShortFloat) * bc[3];
902 if (!blend)
903 bc[3] = 1;
904868
905 vertexData[0] = box.x1;869 vertexData[0] = box.x1;
906 vertexData[1] = box.y1;870 vertexData[1] = box.y1;
@@ -951,12 +915,10 @@
951 /* fill rectangle */915 /* fill rectangle */
952 if (fillColor)916 if (fillColor)
953 {917 {
954 fc[3] = fillColor[3];918 fc[3] = blend ? fillColor[3] : 0.85f * MaxUShortFloat;
955 fc[0] = fillColor[0] * (unsigned long) fc[3] / 65535;919 fc[0] = fillColor[0] * (unsigned long) fc[3] / MaxUShortFloat;
956 fc[1] = fillColor[1] * (unsigned long) fc[3] / 65535;920 fc[1] = fillColor[1] * (unsigned long) fc[3] / MaxUShortFloat;
957 fc[2] = fillColor[2] * (unsigned long) fc[3] / 65535;921 fc[2] = fillColor[2] * (unsigned long) fc[3] / MaxUShortFloat;
958 if (!blend)
959 fc[3] = 1;
960922
961 streamingBuffer->begin (GL_TRIANGLE_STRIP);923 streamingBuffer->begin (GL_TRIANGLE_STRIP);
962 streamingBuffer->addColors (1, fc);924 streamingBuffer->addColors (1, fc);
@@ -977,18 +939,52 @@
977939
978 if (blend)940 if (blend)
979 {941 {
980 glEnable (GL_BLEND);942 glDisable (GL_BLEND);
981 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);943#ifdef USE_GLES
944 glBlendFuncSeparate (origSrc, origDst,
945 origSrcAlpha, origDstAlpha);
946#else
947 glBlendFunc (origSrc, origDst);
948#endif
982 }949 }
983950
984 CompositeScreen *cScreen = CompositeScreen::get (screen);
985 if (cScreen)951 if (cScreen)
986 {952 {
987 CompRect damage (box.x1 - borderWidth,953 CompRegion damageRegion;
988 box.y1 - borderWidth,954
989 box.x2 - box.x1 + 2,955 if (optionGetMode () == MoveOptions::ModeOutline)
990 box.y2 - box.y1 + 2);956 {
991 cScreen->damageRegion (damage);957 // Top
958 damageRegion += CompRect (box.x1 - borderWidth,
959 box.y1 - borderWidth,
960 box.x2 - box.x1 + borderWidth * 2,
961 borderWidth + 1);
962 // Right
963 damageRegion += CompRect (box.x2 - borderWidth,
964 box.y1 - borderWidth,
965 borderWidth + 1,
966 box.y2 - box.y1 + borderWidth * 2);
967 // Bottom
968 damageRegion += CompRect (box.x1 - borderWidth,
969 box.y2 - borderWidth,
970 box.x2 - box.x1 + borderWidth * 2,
971 borderWidth + 1);
972 // Left
973 damageRegion += CompRect (box.x1 - borderWidth,
974 box.y1 - borderWidth,
975 borderWidth + 1,
976 box.y2 - box.y1 + borderWidth * 2);
977 }
978 else
979 {
980 CompRect damage (box.x1 - borderWidth,
981 box.y1 - borderWidth,
982 box.x2 - box.x1 + borderWidth * 2,
983 box.y2 - box.y1 + borderWidth * 2);
984 damageRegion += damage;
985 }
986
987 cScreen->damageRegion (damageRegion);
992 }988 }
993989
994 return true;990 return true;
995991
=== modified file 'plugins/move/src/move.h'
--- plugins/move/src/move.h 2016-09-01 13:59:44 +0000
+++ plugins/move/src/move.h 2017-06-29 01:58:44 +0000
@@ -95,6 +95,10 @@
9595
96 unsigned int origState;96 unsigned int origState;
9797
98 bool paintRect;
99 int rectX;
100 int rectY;
101
98 int snapOffX;102 int snapOffX;
99 int snapBackX;103 int snapBackX;
100104

Subscribers

People subscribed via source and target branches