diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-08-01 15:03:39 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-08-01 15:03:39 +0200 |
| commit | 12da29430c79c5c8af702a8f52048421f0a1b464 (patch) | |
| tree | 5595a596ca31f648ee0b36ce1fa89b1bea1dffed /decorations | |
| parent | 2e0a56a0d9ddcdb610a2239caf43274ce251bb09 (diff) | |
DecoratedWindow: split shadow quads computation based on shaped window state
And reset textures on change (bzr r4163.1.3)
Diffstat (limited to 'decorations')
| -rw-r--r-- | decorations/DecoratedWindow.cpp | 38 | ||||
| -rw-r--r-- | decorations/DecorationsPriv.h | 3 |
2 files changed, 23 insertions, 18 deletions
diff --git a/decorations/DecoratedWindow.cpp b/decorations/DecoratedWindow.cpp index da4c4d743..7638ed453 100644 --- a/decorations/DecoratedWindow.cpp +++ b/decorations/DecoratedWindow.cpp @@ -493,6 +493,12 @@ bool Window::Impl::ShadowDecorated() const return deco_elements_ & cu::DecorationElement::SHADOW; } +bool Window::Impl::ShapedShadowDecorated() const +{ + return deco_elements_ & cu::DecorationElement::SHADOW && + deco_elements_ & cu::DecorationElement::SHAPED; +} + bool Window::Impl::FullyDecorated() const { return deco_elements_ & cu::DecorationElement::BORDER; @@ -503,11 +509,6 @@ bool Window::Impl::ShouldBeDecorated() const return (win_->frame() || win_->hasUnmapReference()) && FullyDecorated(); } -bool Window::Impl::IsRectangular() const -{ - return win_->region().numRects() == 1; -} - GLTexture* Window::Impl::ShadowTexture() const { if (shaped_shadow_pixmap_) @@ -583,9 +584,21 @@ void Window::Impl::ComputeShadowQuads() if (!last_shadow_rect_.isEmpty()) last_shadow_rect_.setGeometry(0, 0, 0, 0); - return; + shaped_shadow_pixmap_.reset(); + } + else if (deco_elements_ & cu::DecorationElement::SHAPED) + { + ComputeShapedShadowQuad(); + } + else + { + shaped_shadow_pixmap_.reset(); + ComputeGenericShadowQuads(); } +} +void Window::Impl::ComputeGenericShadowQuads() +{ const auto* texture = SharedShadowTexture(); if (!texture || !texture->width() || !texture->height()) @@ -712,15 +725,6 @@ cu::PixmapTexture::Ptr Window::Impl::BuildShapedShadowTexture(nux::Size const& s void Window::Impl::ComputeShapedShadowQuad() { - if (!(deco_elements_ & cu::DecorationElement::SHADOW)) - { - if (!last_shadow_rect_.isEmpty()) - last_shadow_rect_.setGeometry(0, 0, 0, 0); - - shaped_shadow_pixmap_ = nullptr; - return; - } - nux::Color color = active() ? manager_->active_shadow_color() : manager_->inactive_shadow_color(); unsigned int radius = active() ? manager_->active_shadow_radius() : manager_->inactive_shadow_radius(); @@ -799,7 +803,7 @@ void Window::Impl::Draw(GLMatrix const& transformation, glwin_->vertexBuffer()->begin(); - unsigned int num_quads = IsRectangular() ? shadow_quads_.size() : 1; + unsigned int num_quads = ShapedShadowDecorated() ? 1 : shadow_quads_.size(); for (unsigned int i = 0; i < num_quads; ++i) { auto& quad = shadow_quads_[Quads::Pos(i)]; @@ -1041,7 +1045,7 @@ void Window::Undecorate() void Window::UpdateDecorationPosition() { impl_->UpdateMonitor(); - impl_->IsRectangular() ? impl_->ComputeShadowQuads() : impl_->ComputeShapedShadowQuad(); + impl_->ComputeShadowQuads(); impl_->UpdateWindowEdgesGeo(); impl_->UpdateDecorationTextures(); impl_->UpdateForceQuitDialogPosition(); diff --git a/decorations/DecorationsPriv.h b/decorations/DecorationsPriv.h index 3faac1c73..3eab08286 100644 --- a/decorations/DecorationsPriv.h +++ b/decorations/DecorationsPriv.h @@ -90,6 +90,7 @@ struct Window::Impl bool IsMaximized() const; bool FullyDecorated() const; bool ShadowDecorated() const; + bool ShapedShadowDecorated() const; void RedrawDecorations(); void Damage(); void SetupAppMenu(); @@ -118,13 +119,13 @@ private: void SyncXShapeWithFrameRegion(); void SyncMenusGeometries() const; bool ShouldBeDecorated() const; - bool IsRectangular() const; GLTexture* ShadowTexture() const; GLTexture* SharedShadowTexture() const; unsigned ShadowRadius() const; std::string const& GetMenusPanelID() const; void ComputeShadowQuads(); + void ComputeGenericShadowQuads(); void ComputeShapedShadowQuad(); void UpdateDecorationTextures(); void UpdateWindowEdgesGeo(); |
