diff options
| author | Andrea Azzarone <azzaronea@gmail.com> | 2012-09-05 10:49:51 +0200 |
|---|---|---|
| committer | Andrea Azzarone <azzaronea@gmail.com> | 2012-09-05 10:49:51 +0200 |
| commit | b51b17ff56e34718acdd46867103c09fd8c0381f (patch) | |
| tree | 943a537ae2523d7ca5a2e878206f7fb56583e6bd /plugins/unityshell/src | |
| parent | 0935bd689f478968513fbe913eefd5aec21a46e1 (diff) | |
Split code in different functions.
(bzr r2637.7.4)
Diffstat (limited to 'plugins/unityshell/src')
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 84 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 6 |
2 files changed, 54 insertions, 36 deletions
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 9cd14f321..95f3d8af0 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -675,42 +675,9 @@ void UnityScreen::paintDisplay() { CompOutput *output = _last_output; - auto graphics_engine = nux::GetGraphicsDisplay()->GetGraphicsEngine(); - auto gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice(); - - if (graphics_engine->UsingGLSLCodePath()) - { - if (launcher_controller_->IsOverlayOpen() && paint_panel_) - { - if (panel_texture_has_changed_ || !panel_texture_.IsValid()) - { - panel_texture_.Release(); - - nux::NBitmapData* bitmap = panel::Style::Instance().GetBackground(screen->width (), screen->height(), 1.0f); - nux::BaseTexture* texture2D = gpu_device->CreateSystemCapableTexture(); - if (bitmap && texture2D) - { - texture2D->Update(bitmap); - panel_texture_ = texture2D->GetDeviceTexture(); - texture2D->UnReference(); - delete bitmap; - } - panel_texture_has_changed_ = false; - } + DrawTopPanelBackground(); - if (panel_texture_.IsValid()) - { - graphics_engine->ResetModelViewMatrixStack(); - graphics_engine->Push2DTranslationModelViewMatrix(0.0f, 0.0f, 0.0f); - graphics_engine->ResetProjectionMatrix(); - graphics_engine->SetOrthographicProjectionMatrix(screen->width (), screen->height()); - - nux::TexCoordXForm texxform; - int panel_height = panel_style_.panel_height; - graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width (), panel_height, panel_texture_, texxform, nux::color::White); - } - } - } + auto gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice(); nux::ObjectPtr<nux::IOpenGLTexture2D> device_texture = gpu_device->CreateTexture2DFromID(gScreen->fbo ()->tex ()->name (), @@ -789,6 +756,53 @@ void UnityScreen::paintDisplay() didShellRepaint = true; } +void UnityScreen::DrawTopPanelBackground() +{ + auto graphics_engine = nux::GetGraphicsDisplay()->GetGraphicsEngine(); + + if (!graphics_engine->UsingGLSLCodePath() || !launcher_controller_->IsOverlayOpen() || !paint_panel_) + return; + + if (TopPanelBackgroundTextureNeedsUpdate()) + UpdateTopPanelBackgroundTexture(); + + if (panel_texture_.IsValid()) + { + graphics_engine->ResetModelViewMatrixStack(); + graphics_engine->Push2DTranslationModelViewMatrix(0.0f, 0.0f, 0.0f); + graphics_engine->ResetProjectionMatrix(); + graphics_engine->SetOrthographicProjectionMatrix(screen->width (), screen->height()); + + nux::TexCoordXForm texxform; + int panel_height = panel_style_.panel_height; + graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width (), panel_height, panel_texture_, texxform, nux::color::White); + } +} + +bool UnityScreen::TopPanelBackgroundTextureNeedsUpdate() const +{ + return panel_texture_has_changed_ || !panel_texture_.IsValid(); +} + +void UnityScreen::UpdateTopPanelBackgroundTexture() +{ + auto gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice(); + auto &panel_style = panel::Style::Instance(); + + panel_texture_.Release(); + + std::unique_ptr<nux::NBitmapData> bitmap(panel_style.GetBackground(screen->width(), screen->height(), 1.0f)); + nux::ObjectPtr<nux::BaseTexture> texture2D(gpu_device->CreateSystemCapableTexture()); + + if (bitmap && texture2D) + { + texture2D->Update(bitmap.get()); + panel_texture_ = texture2D->GetDeviceTexture(); + } + + panel_texture_has_changed_ = false; +} + bool UnityScreen::forcePaintOnTop () { return !allowWindowPaint || diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index b3000c42b..9b59f63d2 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -242,7 +242,11 @@ private: void OnPanelStyleChanged(); void InitGesturesSupport(); - + + void DrawTopPanelBackground(); + bool TopPanelBackgroundTextureNeedsUpdate() const; + void UpdateTopPanelBackgroundTexture(); + nux::animation::TickSource tick_source_; nux::animation::AnimationController animation_controller_; |
