Merge lp://staging/~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-resolution-independance into lp://staging/ubuntu-ui-toolkit/staging

Proposed by Loïc Molinari
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1363
Merged at revision: 1477
Proposed branch: lp://staging/~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-resolution-independance
Merge into: lp://staging/ubuntu-ui-toolkit/staging
Diff against target: 9515 lines (+1764/-7091)
15 files modified
components.api (+4/-1)
debian/copyright (+23/-0)
modules/Ubuntu/Components/plugin/shaders/shape.frag (+47/-11)
modules/Ubuntu/Components/plugin/shaders/shapeoverlay.frag (+48/-11)
modules/Ubuntu/Components/plugin/ucubuntushape.cpp (+309/-301)
modules/Ubuntu/Components/plugin/ucubuntushape.h (+37/-25)
modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp (+85/-176)
modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.h (+2/-2)
modules/Ubuntu/Components/plugin/ucubuntushapetexture.h (+268/-6519)
modules/Ubuntu/Components/tools/3rd_party/edtaa3func.c (+570/-0)
modules/Ubuntu/Components/tools/createshapeimage.cpp (+231/-0)
modules/Ubuntu/Components/tools/shape.svg (+77/-0)
modules/Ubuntu/Components/tools/tools.pro (+5/-0)
tests/resources/ubuntushape/UbuntuShapeOverlayTest.qml (+44/-37)
tests/resources/ubuntushape/UbuntuShapeTest.qml (+14/-8)
To merge this branch: bzr merge lp://staging/~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-resolution-independance
Reviewer Review Type Date Requested Status
Tim Peeters Needs Fixing
PS Jenkins bot continuous-integration Approve
Zsombor Egri Approve
Timo Jyrinki license Approve
Michael Zanetti (community) Needs Fixing
Florian Boucault Pending
Review via email: mp+252492@code.staging.launchpad.net

Description of the change

[UbuntuShape] Added support for resolution independent rendering.

To post a comment you must log in.
Revision history for this message
Michael Zanetti (mzanetti) wrote :

setImplicitWidth/setImplicitHeight are used wrong. They are set to a hardcoded size wile instead they should reflect the real size of the loaded content.

In case of an image, they should reflect the actual pixel size of the loaded image, while for generated rectangles, it should match the set widht/height.

review: Needs Fixing
Revision history for this message
Loïc Molinari (loic.molinari) wrote :

Hey Michael, thanks for the report. This issue has been here for a while, so in order to avoid confusing that already big patch, I'll fix it in another branch.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1354. By Loïc Molinari

Ensured rendering is the same as it was before switching to distance fields.

1355. By Loïc Molinari

Fixed typo.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

54 uniform bool textured;
55 +uniform mediump int aspect;
56
57 varying mediump vec2 shapeCoord;
58 varying mediump vec4 sourceCoord;
59 varying lowp vec4 backgroundColor;
60
61 +const mediump int FLAT = 0x08; // 1 << 3
62 +const mediump int INSET = 0x10; // 1 << 4

are medium precision values no problem in the fragment shader, as it was here in the vertex shader? https://bugs.launchpad.net/tangxi/+bug/1436094

Revision history for this message
Tim Peeters (tpeeters) wrote :

105 + // Blend the shape inner shadow over the current color. The shadow color is black, its
106 + // translucency is stored in the texture.
107 + lowp float shadow = shapeData[int(shapeSide)];
108 + color = vec4(1.0 - shadow) * color + vec4(0.0, 0.0, 0.0, shadow);

Do you need anti-aliasing for the shadow? As I understand this code, it is either on or off.

Revision history for this message
Tim Peeters (tpeeters) wrote :

379 + // The geometry is made of 9 vertices indexed with a triangle strip mode.
380 + // 0 - 1 - 2
381 + // | / | / |
382 + // 3 - 4 - 5
383 + // | / | / |
384 + // 6 - 7 - 8

Why do you need a triangle strip? Couldn't it be done with a single quad? (or two triangles)

Revision history for this message
Tim Peeters (tpeeters) wrote :
review: Needs Fixing
Revision history for this message
Loïc Molinari (loic.molinari) wrote :

> 54 uniform bool textured;
> 55 +uniform mediump int aspect;
> 56
> 57 varying mediump vec2 shapeCoord;
> 58 varying mediump vec4 sourceCoord;
> 59 varying lowp vec4 backgroundColor;
> 60
> 61 +const mediump int FLAT = 0x08; // 1 << 3
> 62 +const mediump int INSET = 0x10; // 1 << 4
>
>
> are medium precision values no problem in the fragment shader, as it was here
> in the vertex shader? https://bugs.launchpad.net/tangxi/+bug/1436094

No, I don't think so, since these are integer values. But I'm going to test on arale since I got it flashed now.

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

> 105 + // Blend the shape inner shadow over the current color. The
> shadow color is black, its
> 106 + // translucency is stored in the texture.
> 107 + lowp float shadow = shapeData[int(shapeSide)];
> 108 + color = vec4(1.0 - shadow) * color + vec4(0.0, 0.0, 0.0,
> shadow);
>
> Do you need anti-aliasing for the shadow? As I understand this code, it is
> either on or off.

This has nothing to do with antialiasing. shapeData[0] contains the top shadow, shapeData[1] contains the bottom shadow. This is needed because shadowing is different on top and bottom of the shape, the shadow distance on the top is higher than on the bottom.

Revision history for this message
Tim Peeters (tpeeters) wrote :

Do we know whether the copyright notice from edtaa3func.c needs to be included anywhere else besides in the source file itself?

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

> 379 + // The geometry is made of 9 vertices indexed with a triangle
> strip mode.
> 380 + // 0 - 1 - 2
> 381 + // | / | / |
> 382 + // 3 - 4 - 5
> 383 + // | / | / |
> 384 + // 6 - 7 - 8
>
> Why do you need a triangle strip? Couldn't it be done with a single quad? (or
> two triangles)

It can't be done with a quad.

I need to have shape coordinate like that to correctly sample from the distance field:
  (1,1) (0,1) - (0,1) (1,1)
  (1,0) (0,0) (0,0) (1,0)
  | |
  (1,0) (0,0) (0,0) (1,0)
  (1,0) (0,0) - (0,0) (1,0)

  It looks like that should be done with 16 vertices, but 9 vertices can do it with middle coordinates set appropriately. Note that I could use 4 vertices like that:
  (-1,-1) - (1,-1)
  | |
  (-1, 1) - (1, 1)

  but that would require affine an affine transformation in the vertex shader with dedicated values for each shape, which would prevent the shapes to be batched together be the batched renderer. That's why I try to store all the per-shape values in the vertices (like for the colors).

Revision history for this message
Tim Peeters (tpeeters) wrote :

Loic, do you think that having a different fragment shader depending on texture and aspect instead of the three if statements in shape.frag could increase the performance even more? Or just two different shaders for the different aspects.

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

> Do we know whether the copyright notice from edtaa3func.c needs to be included
> anywhere else besides in the source file itself?

There's a few licencing issues we'd need to solve. Can edtaa3func.c MIT code be linked to a LGPL3 binary? Should we update debian files (I guess yes, but I don't know what)? All our binary files (executables, not libraries or plugins) or scripts are LGPL3, shouldn't that be GPL3?

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

> The results look ugly on my laptop, see https://www.dropbox.com/s/8yi4fjwa8wwo
> 07h/Screenshot%202015-04-07%2016.42.57.png?dl=0 and https://www.dropbox.com/s/
> 5s0u4vg9veo00m0/Screenshot%202015-04-07%2016.43.34.png?dl=0

Mmmh, strange. Do you have support for standard derivatives on your system (dFdy() and dFdx())?

Revision history for this message
Tim Peeters (tpeeters) wrote :

> > The results look ugly on my laptop, see
> https://www.dropbox.com/s/8yi4fjwa8wwo
> > 07h/Screenshot%202015-04-07%2016.42.57.png?dl=0 and
> https://www.dropbox.com/s/
> > 5s0u4vg9veo00m0/Screenshot%202015-04-07%2016.43.34.png?dl=0
>
> Mmmh, strange. Do you have support for standard derivatives on your system
> (dFdy() and dFdx())?

from glxinfo:

OpenGL ES profile version string: OpenGL ES 2.0 Mesa 10.5.0-rc2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 1.0.16
OpenGL ES profile extensions:
    GL_ANGLE_texture_compression_dxt3, GL_ANGLE_texture_compression_dxt5,
    GL_APPLE_texture_max_level, GL_EXT_blend_minmax,
    GL_EXT_discard_framebuffer, GL_EXT_draw_buffers, GL_EXT_map_buffer_range,
    GL_EXT_multi_draw_arrays, GL_EXT_read_format_bgra,
    GL_EXT_separate_shader_objects, GL_EXT_texture_compression_dxt1,
    GL_EXT_texture_filter_anisotropic, GL_EXT_texture_format_BGRA8888,
    GL_EXT_texture_type_2_10_10_10_REV, GL_EXT_unpack_subimage,
    GL_KHR_context_flush_control, GL_NV_draw_buffers,
    GL_NV_fbo_color_attachments, GL_NV_read_buffer, GL_OES_EGL_image,
    GL_OES_EGL_image_external, GL_OES_depth24, GL_OES_depth_texture,
    GL_OES_element_index_uint, GL_OES_fbo_render_mipmap,
    GL_OES_get_program_binary, GL_OES_mapbuffer, GL_OES_packed_depth_stencil,
    GL_OES_rgb8_rgba8, GL_OES_standard_derivatives, GL_OES_stencil8,
    GL_OES_surfaceless_context, GL_OES_texture_3D, GL_OES_texture_npot,
    GL_OES_vertex_array_object

GL_OES_standard_derivatives is listed here.

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

> Loic, do you think that having a different fragment shader depending on
> texture and aspect instead of the three if statements in shape.frag could
> increase the performance even more? Or just two different shaders for the
> different aspects.

Having different shaders (as we had before) would imply an exponential number of shaders and would make maintenance a nightmare. GPUs have a feature called static flow control which means that when we branch on a fixed uniform variable, the driver can create a dedicated shader with the unused branch shaved off the code. This is also called über-shader and is used a lot in games.

Revision history for this message
Tim Peeters (tpeeters) wrote :

With this shader, the inset renders perfectly: http://paste.ubuntu.com/10763669/

There may be something weird happening related to the 'aspect' uniform.

Revision history for this message
Tim Peeters (tpeeters) wrote :

<loicm> timp: could you try with that? (http://paste.ubuntu.com/10764354/)

I tried^, and it gives the same bad results.

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

Putting dFd*() calls outside of branches (even if uniform based, as accepted by the spec) fixes it. Will update the code.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

For GPL/LGPL, I don't know if there's a strict policy as long as libraries are LGPL and v3 of either license is in use. Considering the core parts of UITK are used in non-defined amount of applications (including possibly proprietary ones), it's probably easiest to just state that UITK is LGPLv3.

MIT license is fine: http://opensource.org/licenses/MIT - there are no restrictions except for the requirement to include copyright/license notice. If LGPLv3 would require the whole to be offered as LGPLv3, then the originally MIT licensed content can be redistributed under LGPLv3 whole.

Please update debian/copyright following the machine readable format it is in. That is, add at the bottom:

File: path/to/yourmitfile.c
Copyright: 201x, copyright owner
License: MIT

License: MIT
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 .
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 .
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.

review: Needs Fixing
1357. By Loïc Molinari

Tweaked constant.

1358. By Loïc Molinari

Updated Debian copyright.

Revision history for this message
Timo Jyrinki (timo-jyrinki) :
review: Approve (license)
1359. By Loïc Molinari

Worked around a standard derivatives bug in Mesa.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1360. By Loïc Molinari

Tweaked constant.

Revision history for this message
Tim Peeters (tpeeters) wrote :

The visuals are good now!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1361. By Loïc Molinari

Pleased license checking CI.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

All looks good to me!

review: Approve
1362. By Loïc Molinari

Fixed a comment.

1363. By Loïc Molinari

Adapted screen-space derivatives to screen orientation.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Looks good to me.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

Does not look good to me. The rendering issue that we discussed before came back.

I suspect this is the guilty change:

60 lowp float dfdt = dFdy(shapeCoord.t);
 60 lowp float dfdt = dfdtFactors.x != 0.0 ? dFdy(shapeCoord.t) : dFdx(shapeCoord.t);

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches