~mc-return/unity/unity.merge-fix1069243-update-manual-tests

« back to all changes in this revision

Viewing changes to unity-shared/IconRenderer.cpp

  • Committer: Tarmac
  • Author(s): Marco Trevisan (Treviño)
  • Date: 2012-10-12 15:15:58 UTC
  • mfrom: (2827.3.4 launcher-reduce-copies)
  • Revision ID: tarmac-20121012151558-pgqzr521tw1gma7x
Launcher: avoid copies in launcher rendering code-path. Approved by Andrea Azzarone.

Show diffs side-by-side

added added

removed removed

Lines of Context:
246
246
 
247
247
  GetInverseScreenPerspectiveMatrix(ViewMatrix, ProjectionMatrix, geo.width, geo.height, 0.1f, 1000.0f, DEGTORAD(90));
248
248
 
249
 
  nux::Matrix4 PremultMatrix = ProjectionMatrix * ViewMatrix;
 
249
  nux::Matrix4 const& PremultMatrix = ProjectionMatrix * ViewMatrix;
250
250
 
251
251
  std::list<RenderArg>::iterator it;
252
252
  int i;
253
 
  for (it = args.begin(), i = 0; it != args.end(); ++it, i++)
 
253
  for (it = args.begin(), i = 0; it != args.end(); ++it, ++i)
254
254
  {
255
255
 
256
256
    IconTextureSource* launcher_icon = it->icon;
343
343
  }
344
344
}
345
345
 
346
 
void IconRenderer::UpdateIconTransform(ui::IconTextureSource* icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry const& geo,
 
346
void IconRenderer::UpdateIconTransform(ui::IconTextureSource* icon, nux::Matrix4 const& ViewProjectionMatrix, nux::Geometry const& geo,
347
347
                                       float x, float y, float w, float h, float z, ui::IconTextureSource::TransformIndex index)
348
348
{
349
 
  UpdateIconSectionTransform (icon, ViewProjectionMatrix, geo, x, y, w, h, z, x, y, w, h, index);
 
349
  UpdateIconSectionTransform(icon, ViewProjectionMatrix, geo, x, y, w, h, z, x, y, w, h, index);
350
350
}
351
351
 
352
 
void IconRenderer::UpdateIconSectionTransform(ui::IconTextureSource* icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry const& geo,
 
352
void IconRenderer::UpdateIconSectionTransform(ui::IconTextureSource* icon, nux::Matrix4 const& ViewProjectionMatrix, nux::Geometry const& geo,
353
353
                                              float x, float y, float w, float h, float z, float xx, float yy, float ww, float hh, ui::IconTextureSource::TransformIndex index)
354
354
{
355
 
  nux::Vector4 v0 = nux::Vector4(x,     y,     z, 1.0f);
356
 
  nux::Vector4 v1 = nux::Vector4(x,     y + h, z, 1.0f);
357
 
  nux::Vector4 v2 = nux::Vector4(x + w, y + h, z, 1.0f);
358
 
  nux::Vector4 v3 = nux::Vector4(x + w, y,     z, 1.0f);
 
355
  nux::Vector4 v0(x,     y,     z, 1.0f);
 
356
  nux::Vector4 v1(x,     y + h, z, 1.0f);
 
357
  nux::Vector4 v2(x + w, y + h, z, 1.0f);
 
358
  nux::Vector4 v3(x + w, y,     z, 1.0f);
359
359
 
360
360
  v0 = ViewProjectionMatrix * v0;
361
361
  v1 = ViewProjectionMatrix * v1;
377
377
  v3.x =  geo.width  * (v3.x + 1.0f) / 2.0f - geo.width  / 2.0f + xx + ww / 2.0f;
378
378
  v3.y = -geo.height * (v3.y - 1.0f) / 2.0f - geo.height / 2.0f + yy + hh / 2.0f;
379
379
 
380
 
 
381
380
  std::vector<nux::Vector4>& vectors = icon->GetTransform(index, monitor);
382
 
 
383
381
  vectors[0] = v0;
384
382
  vectors[1] = v1;
385
383
  vectors[2] = v2;
705
703
 
706
704
void IconRenderer::RenderElement(nux::GraphicsEngine& GfxContext,
707
705
                                 RenderArg const& arg,
708
 
                                 nux::ObjectPtr<nux::IOpenGLBaseTexture> icon,
709
 
                                 nux::Color bkg_color,
710
 
                                 nux::Color colorify,
 
706
                                 nux::ObjectPtr<nux::IOpenGLBaseTexture> const& icon,
 
707
                                 nux::Color const& bkg_color,
 
708
                                 nux::Color const& colorify,
711
709
                                 float alpha,
712
710
                                 bool force_filter,
713
 
                                 std::vector<nux::Vector4>& xform_coords)
 
711
                                 std::vector<nux::Vector4> const& xform_coords)
714
712
{
715
713
  if (icon.IsNull())
716
714
    return;
717
715
 
718
 
  if (nux::Abs(arg.x_rotation) < 0.01f &&
719
 
      nux::Abs(arg.y_rotation) < 0.01f &&
720
 
      nux::Abs(arg.z_rotation) < 0.01f &&
 
716
  if (std::abs(arg.x_rotation) < 0.01f &&
 
717
      std::abs(arg.y_rotation) < 0.01f &&
 
718
      std::abs(arg.z_rotation) < 0.01f &&
721
719
      !force_filter)
 
720
  {
722
721
    icon->SetFiltering(GL_NEAREST, GL_NEAREST);
 
722
  }
723
723
  else
 
724
  {
724
725
    icon->SetFiltering(GL_LINEAR, GL_LINEAR);
 
726
  }
725
727
 
726
728
  nux::Vector4 const& v0 = xform_coords[0];
727
729
  nux::Vector4 const& v1 = xform_coords[1];
969
971
}
970
972
 
971
973
void IconRenderer::RenderProgressToTexture(nux::GraphicsEngine& GfxContext,
972
 
                                           nux::ObjectPtr<nux::IOpenGLBaseTexture> texture,
 
974
                                           nux::ObjectPtr<nux::IOpenGLBaseTexture> const& texture,
973
975
                                           float progress_fill,
974
976
                                           float bias)
975
977
{