diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-11-14 21:43:45 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-11-14 21:43:45 +0100 |
| commit | 0f4d9df5ac85e94028d934e559a6b8a5bf989a4d (patch) | |
| tree | 5301b81ad99fdbaf2f14d543a06de92ab6e37ce7 /unity-shared | |
| parent | 3ae2655c7dfd44b22f8b4319e0aa6baeaace2554 (diff) | |
BackgroundEffectHelper: use GetExpand for computing the blurred area
Also factorize the BlurSigma and BlurRadius computation (bzr r3347.5.9)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/BackgroundEffectHelper.cpp | 32 | ||||
| -rw-r--r-- | unity-shared/BackgroundEffectHelper.h | 12 |
2 files changed, 21 insertions, 23 deletions
diff --git a/unity-shared/BackgroundEffectHelper.cpp b/unity-shared/BackgroundEffectHelper.cpp index fbd8f4996..fec6e1fdd 100644 --- a/unity-shared/BackgroundEffectHelper.cpp +++ b/unity-shared/BackgroundEffectHelper.cpp @@ -108,32 +108,30 @@ bool BackgroundEffectHelper::HasEnabledHelpers() return false; } -void BackgroundEffectHelper::ExpandByRadius(nux::Geometry &geo) +float BackgroundEffectHelper::GetBlurSigma() { nux::GpuDevice* gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice(); int opengl_version = gpu_device->GetOpenGLMajorVersion(); - int sigma = opengl_version >= 3 ? sigma_high : sigma_med; - int radius = 3 * sigma; + return (opengl_version >= 3) ? sigma_high : sigma_med; +} - geo.x -= radius; - geo.y -= radius; - geo.width += 2 * radius; - geo.height += 2 * radius; +int BackgroundEffectHelper::GetBlurRadius() +{ + return GetBlurSigma() * 3; } std::vector <nux::Geometry> BackgroundEffectHelper::GetBlurGeometries() { std::vector <nux::Geometry> geometries; + int radius = GetBlurRadius(); + for (BackgroundEffectHelper * bg_effect_helper : registered_list_) { if (bg_effect_helper->enabled) { /* Use the last requested region. The real region is clipped to the * monitor geometry, but that is done at paint time */ - nux::Geometry geo(bg_effect_helper->requested_blur_geometry_); - - ExpandByRadius(geo); - geometries.push_back(geo); + geometries.push_back(bg_effect_helper->requested_blur_geometry_.GetExpand(radius, radius)); } } @@ -198,9 +196,7 @@ nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetBlurRegion(bo return nux::ObjectPtr<nux::IOpenGLBaseTexture>(); } - int opengl_version = gpu_device->GetOpenGLMajorVersion(); - int sigma = opengl_version >= 3 ? sigma_high : sigma_med; - int radius = 3 * sigma; + const int radius = GetBlurRadius(); // Define a larger region of that account for the blur radius nux::Geometry larger_blur_geometry; @@ -241,10 +237,10 @@ nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetBlurRegion(bo bool support_frag = gpu_device->GetGpuInfo().Support_ARB_Fragment_Shader(); bool support_vert = gpu_device->GetGpuInfo().Support_ARB_Vertex_Shader(); - if (support_vert && support_frag && opengl_version >= 2) + if (support_vert && support_frag && gpu_device->GetOpenGLMajorVersion() >= 2) { float noise_factor = 1.1f; - float gaussian_sigma = opengl_version >= 3 ? sigma_high : sigma_med; + float gaussian_sigma = GetBlurSigma(); nux::ObjectPtr<nux::IOpenGLBaseTexture> device_texture = gpu_device->backup_texture0_; nux::ObjectPtr<nux::CachedBaseTexture> noise_device_texture = graphics_engine->CacheResource(noise_texture_.GetPointer()); @@ -460,8 +456,8 @@ void BackgroundEffectHelper::SetBackbufferRegion(const nux::Geometry &geo) requested_blur_geometry_ = geo; DirtyCache(); - nux::Geometry emit_geometry(geo); - ExpandByRadius(emit_geometry); + int radius = GetBlurRadius(); + auto const& emit_geometry = geo.GetExpand(radius, radius); blur_region_needs_update_.emit(emit_geometry); } } diff --git a/unity-shared/BackgroundEffectHelper.h b/unity-shared/BackgroundEffectHelper.h index 34f01e575..4c779c3e1 100644 --- a/unity-shared/BackgroundEffectHelper.h +++ b/unity-shared/BackgroundEffectHelper.h @@ -59,7 +59,7 @@ public: static bool HasDirtyHelpers(); static bool HasEnabledHelpers(); static bool HasDamageableHelpers(); - static std::vector <nux::Geometry> GetBlurGeometries(); + static std::vector<nux::Geometry> GetBlurGeometries(); static nux::Property<unity::BlurType> blur_type; static nux::Property<float> sigma_high; @@ -71,17 +71,19 @@ public: static nux::Geometry monitor_rect_; static sigc::signal<void, nux::Geometry const&> blur_region_needs_update_; - + nux::FxStructure blur_fx_struct_; nux::FxStructure noise_fx_struct_; - + protected: static void Register (BackgroundEffectHelper* self); static void Unregister (BackgroundEffectHelper* self); private: - void OnEnabledChanged (bool value); - static void ExpandByRadius(nux::Geometry &geometry); + static float GetBlurSigma(); + static int GetBlurRadius(); + + void OnEnabledChanged(bool value); nux::ObjectPtr<nux::BaseTexture> noise_texture_; nux::ObjectPtr<nux::IOpenGLBaseTexture> blur_texture_; |
