~unity-team/unity/x-sru6

« back to all changes in this revision

Viewing changes to unity-shared/OverlayRenderer.cpp

  • Committer: Bileto Bot
  • Date: 2016-09-06 23:17:13 UTC
  • mfrom: (4112.1.19 x-sru4)
  • Revision ID: ci-train-bot@canonical.com-20160906231713-urgarg7fi572kr0s
* SwitcherView: always disable animations when in lowgfx mode (LP:
  #1602784)
* When locked discard damages from windows below lockscreen. (LP:
  #1605180)
* DecoratedWindow: display unmaximize button if the window is
  vertically or horizontally maximized (LP: #1608480)
* Make sure the switcher detail view is properly scaled. Also scale
  the xy_offset to make sure the switcher and launcher do not overlap.
  (LP: #1605256)
* Close session dialog on first ESC. (LP: #1521116)
* Filter out scrolling envents for FilterExpanderLabel. (LP: #1604632)
* Disable menu discovery animation if MenusDiscoveryDuration is 0.
  (LP: #942962)
* Redraw fake decorations on window resize. (LP: #940470)
* Use compiz::Window::serverNext instead of compiz::Window::next in
  IsWindowObscured as the latter can be outdated just after
  scale/spread terminates. (LP: #1614116)
* DecoratedWindow: avoid deferencing an invalid shadow texture ptr,
  and split functions (LP: #1608464)
* DecoratedWindow: display unmaximize button if the window is
  vertically or horizontally maximized (LP: #1608480)
* DecorationsForceQuitDialog: make CSS selectors work with gtk 3.20
* UserAuthenticatorPam: ensure pam_handle_ is null initialized and
  don't proceed if not set (LP: #1611668)
* DecorationStyle: set css name for Gtk 3.20
* OverlayRenderer: properly decorate launcher/panel when the launcher
  is at the bottom (LP: #1611694)
* OverlayRenderer: don't use rotated textures, just rotate them at
  rendering time
* SpreadWidgets: add container for spread filter and new spread
  decorations (LP: #1283314)
* WindowButton: properly partially unmaximize a window when
  middle/left clicking in the restore button (LP: #1616136)

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
// Now that we mask the corners of the dash,
51
51
// draw longer lines to fill the minimal gaps
52
52
const RawPixel CORNER_OVERLAP = 3_em;
 
53
 
 
54
enum class OverlayPosition
 
55
{
 
56
  LEFT,
 
57
  BOTTOM
 
58
};
53
59
}
54
60
 
55
61
// Impl class
82
88
  nux::ObjectPtr<nux::BaseTexture> right_texture_;
83
89
  nux::ObjectPtr<nux::BaseTexture> right_texture_mask_;
84
90
  nux::ObjectPtr<nux::BaseTexture> left_texture_;
85
 
  nux::ObjectPtr<nux::BaseTexture> top_bottom_texture_;
 
91
  nux::ObjectPtr<nux::BaseTexture> top_left_texture_;
 
92
  nux::ObjectPtr<nux::BaseTexture> top_texture_;
 
93
  nux::ObjectPtr<nux::BaseTexture> bottom_texture_;
86
94
 
87
95
  nux::ObjectPtr<nux::BaseTexture> corner_;
88
96
  nux::ObjectPtr<nux::BaseTexture> corner_mask_;
120
128
  parent->scale.changed.connect(sigc::hide(sigc::mem_fun(this, &OverlayRendererImpl::LoadScaledTextures)));
121
129
  parent->owner_type.changed.connect(sigc::hide(sigc::mem_fun(this, &OverlayRendererImpl::LoadScaledTextures)));
122
130
  Settings::Instance().low_gfx.changed.connect(sigc::hide(sigc::mem_fun(this, &OverlayRendererImpl::UpdateTextures)));
123
 
  Settings::Instance().launcher_position.changed.connect(sigc::hide(sigc::mem_fun(this, &OverlayRendererImpl::LoadScaledTextures)));
124
131
  dash::Style::Instance().textures_changed.connect(sigc::mem_fun(this, &OverlayRendererImpl::UpdateTextures));
125
132
  dash::Style::Instance().textures_changed.connect(sigc::mem_fun(this, &OverlayRendererImpl::LoadScaledTextures));
126
133
 
132
139
{
133
140
  double scale = parent->scale;
134
141
  auto& style = dash::Style::Instance();
135
 
  auto dash_position = dash::Position::LEFT;
136
 
 
137
 
  if (Settings::Instance().launcher_position() == LauncherPosition::BOTTOM && parent->owner_type() == OverlayOwner::Dash)
138
 
    dash_position = dash::Position::BOTTOM;
139
 
 
140
 
  horizontal_texture_ = style.GetDashHorizontalTile(scale, dash_position);
141
 
  horizontal_texture_mask_ = style.GetDashHorizontalTileMask(scale, dash_position);
 
142
 
 
143
  horizontal_texture_ = style.GetDashHorizontalTile(scale);
 
144
  horizontal_texture_mask_ = style.GetDashHorizontalTileMask(scale);
142
145
  right_texture_ = style.GetDashRightTile(scale);
143
146
  right_texture_mask_ = style.GetDashRightTileMask(scale);
 
147
  top_left_texture_ = style.GetDashTopLeftTile(scale);
144
148
  left_texture_ = style.GetDashLeftTile(scale);
145
 
  top_bottom_texture_ = style.GetDashTopOrBottomTile(scale, dash_position);
 
149
  top_texture_ = style.GetDashTopTile(scale);
146
150
 
147
 
  corner_ = style.GetDashCorner(scale, dash_position);
148
 
  corner_mask_ = style.GetDashCornerMask(scale, dash_position);
149
 
  left_corner_ = style.GetDashLeftCorner(scale, dash_position);
150
 
  left_corner_mask_ = style.GetDashLeftCornerMask(scale, dash_position);
151
 
  right_corner_ = style.GetDashRightCorner(scale, dash_position);
152
 
  right_corner_mask_ = style.GetDashRightCornerMask(scale, dash_position);
 
151
  corner_ = style.GetDashCorner(scale);
 
152
  corner_mask_ = style.GetDashCornerMask(scale);
 
153
  left_corner_ = style.GetDashLeftCorner(scale);
 
154
  left_corner_mask_ = style.GetDashLeftCornerMask(scale);
 
155
  right_corner_ = style.GetDashRightCorner(scale);
 
156
  right_corner_mask_ = style.GetDashRightCornerMask(scale);
153
157
}
154
158
 
155
159
void OverlayRendererImpl::OnBgColorChanged(nux::Color const& new_color)
610
614
 
611
615
  if (settings.form_factor() != FormFactor::NETBOOK || force_edges)
612
616
  {
613
 
    int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse();
614
 
    nux::Geometry const& monitor_geo = unity::UScreen::GetDefault()->GetMonitorGeometry(monitor);
 
617
    int monitor = UScreen::GetDefault()->GetMonitorAtPosition(absolute_geo.x, absolute_geo.y);
 
618
    auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);
615
619
    int launcher_size = Settings::Instance().LauncherSize(monitor);
616
620
    int panel_height = panel::Style::Instance().PanelHeight(monitor);
617
621
 
618
 
    auto dash_position = dash::Position::LEFT;
 
622
    auto dash_position = OverlayPosition::LEFT;
619
623
    int border_y = content_geo.y;
620
624
    int border_height = larger_absolute_geo.height;
621
625
    if (parent->owner_type() == OverlayOwner::Dash && settings.launcher_position() == LauncherPosition::BOTTOM)
622
626
    {
623
627
      border_y = panel_height;
624
628
      border_height = monitor_geo.height - launcher_size;
625
 
      dash_position = dash::Position::BOTTOM;
 
629
      dash_position = OverlayPosition::BOTTOM;
626
630
    }
627
631
 
628
632
    nux::Geometry geo_border(content_geo.x, border_y, larger_absolute_geo.width - content_geo.x, border_height);
646
650
      auto const& left_tile = left_texture_;
647
651
      auto const& right_corner = right_corner_;
648
652
      auto const& right_corner_mask = right_corner_mask_;
649
 
      auto const& top_tile = top_bottom_texture_;
 
653
      auto const& horizontal_tile = top_texture_;
 
654
 
 
655
      if (dash_position == OverlayPosition::BOTTOM)
 
656
      {
 
657
        // Let's flip all the textures vertically
 
658
        texxform.flip_v_coord = true;
 
659
      }
650
660
 
651
661
      int left_corner_offset = LEFT_CORNER_OFFSET.CP(scale);
652
662
      int top_corner_offset = TOP_CORNER_OFFSET.CP(scale);
662
672
        texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
663
673
        int corner_y = geo.y + (geo.height - corner_size.height);
664
674
 
665
 
        if (dash_position == dash::Position::BOTTOM)
 
675
        if (dash_position == OverlayPosition::BOTTOM)
666
676
          corner_y = geo.y - corner_size.height + top_corner_offset;
667
677
 
668
678
        // Selectively erase blur region in the curbe
700
710
      {
701
711
        // Horizontal repeated texture
702
712
        int real_width = geo.width - (left_corner_size.width - left_corner_offset) - corner_size.width;
703
 
        int offset = real_width % horizontal->GetWidth();
704
713
        int horizontal_y = geo.y + (geo.height - horizontal->GetHeight());
705
714
 
706
 
        if (dash_position == dash::Position::BOTTOM)
 
715
        if (dash_position == OverlayPosition::BOTTOM)
707
716
          horizontal_y = geo.y - horizontal->GetHeight() + top_corner_offset;
708
717
 
709
718
        texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
710
719
        texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
711
720
 
712
721
        // Selectively erase blur region in the curbe
713
 
        gfx_context.QRP_ColorModTexAlpha(left_corner_size.width - left_corner_offset - offset,
 
722
        gfx_context.QRP_ColorModTexAlpha(left_corner_size.width - left_corner_offset,
714
723
                                         horizontal_y,
715
 
                                         real_width + offset,
 
724
                                         real_width,
716
725
                                         horizontal->GetHeight(),
717
726
                                         horizontal_mask->GetDeviceTexture(),
718
727
                                         texxform,
721
730
        // Write correct alpha
722
731
        gfx_context.GetRenderStates().SetBlend(false);
723
732
        gfx_context.GetRenderStates().SetColorMask(false, false, false, true);
724
 
        RenderInverseMask(gfx_context, left_corner_size.width - left_corner_offset - offset,
 
733
        RenderInverseMask(gfx_context, left_corner_size.width - left_corner_offset,
725
734
                             horizontal_y,
726
 
                             real_width + offset,
 
735
                             real_width,
727
736
                             horizontal->GetHeight(),
728
737
                             horizontal_mask->GetDeviceTexture(),
729
738
                             texxform,
733
742
        gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
734
743
        gfx_context.GetRenderStates().SetColorMask(true, true, true, true);
735
744
 
736
 
        gfx_context.QRP_1Tex(left_corner_size.width - left_corner_offset - offset,
 
745
        gfx_context.QRP_1Tex(left_corner_size.width - left_corner_offset,
737
746
                             horizontal_y,
738
 
                             real_width + offset,
 
747
                             real_width,
739
748
                             horizontal->GetHeight(),
740
749
                             horizontal->GetDeviceTexture(),
741
750
                             texxform,
747
756
        texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
748
757
        int left_corner_y = geo.y + (geo.height - left_corner_size.height);
749
758
 
750
 
        if (dash_position == dash::Position::BOTTOM)
 
759
        if (dash_position == OverlayPosition::BOTTOM)
751
760
          left_corner_y = geo.y - left_corner_size.height + top_corner_offset;
752
761
 
753
 
        if (dash_position == dash::Position::LEFT)
 
762
        if (dash_position == OverlayPosition::LEFT)
754
763
        {
755
764
          // Selectively erase blur region in the curbe
756
765
          gfx_context.QRP_ColorModTexAlpha(geo.x - left_corner_offset,
792
801
        int offset = real_height % left_tile->GetHeight();
793
802
        int left_texture_y = geo.y + geo.height;
794
803
 
795
 
        if (dash_position == dash::Position::BOTTOM)
 
804
        if (dash_position == OverlayPosition::BOTTOM)
796
805
        {
797
 
          left_texture_y = panel_height;
798
 
          real_height = monitor_geo.height - launcher_size - content_geo.height - left_corner->GetHeight() - panel_height + top_corner_offset;
 
806
          left_texture_y = panel_height + top_left_texture_->GetHeight();
 
807
          real_height = monitor_geo.height - launcher_size - content_geo.height - left_corner->GetHeight() - panel_height + top_corner_offset - top_left_texture_->GetHeight();
799
808
        }
800
809
        else if (settings.launcher_position() == LauncherPosition::BOTTOM)
801
810
        {
802
 
          real_height -= launcher_size;
 
811
          real_height -= launcher_size + top_left_texture_->GetWidth();
803
812
        }
804
813
 
805
814
        texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
819
828
        texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
820
829
        int right_edge_y = geo.y + right_corner_size.height - top_corner_offset;
821
830
 
822
 
        if (dash_position == dash::Position::BOTTOM)
 
831
        if (dash_position == OverlayPosition::BOTTOM)
823
832
          right_edge_y = geo.y + top_corner_offset;
824
833
 
825
834
        // Selectively erase blur region in the curbe
860
869
        texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
861
870
        int right_corner_y = geo.y - top_corner_offset;
862
871
 
863
 
        if (dash_position == dash::Position::BOTTOM)
 
872
        if (dash_position == OverlayPosition::BOTTOM)
864
873
          right_corner_y = geo.y + content_geo.height - right_corner_size.height + top_corner_offset;
865
874
 
866
875
        // Selectively erase blur region in the curbe
900
909
        texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
901
910
        int y = geo.y - top_corner_offset;
902
911
 
903
 
        if (dash_position == dash::Position::BOTTOM)
904
 
          y = geo.y + content_geo.height - top_tile->GetHeight() + top_corner_offset;
 
912
        if (dash_position == OverlayPosition::BOTTOM)
 
913
          y = geo.y + content_geo.height - horizontal_tile->GetHeight() + top_corner_offset;
905
914
 
906
915
        gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
907
916
        gfx_context.QRP_1Tex(geo.x + geo.width,
908
917
                             y,
909
918
                             geometry.width - (geo.x + geo.width),
910
 
                             top_tile->GetHeight(),
911
 
                             top_tile->GetDeviceTexture(),
 
919
                             horizontal_tile->GetHeight(),
 
920
                             horizontal_tile->GetDeviceTexture(),
912
921
                             texxform,
913
922
                             nux::color::White);
 
923
 
 
924
        if (dash_position == OverlayPosition::BOTTOM)
 
925
        {
 
926
          // Top Left edge
 
927
          nux::TexCoordXForm top_texxform;
 
928
          top_texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
 
929
          top_texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
 
930
 
 
931
          gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
 
932
          gfx_context.QRP_1Tex(0,
 
933
                               panel_height,
 
934
                               top_left_texture_->GetWidth(),
 
935
                               top_left_texture_->GetHeight(),
 
936
                               top_left_texture_->GetDeviceTexture(),
 
937
                               top_texxform,
 
938
                               nux::color::White);
 
939
          // Top edge
 
940
          top_texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
 
941
          top_texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
 
942
          gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
 
943
          gfx_context.QRP_1Tex(top_left_texture_->GetWidth(),
 
944
                               panel_height - top_corner_offset,
 
945
                               monitor_geo.width - top_left_texture_->GetWidth(),
 
946
                               horizontal_tile->GetHeight(),
 
947
                               horizontal_tile->GetDeviceTexture(),
 
948
                               top_texxform,
 
949
                               nux::color::White);
 
950
        }
 
951
        else if (settings.launcher_position() == LauncherPosition::BOTTOM)
 
952
        {
 
953
          int above_launcher_y = monitor_geo.height - panel_height - launcher_size;
 
954
          bool was_flipped = texxform.flip_v_coord;
 
955
 
 
956
          // Bottom Left edge
 
957
          texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
 
958
          texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
 
959
          texxform.flip_v_coord = true;
 
960
 
 
961
          gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
 
962
          gfx_context.QRP_1Tex(0,
 
963
                               above_launcher_y - top_left_texture_->GetWidth(),
 
964
                               top_left_texture_->GetWidth(),
 
965
                               top_left_texture_->GetHeight(),
 
966
                               top_left_texture_->GetDeviceTexture(),
 
967
                               texxform,
 
968
                               nux::color::White);
 
969
 
 
970
          // Bottom edge
 
971
          texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
 
972
          texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
 
973
 
 
974
          gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
 
975
          gfx_context.QRP_1Tex(top_left_texture_->GetHeight(),
 
976
                               above_launcher_y + top_corner_offset - horizontal_tile->GetHeight(),
 
977
                               monitor_geo.width - top_left_texture_->GetHeight(),
 
978
                               horizontal_tile->GetHeight(),
 
979
                               horizontal_tile->GetDeviceTexture(),
 
980
                               texxform,
 
981
                               nux::color::White);
 
982
 
 
983
          texxform.flip_v_coord = was_flipped;
 
984
        }
914
985
      }
915
986
    }
916
987