summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorNick Dedekind <nicholas.dedekind@gmail.com>2012-10-31 17:33:00 +0100
committerNick Dedekind <nicholas.dedekind@gmail.com>2012-10-31 17:33:00 +0100
commit829f338433192fb45d4d5091486bb94c1f0eb380 (patch)
tree14422040f591aea4f27ae250ec2ef3e24dfd5efd /unity-shared
parent871b4f1dbd9a2e88b596a3c60da480a9cd1bd069 (diff)
Added icon shadow on launcher drag.
Fixes LP: #765715 (bzr r2873.3.1)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/CMakeLists.txt1
-rw-r--r--unity-shared/GraphicsUtils.cpp71
-rw-r--r--unity-shared/GraphicsUtils.h36
-rw-r--r--unity-shared/IconRenderer.cpp28
-rw-r--r--unity-shared/IconRenderer.h4
5 files changed, 111 insertions, 29 deletions
diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt
index 28dcc84e8..0c39967d1 100644
--- a/unity-shared/CMakeLists.txt
+++ b/unity-shared/CMakeLists.txt
@@ -34,6 +34,7 @@ set (UNITY_SHARED_SOURCES
DashStyle.cpp
DefaultThumbnailProvider.cpp
FontSettings.cpp
+ GraphicsUtils.cpp
IMTextEntry.cpp
IconLoader.cpp
IconRenderer.cpp
diff --git a/unity-shared/GraphicsUtils.cpp b/unity-shared/GraphicsUtils.cpp
new file mode 100644
index 000000000..dfd8dbeae
--- /dev/null
+++ b/unity-shared/GraphicsUtils.cpp
@@ -0,0 +1,71 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2010 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
+ */
+
+#include "GraphicsUtils.h"
+#include <NuxGraphics/GLTextureResourceManager.h>
+
+namespace unity
+{
+namespace graphics
+{
+
+std::stack<nux::ObjectPtr<nux::IOpenGLBaseTexture>> rendering_stack;
+
+void PushOffscreenRenderTarget_(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
+{
+ int width = texture->GetWidth();
+ int height = texture->GetHeight();
+
+ auto graphics_display = nux::GetGraphicsDisplay();
+ auto gpu_device = graphics_display->GetGpuDevice();
+ gpu_device->FormatFrameBufferObject(width, height, nux::BITFMT_R8G8B8A8);
+ gpu_device->SetColorRenderTargetSurface(0, texture->GetSurfaceLevel(0));
+ gpu_device->ActivateFrameBuffer();
+
+ auto graphics_engine = graphics_display->GetGraphicsEngine();
+ graphics_engine->SetContext(0, 0, width, height);
+ graphics_engine->SetViewport(0, 0, width, height);
+ graphics_engine->Push2DWindow(width, height);
+ graphics_engine->EmptyClippingRegion();
+}
+
+void PushOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
+{
+ PushOffscreenRenderTarget_(texture);
+ rendering_stack.push(texture);
+}
+
+void PopOffscreenRenderTarget()
+{
+ g_assert(rendering_stack.size() > 0);
+
+ rendering_stack.pop();
+ if (rendering_stack.size() > 0)
+ {
+ nux::ObjectPtr<nux::IOpenGLBaseTexture>& texture = rendering_stack.top();
+ PushOffscreenRenderTarget_(texture);
+ }
+ else
+ {
+ nux::GetWindowCompositor().RestoreRenderingSurface();
+ }
+}
+
+}
+} \ No newline at end of file
diff --git a/unity-shared/GraphicsUtils.h b/unity-shared/GraphicsUtils.h
new file mode 100644
index 000000000..dd65d3b00
--- /dev/null
+++ b/unity-shared/GraphicsUtils.h
@@ -0,0 +1,36 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2010 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
+ */
+
+#ifndef UNITY_GRAPHICS_ADAPTER
+#define UNITY_GRAPHICS_ADAPTER
+
+#include <Nux/Nux.h>
+
+namespace unity
+{
+namespace graphics
+{
+
+void PushOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
+void PopOffscreenRenderTarget();
+
+}
+}
+
+#endif // UNITY_GRAPHICS_ADAPTER \ No newline at end of file
diff --git a/unity-shared/IconRenderer.cpp b/unity-shared/IconRenderer.cpp
index ca6b0db5f..980cb6e0c 100644
--- a/unity-shared/IconRenderer.cpp
+++ b/unity-shared/IconRenderer.cpp
@@ -26,6 +26,7 @@
#include <NuxGraphics/GLTextureResourceManager.h>
#include <NuxGraphics/CairoGraphics.h>
+#include "GraphicsUtils.h"
#include <gtk/gtk.h>
@@ -1010,7 +1011,7 @@ void IconRenderer::RenderProgressToTexture(nux::GraphicsEngine& GfxContext,
int progress_y = fill_y + (fill_height - progress_height) / 2;
int half_size = (right_edge - left_edge) / 2;
- SetOffscreenRenderTarget(texture);
+ unity::graphics::PushOffscreenRenderTarget(texture);
// FIXME
glClear(GL_COLOR_BUFFER_BIT);
@@ -1041,7 +1042,7 @@ void IconRenderer::RenderProgressToTexture(nux::GraphicsEngine& GfxContext,
GfxContext.PopClippingRectangle();
- RestoreSystemRenderTarget();
+ unity::graphics::PopOffscreenRenderTarget();
}
void IconRenderer::DestroyTextures()
@@ -1134,29 +1135,6 @@ void IconRenderer::GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, n
PerspectiveMatrix.Perspective(Fovy, AspectRatio, NearClipPlane, FarClipPlane);
}
-void
-IconRenderer::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
-{
- int width = texture->GetWidth();
- int height = texture->GetHeight();
-
- nux::GetGraphicsDisplay()->GetGpuDevice()->FormatFrameBufferObject(width, height, nux::BITFMT_R8G8B8A8);
- nux::GetGraphicsDisplay()->GetGpuDevice()->SetColorRenderTargetSurface(0, texture->GetSurfaceLevel(0));
- nux::GetGraphicsDisplay()->GetGpuDevice()->ActivateFrameBuffer();
-
- nux::GetGraphicsDisplay()->GetGraphicsEngine()->SetContext(0, 0, width, height);
- nux::GetGraphicsDisplay()->GetGraphicsEngine()->SetViewport(0, 0, width, height);
- nux::GetGraphicsDisplay()->GetGraphicsEngine()->Push2DWindow(width, height);
- nux::GetGraphicsDisplay()->GetGraphicsEngine()->EmptyClippingRegion();
-}
-
-void
-IconRenderer::RestoreSystemRenderTarget()
-{
- nux::GetWindowCompositor().RestoreRenderingSurface();
-}
-
-
// The local namespace is purely for namespacing the file local variables below.
namespace local
{
diff --git a/unity-shared/IconRenderer.h b/unity-shared/IconRenderer.h
index d45fcd715..9b84e3e3e 100644
--- a/unity-shared/IconRenderer.h
+++ b/unity-shared/IconRenderer.h
@@ -84,10 +84,6 @@ protected:
float FarClipPlane,
float Fovy);
- void SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
-
- void RestoreSystemRenderTarget();
-
private:
int icon_size;
int image_size;