Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  nsRectIntersectGenericImpl.h

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */


#ifndef GFX_SRC_NSRECTINTERSECTGENERICIMPL_H_
#define GFX_SRC_NSRECTINTERSECTGENERICIMPL_H_

#include "nsRectIntersectGeneric.h"

#include <xsimd/xsimd.hpp>

template <class Arch>
void mozilla::IntersectEngine<Arch>::Intersect(const int32_t lhs[4],
                                               const int32_t rhs[4],
                                               int32_t result[4]) {
  using batch_type = xsimd::batch<int32_t, Arch>;
  static_assert(batch_type::size == 4"Algorithm tied to 128 bits registers");

  auto rect1 = batch_type::load_unaligned(lhs);  // x1, y1, w1, h1
  auto rect2 = batch_type::load_unaligned(rhs);  // x2, y2, w2, h2
  auto resultRect = xsimd::max(rect1, rect2);    // xr, yr, zz, zz

  // result.width = std::min<int32_t>(x - result.x + width,
  //                                  aRect.x - result.x + aRect.width);
  // result.height = std::min<int32_t>(y - result.y + height,
  //                                   aRect.y - result.y + aRect.height);
  auto widthheight = xsimd::min(
      rect1 - resultRect + xsimd::slide_right<8>(rect1),
      rect2 - resultRect + xsimd::slide_right<8>(rect2));  // w, h, zz, zz
  widthheight = xsimd::slide_left<8>(widthheight);         // 00, 00, wr, hr

  constexpr xsimd::batch_bool_constant<int32_t, Arch, true, true, falsefalse>
      mask;
  resultRect = xsimd::select(mask, resultRect, widthheight);  // xr, yr, wr, hr

  if (((resultRect < 0).mask() & 0xC) != 0) {
    // It's potentially more efficient to store all 0s. But the non vectorized
    // code leaves x/y intact so let's do the same here.
    resultRect = resultRect & xsimd::batch<int32_t, Arch>{-1, -100};
  }

  resultRect.store_unaligned(result);
}

template <class Arch>
bool mozilla::IntersectEngine<Arch>::IntersectRect(const int32_t lhs[4],
                                                   const int32_t rhs[4],
                                                   int32_t result[4]) {
  using batch_type = xsimd::batch<int32_t, Arch>;
  static_assert(batch_type::size == 4"Algorithm tied to 128 bits registers");

  auto rect1 = batch_type::load_unaligned(lhs);  // x1, y1, w1, h1
  auto rect2 = batch_type::load_unaligned(rhs);  // x2, y2, w2, h2
  auto resultRect = xsimd::max(rect1, rect2);    // xr, yr, zz, zz

  // result.width = std::min<int32_t>(x - result.x + width,
  //                                  aRect.x - result.x + aRect.width);
  // result.height = std::min<int32_t>(y - result.y + height,
  //                                   aRect.y - result.y + aRect.height);
  auto widthheight = xsimd::min(
      rect1 - resultRect + xsimd::slide_right<8>(rect1),
      rect2 - resultRect + xsimd::slide_right<8>(rect2));  // w, h, zz, zz
  widthheight = xsimd::slide_left<8>(widthheight);         // 00, 00, wr, hr

  constexpr xsimd::batch_bool_constant<int32_t, Arch, true, true, falsefalse>
      mask;
  resultRect = xsimd::select(mask, resultRect, widthheight);  // xr, yr, wr, hr

  const bool isDisjoint = ((resultRect > 0).mask() & 0xC) != 0xC;
  if (isDisjoint) {
    // It's potentially more efficient to store all 0s. But the non vectorized
    // code leaves x/y intact so let's do the same here.
    resultRect = resultRect & xsimd::batch<int32_t, Arch>{-1, -100};
  }
  resultRect.store_unaligned(result);
  return !isDisjoint;
}

#endif  // GFX_SRC_NSRECTINTERSECTGENERICIMPL_H_

Messung V0.5 in Prozent
C=90 H=95 G=92

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=141584
#Domains=752002