Merge lp:~nick-dedekind/unity/lp765715.launcher-icon-shadow into lp:unity

Proposed by Nick Dedekind
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2878
Proposed branch: lp:~nick-dedekind/unity/lp765715.launcher-icon-shadow
Merge into: lp:unity
Diff against target: 481 lines (+149/-100)
10 files modified
launcher/Launcher.cpp (+12/-44)
launcher/Launcher.h (+0/-3)
launcher/LauncherDragWindow.cpp (+20/-18)
launcher/LauncherDragWindow.h (+4/-4)
launcher/SoftwareCenterLauncherIcon.cpp (+2/-2)
unity-shared/CMakeLists.txt (+1/-0)
unity-shared/GraphicsUtils.cpp (+71/-0)
unity-shared/GraphicsUtils.h (+36/-0)
unity-shared/IconRenderer.cpp (+3/-25)
unity-shared/IconRenderer.h (+0/-4)
To merge this branch: bzr merge lp:~nick-dedekind/unity/lp765715.launcher-icon-shadow
Reviewer Review Type Date Requested Status
John Lea (community) design Approve
Andrea Azzarone (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+132461@code.launchpad.net

Commit message

Increase the size of the launcher icon drag window so the shadow is not cut off.

Description of the change

= Problem description =

https://bugs.launchpad.net/unity/+bug/765715
A shadow should appear on the right and bottom sides of a dragged launcher icon.

= The fix =

Increase the size of the launcher icon drag window so the shadow is not cut off.
Refactored drag launcher window to conform to unity variable naming conventions.

= Test coverage =

No test. Visual change.

https://bugs.launchpad.net/unity/+bug/765715/+attachment/3424675/+files/shadow.png

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

17 - , _render_drag_window(false)

Do we need to remove it from Launcher.h too?

295 + * Copyright (C) 2010 Canonical Ltd

2010? :)

348 + g_assert(rendering_stack.size() > 0);
351 + if (rendering_stack.size() > 0)

Please use std::stack::empty here.

review: Approve
Revision history for this message
John Lea (johnlea) :
review: Approve (design)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'launcher/Launcher.cpp'
--- launcher/Launcher.cpp 2012-10-31 20:34:34 +0000
+++ launcher/Launcher.cpp 2012-11-01 08:29:20 +0000
@@ -49,6 +49,8 @@
49#include "unity-shared/UScreen.h"49#include "unity-shared/UScreen.h"
50#include "unity-shared/UBusMessages.h"50#include "unity-shared/UBusMessages.h"
51#include "unity-shared/UnitySettings.h"51#include "unity-shared/UnitySettings.h"
52#include "unity-shared/GraphicsUtils.h"
53
5254
53#include <UnityCore/GLibWrapper.h>55#include <UnityCore/GLibWrapper.h>
54#include <UnityCore/Variant.h>56#include <UnityCore/Variant.h>
@@ -114,7 +116,6 @@
114 , _active_quicklist(nullptr)116 , _active_quicklist(nullptr)
115 , _hovered(false)117 , _hovered(false)
116 , _hidden(false)118 , _hidden(false)
117 , _render_drag_window(false)
118 , _shortcuts_shown(false)119 , _shortcuts_shown(false)
119 , _data_checked(false)120 , _data_checked(false)
120 , _steal_drag(false)121 , _steal_drag(false)
@@ -152,8 +153,6 @@
152153
153 _collection_window->collected.connect(sigc::mem_fun(this, &Launcher::OnDNDDataCollected));154 _collection_window->collected.connect(sigc::mem_fun(this, &Launcher::OnDNDDataCollected));
154155
155 _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8);
156
157 bg_effect_helper_.owner = this;156 bg_effect_helper_.owner = this;
158 bg_effect_helper_.enabled = false;157 bg_effect_helper_.enabled = false;
159158
@@ -1757,13 +1756,6 @@
1757 nux::Geometry const& geo_absolute = GetAbsoluteGeometry();1756 nux::Geometry const& geo_absolute = GetAbsoluteGeometry();
1758 RenderArgs(args, bkg_box, &launcher_alpha, geo_absolute);1757 RenderArgs(args, bkg_box, &launcher_alpha, geo_absolute);
1759 bkg_box.width -= RIGHT_LINE_WIDTH;1758 bkg_box.width -= RIGHT_LINE_WIDTH;
1760
1761 if (_drag_icon && _render_drag_window)
1762 {
1763 RenderIconToTexture(GfxContext, _drag_icon, _offscreen_drag_texture);
1764 _render_drag_window = false;
1765 ShowDragWindow();
1766 }
1767 1759
1768 nux::Color clear_colour = nux::Color(0x00000000);1760 nux::Color clear_colour = nux::Color(0x00000000);
1769 1761
@@ -2030,10 +2022,10 @@
2030 _drag_icon_position = _model->IconIndex(icon);2022 _drag_icon_position = _model->IconIndex(icon);
20312023
2032 HideDragWindow();2024 HideDragWindow();
2033 _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(_icon_size, _icon_size, 1, nux::BITFMT_R8G8B8A8);2025 _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(GetWidth(), GetWidth(), 1, nux::BITFMT_R8G8B8A8);
2034 _drag_window = new LauncherDragWindow(_offscreen_drag_texture);2026 _drag_window = new LauncherDragWindow(_offscreen_drag_texture);
20352027 RenderIconToTexture(nux::GetWindowThread()->GetGraphicsEngine(), _drag_icon, _offscreen_drag_texture);
2036 _render_drag_window = true;2028 ShowDragWindow();
20372029
2038 ubus_.SendMessage(UBUS_LAUNCHER_ICON_START_DND);2030 ubus_.SendMessage(UBUS_LAUNCHER_ICON_START_DND);
2039}2031}
@@ -2077,8 +2069,6 @@
2077 if (MouseBeyondDragThreshold())2069 if (MouseBeyondDragThreshold())
2078 TimeUtil::SetTimeStruct(&_times[TIME_DRAG_THRESHOLD], &_times[TIME_DRAG_THRESHOLD], ANIM_DURATION_SHORT);2070 TimeUtil::SetTimeStruct(&_times[TIME_DRAG_THRESHOLD], &_times[TIME_DRAG_THRESHOLD], ANIM_DURATION_SHORT);
20792071
2080 _render_drag_window = false;
2081
2082 _hide_machine.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, false);2072 _hide_machine.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, false);
2083 ubus_.SendMessage(UBUS_LAUNCHER_ICON_END_DND);2073 ubus_.SendMessage(UBUS_LAUNCHER_ICON_END_DND);
2084}2074}
@@ -2503,7 +2493,7 @@
2503 clock_gettime(CLOCK_MONOTONIC, &current);2493 clock_gettime(CLOCK_MONOTONIC, &current);
25042494
2505 SetupRenderArg(icon, current, arg);2495 SetupRenderArg(icon, current, arg);
2506 arg.render_center = nux::Point3(roundf(_icon_size / 2.0f), roundf(_icon_size / 2.0f), 0.0f);2496 arg.render_center = nux::Point3(roundf(texture->GetWidth() / 2.0f), roundf(texture->GetHeight() / 2.0f), 0.0f);
2507 arg.logical_center = arg.render_center;2497 arg.logical_center = arg.render_center;
2508 arg.x_rotation = 0.0f;2498 arg.x_rotation = 0.0f;
2509 arg.running_arrow = false;2499 arg.running_arrow = false;
@@ -2515,7 +2505,7 @@
2515 std::list<RenderArg> drag_args;2505 std::list<RenderArg> drag_args;
2516 drag_args.push_front(arg);2506 drag_args.push_front(arg);
25172507
2518 SetOffscreenRenderTarget(texture);2508 graphics::PushOffscreenRenderTarget(texture);
25192509
2520 unsigned int alpha = 0, src = 0, dest = 0;2510 unsigned int alpha = 0, src = 0, dest = 0;
2521 GfxContext.GetRenderStates().GetBlend(alpha, src, dest);2511 GfxContext.GetRenderStates().GetBlend(alpha, src, dest);
@@ -2529,9 +2519,11 @@
25292519
2530 GfxContext.GetRenderStates().SetBlend(alpha, src, dest);2520 GfxContext.GetRenderStates().SetBlend(alpha, src, dest);
25312521
2532 icon_renderer->PreprocessIcons(drag_args, nux::Geometry(0, 0, _icon_size, _icon_size));2522 nux::Geometry geo(0, 0, texture->GetWidth(), texture->GetWidth());
2533 icon_renderer->RenderIcon(nux::GetWindowThread()->GetGraphicsEngine(), arg, nux::Geometry(0, 0, _icon_size, _icon_size), nux::Geometry(0, 0, _icon_size, _icon_size));2523
2534 RestoreSystemRenderTarget();2524 icon_renderer->PreprocessIcons(drag_args, geo);
2525 icon_renderer->RenderIcon(GfxContext, arg, geo, geo);
2526 unity::graphics::PopOffscreenRenderTarget();
2535}2527}
25362528
2537nux::GestureDeliveryRequest Launcher::GestureEvent(const nux::GestureEvent &event)2529nux::GestureDeliveryRequest Launcher::GestureEvent(const nux::GestureEvent &event)
@@ -2552,30 +2544,6 @@
2552 return nux::GestureDeliveryRequest::NONE;2544 return nux::GestureDeliveryRequest::NONE;
2553}2545}
25542546
2555void
2556Launcher::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
2557{
2558 int width = texture->GetWidth();
2559 int height = texture->GetHeight();
2560
2561 auto graphics_display = nux::GetGraphicsDisplay();
2562 auto gpu_device = graphics_display->GetGpuDevice();
2563 gpu_device->FormatFrameBufferObject(width, height, nux::BITFMT_R8G8B8A8);
2564 gpu_device->SetColorRenderTargetSurface(0, texture->GetSurfaceLevel(0));
2565 gpu_device->ActivateFrameBuffer();
2566
2567 auto graphics_engine = graphics_display->GetGraphicsEngine();
2568 graphics_engine->SetContext(0, 0, width, height);
2569 graphics_engine->SetViewport(0, 0, width, height);
2570 graphics_engine->Push2DWindow(width, height);
2571 graphics_engine->EmptyClippingRegion();
2572}
2573
2574void Launcher::RestoreSystemRenderTarget()
2575{
2576 nux::GetWindowCompositor().RestoreRenderingSurface();
2577}
2578
2579bool Launcher::DndIsSpecialRequest(std::string const& uri) const2547bool Launcher::DndIsSpecialRequest(std::string const& uri) const
2580{2548{
2581 return (boost::algorithm::ends_with(uri, ".desktop") || uri.find("device://") == 0);2549 return (boost::algorithm::ends_with(uri, ".desktop") || uri.find("device://") == 0);
25822550
=== modified file 'launcher/Launcher.h'
--- launcher/Launcher.h 2012-10-29 09:34:54 +0000
+++ launcher/Launcher.h 2012-11-01 08:29:20 +0000
@@ -317,9 +317,6 @@
317317
318 virtual long PostLayoutManagement(long LayoutResult);318 virtual long PostLayoutManagement(long LayoutResult);
319319
320 void SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
321 void RestoreSystemRenderTarget();
322
323 void OnDisplayChanged(Display* display);320 void OnDisplayChanged(Display* display);
324 void OnDNDDataCollected(const std::list<char*>& mimes);321 void OnDNDDataCollected(const std::list<char*>& mimes);
325322
326323
=== modified file 'launcher/LauncherDragWindow.cpp'
--- launcher/LauncherDragWindow.cpp 2012-10-11 01:44:15 +0000
+++ launcher/LauncherDragWindow.cpp 2012-11-01 08:29:20 +0000
@@ -35,17 +35,19 @@
35{35{
36 const float QUICK_ANIMATION_SPEED = 0.3f;36 const float QUICK_ANIMATION_SPEED = 0.3f;
37 const float SLOW_ANIMATION_SPEED = 0.05f;37 const float SLOW_ANIMATION_SPEED = 0.05f;
38
39 const int ANIMATION_THRESHOLD = 5;
38}40}
3941
40NUX_IMPLEMENT_OBJECT_TYPE(LauncherDragWindow);42NUX_IMPLEMENT_OBJECT_TYPE(LauncherDragWindow);
4143
42LauncherDragWindow::LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> icon)44LauncherDragWindow::LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
43 : nux::BaseWindow("")45 : nux::BaseWindow("")
44 , animation_speed_(QUICK_ANIMATION_SPEED)46 , animation_speed_(QUICK_ANIMATION_SPEED)
45 , _cancelled(false)47 , cancelled_(false)
46 , _icon(icon)48 , texture_(texture)
47{49{
48 SetBaseSize(_icon->GetWidth(), _icon->GetHeight());50 SetBaseSize(texture_->GetWidth(), texture_->GetHeight());
4951
50 key_down.connect([this] (unsigned long, unsigned long keysym, unsigned long, const char*, unsigned short) {52 key_down.connect([this] (unsigned long, unsigned long keysym, unsigned long, const char*, unsigned short) {
51 if (keysym == NUX_VK_ESCAPE)53 if (keysym == NUX_VK_ESCAPE)
@@ -72,18 +74,18 @@
7274
73bool LauncherDragWindow::Cancelled() const75bool LauncherDragWindow::Cancelled() const
74{76{
75 return _cancelled;77 return cancelled_;
76}78}
7779
78void LauncherDragWindow::CancelDrag()80void LauncherDragWindow::CancelDrag()
79{81{
80 _cancelled = true;82 cancelled_ = true;
81 drag_cancel_request.emit();83 drag_cancel_request.emit();
82}84}
8385
84void LauncherDragWindow::SetAnimationTarget(int x, int y)86void LauncherDragWindow::SetAnimationTarget(int x, int y)
85{87{
86 _animation_target = nux::Point2(x, y);88 animation_target_ = nux::Point2(x, y);
87}89}
8890
89void LauncherDragWindow::StartQuickAnimation()91void LauncherDragWindow::StartQuickAnimation()
@@ -113,16 +115,16 @@
113115
114 int half_size = geo.width / 2;116 int half_size = geo.width / 2;
115117
116 int target_x = static_cast<int>(_animation_target.x) - half_size;118 int target_x = static_cast<int>(animation_target_.x) - half_size;
117 int target_y = static_cast<int>(_animation_target.y) - half_size;119 int target_y = static_cast<int>(animation_target_.y) - half_size;
118120
119 int x_delta = static_cast<int>(static_cast<float>(target_x - geo.x) * animation_speed_);121 int x_delta = static_cast<int>(static_cast<float>(target_x - geo.x) * animation_speed_);
120 if (std::abs(x_delta) < 5)122 if (std::abs(x_delta) < ANIMATION_THRESHOLD)
121 x_delta = (x_delta >= 0) ? std::min(5, target_x - geo.x) : std::max(-5, target_x - geo.x);123 x_delta = (x_delta >= 0) ? std::min(ANIMATION_THRESHOLD, target_x - geo.x) : std::max(-ANIMATION_THRESHOLD, target_x - geo.x);
122124
123 int y_delta = static_cast<int>(static_cast<float>(target_y - geo.y) * animation_speed_);125 int y_delta = static_cast<int>(static_cast<float>(target_y - geo.y) * animation_speed_);
124 if (std::abs(y_delta) < 5)126 if (std::abs(y_delta) < ANIMATION_THRESHOLD)
125 y_delta = (y_delta >= 0) ? std::min(5, target_y - geo.y) : std::max(-5, target_y - geo.y);127 y_delta = (y_delta >= 0) ? std::min(ANIMATION_THRESHOLD, target_y - geo.y) : std::max(-ANIMATION_THRESHOLD, target_y - geo.y);
126128
127 SetBaseXY(geo.x + x_delta, geo.y + y_delta);129 SetBaseXY(geo.x + x_delta, geo.y + y_delta);
128130
@@ -151,11 +153,11 @@
151 nux::TexCoordXForm texxform;153 nux::TexCoordXForm texxform;
152 texxform.FlipVCoord(true);154 texxform.FlipVCoord(true);
153155
154 GfxContext.QRP_1Tex(0,156 GfxContext.QRP_1Tex(geo.x,
155 0,157 geo.y,
156 _icon->GetWidth(),158 texture_->GetWidth(),
157 _icon->GetHeight(),159 texture_->GetHeight(),
158 _icon,160 texture_,
159 texxform,161 texxform,
160 nux::color::White);162 nux::color::White);
161163
162164
=== modified file 'launcher/LauncherDragWindow.h'
--- launcher/LauncherDragWindow.h 2012-09-13 00:48:06 +0000
+++ launcher/LauncherDragWindow.h 2012-11-01 08:29:20 +0000
@@ -36,7 +36,7 @@
36{36{
37 NUX_DECLARE_OBJECT_TYPE(LauncherDragWindow, nux::BaseWindow);37 NUX_DECLARE_OBJECT_TYPE(LauncherDragWindow, nux::BaseWindow);
38public:38public:
39 LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> icon);39 LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
40 ~LauncherDragWindow();40 ~LauncherDragWindow();
4141
42 void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw);42 void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw);
@@ -62,9 +62,9 @@
62 void CancelDrag();62 void CancelDrag();
63 63
64 float animation_speed_;64 float animation_speed_;
65 bool _cancelled;65 bool cancelled_;
66 nux::ObjectPtr<nux::IOpenGLBaseTexture> _icon;66 nux::ObjectPtr<nux::IOpenGLBaseTexture> texture_;
67 nux::Point2 _animation_target;67 nux::Point2 animation_target_;
68 glib::Source::UniquePtr animation_timer_;68 glib::Source::UniquePtr animation_timer_;
69};69};
7070
7171
=== modified file 'launcher/SoftwareCenterLauncherIcon.cpp'
--- launcher/SoftwareCenterLauncherIcon.cpp 2012-10-17 11:08:05 +0000
+++ launcher/SoftwareCenterLauncherIcon.cpp 2012-11-01 08:29:20 +0000
@@ -68,8 +68,8 @@
68 launcher_ = launcher;68 launcher_ = launcher;
6969
70 icon_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(70 icon_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(
71 launcher->GetIconSize(),71 launcher->GetWidth(),
72 launcher->GetIconSize(),72 launcher->GetWidth(),
73 1,73 1,
74 nux::BITFMT_R8G8B8A8);74 nux::BITFMT_R8G8B8A8);
7575
7676
=== modified file 'unity-shared/CMakeLists.txt'
--- unity-shared/CMakeLists.txt 2012-10-18 10:44:07 +0000
+++ unity-shared/CMakeLists.txt 2012-11-01 08:29:20 +0000
@@ -34,6 +34,7 @@
34 DashStyle.cpp34 DashStyle.cpp
35 DefaultThumbnailProvider.cpp35 DefaultThumbnailProvider.cpp
36 FontSettings.cpp36 FontSettings.cpp
37 GraphicsUtils.cpp
37 IMTextEntry.cpp38 IMTextEntry.cpp
38 IconLoader.cpp39 IconLoader.cpp
39 IconRenderer.cpp40 IconRenderer.cpp
4041
=== added file 'unity-shared/GraphicsUtils.cpp'
--- unity-shared/GraphicsUtils.cpp 1970-01-01 00:00:00 +0000
+++ unity-shared/GraphicsUtils.cpp 2012-11-01 08:29:20 +0000
@@ -0,0 +1,71 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2010 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20#include "GraphicsUtils.h"
21#include <NuxGraphics/GLTextureResourceManager.h>
22
23namespace unity
24{
25namespace graphics
26{
27
28std::stack<nux::ObjectPtr<nux::IOpenGLBaseTexture>> rendering_stack;
29
30void PushOffscreenRenderTarget_(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
31{
32 int width = texture->GetWidth();
33 int height = texture->GetHeight();
34
35 auto graphics_display = nux::GetGraphicsDisplay();
36 auto gpu_device = graphics_display->GetGpuDevice();
37 gpu_device->FormatFrameBufferObject(width, height, nux::BITFMT_R8G8B8A8);
38 gpu_device->SetColorRenderTargetSurface(0, texture->GetSurfaceLevel(0));
39 gpu_device->ActivateFrameBuffer();
40
41 auto graphics_engine = graphics_display->GetGraphicsEngine();
42 graphics_engine->SetContext(0, 0, width, height);
43 graphics_engine->SetViewport(0, 0, width, height);
44 graphics_engine->Push2DWindow(width, height);
45 graphics_engine->EmptyClippingRegion();
46}
47
48void PushOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
49{
50 PushOffscreenRenderTarget_(texture);
51 rendering_stack.push(texture);
52}
53
54void PopOffscreenRenderTarget()
55{
56 g_assert(rendering_stack.size() > 0);
57
58 rendering_stack.pop();
59 if (rendering_stack.size() > 0)
60 {
61 nux::ObjectPtr<nux::IOpenGLBaseTexture>& texture = rendering_stack.top();
62 PushOffscreenRenderTarget_(texture);
63 }
64 else
65 {
66 nux::GetWindowCompositor().RestoreRenderingSurface();
67 }
68}
69
70}
71}
0\ No newline at end of file72\ No newline at end of file
173
=== added file 'unity-shared/GraphicsUtils.h'
--- unity-shared/GraphicsUtils.h 1970-01-01 00:00:00 +0000
+++ unity-shared/GraphicsUtils.h 2012-11-01 08:29:20 +0000
@@ -0,0 +1,36 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2010 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20#ifndef UNITY_GRAPHICS_ADAPTER
21#define UNITY_GRAPHICS_ADAPTER
22
23#include <Nux/Nux.h>
24
25namespace unity
26{
27namespace graphics
28{
29
30void PushOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
31void PopOffscreenRenderTarget();
32
33}
34}
35
36#endif // UNITY_GRAPHICS_ADAPTER
0\ No newline at end of file37\ No newline at end of file
138
=== modified file 'unity-shared/IconRenderer.cpp'
--- unity-shared/IconRenderer.cpp 2012-10-17 22:13:25 +0000
+++ unity-shared/IconRenderer.cpp 2012-11-01 08:29:20 +0000
@@ -26,6 +26,7 @@
26#include <NuxGraphics/GLTextureResourceManager.h>26#include <NuxGraphics/GLTextureResourceManager.h>
2727
28#include <NuxGraphics/CairoGraphics.h>28#include <NuxGraphics/CairoGraphics.h>
29#include "GraphicsUtils.h"
2930
30#include <gtk/gtk.h>31#include <gtk/gtk.h>
3132
@@ -1010,7 +1011,7 @@
1010 int progress_y = fill_y + (fill_height - progress_height) / 2;1011 int progress_y = fill_y + (fill_height - progress_height) / 2;
1011 int half_size = (right_edge - left_edge) / 2;1012 int half_size = (right_edge - left_edge) / 2;
10121013
1013 SetOffscreenRenderTarget(texture);1014 unity::graphics::PushOffscreenRenderTarget(texture);
10141015
1015 // FIXME1016 // FIXME
1016 glClear(GL_COLOR_BUFFER_BIT);1017 glClear(GL_COLOR_BUFFER_BIT);
@@ -1041,7 +1042,7 @@
10411042
1042 GfxContext.PopClippingRectangle();1043 GfxContext.PopClippingRectangle();
10431044
1044 RestoreSystemRenderTarget();1045 unity::graphics::PopOffscreenRenderTarget();
1045}1046}
10461047
1047void IconRenderer::DestroyTextures()1048void IconRenderer::DestroyTextures()
@@ -1134,29 +1135,6 @@
1134 PerspectiveMatrix.Perspective(Fovy, AspectRatio, NearClipPlane, FarClipPlane);1135 PerspectiveMatrix.Perspective(Fovy, AspectRatio, NearClipPlane, FarClipPlane);
1135}1136}
11361137
1137void
1138IconRenderer::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
1139{
1140 int width = texture->GetWidth();
1141 int height = texture->GetHeight();
1142
1143 nux::GetGraphicsDisplay()->GetGpuDevice()->FormatFrameBufferObject(width, height, nux::BITFMT_R8G8B8A8);
1144 nux::GetGraphicsDisplay()->GetGpuDevice()->SetColorRenderTargetSurface(0, texture->GetSurfaceLevel(0));
1145 nux::GetGraphicsDisplay()->GetGpuDevice()->ActivateFrameBuffer();
1146
1147 nux::GetGraphicsDisplay()->GetGraphicsEngine()->SetContext(0, 0, width, height);
1148 nux::GetGraphicsDisplay()->GetGraphicsEngine()->SetViewport(0, 0, width, height);
1149 nux::GetGraphicsDisplay()->GetGraphicsEngine()->Push2DWindow(width, height);
1150 nux::GetGraphicsDisplay()->GetGraphicsEngine()->EmptyClippingRegion();
1151}
1152
1153void
1154IconRenderer::RestoreSystemRenderTarget()
1155{
1156 nux::GetWindowCompositor().RestoreRenderingSurface();
1157}
1158
1159
1160// The local namespace is purely for namespacing the file local variables below.1138// The local namespace is purely for namespacing the file local variables below.
1161namespace local1139namespace local
1162{1140{
11631141
=== modified file 'unity-shared/IconRenderer.h'
--- unity-shared/IconRenderer.h 2012-10-11 20:01:44 +0000
+++ unity-shared/IconRenderer.h 2012-11-01 08:29:20 +0000
@@ -84,10 +84,6 @@
84 float FarClipPlane,84 float FarClipPlane,
85 float Fovy);85 float Fovy);
8686
87 void SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
88
89 void RestoreSystemRenderTarget();
90
91private:87private:
92 int icon_size;88 int icon_size;
93 int image_size;89 int image_size;