Merge lp:~nick-dedekind/unity/lp765715.launcher-icon-shadow into lp:unity
- lp765715.launcher-icon-shadow
- Merge into trunk
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 |
Related bugs: |
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:/
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:/
To post a comment you must log in.
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
1 | === modified file 'launcher/Launcher.cpp' | |||
2 | --- launcher/Launcher.cpp 2012-10-31 20:34:34 +0000 | |||
3 | +++ launcher/Launcher.cpp 2012-11-01 08:29:20 +0000 | |||
4 | @@ -49,6 +49,8 @@ | |||
5 | 49 | #include "unity-shared/UScreen.h" | 49 | #include "unity-shared/UScreen.h" |
6 | 50 | #include "unity-shared/UBusMessages.h" | 50 | #include "unity-shared/UBusMessages.h" |
7 | 51 | #include "unity-shared/UnitySettings.h" | 51 | #include "unity-shared/UnitySettings.h" |
8 | 52 | #include "unity-shared/GraphicsUtils.h" | ||
9 | 53 | |||
10 | 52 | 54 | ||
11 | 53 | #include <UnityCore/GLibWrapper.h> | 55 | #include <UnityCore/GLibWrapper.h> |
12 | 54 | #include <UnityCore/Variant.h> | 56 | #include <UnityCore/Variant.h> |
13 | @@ -114,7 +116,6 @@ | |||
14 | 114 | , _active_quicklist(nullptr) | 116 | , _active_quicklist(nullptr) |
15 | 115 | , _hovered(false) | 117 | , _hovered(false) |
16 | 116 | , _hidden(false) | 118 | , _hidden(false) |
17 | 117 | , _render_drag_window(false) | ||
18 | 118 | , _shortcuts_shown(false) | 119 | , _shortcuts_shown(false) |
19 | 119 | , _data_checked(false) | 120 | , _data_checked(false) |
20 | 120 | , _steal_drag(false) | 121 | , _steal_drag(false) |
21 | @@ -152,8 +153,6 @@ | |||
22 | 152 | 153 | ||
23 | 153 | _collection_window->collected.connect(sigc::mem_fun(this, &Launcher::OnDNDDataCollected)); | 154 | _collection_window->collected.connect(sigc::mem_fun(this, &Launcher::OnDNDDataCollected)); |
24 | 154 | 155 | ||
25 | 155 | _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8); | ||
26 | 156 | |||
27 | 157 | bg_effect_helper_.owner = this; | 156 | bg_effect_helper_.owner = this; |
28 | 158 | bg_effect_helper_.enabled = false; | 157 | bg_effect_helper_.enabled = false; |
29 | 159 | 158 | ||
30 | @@ -1757,13 +1756,6 @@ | |||
31 | 1757 | nux::Geometry const& geo_absolute = GetAbsoluteGeometry(); | 1756 | nux::Geometry const& geo_absolute = GetAbsoluteGeometry(); |
32 | 1758 | RenderArgs(args, bkg_box, &launcher_alpha, geo_absolute); | 1757 | RenderArgs(args, bkg_box, &launcher_alpha, geo_absolute); |
33 | 1759 | bkg_box.width -= RIGHT_LINE_WIDTH; | 1758 | bkg_box.width -= RIGHT_LINE_WIDTH; |
34 | 1760 | |||
35 | 1761 | if (_drag_icon && _render_drag_window) | ||
36 | 1762 | { | ||
37 | 1763 | RenderIconToTexture(GfxContext, _drag_icon, _offscreen_drag_texture); | ||
38 | 1764 | _render_drag_window = false; | ||
39 | 1765 | ShowDragWindow(); | ||
40 | 1766 | } | ||
41 | 1767 | 1759 | ||
42 | 1768 | nux::Color clear_colour = nux::Color(0x00000000); | 1760 | nux::Color clear_colour = nux::Color(0x00000000); |
43 | 1769 | 1761 | ||
44 | @@ -2030,10 +2022,10 @@ | |||
45 | 2030 | _drag_icon_position = _model->IconIndex(icon); | 2022 | _drag_icon_position = _model->IconIndex(icon); |
46 | 2031 | 2023 | ||
47 | 2032 | HideDragWindow(); | 2024 | HideDragWindow(); |
49 | 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); |
50 | 2034 | _drag_window = new LauncherDragWindow(_offscreen_drag_texture); | 2026 | _drag_window = new LauncherDragWindow(_offscreen_drag_texture); |
53 | 2035 | 2027 | RenderIconToTexture(nux::GetWindowThread()->GetGraphicsEngine(), _drag_icon, _offscreen_drag_texture); | |
54 | 2036 | _render_drag_window = true; | 2028 | ShowDragWindow(); |
55 | 2037 | 2029 | ||
56 | 2038 | ubus_.SendMessage(UBUS_LAUNCHER_ICON_START_DND); | 2030 | ubus_.SendMessage(UBUS_LAUNCHER_ICON_START_DND); |
57 | 2039 | } | 2031 | } |
58 | @@ -2077,8 +2069,6 @@ | |||
59 | 2077 | if (MouseBeyondDragThreshold()) | 2069 | if (MouseBeyondDragThreshold()) |
60 | 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); |
61 | 2079 | 2071 | ||
62 | 2080 | _render_drag_window = false; | ||
63 | 2081 | |||
64 | 2082 | _hide_machine.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, false); | 2072 | _hide_machine.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, false); |
65 | 2083 | ubus_.SendMessage(UBUS_LAUNCHER_ICON_END_DND); | 2073 | ubus_.SendMessage(UBUS_LAUNCHER_ICON_END_DND); |
66 | 2084 | } | 2074 | } |
67 | @@ -2503,7 +2493,7 @@ | |||
68 | 2503 | clock_gettime(CLOCK_MONOTONIC, ¤t); | 2493 | clock_gettime(CLOCK_MONOTONIC, ¤t); |
69 | 2504 | 2494 | ||
70 | 2505 | SetupRenderArg(icon, current, arg); | 2495 | SetupRenderArg(icon, current, arg); |
72 | 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); |
73 | 2507 | arg.logical_center = arg.render_center; | 2497 | arg.logical_center = arg.render_center; |
74 | 2508 | arg.x_rotation = 0.0f; | 2498 | arg.x_rotation = 0.0f; |
75 | 2509 | arg.running_arrow = false; | 2499 | arg.running_arrow = false; |
76 | @@ -2515,7 +2505,7 @@ | |||
77 | 2515 | std::list<RenderArg> drag_args; | 2505 | std::list<RenderArg> drag_args; |
78 | 2516 | drag_args.push_front(arg); | 2506 | drag_args.push_front(arg); |
79 | 2517 | 2507 | ||
81 | 2518 | SetOffscreenRenderTarget(texture); | 2508 | graphics::PushOffscreenRenderTarget(texture); |
82 | 2519 | 2509 | ||
83 | 2520 | unsigned int alpha = 0, src = 0, dest = 0; | 2510 | unsigned int alpha = 0, src = 0, dest = 0; |
84 | 2521 | GfxContext.GetRenderStates().GetBlend(alpha, src, dest); | 2511 | GfxContext.GetRenderStates().GetBlend(alpha, src, dest); |
85 | @@ -2529,9 +2519,11 @@ | |||
86 | 2529 | 2519 | ||
87 | 2530 | GfxContext.GetRenderStates().SetBlend(alpha, src, dest); | 2520 | GfxContext.GetRenderStates().SetBlend(alpha, src, dest); |
88 | 2531 | 2521 | ||
92 | 2532 | icon_renderer->PreprocessIcons(drag_args, nux::Geometry(0, 0, _icon_size, _icon_size)); | 2522 | nux::Geometry geo(0, 0, texture->GetWidth(), texture->GetWidth()); |
93 | 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 | |
94 | 2534 | RestoreSystemRenderTarget(); | 2524 | icon_renderer->PreprocessIcons(drag_args, geo); |
95 | 2525 | icon_renderer->RenderIcon(GfxContext, arg, geo, geo); | ||
96 | 2526 | unity::graphics::PopOffscreenRenderTarget(); | ||
97 | 2535 | } | 2527 | } |
98 | 2536 | 2528 | ||
99 | 2537 | nux::GestureDeliveryRequest Launcher::GestureEvent(const nux::GestureEvent &event) | 2529 | nux::GestureDeliveryRequest Launcher::GestureEvent(const nux::GestureEvent &event) |
100 | @@ -2552,30 +2544,6 @@ | |||
101 | 2552 | return nux::GestureDeliveryRequest::NONE; | 2544 | return nux::GestureDeliveryRequest::NONE; |
102 | 2553 | } | 2545 | } |
103 | 2554 | 2546 | ||
104 | 2555 | void | ||
105 | 2556 | Launcher::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture) | ||
106 | 2557 | { | ||
107 | 2558 | int width = texture->GetWidth(); | ||
108 | 2559 | int height = texture->GetHeight(); | ||
109 | 2560 | |||
110 | 2561 | auto graphics_display = nux::GetGraphicsDisplay(); | ||
111 | 2562 | auto gpu_device = graphics_display->GetGpuDevice(); | ||
112 | 2563 | gpu_device->FormatFrameBufferObject(width, height, nux::BITFMT_R8G8B8A8); | ||
113 | 2564 | gpu_device->SetColorRenderTargetSurface(0, texture->GetSurfaceLevel(0)); | ||
114 | 2565 | gpu_device->ActivateFrameBuffer(); | ||
115 | 2566 | |||
116 | 2567 | auto graphics_engine = graphics_display->GetGraphicsEngine(); | ||
117 | 2568 | graphics_engine->SetContext(0, 0, width, height); | ||
118 | 2569 | graphics_engine->SetViewport(0, 0, width, height); | ||
119 | 2570 | graphics_engine->Push2DWindow(width, height); | ||
120 | 2571 | graphics_engine->EmptyClippingRegion(); | ||
121 | 2572 | } | ||
122 | 2573 | |||
123 | 2574 | void Launcher::RestoreSystemRenderTarget() | ||
124 | 2575 | { | ||
125 | 2576 | nux::GetWindowCompositor().RestoreRenderingSurface(); | ||
126 | 2577 | } | ||
127 | 2578 | |||
128 | 2579 | bool Launcher::DndIsSpecialRequest(std::string const& uri) const | 2547 | bool Launcher::DndIsSpecialRequest(std::string const& uri) const |
129 | 2580 | { | 2548 | { |
130 | 2581 | return (boost::algorithm::ends_with(uri, ".desktop") || uri.find("device://") == 0); | 2549 | return (boost::algorithm::ends_with(uri, ".desktop") || uri.find("device://") == 0); |
131 | 2582 | 2550 | ||
132 | === modified file 'launcher/Launcher.h' | |||
133 | --- launcher/Launcher.h 2012-10-29 09:34:54 +0000 | |||
134 | +++ launcher/Launcher.h 2012-11-01 08:29:20 +0000 | |||
135 | @@ -317,9 +317,6 @@ | |||
136 | 317 | 317 | ||
137 | 318 | virtual long PostLayoutManagement(long LayoutResult); | 318 | virtual long PostLayoutManagement(long LayoutResult); |
138 | 319 | 319 | ||
139 | 320 | void SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture); | ||
140 | 321 | void RestoreSystemRenderTarget(); | ||
141 | 322 | |||
142 | 323 | void OnDisplayChanged(Display* display); | 320 | void OnDisplayChanged(Display* display); |
143 | 324 | void OnDNDDataCollected(const std::list<char*>& mimes); | 321 | void OnDNDDataCollected(const std::list<char*>& mimes); |
144 | 325 | 322 | ||
145 | 326 | 323 | ||
146 | === modified file 'launcher/LauncherDragWindow.cpp' | |||
147 | --- launcher/LauncherDragWindow.cpp 2012-10-11 01:44:15 +0000 | |||
148 | +++ launcher/LauncherDragWindow.cpp 2012-11-01 08:29:20 +0000 | |||
149 | @@ -35,17 +35,19 @@ | |||
150 | 35 | { | 35 | { |
151 | 36 | const float QUICK_ANIMATION_SPEED = 0.3f; | 36 | const float QUICK_ANIMATION_SPEED = 0.3f; |
152 | 37 | const float SLOW_ANIMATION_SPEED = 0.05f; | 37 | const float SLOW_ANIMATION_SPEED = 0.05f; |
153 | 38 | |||
154 | 39 | const int ANIMATION_THRESHOLD = 5; | ||
155 | 38 | } | 40 | } |
156 | 39 | 41 | ||
157 | 40 | NUX_IMPLEMENT_OBJECT_TYPE(LauncherDragWindow); | 42 | NUX_IMPLEMENT_OBJECT_TYPE(LauncherDragWindow); |
158 | 41 | 43 | ||
160 | 42 | LauncherDragWindow::LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> icon) | 44 | LauncherDragWindow::LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture) |
161 | 43 | : nux::BaseWindow("") | 45 | : nux::BaseWindow("") |
162 | 44 | , animation_speed_(QUICK_ANIMATION_SPEED) | 46 | , animation_speed_(QUICK_ANIMATION_SPEED) |
165 | 45 | , _cancelled(false) | 47 | , cancelled_(false) |
166 | 46 | , _icon(icon) | 48 | , texture_(texture) |
167 | 47 | { | 49 | { |
169 | 48 | SetBaseSize(_icon->GetWidth(), _icon->GetHeight()); | 50 | SetBaseSize(texture_->GetWidth(), texture_->GetHeight()); |
170 | 49 | 51 | ||
171 | 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) { |
172 | 51 | if (keysym == NUX_VK_ESCAPE) | 53 | if (keysym == NUX_VK_ESCAPE) |
173 | @@ -72,18 +74,18 @@ | |||
174 | 72 | 74 | ||
175 | 73 | bool LauncherDragWindow::Cancelled() const | 75 | bool LauncherDragWindow::Cancelled() const |
176 | 74 | { | 76 | { |
178 | 75 | return _cancelled; | 77 | return cancelled_; |
179 | 76 | } | 78 | } |
180 | 77 | 79 | ||
181 | 78 | void LauncherDragWindow::CancelDrag() | 80 | void LauncherDragWindow::CancelDrag() |
182 | 79 | { | 81 | { |
184 | 80 | _cancelled = true; | 82 | cancelled_ = true; |
185 | 81 | drag_cancel_request.emit(); | 83 | drag_cancel_request.emit(); |
186 | 82 | } | 84 | } |
187 | 83 | 85 | ||
188 | 84 | void LauncherDragWindow::SetAnimationTarget(int x, int y) | 86 | void LauncherDragWindow::SetAnimationTarget(int x, int y) |
189 | 85 | { | 87 | { |
191 | 86 | _animation_target = nux::Point2(x, y); | 88 | animation_target_ = nux::Point2(x, y); |
192 | 87 | } | 89 | } |
193 | 88 | 90 | ||
194 | 89 | void LauncherDragWindow::StartQuickAnimation() | 91 | void LauncherDragWindow::StartQuickAnimation() |
195 | @@ -113,16 +115,16 @@ | |||
196 | 113 | 115 | ||
197 | 114 | int half_size = geo.width / 2; | 116 | int half_size = geo.width / 2; |
198 | 115 | 117 | ||
201 | 116 | int target_x = static_cast<int>(_animation_target.x) - half_size; | 118 | int target_x = static_cast<int>(animation_target_.x) - half_size; |
202 | 117 | int target_y = static_cast<int>(_animation_target.y) - half_size; | 119 | int target_y = static_cast<int>(animation_target_.y) - half_size; |
203 | 118 | 120 | ||
204 | 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_); |
207 | 120 | if (std::abs(x_delta) < 5) | 122 | if (std::abs(x_delta) < ANIMATION_THRESHOLD) |
208 | 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); |
209 | 122 | 124 | ||
210 | 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_); |
213 | 124 | if (std::abs(y_delta) < 5) | 126 | if (std::abs(y_delta) < ANIMATION_THRESHOLD) |
214 | 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); |
215 | 126 | 128 | ||
216 | 127 | SetBaseXY(geo.x + x_delta, geo.y + y_delta); | 129 | SetBaseXY(geo.x + x_delta, geo.y + y_delta); |
217 | 128 | 130 | ||
218 | @@ -151,11 +153,11 @@ | |||
219 | 151 | nux::TexCoordXForm texxform; | 153 | nux::TexCoordXForm texxform; |
220 | 152 | texxform.FlipVCoord(true); | 154 | texxform.FlipVCoord(true); |
221 | 153 | 155 | ||
227 | 154 | GfxContext.QRP_1Tex(0, | 156 | GfxContext.QRP_1Tex(geo.x, |
228 | 155 | 0, | 157 | geo.y, |
229 | 156 | _icon->GetWidth(), | 158 | texture_->GetWidth(), |
230 | 157 | _icon->GetHeight(), | 159 | texture_->GetHeight(), |
231 | 158 | _icon, | 160 | texture_, |
232 | 159 | texxform, | 161 | texxform, |
233 | 160 | nux::color::White); | 162 | nux::color::White); |
234 | 161 | 163 | ||
235 | 162 | 164 | ||
236 | === modified file 'launcher/LauncherDragWindow.h' | |||
237 | --- launcher/LauncherDragWindow.h 2012-09-13 00:48:06 +0000 | |||
238 | +++ launcher/LauncherDragWindow.h 2012-11-01 08:29:20 +0000 | |||
239 | @@ -36,7 +36,7 @@ | |||
240 | 36 | { | 36 | { |
241 | 37 | NUX_DECLARE_OBJECT_TYPE(LauncherDragWindow, nux::BaseWindow); | 37 | NUX_DECLARE_OBJECT_TYPE(LauncherDragWindow, nux::BaseWindow); |
242 | 38 | public: | 38 | public: |
244 | 39 | LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> icon); | 39 | LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture); |
245 | 40 | ~LauncherDragWindow(); | 40 | ~LauncherDragWindow(); |
246 | 41 | 41 | ||
247 | 42 | void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw); | 42 | void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw); |
248 | @@ -62,9 +62,9 @@ | |||
249 | 62 | void CancelDrag(); | 62 | void CancelDrag(); |
250 | 63 | 63 | ||
251 | 64 | float animation_speed_; | 64 | float animation_speed_; |
255 | 65 | bool _cancelled; | 65 | bool cancelled_; |
256 | 66 | nux::ObjectPtr<nux::IOpenGLBaseTexture> _icon; | 66 | nux::ObjectPtr<nux::IOpenGLBaseTexture> texture_; |
257 | 67 | nux::Point2 _animation_target; | 67 | nux::Point2 animation_target_; |
258 | 68 | glib::Source::UniquePtr animation_timer_; | 68 | glib::Source::UniquePtr animation_timer_; |
259 | 69 | }; | 69 | }; |
260 | 70 | 70 | ||
261 | 71 | 71 | ||
262 | === modified file 'launcher/SoftwareCenterLauncherIcon.cpp' | |||
263 | --- launcher/SoftwareCenterLauncherIcon.cpp 2012-10-17 11:08:05 +0000 | |||
264 | +++ launcher/SoftwareCenterLauncherIcon.cpp 2012-11-01 08:29:20 +0000 | |||
265 | @@ -68,8 +68,8 @@ | |||
266 | 68 | launcher_ = launcher; | 68 | launcher_ = launcher; |
267 | 69 | 69 | ||
268 | 70 | icon_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture( | 70 | icon_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture( |
271 | 71 | launcher->GetIconSize(), | 71 | launcher->GetWidth(), |
272 | 72 | launcher->GetIconSize(), | 72 | launcher->GetWidth(), |
273 | 73 | 1, | 73 | 1, |
274 | 74 | nux::BITFMT_R8G8B8A8); | 74 | nux::BITFMT_R8G8B8A8); |
275 | 75 | 75 | ||
276 | 76 | 76 | ||
277 | === modified file 'unity-shared/CMakeLists.txt' | |||
278 | --- unity-shared/CMakeLists.txt 2012-10-18 10:44:07 +0000 | |||
279 | +++ unity-shared/CMakeLists.txt 2012-11-01 08:29:20 +0000 | |||
280 | @@ -34,6 +34,7 @@ | |||
281 | 34 | DashStyle.cpp | 34 | DashStyle.cpp |
282 | 35 | DefaultThumbnailProvider.cpp | 35 | DefaultThumbnailProvider.cpp |
283 | 36 | FontSettings.cpp | 36 | FontSettings.cpp |
284 | 37 | GraphicsUtils.cpp | ||
285 | 37 | IMTextEntry.cpp | 38 | IMTextEntry.cpp |
286 | 38 | IconLoader.cpp | 39 | IconLoader.cpp |
287 | 39 | IconRenderer.cpp | 40 | IconRenderer.cpp |
288 | 40 | 41 | ||
289 | === added file 'unity-shared/GraphicsUtils.cpp' | |||
290 | --- unity-shared/GraphicsUtils.cpp 1970-01-01 00:00:00 +0000 | |||
291 | +++ unity-shared/GraphicsUtils.cpp 2012-11-01 08:29:20 +0000 | |||
292 | @@ -0,0 +1,71 @@ | |||
293 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
294 | 2 | /* | ||
295 | 3 | * Copyright (C) 2010 Canonical Ltd | ||
296 | 4 | * | ||
297 | 5 | * This program is free software: you can redistribute it and/or modify | ||
298 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
299 | 7 | * published by the Free Software Foundation. | ||
300 | 8 | * | ||
301 | 9 | * This program is distributed in the hope that it will be useful, | ||
302 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
303 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
304 | 12 | * GNU General Public License for more details. | ||
305 | 13 | * | ||
306 | 14 | * You should have received a copy of the GNU General Public License | ||
307 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
308 | 16 | * | ||
309 | 17 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
310 | 18 | */ | ||
311 | 19 | |||
312 | 20 | #include "GraphicsUtils.h" | ||
313 | 21 | #include <NuxGraphics/GLTextureResourceManager.h> | ||
314 | 22 | |||
315 | 23 | namespace unity | ||
316 | 24 | { | ||
317 | 25 | namespace graphics | ||
318 | 26 | { | ||
319 | 27 | |||
320 | 28 | std::stack<nux::ObjectPtr<nux::IOpenGLBaseTexture>> rendering_stack; | ||
321 | 29 | |||
322 | 30 | void PushOffscreenRenderTarget_(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture) | ||
323 | 31 | { | ||
324 | 32 | int width = texture->GetWidth(); | ||
325 | 33 | int height = texture->GetHeight(); | ||
326 | 34 | |||
327 | 35 | auto graphics_display = nux::GetGraphicsDisplay(); | ||
328 | 36 | auto gpu_device = graphics_display->GetGpuDevice(); | ||
329 | 37 | gpu_device->FormatFrameBufferObject(width, height, nux::BITFMT_R8G8B8A8); | ||
330 | 38 | gpu_device->SetColorRenderTargetSurface(0, texture->GetSurfaceLevel(0)); | ||
331 | 39 | gpu_device->ActivateFrameBuffer(); | ||
332 | 40 | |||
333 | 41 | auto graphics_engine = graphics_display->GetGraphicsEngine(); | ||
334 | 42 | graphics_engine->SetContext(0, 0, width, height); | ||
335 | 43 | graphics_engine->SetViewport(0, 0, width, height); | ||
336 | 44 | graphics_engine->Push2DWindow(width, height); | ||
337 | 45 | graphics_engine->EmptyClippingRegion(); | ||
338 | 46 | } | ||
339 | 47 | |||
340 | 48 | void PushOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture) | ||
341 | 49 | { | ||
342 | 50 | PushOffscreenRenderTarget_(texture); | ||
343 | 51 | rendering_stack.push(texture); | ||
344 | 52 | } | ||
345 | 53 | |||
346 | 54 | void PopOffscreenRenderTarget() | ||
347 | 55 | { | ||
348 | 56 | g_assert(rendering_stack.size() > 0); | ||
349 | 57 | |||
350 | 58 | rendering_stack.pop(); | ||
351 | 59 | if (rendering_stack.size() > 0) | ||
352 | 60 | { | ||
353 | 61 | nux::ObjectPtr<nux::IOpenGLBaseTexture>& texture = rendering_stack.top(); | ||
354 | 62 | PushOffscreenRenderTarget_(texture); | ||
355 | 63 | } | ||
356 | 64 | else | ||
357 | 65 | { | ||
358 | 66 | nux::GetWindowCompositor().RestoreRenderingSurface(); | ||
359 | 67 | } | ||
360 | 68 | } | ||
361 | 69 | |||
362 | 70 | } | ||
363 | 71 | } | ||
364 | 0 | \ No newline at end of file | 72 | \ No newline at end of file |
365 | 1 | 73 | ||
366 | === added file 'unity-shared/GraphicsUtils.h' | |||
367 | --- unity-shared/GraphicsUtils.h 1970-01-01 00:00:00 +0000 | |||
368 | +++ unity-shared/GraphicsUtils.h 2012-11-01 08:29:20 +0000 | |||
369 | @@ -0,0 +1,36 @@ | |||
370 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
371 | 2 | /* | ||
372 | 3 | * Copyright (C) 2010 Canonical Ltd | ||
373 | 4 | * | ||
374 | 5 | * This program is free software: you can redistribute it and/or modify | ||
375 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
376 | 7 | * published by the Free Software Foundation. | ||
377 | 8 | * | ||
378 | 9 | * This program is distributed in the hope that it will be useful, | ||
379 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
380 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
381 | 12 | * GNU General Public License for more details. | ||
382 | 13 | * | ||
383 | 14 | * You should have received a copy of the GNU General Public License | ||
384 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
385 | 16 | * | ||
386 | 17 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
387 | 18 | */ | ||
388 | 19 | |||
389 | 20 | #ifndef UNITY_GRAPHICS_ADAPTER | ||
390 | 21 | #define UNITY_GRAPHICS_ADAPTER | ||
391 | 22 | |||
392 | 23 | #include <Nux/Nux.h> | ||
393 | 24 | |||
394 | 25 | namespace unity | ||
395 | 26 | { | ||
396 | 27 | namespace graphics | ||
397 | 28 | { | ||
398 | 29 | |||
399 | 30 | void PushOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture); | ||
400 | 31 | void PopOffscreenRenderTarget(); | ||
401 | 32 | |||
402 | 33 | } | ||
403 | 34 | } | ||
404 | 35 | |||
405 | 36 | #endif // UNITY_GRAPHICS_ADAPTER | ||
406 | 0 | \ No newline at end of file | 37 | \ No newline at end of file |
407 | 1 | 38 | ||
408 | === modified file 'unity-shared/IconRenderer.cpp' | |||
409 | --- unity-shared/IconRenderer.cpp 2012-10-17 22:13:25 +0000 | |||
410 | +++ unity-shared/IconRenderer.cpp 2012-11-01 08:29:20 +0000 | |||
411 | @@ -26,6 +26,7 @@ | |||
412 | 26 | #include <NuxGraphics/GLTextureResourceManager.h> | 26 | #include <NuxGraphics/GLTextureResourceManager.h> |
413 | 27 | 27 | ||
414 | 28 | #include <NuxGraphics/CairoGraphics.h> | 28 | #include <NuxGraphics/CairoGraphics.h> |
415 | 29 | #include "GraphicsUtils.h" | ||
416 | 29 | 30 | ||
417 | 30 | #include <gtk/gtk.h> | 31 | #include <gtk/gtk.h> |
418 | 31 | 32 | ||
419 | @@ -1010,7 +1011,7 @@ | |||
420 | 1010 | int progress_y = fill_y + (fill_height - progress_height) / 2; | 1011 | int progress_y = fill_y + (fill_height - progress_height) / 2; |
421 | 1011 | int half_size = (right_edge - left_edge) / 2; | 1012 | int half_size = (right_edge - left_edge) / 2; |
422 | 1012 | 1013 | ||
424 | 1013 | SetOffscreenRenderTarget(texture); | 1014 | unity::graphics::PushOffscreenRenderTarget(texture); |
425 | 1014 | 1015 | ||
426 | 1015 | // FIXME | 1016 | // FIXME |
427 | 1016 | glClear(GL_COLOR_BUFFER_BIT); | 1017 | glClear(GL_COLOR_BUFFER_BIT); |
428 | @@ -1041,7 +1042,7 @@ | |||
429 | 1041 | 1042 | ||
430 | 1042 | GfxContext.PopClippingRectangle(); | 1043 | GfxContext.PopClippingRectangle(); |
431 | 1043 | 1044 | ||
433 | 1044 | RestoreSystemRenderTarget(); | 1045 | unity::graphics::PopOffscreenRenderTarget(); |
434 | 1045 | } | 1046 | } |
435 | 1046 | 1047 | ||
436 | 1047 | void IconRenderer::DestroyTextures() | 1048 | void IconRenderer::DestroyTextures() |
437 | @@ -1134,29 +1135,6 @@ | |||
438 | 1134 | PerspectiveMatrix.Perspective(Fovy, AspectRatio, NearClipPlane, FarClipPlane); | 1135 | PerspectiveMatrix.Perspective(Fovy, AspectRatio, NearClipPlane, FarClipPlane); |
439 | 1135 | } | 1136 | } |
440 | 1136 | 1137 | ||
441 | 1137 | void | ||
442 | 1138 | IconRenderer::SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture) | ||
443 | 1139 | { | ||
444 | 1140 | int width = texture->GetWidth(); | ||
445 | 1141 | int height = texture->GetHeight(); | ||
446 | 1142 | |||
447 | 1143 | nux::GetGraphicsDisplay()->GetGpuDevice()->FormatFrameBufferObject(width, height, nux::BITFMT_R8G8B8A8); | ||
448 | 1144 | nux::GetGraphicsDisplay()->GetGpuDevice()->SetColorRenderTargetSurface(0, texture->GetSurfaceLevel(0)); | ||
449 | 1145 | nux::GetGraphicsDisplay()->GetGpuDevice()->ActivateFrameBuffer(); | ||
450 | 1146 | |||
451 | 1147 | nux::GetGraphicsDisplay()->GetGraphicsEngine()->SetContext(0, 0, width, height); | ||
452 | 1148 | nux::GetGraphicsDisplay()->GetGraphicsEngine()->SetViewport(0, 0, width, height); | ||
453 | 1149 | nux::GetGraphicsDisplay()->GetGraphicsEngine()->Push2DWindow(width, height); | ||
454 | 1150 | nux::GetGraphicsDisplay()->GetGraphicsEngine()->EmptyClippingRegion(); | ||
455 | 1151 | } | ||
456 | 1152 | |||
457 | 1153 | void | ||
458 | 1154 | IconRenderer::RestoreSystemRenderTarget() | ||
459 | 1155 | { | ||
460 | 1156 | nux::GetWindowCompositor().RestoreRenderingSurface(); | ||
461 | 1157 | } | ||
462 | 1158 | |||
463 | 1159 | |||
464 | 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. |
465 | 1161 | namespace local | 1139 | namespace local |
466 | 1162 | { | 1140 | { |
467 | 1163 | 1141 | ||
468 | === modified file 'unity-shared/IconRenderer.h' | |||
469 | --- unity-shared/IconRenderer.h 2012-10-11 20:01:44 +0000 | |||
470 | +++ unity-shared/IconRenderer.h 2012-11-01 08:29:20 +0000 | |||
471 | @@ -84,10 +84,6 @@ | |||
472 | 84 | float FarClipPlane, | 84 | float FarClipPlane, |
473 | 85 | float Fovy); | 85 | float Fovy); |
474 | 86 | 86 | ||
475 | 87 | void SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture); | ||
476 | 88 | |||
477 | 89 | void RestoreSystemRenderTarget(); | ||
478 | 90 | |||
479 | 91 | private: | 87 | private: |
480 | 92 | int icon_size; | 88 | int icon_size; |
481 | 93 | int image_size; | 89 | int image_size; |
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); stack.size( ) > 0)
351 + if (rendering_
Please use std::stack::empty here.