hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
listlengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
listlengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
listlengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4b1c7a50340290b1732b7ba23d42e22aa3bfa412
| 15,323
|
cpp
|
C++
|
src/uti_image/ImVis/Vino_Geom.cpp
|
lusul/micmac
|
ebcdde13316e1be38bb468acf3f1aca7509d9c0f
|
[
"CECILL-B"
] | null | null | null |
src/uti_image/ImVis/Vino_Geom.cpp
|
lusul/micmac
|
ebcdde13316e1be38bb468acf3f1aca7509d9c0f
|
[
"CECILL-B"
] | null | null | null |
src/uti_image/ImVis/Vino_Geom.cpp
|
lusul/micmac
|
ebcdde13316e1be38bb468acf3f1aca7509d9c0f
|
[
"CECILL-B"
] | 2
|
2020-06-13T15:07:21.000Z
|
2021-04-09T07:01:45.000Z
|
/*Header-MicMac-eLiSe-25/06/2007
MicMac : Multi Image Correspondances par Methodes Automatiques de Correlation
eLiSe : ELements of an Image Software Environnement
www.micmac.ign.fr
Copyright : Institut Geographique National
Author : Marc Pierrot Deseilligny
Contributors : Gregoire Maillet, Didier Boldo.
[1] M. Pierrot-Deseilligny, N. Paparoditis.
"A multiresolution and optimization-based image matching approach:
An application to surface reconstruction from SPOT5-HRS stereo imagery."
In IAPRS vol XXXVI-1/W41 in ISPRS Workshop On Topographic Mapping From Space
(With Special Emphasis on Small Satellites), Ankara, Turquie, 02-2006.
[2] M. Pierrot-Deseilligny, "MicMac, un lociel de mise en correspondance
d'images, adapte au contexte geograhique" to appears in
Bulletin d'information de l'Institut Geographique National, 2007.
Francais :
MicMac est un logiciel de mise en correspondance d'image adapte
au contexte de recherche en information geographique. Il s'appuie sur
la bibliotheque de manipulation d'image eLiSe. Il est distibue sous la
licences Cecill-B. Voir en bas de fichier et http://www.cecill.info.
English :
MicMac is an open source software specialized in image matching
for research in geographic information. MicMac is built on the
eLiSe image library. MicMac is governed by the "Cecill-B licence".
See below and http://www.cecill.info.
Header-MicMac-eLiSe-25/06/2007*/
#include "general/sys_dep.h"
#if (ELISE_X11)
#include "Vino.h"
/****************************************/
/* */
/* Grab Geom */
/* */
/****************************************/
ElList<Pt2di> cAppli_Vino::GetPtsImage(bool GlobScale,bool ModeRect,bool AcceptPoint)
{
std::string aMessage = "Clik for polygone ; Shift Clik to finish ; Enter 2 point for rectangle";
if (AcceptPoint) aMessage = aMessage + "; Enter 1 point for a single pixel";
PutMessageRelief(0,"Clik for polygone ; Shift Clik to finish ; Enter 2 point for rectangle");
ElImScroller * aCurScr = GlobScale ? mScr : mScr->CurScale();
bool Cont=true;
ElList<Pt2di> aList;
Pt2dr aLastW(-1,-1);
while (Cont)
{
Clik aClik = mW->clik_in();
Pt2dr aPW = aClik._pt;
Pt2di aPU = round_ni(aCurScr->to_user(aPW));
aList = aList + aPU;
mW->fill_rect(aPW-Pt2dr(3,3),aPW+Pt2dr(3,3),mW->pdisc()(P8COL::green));
if (aLastW.x >0)
{
mW->draw_seg(aPW,aLastW,mW->pdisc()(P8COL::red));
}
aLastW = aPW;
Cont = (!aClik.shifted()) || ((aList.card()==1) && (!AcceptPoint));
if (ModeRect && (aList.card()>=2))
{
Cont = false;
}
}
return aList;
}
Pt2dr cAppli_Vino::ToCoordAsc(const Pt2dr & aP)
{
return Sup(Pt2dr(0,0),Inf(Pt2dr(SzW()),mScr->to_user(aP).mcbyc(mRatioFulXY)));
}
void cAppli_Vino::ShowAsc()
{
mWAscH->clear();
mWAscV->clear();
Pt2dr aP00 = ToCoordAsc(Pt2dr(0,0));
Pt2dr aP10 = ToCoordAsc((Pt2dr(SzW().x,0))) ;
Pt2dr aP01 = ToCoordAsc(Pt2dr(0,SzW().y));
mWAscH->fill_rect
(
Pt2dr(aP00.x,0),
Pt2dr(ElMax(aP00.x+1,aP10.x),LargAsc()),
mWAscH->pdisc()(P8COL::yellow)
);
mWAscV->fill_rect
(
Pt2dr(0,aP00.y),
Pt2dr(LargAsc(),ElMax(aP00.y+1,aP01.y)),
mWAscV->pdisc()(P8COL::yellow)
);
std::string aStrZoom = "Zoom=" + StrNbChifSign(mScr->sc(),3); // ToString(mScr->sc());
mW->fixed_string(Pt2dr(5,10),aStrZoom.c_str(),mW->pdisc()(P8COL::black),true);
ShowVect();
}
void cAppli_Vino::GUR_query_pointer(Clik aCl,bool)
{
if (mModeGrab==eModeGrapZoomVino)
{
double aDY= aCl._pt.y - mP0Click.y;
double aMulScale = pow(2.0,aDY/SpeedZoomGrab());
// mScr->set(mTr0,mScale0*aMulScale,true);
mScr->SetScArroundPW(mP0Click,mScale0*aMulScale,true);
// std::cout << "GUR_query_pointer " << mP0Click << " " << aCl._pt << "\n";
}
if (mModeGrab==eModeGrapTranslateVino)
{
mScr->set(mTr0-(aCl._pt-mP0Click)/mScale0,mScale0,false);
}
if (mModeGrab==eModeGrapAscX)
{
mScr->set(mTr0+Pt2dr(aCl._pt.x-mP0Click.x,0)/mRatioFulXY.x,mScale0,false);
ShowAsc();
}
if (mModeGrab==eModeGrapAscY)
{
mScr->set(mTr0+Pt2dr(0,aCl._pt.y-mP0Click.y)/mRatioFulXY.y,mScale0,false);
ShowAsc();
}
if (mModeGrab==eModeGrapShowRadiom)
{
ShowOneVal(aCl._pt);
}
if (mModeGrab==eModeVinoPopUp)
{
mPopUpCur->SetPtActif(Pt2di(aCl._pt));
}
}
void cAppli_Vino::ZoomMolette()
{
double aSc = mScale0 * pow(2.0,SpeedZoomMolette()*(mBut0==5?1:-1));
mScr->SetScArroundPW(mP0Click,aSc,false);
}
void cAppli_Vino::GetRect(Pt2dr & aP0,Pt2dr &aP1)
{
ElList<Pt2di> aL = GetPtsImage(true,true,false);
aP0 = Pt2dr(aL.car());
aP1 = Pt2dr(aL.cdr().car());
pt_set_min_max(aP0,aP1);
}
void cAppli_Vino::ZoomRect()
{
Pt2dr aP0,aP1;
GetRect(aP0,aP1);
Pt2dr aSz = aP1-aP0;
double aScale = ElMin(SzW().x/aSz.x,SzW().y/aSz.y);
// std::cout << "SCALE " << aScale << " " << aSz << "\n";
// mScr->SetScArroundPW(mScr->to_win((aP0+aP1)/2.0),aScale,false);
Pt2dr aSzU = SzW() / aScale;
Pt2dr aMil = (aP0+aP1)/2.0;
mScr->set(aMil-aSzU/2.0,aScale);
ShowAsc();
}
void cAppli_Vino::ExeClikGeom(Clik aCl)
{
if (mShift0)
{
if (mCtrl0)
{
mScr->set_max();
}
else
{
mModeGrab = eModeGrapZoomVino;
mW->grab(*this);
mScr->SetScArroundPW(mP0Click,mScr->sc(),false);
}
}
else
{
if (mCtrl0)
{
mScr->SetScArroundPW(mP0Click,1.0,false);
}
else
{
mModeGrab = eModeGrapTranslateVino;
mW->grab(*this);
}
}
ShowAsc();
}
/**************** A mettre dans un autre fichier Show/Inspect-Vect ******/
void cAppli_Vino::ShowVect()
{
if (mWithPCarac)
ShowVectPCarac();
}
int cAppli_Vino::IndexNearest(double aDistSeuil,const Pt2dr & aPClU,double * aDist,eTypePtRemark aType)
{
cVecTplResRVoisin<cOnePCarac *> aVRV;
mQTPC->RVoisins(aVRV,aPClU,aDistSeuil);
// mAppli.Qt2()->KPPVois(aP0,2,100.0);
cOnePCarac * aRes=nullptr;
double aDMin=1e20;
// for (int aKP=0 ; aKP<int(mSPC->OnePCarac().size()) ; aKP++)
for (const auto & aPCP : static_cast<std::vector<cOnePCarac *> &>(aVRV) )
{
// const auto & aPC = mSPC->OnePCarac()[aKP];
double aDist = euclid(aPCP->Pt(),aPClU);
if ( ((aPCP->Kind()==aType)||(aType==eTPR_NoLabel)) && (aDist<aDMin))
{
aDMin = aDist;
aRes = aPCP;
}
}
if (aDist)
*aDist = aDMin;
int anIndex = (aRes ? aRes->Id() : -1);
return anIndex;
}
const cOnePCarac * cAppli_Vino::Nearest(double aDistSeuil,const Pt2dr & aPClU,double * aDist,eTypePtRemark aType)
{
int I = IndexNearest(aDistSeuil,aPClU,aDist,aType);
if (I>=0) return &(mSPC->OnePCarac()[I]);
return nullptr;
}
void ShowCurve(Im2D_INT1 aIm,int aY,const Pt2di & aP0,const Pt2di & aP1,Video_Win * aW,int aCoul)
{
int aTx = aIm.tx();
// std::cout << "TXxxx= " << aTx << "\n";
INT1 * aV = aIm.data()[aY];
double aVmax = aV[0];
double aVmin = aV[0];
for (int anX=1 ; anX<aTx ; anX++)
{
aVmin = ElMin(aVmin,double(aV[anX]));
aVmax = ElMax(aVmax,double(aV[anX]));
}
std::vector<double> aVX;
std::vector<double> aVY;
for (int anX=0 ; anX<aTx ; anX++)
{
aVX.push_back(aP0.x+ ( anX /double(aTx-1)) * (aP1.x-aP0.x));
aVY.push_back(aP0.y+ ((aV[anX]-aVmin) /(aVmax-aVmin) ) * (aP1.y-aP0.y));
}
ELISE_COPY ( rectangle(aP0,aP1), 255, aW->ogray());
for (int anX=1 ; anX<int(aTx) ; anX++)
{
aW->draw_seg
(
Pt2dr(aVX[anX-1],aVY[anX-1]),
Pt2dr(aVX[anX],aVY[anX]),
aW->pdisc()(aCoul)
);
}
}
void cAppli_Vino::ShowSPC(const Pt2dr & aPClW)
{
ElSimilitude aU2W = mScr->to_win();
ElSimilitude aW2U = mScr->to_user();
Pt2dr aPClU = aW2U(aPClW);
mW->draw_circle_loc(aPClW,3.0,mW->pdisc()(P8COL::cyan));
const cOnePCarac * aNearest = Nearest(1000.0,aPClU);
if (aNearest)
{
// mW->draw_circle_loc(aU2W(aNearest->Pt()),3.0,mW->pdisc()(P8COL::magenta));
// mW->draw_circle_loc(aU2W(aNearest->Pt()),5.0,mW->pdisc()(P8COL::magenta));
double aSc = mScr->sc();
for (const auto & aRho : aNearest->VectRho())
{
mW->draw_circle_loc(aU2W(aNearest->Pt()),aSc*aRho,mW->pdisc()(P8COL::magenta));
}
if (!mAVSI.empty())
std::cout << "#########################################################\n";
std::cout << "PTT=" << aNearest->Pt() << mNameIm << "\n";
std::cout << " * Id= : " << aNearest->Id() << "\n";
std::cout << " * AutoC : " << aNearest->AutoCorrel() << "\n";
std::cout << " * Scale : " << aNearest->Scale() << "\n";
std::cout << " * SStab : " << aNearest->ScaleStab() << "\n";
std::cout << " * Contr : " << aNearest->Contraste() << " Rel : " << aNearest->ContrasteRel() << "\n";
std::cout << "Rhoooo " << aNearest->VectRho() << "\n";
std::cout << "\n";
{
Im2D_INT1 aImLogT = aNearest->ImLogPol();
int aZoom=10;
Pt2di aSz = aImLogT.sz();
ELISE_COPY
(
rectangle(Pt2di(0,0),Pt2di(aSz.y*aZoom,aSz.x*aZoom)),
Max(0,Min(255,128 + 2 * aImLogT.in()[Virgule(FY,FX)/aZoom])),
mW->ogray()
);
int aMarge = 5;
int aSzW = 45;
int aPer = 8;
bool ShowInvRad = true;
bool ShowProfRad = true;
std::vector<Im2D_INT1> aVIm2Show;
if (ShowInvRad)
aVIm2Show.push_back(aNearest->InvR().ImRad());
if (ShowProfRad)
{
aVIm2Show.push_back(aNearest->ProfR().ImProfil());
}
int aCpt = 0;
for (int aKIm =0 ; aKIm<int(aVIm2Show.size()) ; aKIm++)
{
int aNbY = aVIm2Show[aKIm].sz().y;
for (int anY=0 ; anY<aNbY ; anY++)
{
int aX0 = aMarge+(aCpt%aPer) * (aMarge+aSzW);
int aX1 = aX0 + aSzW;
int aY0 = aSz.x*aZoom + aMarge+(aCpt/aPer) * (aMarge+aSzW);
int aY1 = aY0 + aSzW;
ShowCurve
(
aVIm2Show[aKIm],
anY,
Pt2di(aX0,aY0), Pt2di(aX1,aY1),
mW,
1 + (anY%6)
);
aCpt++;
}
}
}
if (! mVptHom.empty())
{
int aK = IndexNearest(1000.0,aPClU);
ELISE_ASSERT((aK>=0) && aNearest==&(mSPC->OnePCarac()[aK]),"NEAREST !!??");
const cOnePCarac * aPCHom = mVptHom.at(aK);
if (aPCHom)
{
ElSimilitude aHU2W = mAVSI.at(0)->mScr->to_win();
Pt2dr aPt = aHU2W(aPCHom->Pt());
std::cout << "HOMMM " << aPt << "\n";
mAVSI.at(0)->ShowSPC(aPt);
TestMatchInvRad(mSPC->OnePCarac(),aNearest,aPCHom);
}
}
}
}
void cAppli_Vino::ShowVectPCarac()
{
ElSimilitude aSim = mScr->to_win();
if (mSPC)
{
for (int aKP=0 ; aKP<int(mSPC->OnePCarac().size()) ; aKP++)
{
const cOnePCarac & aPC = mSPC->OnePCarac()[aKP];
Pt2dr aPU = aPC.Pt();
Pt2dr aPW = aSim(aPU);
if ( (aPW.x>0) && (aPW.y>0) && (aPW.x<SzW().x) && (aPW.y<SzW().y)
&& (aPC.ContrasteRel()>mSeuilContRel) && (aPC.AutoCorrel()< mSeuilAC)
)
{
mW->draw_circle_loc(aPW,aPC.Scale()*2*mScr->sc(),mW->pdisc()(P8COL::yellow));
bool HighL = (mVptHom.size() && mVptHom.at(aKP));
ShowPt(aPC,aSim,mW,HighL);
// Pt2dr aDirMS = aPC.DirMS();
Pt2dr aDirMS = aPC.DirAC();
// std::cout << "aDirMS " << aDirMS << "\n";
if (euclid(aDirMS) != 0)
{
aDirMS = vunit(aDirMS) * 20.0;
mW->draw_seg(aPW,aPW+aDirMS,mW->pdisc()(P8COL::green));
}
}
else
{
// std::cout << "FfFffff " << aPU << " " << aPW << "\n";
}
}
}
if (mVSift.size())
{
for (const auto & aSP : mVSift)
{
Pt2dr aPU(aSP.x*mSSF,aSP.y*mSSF);
Pt2dr aPW = aSim(aPU);
if ((aPW.x>0) && (aPW.y>0) && (aPW.x<SzW().x) && (aPW.y<SzW().y))
{
mW->draw_circle_loc(aPW,3.0,mW->pdisc()(P8COL::red));
Pt2dr aDir = Pt2dr::FromPolar(20,aSP.angle);
mW->draw_seg(aPW,aPW+aDir,mW->pdisc()(P8COL::green));
mW->draw_circle_loc(aPW,aSP.scale*2*mScr->sc(),mW->pdisc()(P8COL::yellow));
// std::cout << "TETA " << aSP.scale << " " << aSP.angle << "\n";
//ShowPt(aP,aSim,mW);
}
else
{
// std::cout << "FfFffff " << aPU << " " << aPW << "\n";
}
}
}
}
#endif
/*Footer-MicMac-eLiSe-25/06/2007
Ce logiciel est un programme informatique servant à la mise en
correspondances d'images pour la reconstruction du relief.
Ce logiciel est régi par la licence CeCILL-B soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".
En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.
A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, à l'utilisation, à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant
donné sa spécificité de logiciel libre, qui peut le rendre complexe à
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant des connaissances informatiques approfondies. Les
utilisateurs sont donc invités à charger et tester l'adéquation du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement,
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL-B, et que vous en avez accepté les
termes.
Footer-MicMac-eLiSe-25/06/2007*/
| 30.22288
| 117
| 0.555178
|
lusul
|
4b1cdc9df3a72b0d80475a1ee0c1d86842c1956c
| 2,591
|
cpp
|
C++
|
src/cpp/lib/QtWidgets/QCheckBox/qcheckbox_wrap.cpp
|
pepf/nodegui
|
9e667c7a86f974dd792370d247e03f7ab9817ae5
|
[
"MIT"
] | 1
|
2019-10-31T08:17:44.000Z
|
2019-10-31T08:17:44.000Z
|
src/cpp/lib/QtWidgets/QCheckBox/qcheckbox_wrap.cpp
|
semonec/nodegui
|
cd7906710af3e8420bb3b7d275f47fe4fa074e37
|
[
"MIT"
] | null | null | null |
src/cpp/lib/QtWidgets/QCheckBox/qcheckbox_wrap.cpp
|
semonec/nodegui
|
cd7906710af3e8420bb3b7d275f47fe4fa074e37
|
[
"MIT"
] | null | null | null |
#include "QtWidgets/QCheckBox/qcheckbox_wrap.h"
#include <QWidget>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
Napi::FunctionReference QCheckBoxWrap::constructor;
Napi::Object QCheckBoxWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QCheckBox";
Napi::Function func =
DefineClass(env, CLASSNAME,
{InstanceMethod("setText", &QCheckBoxWrap::setText),
InstanceMethod("setChecked", &QCheckBoxWrap::setChecked),
InstanceMethod("isChecked", &QCheckBoxWrap::isChecked),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QCheckBoxWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NCheckBox* QCheckBoxWrap::getInternalInstance() { return this->instance; }
QCheckBoxWrap::QCheckBoxWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QCheckBoxWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
QWidgetWrap* parentWidgetWrap =
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
this->instance = new NCheckBox(parentWidgetWrap->getInternalInstance());
} else if (info.Length() == 0) {
this->instance = new NCheckBox();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = this->getInternalInstance();
// Adds measure function on yoga node so that widget size is calculated based
// on its text also.
YGNodeSetMeasureFunc(this->instance->getFlexNode(),
&extrautils::measureQtWidget);
}
QCheckBoxWrap::~QCheckBoxWrap() { extrautils::safeDelete(this->instance); }
Napi::Value QCheckBoxWrap::setText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::String text = info[0].As<Napi::String>();
std::string label = text.Utf8Value();
this->instance->setText(label.c_str());
return env.Null();
}
Napi::Value QCheckBoxWrap::isChecked(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
bool isChecked = this->instance->isChecked();
return Napi::Value::From(env, isChecked);
}
Napi::Value QCheckBoxWrap::setChecked(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Boolean check = info[0].As<Napi::Boolean>();
this->instance->setChecked(check.Value());
return env.Null();
}
| 34.092105
| 79
| 0.689309
|
pepf
|
4b2176f5611655802ee21623825f55cf2b60034a
| 29,390
|
cpp
|
C++
|
test/test_serdes.cpp
|
DarrenLevine/cppserdes
|
5078cc111f1eda67623d5a4e74a7e703ca19f3a2
|
[
"MIT"
] | 77
|
2021-07-04T03:00:08.000Z
|
2022-03-14T14:41:14.000Z
|
test/test_serdes.cpp
|
DarrenLevine/cppserdes
|
5078cc111f1eda67623d5a4e74a7e703ca19f3a2
|
[
"MIT"
] | null | null | null |
test/test_serdes.cpp
|
DarrenLevine/cppserdes
|
5078cc111f1eda67623d5a4e74a7e703ca19f3a2
|
[
"MIT"
] | null | null | null |
#include "../test/test_utilities.h"
static void test_variable_arrays()
{
using test_array_t = serdes::array<uint8_t, uint8_t>;
{
uint8_t length = 3;
uint8_t array[] = {0xAB, 0xCD, 0xEF, 0x12, 0x23};
uint16_t serial_data[4] = {};
serdes::packet(serial_data) << test_array_t(array, length);
ASSERT_EQUALS(serial_data, {0xABCD, 0xEF00, 0x0000});
std::fill(array, array + sizeof(array), 0xFF);
serdes::packet(serial_data) >> test_array_t(array, length);
ASSERT_EQUALS(array, {0xAB, 0xCD, 0xEF, 0xFF, 0xFF});
}
{
uint8_t array[] = {0xAB, 0xCD, 0xEF, 0x12, 0x23};
uint8_t length = sizeof(array) / sizeof(array[0]) + 1; // force an overrun
uint16_t serial_data[6] = {};
auto store_result = (serdes::packet(serial_data) << test_array_t(array, length));
ASSERT_EQUALS(static_cast<int>(store_result.status), static_cast<int>(serdes::status_e::ARRAY_SIZE_OVER_MAX));
ASSERT_EQUALS(store_result.bit_offset, (length - 1) * 8);
ASSERT_EQUALS(serial_data, {0xABCD, 0xEF12, 0x2300, 0x0000});
std::fill(array, array + sizeof(array), 0xFF);
auto load_result = (serdes::packet(serial_data) >> test_array_t(array, length));
ASSERT_EQUALS(static_cast<int>(load_result.status), static_cast<int>(serdes::status_e::ARRAY_SIZE_OVER_MAX));
ASSERT_EQUALS(load_result.bit_offset, (length - 1) * 8);
ASSERT_EQUALS(array, {0xAB, 0xCD, 0xEF, 0x12, 0x23});
}
{
struct my_info : serdes::packet_base
{
uint8_t length = 3;
uint8_t data[5] = {0xAB, 0xCD, 0xEF, 0x12, 0x23};
void format(serdes::packet &p)
{
p + length + test_array_t(data, length) + test_array_t(data + 3, 2, 2); // variable length, sized erased
}
};
my_info m;
uint16_t serial_data[4] = {};
m.store(serial_data);
ASSERT_EQUALS(serial_data, {0x03AB, 0xCDEF, 0x1223, 0x0000});
m.length = 0;
std::fill(m.data, m.data + sizeof(m.data), 0xFF);
m.load(serial_data);
ASSERT_EQUALS(m.length, 3);
ASSERT_EQUALS(m.data, {0xAB, 0xCD, 0xEF, 0x12, 0x23});
}
}
static void test_variable_packet_base_arrays()
{
{
struct coordinates : serdes::packet_base
{
uint8_t x = 0xAB, y = 0xCD, z = 0xEF, q = 0x12;
void format(serdes::packet &p) override
{
p + x + y + z + q;
}
};
struct my_info : serdes::packet_base
{
int16_t length = 3;
coordinates data[5] = {};
void format(serdes::packet &p)
{
p + length + serdes::array<coordinates, int16_t>(data, length);
}
};
my_info m;
uint32_t serial_data[5] = {};
m.store(serial_data);
ASSERT_EQUALS(serial_data, {0x0003ABCD_u32, 0xEF12ABCD_u32, 0xEF12ABCD_u32, 0xEF120000_u32, 0x00000000_u32});
m.length = 0;
for (size_t i = 0; i < sizeof(m.data) / sizeof(m.data[0]); i++)
{
m.data[i].x = i;
m.data[i].y = i + 1;
m.data[i].z = i + 2;
m.data[i].q = i + 3;
}
m.load(serial_data);
ASSERT_EQUALS(m.length, 3);
for (size_t i = 0; i < static_cast<size_t>(m.length); i++)
{
ASSERT_EQUALS(m.data[i].x, 0xAB_u8);
ASSERT_EQUALS(m.data[i].y, 0xCD_u8);
ASSERT_EQUALS(m.data[i].z, 0xEF_u8);
ASSERT_EQUALS(m.data[i].q, 0x12_u8);
}
for (size_t i = static_cast<size_t>(m.length); i < sizeof(m.data) / sizeof(m.data[0]); i++)
{
ASSERT_EQUALS(m.data[i].x, uint8_t(i + 0));
ASSERT_EQUALS(m.data[i].y, uint8_t(i + 1));
ASSERT_EQUALS(m.data[i].z, uint8_t(i + 2));
ASSERT_EQUALS(m.data[i].q, uint8_t(i + 3));
}
}
}
static void test_fixed_sized_arrays()
{
{
uint8_t length = 3;
uint8_t array[] = {0xAB, 0xCD, 0xEF, 0x12, 0x23};
uint16_t serial_data[4] = {};
serdes::packet(serial_data) << array;
ASSERT_EQUALS(serial_data, {0xABCD, 0xEF12, 0x2300});
std::fill(array, array + sizeof(array), 0xFF);
serdes::packet(serial_data) >> array;
ASSERT_EQUALS(array, {0xAB, 0xCD, 0xEF, 0x12, 0x23});
}
{
struct my_info : serdes::packet_base
{
uint8_t length = 3;
uint8_t data[5] = {0xAB, 0xCD, 0xEF, 0x12, 0x23};
int16_t data2 = 0x2345;
void format(serdes::packet &p)
{
p + length + data + data2;
}
};
my_info m;
uint16_t serial_data[4] = {};
m.store(serial_data);
ASSERT_EQUALS(serial_data, {0x03AB, 0xCDEF, 0x1223, 0x2345});
m.length = 0;
m.data2 = 9;
std::fill(m.data, m.data + sizeof(m.data), 0xFF);
m.load(serial_data);
ASSERT_EQUALS(m.length, 3);
ASSERT_EQUALS(m.data, {0xAB, 0xCD, 0xEF, 0x12, 0x23});
ASSERT_EQUALS(m.data2, 0x2345);
}
}
static void test_bitpacked_arrays()
{
uint64_t AB_flags[8] = {1, 0, 1, 0, 1, 0, 1, 1};
uint64_t CD_flags[8] = {1, 1, 0, 0, 1, 1, 0, 1};
int array_length = 8;
using test_array_t = serdes::array<uint64_t, int>;
uint16_t serial_data[4] = {};
serdes::packet(serial_data) << serdes::bitpack<test_array_t, int>(test_array_t(AB_flags, array_length), 1) << serdes::bitpack<uint64_t[8], size_t>(CD_flags, 1);
ASSERT_EQUALS(serial_data, {0xABCD, 0x0000});
std::fill(AB_flags, AB_flags + 8, 0xF0);
serdes::packet(serial_data) >> serdes::bitpack<test_array_t, int>(test_array_t(AB_flags, array_length), 1) << serdes::bitpack<uint64_t[8], size_t>(CD_flags, 1);
ASSERT_EQUALS(AB_flags, {1, 0, 1, 0, 1, 0, 1, 1});
ASSERT_EQUALS(CD_flags, {1, 1, 0, 0, 1, 1, 0, 1});
}
static void test_dynamic_bitlength_captures()
{
struct my_info : serdes::packet_base
{
int8_t bits_in_time_tag = 0;
uint16_t time_tag = 0;
int8_t bits_in_time_tag2 = 0;
uint16_t time_tag2 = 0;
void format(serdes::packet &archive)
{
archive +
bits_in_time_tag +
serdes::bitpack<uint16_t, int8_t>(time_tag, bits_in_time_tag) +
bits_in_time_tag2 +
serdes::bitpack<uint16_t, int8_t>(time_tag2, serdes::bit_length(bits_in_time_tag2));
}
};
uint16_t serial_data[] = {0x4B0, 0x8AB0};
my_info object;
object.load(serial_data);
ASSERT_EQUALS(object.bits_in_time_tag, 4_i8);
ASSERT_EQUALS(object.time_tag, 0xB_u16);
ASSERT_EQUALS(object.bits_in_time_tag2, 8_i8);
ASSERT_EQUALS(object.time_tag2, 0xAB_u16);
}
static void test_aligned_byte_arrays()
{
{
uint8_t length = 3;
uint8_t array[] = {0xAB, 0xCD, 0xEF, 0x12, 0x23};
uint8_t serial_data[6] = {};
serdes::packet(serial_data) << length << array;
ASSERT_EQUALS(serial_data, {0x3, 0xAB, 0xCD, 0xEF, 0x12, 0x23});
length = 100;
std::fill(array, array + sizeof(array), 0xFF);
serdes::packet(serial_data) >> length >> array;
ASSERT_EQUALS(array, {0xAB, 0xCD, 0xEF, 0x12, 0x23});
ASSERT_EQUALS(length, 3);
}
{
struct my_info : serdes::packet_base
{
uint8_t length = 3;
uint8_t data[5] = {0xAB, 0xCD, 0xEF, 0x12, 0x23};
int16_t data2 = 0x2345;
void format(serdes::packet &p)
{
p + length + data + data2;
}
};
my_info m;
uint8_t serial_data[8] = {};
m.store(serial_data);
ASSERT_EQUALS(serial_data, {0x03, 0xAB, 0xCD, 0xEF, 0x12, 0x23, 0x23, 0x45});
m.length = 0;
m.data2 = 9;
std::fill(m.data, m.data + sizeof(m.data), 0xFF);
m.load(serial_data);
ASSERT_EQUALS(m.length, 3);
ASSERT_EQUALS(m.data, {0xAB, 0xCD, 0xEF, 0x12, 0x23});
ASSERT_EQUALS(m.data2, 0x2345);
}
}
static void test_inheritance_nesting()
{
struct header_type : serdes::packet_base
{
uint8_t id = 9;
uint16_t length = 1;
int8_t source = 2;
void format(serdes::packet &p) override
{
p.add(id);
p.add(length, [&]() noexcept
{ return length < 3; }); // a validation criteria
p.add(source);
p.pad(32);
}
};
struct command : header_type
{
bool flags[3] = {true, false, true};
double x = -1.0, y = -2.0, z = 3.14;
uint32_t pattern = 0xABCD0123;
void format(serdes::packet &p) override
{
header_type::format(p);
p + serdes::pad<int>(5) + flags + serdes::bitpack<uint32_t, int>(pattern, 23) + serdes::align<int>(8) + x + y + z;
}
};
struct compound_command : serdes::packet_base
{
command beginning_data = {};
uint16_t ending_data[3] = {1, 2, 3};
void format(serdes::packet &p) override
{
beginning_data.format(p);
p + ending_data;
}
};
// save the original struct data
uint16_t serialized_data[40] = {};
compound_command c;
c.store(serialized_data);
ASSERT_EQUALS(serialized_data, {0x0900, 0x0102, 0x0000, 0x0000, 0x059A, 0x0246, 0xBFF0, 0x0000, 0x0000,
0x0000, 0xC000, 0x0000, 0x0000, 0x0000, 0x4009, 0x1EB8, 0x51EB, 0x851F,
0x0001, 0x0002, 0x0003});
{
// clear out the struct with zeros
uint16_t empty_data[40] = {};
c.load(empty_data);
ASSERT_EQUALS(c.beginning_data.id, 0);
ASSERT_EQUALS(c.beginning_data.length, 0);
ASSERT_EQUALS(c.beginning_data.source, 0);
ASSERT_EQUALS(c.beginning_data.flags[0], false);
ASSERT_EQUALS(c.beginning_data.flags[1], false);
ASSERT_EQUALS(c.beginning_data.flags[2], false);
ASSERT_EQUALS(c.beginning_data.x, 0.0);
ASSERT_EQUALS(c.beginning_data.y, 0.0);
ASSERT_EQUALS(c.beginning_data.z, 0.0);
ASSERT_EQUALS(c.beginning_data.pattern, 0);
ASSERT_EQUALS(c.ending_data, {0, 0, 0});
}
c.load(serialized_data);
ASSERT_EQUALS(c.beginning_data.id, 9);
ASSERT_EQUALS(c.beginning_data.length, 1);
ASSERT_EQUALS(c.beginning_data.source, 2);
ASSERT_EQUALS(c.beginning_data.flags[0], true);
ASSERT_EQUALS(c.beginning_data.flags[1], false);
ASSERT_EQUALS(c.beginning_data.flags[2], true);
ASSERT_EQUALS(c.beginning_data.x, -1.0);
ASSERT_EQUALS(c.beginning_data.y, -2.0);
ASSERT_EQUALS(c.beginning_data.z, 3.14);
ASSERT_EQUALS(c.beginning_data.pattern, 0x4D0123);
ASSERT_EQUALS(c.ending_data, {1, 2, 3});
}
static void test_edittable_formats()
{
struct coordinates : serdes::packet_base
{
int32_t x = -9, y = 10, z = -11;
serdes::formatter edittable_format[3] = {
serdes::init_this_formatter(x),
serdes::init_this_formatter(y),
serdes::init_this_formatter(z)};
void format(serdes::packet &p) override
{
p + edittable_format;
}
};
uint16_t serial_data[6] = {0x0000, 0x0001, 0x0000, 0x0002, 0xFFFF, 0xFFFB};
coordinates A;
A.load(serial_data);
ASSERT_EQUALS(A.x, 1);
ASSERT_EQUALS(A.y, 2);
ASSERT_EQUALS(A.z, -5);
std::fill(serial_data, serial_data + sizeof(serial_data) / sizeof(serial_data[0]), 0);
uint8_t replacement_y = 0xE0;
A.edittable_format[1] = serdes::init_formatter(replacement_y);
A.x = 0xF345F012;
A.y = 0xFADA9876; // wont be used (replaced above)
A.z = 0xFEE35432;
A.store(serial_data);
ASSERT_EQUALS(serial_data, {0xF345, 0xF012, 0xE0FE, 0xE354, 0x3200, 0x0000});
serial_data[2] = 0x97FE;
A.load(serial_data);
ASSERT_EQUALS(replacement_y, 0x97);
}
static void test_bitpacking_and_strings()
{
uint32_t serial_data[10] = {};
// serialize some data
serdes::packet(serial_data) << 0xABCD_u16 << "hello!" << 123_i8 << serdes::bitpack<int32_t, int>(-9_i32, serdes::bit_length(6));
ASSERT_EQUALS(serial_data, {0xABCD6865_u32, 0x6C6C6F21_u32, 0x007BDC00_u32, 0x00000000_u32});
uint16_t x;
int8_t y;
int32_t z{};
char str[7];
// deserialize the data
serdes::packet(serial_data) >> x >> str >> y >> serdes::bitpack<int32_t, int>(z, serdes::bit_length(6));
ASSERT_EQUALS(x, 0xABCD);
ASSERT_EQUALS(y, 123);
ASSERT_EQUALS(z, -9);
ASSERT_EQUALS(str, {'h', 'e', 'l', 'l', 'o', '!', '\0'});
}
static void test_alignment_and_padding()
{
{
uint16_t serial_data[10] = {};
serdes::packet p(serial_data);
p << serdes::pad<int>(10) << 0xFBCD_u16 << serdes::align<int>(32) << serdes::bitpack<int32_t, int>(0x12F, serdes::bit_length(4)) << 0x1ABC_u16;
ASSERT_EQUALS(serial_data, {0x003E, 0xF340, 0xF1AB, 0xC000});
uint16_t x;
uint16_t y;
uint16_t z;
p >> serdes::pad<int>(10) >> x >> serdes::align<int>(32) >> serdes::bitpack<uint16_t, int>(y, serdes::bit_length(4)) >> z;
ASSERT_EQUALS(x, 0xFBCD);
ASSERT_EQUALS(y, 0xF);
ASSERT_EQUALS(z, 0x1ABC);
}
{
struct test_struct : serdes::packet_base
{
uint16_t x = 0xFBCD;
uint16_t y = 0x012F;
uint16_t z = 0x1ABC;
void format(serdes::packet &p) override
{
p + serdes::pad<int>(10) + x + serdes::align<int>(32) + serdes::bitpack<uint16_t, int>(y, serdes::bit_length(4)) + z;
}
};
test_struct object;
uint32_t serial_data_u32[10] = {};
object.store(serial_data_u32);
ASSERT_EQUALS(serial_data_u32, {0x003EF340_u32, 0xF1ABC000_u32});
uint8_t serial_data_u8[10] = {};
object.store(serial_data_u8);
ASSERT_EQUALS(serial_data_u8, {0x00, 0x3E, 0xF3, 0x40, 0xF1, 0xAB, 0xC0, 0x00});
uint8_t zero_serial_data_u8[10] = {};
object.load(zero_serial_data_u8);
ASSERT_EQUALS(object.x, 0);
ASSERT_EQUALS(object.y, 0);
ASSERT_EQUALS(object.z, 0);
object.load(serial_data_u32);
ASSERT_EQUALS(object.x, 0xFBCD);
ASSERT_EQUALS(object.y, 0xF);
ASSERT_EQUALS(object.z, 0x1ABC);
object.load(zero_serial_data_u8);
object.load(serial_data_u8);
ASSERT_EQUALS(object.x, 0xFBCD);
ASSERT_EQUALS(object.y, 0xF);
ASSERT_EQUALS(object.z, 0x1ABC);
}
}
static void test_error_catching()
{
struct coordinates : serdes::packet_base
{
int32_t x = -9, y = 10, z = -11;
bool flags[8] = {};
// defining the format to use for both serialization and deserialization
void format(serdes::packet &p) override
{
auto y_with_check = serdes::init_formatter(y, [&]() noexcept
{ return y > 6; });
p + x + y_with_check + z + flags;
}
};
{
coordinates A;
// providing some invalid data on purpose
uint16_t serial_data[6] = {0x0000, 0x0001, 0x0000, 0x0002, 0xFFFF, 0xFFFB};
// confirming the error is caught on load
auto load_result = A.load(serial_data);
ASSERT_EQUALS(static_cast<int>(load_result.status), static_cast<int>(serdes::status_e::INVALID_FIELD));
ASSERT_EQUALS(load_result.bits, 64);
// confirming the error is caught on store
auto store_result = A.store(serial_data);
ASSERT_EQUALS(static_cast<int>(store_result.status), static_cast<int>(serdes::status_e::INVALID_FIELD));
ASSERT_EQUALS(store_result.bits, 32);
// changing the value to be valid
A.y = 100;
// providing some data which is too small on purpose
uint16_t serial_data_too_small[2] = {0x0000, 0x0001};
// confirming the error is caught on store
auto store_result2 = A.store(serial_data_too_small);
ASSERT_EQUALS(static_cast<int>(store_result2.status), static_cast<int>(serdes::status_e::EXCEEDED_SERIAL_SIZE));
ASSERT_EQUALS(store_result2.bits, 32);
// confirming that the format can be used with no errors
uint16_t large_serial_data[7] = {0x0000, 0x0001, 0x0000, 0x00FF, 0xFFFF, 0xFFFB, 0xAAAA};
auto store_result3 = A.load(large_serial_data);
ASSERT_EQUALS(static_cast<int>(store_result3.status), static_cast<int>(serdes::status_e::NO_ERROR));
ASSERT_EQUALS(store_result3.bits, 104);
ASSERT_EQUALS(A.flags, {true, false, true, false, true, false, true, false});
}
{
uint8_t serial_data[10] = {};
auto load_status = (serdes::packet(serial_data) >> serdes::init_formatter(0xF01E_u16));
ASSERT_EQUALS(static_cast<int>(load_status.status), static_cast<int>(serdes::status_e::NO_LOAD_TO_RVALUE));
ASSERT_EQUALS(load_status.bit_offset, 0);
}
}
static void test_formatter_lambdas()
{
uint16_t value = 0xDCBA;
serdes::formatter x(serdes::init_formatter(value));
serdes::formatter y(serdes::init_formatter(0xF01E_u16));
uint16_t z_value = 0x9876;
serdes::formatter z{[&](serdes::packet &p)
{ p + z_value; }};
uint8_t serial_data[10] = {};
auto store_status = (serdes::packet(serial_data) << x << y << z);
ASSERT_EQUALS(serial_data, {0xDC, 0xBA, 0xF0, 0x1E, 0x98, 0x76, 0x00});
ASSERT_EQUALS(static_cast<int>(store_status.status), static_cast<int>(serdes::status_e::NO_ERROR));
ASSERT_EQUALS(store_status.bit_offset, 48);
auto load_status = (serdes::packet(serial_data) >> x >> y >> z);
ASSERT_EQUALS(static_cast<int>(load_status.status), static_cast<int>(serdes::status_e::NO_LOAD_TO_RVALUE));
ASSERT_EQUALS(load_status.bit_offset, 16);
}
static void test_delimited_arrays()
{
struct my_delimited_data : serdes::packet_base
{
char data[100] = {};
void format(serdes::packet &p) override
{
p + serdes::delimited_array<char>(data, '\0');
}
};
const size_t serial_data_size = 50;
uint8_t serial_data[serial_data_size] = "Hello World!";
my_delimited_data object;
auto load_result = object.load(serial_data);
ASSERT_EQUALS(strcmp(object.data, "Hello World!"), 0);
ASSERT_EQUALS(load_result.bits, 104);
ASSERT_EQUALS(static_cast<int>(load_result.status), static_cast<int>(serdes::status_e::NO_ERROR));
serdes::packet(serial_data) << "other stuff";
auto load2_result = object.load(serial_data);
ASSERT_EQUALS(strcmp(object.data, "other stuff"), 0);
ASSERT_EQUALS(load2_result.bits, 96);
ASSERT_EQUALS(static_cast<int>(load2_result.status), static_cast<int>(serdes::status_e::NO_ERROR));
strcpy(object.data, "small");
auto store_result = object.store(serial_data);
ASSERT_EQUALS(strcmp(reinterpret_cast<char *>(&serial_data[0]), "small"), 0);
ASSERT_EQUALS(store_result.bits, 6 * 8);
ASSERT_EQUALS(static_cast<int>(store_result.status), static_cast<int>(serdes::status_e::NO_ERROR));
for (size_t i = 0; i < sizeof(object.data) / sizeof(object.data[0]); i++)
object.data[i] = 'h';
auto store_result2 = object.store(serial_data);
bool all_serial_data_matched = true;
for (size_t i = 0; i < serial_data_size; i++)
all_serial_data_matched &= serial_data[i] == 'h';
ASSERT_EQUALS(all_serial_data_matched, true);
ASSERT_EQUALS(store_result2.bits, 400);
ASSERT_EQUALS(static_cast<int>(store_result2.status), static_cast<int>(serdes::status_e::EXCEEDED_SERIAL_SIZE));
uint8_t serial_data2[100] = {};
auto store_result4 = object.store(serial_data2);
ASSERT_EQUALS(store_result4.bits, 8 * 100);
ASSERT_EQUALS(static_cast<int>(store_result4.status), static_cast<int>(serdes::status_e::DELIMITER_NOT_FOUND));
}
static void test_nested_delimited_arrays()
{
struct my_bitpacked_char : serdes::packet_base
{
char data = 0;
void format(serdes::packet &p) override
{
p + serdes::pad<int>(2) + serdes::bitpack<char, int>(data, 6);
}
my_bitpacked_char &operator=(const char x)
{
data = x;
return *this;
}
bool operator==(const my_bitpacked_char x) const
{
return data == x.data;
}
};
struct my_delimited_data : serdes::packet_base
{
my_bitpacked_char data[100] = {};
void format(serdes::packet &p) override
{
p + serdes::delimited_array<my_bitpacked_char>(data, my_bitpacked_char());
}
};
const size_t serial_data_size = 50;
uint8_t serial_data[serial_data_size] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0};
my_delimited_data object;
auto load_result = object.load(serial_data);
for (size_t i = 1; i < 13; i++)
ASSERT_EQUALS(object.data[i - 1].data, char(i));
ASSERT_EQUALS(object.data[13].data, char(0));
ASSERT_EQUALS(load_result.bits, 104_zu);
ASSERT_EQUALS(static_cast<int>(load_result.status), static_cast<int>(serdes::status_e::NO_ERROR));
char new_str[] = {8, 3, 6, 4, 5, 4, 7, 6, 5, 10, 2, 0};
serdes::packet(serial_data) << new_str;
auto load2_result = object.load(serial_data);
for (size_t i = 0; i < sizeof(new_str) / sizeof(new_str[0]); i++)
ASSERT_EQUALS(object.data[i].data, new_str[i]);
ASSERT_EQUALS(load2_result.bits, 96);
ASSERT_EQUALS(static_cast<int>(load2_result.status), static_cast<int>(serdes::status_e::NO_ERROR));
object.data[2] = 12;
object.data[4] = 15;
object.data[5] = 0;
auto store_result = object.store(serial_data);
ASSERT_EQUALS(serial_data[2], uint8_t(12));
ASSERT_EQUALS(serial_data[4], uint8_t(15));
ASSERT_EQUALS(serial_data[5], uint8_t(0));
ASSERT_EQUALS(store_result.bits, 6 * 8);
ASSERT_EQUALS(static_cast<int>(store_result.status), static_cast<int>(serdes::status_e::NO_ERROR));
for (size_t i = 0; i < sizeof(object.data) / sizeof(object.data[0]); i++)
object.data[i] = 3;
auto store_result2 = object.store(serial_data);
bool all_serial_data_matched = true;
for (size_t i = 0; i < serial_data_size; i++)
all_serial_data_matched &= serial_data[i] == 3;
ASSERT_EQUALS(all_serial_data_matched, true);
ASSERT_EQUALS(store_result2.bits, 400);
ASSERT_EQUALS(static_cast<int>(store_result2.status), static_cast<int>(serdes::status_e::EXCEEDED_SERIAL_SIZE));
uint8_t serial_data2[100] = {};
auto store_result4 = object.store(serial_data2);
ASSERT_EQUALS(store_result4.bits, 8 * 100);
ASSERT_EQUALS(static_cast<int>(store_result4.status), static_cast<int>(serdes::status_e::DELIMITER_NOT_FOUND));
}
static void test_bitpacked_delimited_arrays()
{
struct my_delimited_data : serdes::packet_base
{
unsigned char data[100] = {};
void format(serdes::packet &p) override
{
p + serdes::bitpack<serdes::delimited_array<unsigned char>, int>(serdes::delimited_array<unsigned char>(data, '\0'), 4);
}
};
const size_t serial_data_size = 25;
uint8_t expected_data[] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0xF, 0x1, 0x1, 0x2, 0x2, 0x3, 0x3, 0x4, 0x4, 0x5, 0x0};
uint8_t serial_data[serial_data_size] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF, 0x11, 0x22, 0x33, 0x44, 0x50};
my_delimited_data object;
auto load_result = object.load(serial_data);
for (size_t i = 0; i < sizeof(expected_data); i++)
ASSERT_EQUALS(object.data[i], expected_data[i]);
ASSERT_EQUALS(load_result.bits, 104_zu);
ASSERT_EQUALS(static_cast<int>(load_result.status), static_cast<int>(serdes::status_e::NO_ERROR));
unsigned char new_str[] = {0xFF, 0x11, 0x22, 0x33, 0x44, 0x51, 0x78, 0x9A, 0xBC, 0xDE, 0x56, 0x50};
uint8_t expected_data2[] = {0xF, 0xF, 0x1, 0x1, 0x2, 0x2, 0x3, 0x3, 0x4, 0x4, 0x5, 0x1, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0x5, 0x6, 0x5, 0x0};
serdes::packet(serial_data) << new_str;
auto load2_result = object.load(serial_data);
for (size_t i = 0; i < sizeof(expected_data2); i++)
ASSERT_EQUALS(object.data[i], expected_data2[i]);
ASSERT_EQUALS(load2_result.bits, 96);
ASSERT_EQUALS(static_cast<int>(load2_result.status), static_cast<int>(serdes::status_e::NO_ERROR));
object.data[0] = 0xA;
object.data[1] = 0xB;
object.data[2] = 0xC;
object.data[3] = 0xD;
object.data[4] = 0xE;
object.data[5] = 0x0;
auto store_result = object.store(serial_data);
ASSERT_EQUALS(serial_data[0], uint8_t(0xAB));
ASSERT_EQUALS(serial_data[1], uint8_t(0xCD));
ASSERT_EQUALS(serial_data[2], uint8_t(0xE0));
ASSERT_EQUALS(store_result.bits, 6 * 4);
ASSERT_EQUALS(static_cast<int>(store_result.status), static_cast<int>(serdes::status_e::NO_ERROR));
for (size_t i = 0; i < sizeof(object.data) / sizeof(object.data[0]); i++)
object.data[i] = 0x3;
auto store_result2 = object.store(serial_data);
bool all_serial_data_matched = true;
for (size_t i = 0; i < serial_data_size; i++)
all_serial_data_matched &= serial_data[i] == 0x33;
ASSERT_EQUALS(all_serial_data_matched, true);
ASSERT_EQUALS(store_result2.bits, 200);
ASSERT_EQUALS(static_cast<int>(store_result2.status), static_cast<int>(serdes::status_e::EXCEEDED_SERIAL_SIZE));
uint8_t serial_data2[50] = {};
auto store_result4 = object.store(serial_data2);
ASSERT_EQUALS(store_result4.bits, 8 * 50);
ASSERT_EQUALS(static_cast<int>(store_result4.status), static_cast<int>(serdes::status_e::DELIMITER_NOT_FOUND));
}
static void test_virtual_formatters()
{
struct optional_and_mandatory_data_test : serdes::packet_base
{
uint8_t x = 0;
serdes::formatter optional_data = {serdes::virtual_formatter};
uint8_t y = 0;
serdes::formatter mandatory_data = {serdes::pure_virtual_formatter};
void format(serdes::packet &packet) override
{
packet + x + optional_data + y + mandatory_data;
}
};
optional_and_mandatory_data_test obj;
uint8_t data[4] = {};
auto store_result = obj.store(data);
ASSERT_EQUALS(store_result.bits, 16_zu);
ASSERT_EQUALS(static_cast<int>(store_result.status), static_cast<int>(serdes::status_e::FORMATTER_NOT_SET));
auto load_result = obj.load(data);
ASSERT_EQUALS(load_result.bits, 16_zu);
ASSERT_EQUALS(static_cast<int>(load_result.status), static_cast<int>(serdes::status_e::FORMATTER_NOT_SET));
}
static void test_object_oriented_virtual_formatters()
{
struct packet_format : serdes::packet_base
{
uint8_t id = 0;
serdes::formatter payload = {serdes::pure_virtual_formatter};
uint16_t checksum = 0;
serdes::formatter optional_trailing_data = {serdes::virtual_formatter};
void format(serdes::packet &p) override
{
p + id + payload + checksum + optional_trailing_data;
}
};
struct amperage_command : packet_format
{
uint64_t amperage = 0;
amperage_command()
{
packet_format::payload = {serdes::init_formatter(amperage)};
}
};
struct voltage_command : packet_format
{
struct payload_t : serdes::packet_base
{
uint32_t voltage = 0;
void format(serdes::packet &p) override
{
p + voltage;
}
} payload = {};
voltage_command()
{
packet_format::payload = {serdes::init_formatter(payload)};
}
};
uint8_t serial_data[] = {0xAB, 0x01, 0x02, 0x03, 0x04, 0xCD, 0xEF, 0x05, 0x06, 0x07, 0x08};
amperage_command obj;
auto result = obj.load(serial_data);
ASSERT_EQUALS(static_cast<int>(result.status), static_cast<int>(serdes::status_e::NO_ERROR));
ASSERT_EQUALS(obj.id, 0xAB_u8);
ASSERT_EQUALS(obj.amperage, 0x01020304CDEF0506_u64);
ASSERT_EQUALS(obj.checksum, 0x0708_u16);
uint8_t serial_data2[11] = {};
obj.store(serial_data2);
ASSERT_EQUALS(serial_data2, {0xAB, 0x01, 0x02, 0x03, 0x04, 0xCD, 0xEF, 0x05, 0x06, 0x07, 0x08});
voltage_command obj2;
auto result2 = obj2.load(serial_data);
ASSERT_EQUALS(static_cast<int>(result.status), static_cast<int>(serdes::status_e::NO_ERROR));
ASSERT_EQUALS(obj2.id, 0xAB_u8);
ASSERT_EQUALS(obj2.payload.voltage, 0x01020304_u32);
ASSERT_EQUALS(obj2.checksum, 0xCDEF_u16);
}
static void testset_serdes()
{
test_variable_arrays();
test_variable_packet_base_arrays();
test_fixed_sized_arrays();
test_bitpacked_arrays();
test_dynamic_bitlength_captures();
test_aligned_byte_arrays();
test_inheritance_nesting();
test_edittable_formats();
test_bitpacking_and_strings();
test_alignment_and_padding();
test_error_catching();
test_formatter_lambdas();
test_delimited_arrays();
test_nested_delimited_arrays();
test_bitpacked_delimited_arrays();
test_virtual_formatters();
test_object_oriented_virtual_formatters();
}
#ifndef DISBALE_TESTS_MAIN
int main()
{
testset_serdes();
PRINT_SUMMARY();
}
#endif
| 37.535121
| 164
| 0.62477
|
DarrenLevine
|
4b27988a3d9f47591049cde3485374aa9f174ef8
| 582
|
cpp
|
C++
|
unit_tests/os_interface/linux/performance_counters_linux_tests.cpp
|
FelipeMLopez/compute-runtime
|
3e3d2d3b3ac9129b1ee9c4251a2586fef0b300b8
|
[
"MIT"
] | null | null | null |
unit_tests/os_interface/linux/performance_counters_linux_tests.cpp
|
FelipeMLopez/compute-runtime
|
3e3d2d3b3ac9129b1ee9c4251a2586fef0b300b8
|
[
"MIT"
] | null | null | null |
unit_tests/os_interface/linux/performance_counters_linux_tests.cpp
|
FelipeMLopez/compute-runtime
|
3e3d2d3b3ac9129b1ee9c4251a2586fef0b300b8
|
[
"MIT"
] | null | null | null |
/*
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "unit_tests/os_interface/linux/mock_performance_counters_linux.h"
#include "unit_tests/os_interface/mock_performance_counters.h"
#include "gtest/gtest.h"
using namespace NEO;
struct PerformanceCountersLinuxTest : public PerformanceCountersFixture,
public ::testing::Test {
void SetUp() override {
PerformanceCountersFixture::SetUp();
}
void TearDown() override {
PerformanceCountersFixture::TearDown();
}
};
| 23.28
| 74
| 0.685567
|
FelipeMLopez
|
4b283e8e4baa4c1aebeb34debcde0bc22875d121
| 119,443
|
cpp
|
C++
|
module/mpc-be/SRC/src/ExtLib/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.cpp
|
1aq/PBox
|
67ced599ee36ceaff097c6584f8100cf96006dfe
|
[
"MIT"
] | null | null | null |
module/mpc-be/SRC/src/ExtLib/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.cpp
|
1aq/PBox
|
67ced599ee36ceaff097c6584f8100cf96006dfe
|
[
"MIT"
] | null | null | null |
module/mpc-be/SRC/src/ExtLib/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.cpp
|
1aq/PBox
|
67ced599ee36ceaff097c6584f8100cf96006dfe
|
[
"MIT"
] | null | null | null |
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license that can
* be found in the License.html file in the root of the source tree.
*/
//---------------------------------------------------------------------------
// Pre-compilation
#include "MediaInfo/PreComp.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include "MediaInfo/Setup.h"
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#if defined(MEDIAINFO_REFERENCES_YES)
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
#include "MediaInfo/MediaInfo_Internal.h"
#include "ZenLib/File.h"
#include "ZenLib/FileName.h"
#include "ZenLib/Format/Http/Http_Utils.h"
#include <set>
#include <algorithm>
#include <cfloat>
#if MEDIAINFO_EVENTS
#include "MediaInfo/MediaInfo_Events_Internal.h"
#include "MediaInfo/MediaInfo_Config_PerPackage.h"
#endif //MEDIAINFO_EVENTS
#if MEDIAINFO_AES
#include "ThirdParty/base64/base64.h"
#endif //MEDIAINFO_AES
using namespace std;
//---------------------------------------------------------------------------
namespace MediaInfoLib
{
//***************************************************************************
// Constructor/Destructor
//***************************************************************************
//---------------------------------------------------------------------------
File__ReferenceFilesHelper::File__ReferenceFilesHelper(File__Analyze* MI_, MediaInfo_Config_MediaInfo* Config_)
{
//In
TestContinuousFileNames=false;
ContainerHasNoId=false;
ID_Max=0;
//Private
Sequences_Current=0;
MI=MI_;
Config=Config_;
Init_Done=false;
FrameRate=0;
Duration=0;
#if MEDIAINFO_DEMUX
Demux_Interleave=false;
DTS_Minimal=(int64u)-1;
#endif //MEDIAINFO_DEMUX
#if MEDIAINFO_EVENTS
StreamID_Previous=(int64u)-1;
#endif //MEDIAINFO_EVENTS
#if MEDIAINFO_DEMUX
Offset_Video_DTS=0;
#endif //MEDIAINFO_DEMUX
//Temp
FilesForStorage=false;
HasMainFile=false;
HasMainFile_Filled=false;
#if MEDIAINFO_NEXTPACKET
DTS_Interval=(int64u)-1;
#endif //MEDIAINFO_NEXTPACKET
}
//---------------------------------------------------------------------------
File__ReferenceFilesHelper::~File__ReferenceFilesHelper()
{
size_t Sequences_Size=Sequences.size();
for (size_t Sequences_Pos=0; Sequences_Pos<Sequences_Size; ++Sequences_Pos)
delete Sequences[Sequences_Pos];
}
//***************************************************************************
// Streams management
//***************************************************************************
//---------------------------------------------------------------------------
bool File__ReferenceFilesHelper_Algo1 (const sequence* Ref1, const sequence* Ref2) { return (Ref1->StreamID<Ref2->StreamID);}
bool File__ReferenceFilesHelper_Algo2 (const sequence* Ref1, const sequence* Ref2) { return (Ref1->StreamPos<Ref2->StreamPos);}
bool File__ReferenceFilesHelper_Algo3 (const sequence* Ref1, const sequence* Ref2) { return (Ref1->StreamKind<Ref2->StreamKind);}
void File__ReferenceFilesHelper_InfoFromFileName (sequences &Sequences)
{
ZtringListList List;
vector<size_t> Iterators;
size_t ItemsValid=0;
for (size_t Sequences_Pos=0; Sequences_Pos<Sequences.size(); Sequences_Pos++)
{
ZtringList List2;
List2.Separator_Set(0, __T(" "));
if (Sequences[Sequences_Pos]->StreamKind==Stream_Audio && !Sequences[Sequences_Pos]->FileNames.empty())
{
Ztring Name=Sequences[Sequences_Pos]->FileNames[0];
while (Name.FindAndReplace(__T("51 "), Ztring()));
while (Name.FindAndReplace(__T("_"), __T(" ")));
while (Name.FindAndReplace(__T("."), __T(" ")));
while (Name.FindAndReplace(__T(" "), __T(" ")));
size_t PathSeparator_Pos=Name.rfind(PathSeparator);
if (PathSeparator_Pos!=(size_t)-1)
Name.erase(0, PathSeparator_Pos+1);
//Removing extension
if (Name.size()>4 && Name.rfind(__T('.'))==Name.size())
Name.resize(Name.size()-4);
List2.Write(Name);
for (size_t Pos=0; Pos<List2.size(); Pos++)
List2[Pos].MakeLowerCase();
List.push_back(List2);
Iterators.push_back(Sequences_Pos);
ItemsValid++;
}
else
List.push_back(Ztring());
}
if (ItemsValid<2)
return;
for (size_t Pos2=0; Pos2<List.size(); Pos2++)
{
size_t ChannelLayout_Pos=(size_t)-1;
size_t Language_Pos=(size_t)-1;
//Pos = index file parts
for (size_t Pos=0; Pos<List[Pos2].size(); Pos++)
{
if (Pos>=List[Pos2].size())
break; //Maybe begin of title
const Ztring &Test=List[Pos2][List[Pos2].size()-1-Pos];
//ChannelLayout
if (ChannelLayout_Pos==(size_t)-1
&& (Test==__T("l")
|| Test==__T("r")
|| Test==__T("lt")
|| Test==__T("rt")
|| Test==__T("c")
|| Test==__T("lf")
|| Test==__T("lfe")
|| Test==__T("sub")
|| Test==__T("ls")
|| Test==__T("rs")
|| Test==__T("lsr")
|| Test==__T("rsr")
|| Test==__T("b")
|| Test==__T("mono")))
{
ChannelLayout_Pos = Pos;
}
//Language
if (Language_Pos==(size_t)-1
&& (Test==__T("ara")
|| Test==__T("deu")
|| Test==__T("eng")
|| Test==__T("fra")
|| Test==__T("fre")
|| Test==__T("ger")
|| Test==__T("ita")
|| Test==__T("jpn")
|| Test==__T("las") //Latin America Spanish
|| Test==__T("rus")
|| Test==__T("spa")))
{
Language_Pos = Pos;
}
if (ChannelLayout_Pos!=(size_t)-1 && Language_Pos!=(size_t)-1)
break;
}
//ChannelLayout
if (ChannelLayout_Pos!=(size_t)-1)
{
Ztring ChannelPositions, ChannelPositions2, ChannelLayout;
if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("l"))
{
ChannelPositions=__T("Front: L");
ChannelPositions2=__T("1/0/0");
ChannelLayout=__T("L");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("lt"))
{
ChannelPositions=__T("Front: Lt");
ChannelPositions2=__T("1/0/0");
ChannelLayout=__T("Lt");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("rt"))
{
ChannelPositions=__T("Front: Rt");
ChannelPositions2=__T("1/0/0");
ChannelLayout=__T("Rt");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("r"))
{
ChannelPositions=__T("Front: R");
ChannelPositions2=__T("1/0/0");
ChannelLayout=__T("R");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("c") || List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("mono"))
{
ChannelPositions=__T("Front: C");
ChannelPositions2=__T("1/0/0");
ChannelLayout=__T("C");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("lf") || List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("lfe") || List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("sub"))
{
ChannelPositions=__T("LFE");
ChannelPositions2=__T(".1");
ChannelLayout=__T("LFE");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("ls"))
{
ChannelPositions=__T("Side: L");
ChannelPositions2=__T("0/1/0");
ChannelLayout=__T("Ls");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("rs"))
{
ChannelPositions=__T("Side: R");
ChannelPositions2=__T("0/1/0");
ChannelLayout=__T("Rs");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("lsr"))
{
ChannelPositions=__T("Back: L");
ChannelPositions2=__T("0/0/1");
ChannelLayout=__T("Lsr");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("rsr"))
{
ChannelPositions=__T("Back: R");
ChannelPositions2=__T("0/0/1");
ChannelLayout=__T("Rsr");
}
else if (List[Pos2][List[Pos2].size()-1-ChannelLayout_Pos]==__T("b"))
{
ChannelPositions=__T("Back: C");
ChannelPositions2=__T("0/0/1");
ChannelLayout=__T("Cs");
}
Sequences[Pos2]->Infos["ChannelPositions"]=ChannelPositions;
Sequences[Pos2]->Infos["ChannelPositions/String2"]=ChannelPositions2;
Sequences[Pos2]->Infos["ChannelLayout"]=ChannelLayout;
}
//Language
if (Language_Pos!=(size_t)-1)
if (1+Language_Pos<List[Pos2].size())
{
Ztring Language;
if (List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("ara"))
Language=__T("ar");
else if (List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("deu") || List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("ger"))
Language=__T("de");
else if (List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("eng"))
Language=__T("en");
else if (List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("fra") || List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("fre"))
Language=__T("fr");
else if (List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("ita"))
Language=__T("it");
else if (List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("jpn"))
Language=__T("ja");
else if (List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("las")) //Latin America Spanish
Language=__T("es-419");
else if (List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("rus"))
Language=__T("ru");
else if (List[Pos2][List[Pos2].size()-1-Language_Pos]==__T("spa"))
Language=__T("es");
Sequences[Pos2]->Infos["Language"]=Language.empty()?List[Pos2][List[Pos2].size()-1-Language_Pos]:Language;
}
}
}
//***************************************************************************
// In
//***************************************************************************
//---------------------------------------------------------------------------
void File__ReferenceFilesHelper::AddSequence(sequence* NewSequence)
{
Sequences.push_back(NewSequence);
}
//---------------------------------------------------------------------------
void File__ReferenceFilesHelper::DetectSameReels(vector<size_t> &ReelCount)
{
if (ReelCount.size()<=1)
return;
// Finding the max count of streams per stream kind
size_t StreamCounts_Max[Stream_Max+1];
size_t StreamCounts[Stream_Max+1];
vector<size_t> Sequence_Pos_PerKind[Stream_Max+1];
memset(StreamCounts_Max, 0x00, (Stream_Max+1)*sizeof(size_t));
size_t Sequence_Pos=0;
for (size_t r=0; r<ReelCount.size(); r++)
{
memset(StreamCounts, 0x00, (Stream_Max+1)*sizeof(size_t));
for (size_t i=0; i<ReelCount[r]; i++)
{
if (Sequence_Pos_PerKind[Sequences[Sequence_Pos]->StreamKind].size()<=StreamCounts[Sequences[Sequence_Pos]->StreamKind])
Sequence_Pos_PerKind[Sequences[Sequence_Pos]->StreamKind].push_back(Sequence_Pos);
StreamCounts[Sequences[Sequence_Pos]->StreamKind]++;
Sequence_Pos++;
}
for (size_t i=0; i<Stream_Max+1; i++)
if (StreamCounts[i] && StreamCounts[i]!=StreamCounts_Max[i])
{
if (StreamCounts_Max[i])
return; // incoherent count of streams per stream kind, we do nothing
StreamCounts_Max[i]=StreamCounts[i];
}
}
//Merge resources from different reels
Sequence_Pos=ReelCount[0];
vector<size_t> Sequence_Pos_toDelete;
for (size_t r=1; r<ReelCount.size(); r++)
{
memset(StreamCounts, 0x00, (Stream_Max+1)*sizeof(size_t));
for (size_t i=0; i<ReelCount[r]; i++)
{
if (Sequences[Sequence_Pos]->StreamKind!=Stream_Max)
{
size_t Sequence_Pos_First=Sequence_Pos_PerKind[Sequences[Sequence_Pos]->StreamKind][StreamCounts[Sequences[Sequence_Pos]->StreamKind]];
if (Sequence_Pos!=Sequence_Pos_First)
{
Sequences[Sequence_Pos_First]->Resources.insert(Sequences[Sequence_Pos_First]->Resources.end(), Sequences[Sequence_Pos]->Resources.begin(), Sequences[Sequence_Pos]->Resources.end());
Sequence_Pos_toDelete.push_back(Sequence_Pos);
}
}
StreamCounts[Sequences[Sequence_Pos]->StreamKind]++;
Sequence_Pos++;
}
}
// Remove other reels
for (size_t i=Sequence_Pos_toDelete.size()-1; i!=(size_t)-1; i--)
{
delete Sequences[Sequence_Pos_toDelete[i]];
Sequences.erase(Sequences.begin()+Sequence_Pos_toDelete[i]);
}
// Fake StreamIDs
for (size_t i=0; i<Sequences.size(); i++)
Sequences[i]->StreamID=i+1;
}
//---------------------------------------------------------------------------
void File__ReferenceFilesHelper::UpdateFileName(const Ztring& OldFileName, const Ztring& NewFileName)
{
size_t Sequences_Size=Sequences.size();
for (size_t Sequences_Pos=0; Sequences_Pos<Sequences_Size; ++Sequences_Pos)
{
sequence* Sequence=Sequences[Sequences_Pos];
Sequence->UpdateFileName(OldFileName, NewFileName);
}
}
//---------------------------------------------------------------------------
#if MEDIAINFO_ADVANCED
void File__ReferenceFilesHelper::UpdateMetaDataFromSourceEncoding(const string& SourceEncoding, const string& Name, const string& Value)
{
size_t Sequences_Size=Sequences.size();
for (size_t Sequences_Pos=0; Sequences_Pos<Sequences_Size; ++Sequences_Pos)
{
sequence* Sequence=Sequences[Sequences_Pos];
Sequence->UpdateMetaDataFromSourceEncoding(SourceEncoding, Name, Value);
}
}
#endif //MEDIAINFO_ADVANCED
//***************************************************************************
// Streams management
//***************************************************************************
void File__ReferenceFilesHelper::ParseReferences()
{
if (!Init_Done)
{
#if MEDIAINFO_FILTER
if (MI->Config->File_Filter_Audio_Get())
{
for (size_t Pos=0; Pos<Sequences.size(); Pos++)
if (Sequences[Pos]->StreamKind!=Stream_Audio)
{
Sequences.erase(Sequences.begin()+Pos);
Pos--;
}
}
#endif //MEDIAINFO_FILTER
//Filling Filenames from the more complete version and Edit rates
float64 EditRate=DBL_MAX;
size_t EditRate_Count=0;
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
if (Sequences[Sequences_Current]->FileNames.empty())
for (size_t Pos=0; Pos<Sequences[Sequences_Current]->Resources.size(); Pos++)
{
for (size_t Resource_FileNames_Pos=0; Resource_FileNames_Pos<Sequences[Sequences_Current]->Resources[Pos]->FileNames.size(); Resource_FileNames_Pos++)
Sequences[Sequences_Current]->FileNames.push_back(Sequences[Sequences_Current]->Resources[Pos]->FileNames[Resource_FileNames_Pos]);
if (Sequences[Sequences_Current]->Resources[Pos]->EditRate && EditRate!=Sequences[Sequences_Current]->Resources[Pos]->EditRate)
{
if (EditRate>Sequences[Sequences_Current]->Resources[Pos]->EditRate)
EditRate=Sequences[Sequences_Current]->Resources[Pos]->EditRate;
EditRate_Count++;
}
}
if (EditRate_Count>1)
//Multiple rates, using only one rate
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
for (size_t Pos=0; Pos<Sequences[Sequences_Current]->Resources.size(); Pos++)
if (Sequences[Sequences_Current]->Resources[Pos]->EditRate && EditRate!=Sequences[Sequences_Current]->Resources[Pos]->EditRate)
{
if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore)
{
float64 Temp=(float64)Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore;
Temp/=Sequences[Sequences_Current]->Resources[Pos]->EditRate;
Temp*=EditRate;
Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore=float64_int64s(Temp);
}
if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter!=(int64u)-1)
{
float64 Temp=(float64)Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter;
Temp/=Sequences[Sequences_Current]->Resources[Pos]->EditRate;
Temp*=EditRate;
Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter=float64_int64s(Temp);
}
if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration!=(int64u)-1)
{
float64 Temp=(float64)Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration;
Temp/=Sequences[Sequences_Current]->Resources[Pos]->EditRate;
Temp*=EditRate;
Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration=float64_int64s(Temp);
}
Sequences[Sequences_Current]->Resources[Pos]->EditRate=EditRate;
}
//Testing IDs
std::set<int64u> StreamList;
bool StreamList_DuplicatedIds=false;
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
if (StreamList.find(Sequences[Sequences_Current]->StreamID)==StreamList.end())
StreamList.insert(Sequences[Sequences_Current]->StreamID);
else
{
StreamList_DuplicatedIds=true;
break;
}
if (StreamList_DuplicatedIds)
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
Sequences[Sequences_Current]->StreamID=Sequences_Current+1;
if (Sequences.size()==1 && (*Sequences.begin())->StreamID==(int64u)-1)
{
ContainerHasNoId=true;
#if MEDIAINFO_EVENTS
MI->StreamIDs_Width[MI->StreamIDs_Size-1]=0;
#endif //MEDIAINFO_EVENTS
}
std::sort(Sequences.begin(), Sequences.end(), File__ReferenceFilesHelper_Algo1);
std::sort(Sequences.begin(), Sequences.end(), File__ReferenceFilesHelper_Algo2);
std::sort(Sequences.begin(), Sequences.end(), File__ReferenceFilesHelper_Algo3);
//InfoFromFileName
File__ReferenceFilesHelper_InfoFromFileName(Sequences);
#if MEDIAINFO_EVENTS
if (MI->Config->Config_PerPackage==NULL)
{
MI->Config->Config_PerPackage=new MediaInfo_Config_PerPackage;
MI->Config->Config_PerPackage->CountOfPackages=Sequences.size();
}
#endif //MEDIAINFO_EVENTS
//Configuring file names
Sequences_Current=0;
while (Sequences_Current<Sequences.size())
{
ZtringList Names=Sequences[Sequences_Current]->FileNames;
ZtringList AbsoluteNames; AbsoluteNames.Separator_Set(0, ",");
for (size_t Pos=0; Pos<Names.size(); Pos++)
{
if (Names[Pos].find(__T("file:///"))==0)
{
Names[Pos].erase(0, 8); //Removing "file:///", this is the default behaviour and this makes comparison easier
Names[Pos]=ZenLib::Format::Http::URL_Encoded_Decode(Names[Pos]);
}
if (Names[Pos].find(__T("file://"))==0)
{
Names[Pos].erase(0, 7); //Removing "file://", this is the default behaviour and this makes comparison easier
Names[Pos]=ZenLib::Format::Http::URL_Encoded_Decode(Names[Pos]);
}
if (Names[Pos].find(__T("file:"))==0)
{
Names[Pos].erase(0, 5); //Removing "file:", this is the default behaviour and this makes comparison easier
Names[Pos]=ZenLib::Format::Http::URL_Encoded_Decode(Names[Pos]);
}
Ztring AbsoluteName;
if (Names[Pos].find(__T(':'))!=1 && Names[Pos].find(__T("/"))!=0 && Names[Pos].find(__T("\\\\"))!=0) //If absolute patch
{
if (MI->File_Name.find(__T("://"))==string::npos)
AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name);
else
{
size_t Pos_Path=MI->File_Name.find_last_of('/');
if (Pos_Path!=Ztring::npos)
AbsoluteName=MI->File_Name.substr(0, Pos_Path);
}
if (!AbsoluteName.empty())
AbsoluteName+=ZenLib::PathSeparator;
}
AbsoluteName+=Names[Pos];
#ifdef __WINDOWS__
if (AbsoluteName.find(__T("://"))==string::npos)
AbsoluteName.FindAndReplace(__T("/"), __T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization local file
else
AbsoluteName.FindAndReplace(__T("\\"), __T("/"), 0, Ztring_Recursive); //Names[Pos] normalization with protocol (so "/" in all cases)
#endif //__WINDOWS__
AbsoluteNames.push_back(AbsoluteName);
}
if (AbsoluteNames.empty() || !(AbsoluteNames[0].find(__T("://"))!=string::npos || File::Exists(AbsoluteNames[0])))
{
AbsoluteNames.clear();
//Configuring file name (this time, we try to force URL decode in all cases)
for (size_t Pos=0; Pos<Names.size(); Pos++)
{
Names[Pos]=ZenLib::Format::Http::URL_Encoded_Decode(Names[Pos]);
Ztring AbsoluteName;
if (Names[Pos].find(__T(':'))!=1 && Names[Pos].find(__T("/"))!=0 && Names[Pos].find(__T("\\\\"))!=0) //If absolute patch
{
if (MI->File_Name.find(__T("://"))==string::npos)
AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name);
else
{
size_t Pos_Path=MI->File_Name.find_last_of('/');
if (Pos_Path!=Ztring::npos)
AbsoluteName=MI->File_Name.substr(0, Pos_Path);
}
if (!AbsoluteName.empty())
AbsoluteName+=ZenLib::PathSeparator;
}
AbsoluteName+=Names[Pos];
#ifdef __WINDOWS__
AbsoluteName.FindAndReplace(__T("/"), __T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization
#endif //__WINDOWS__
AbsoluteNames.push_back(AbsoluteName);
}
if (AbsoluteNames.empty() || !File::Exists(AbsoluteNames[0]))
{
AbsoluteNames.clear();
Names=Sequences[Sequences_Current]->FileNames;
//Configuring file name (this time, we try to test local files)
size_t PathSeparator_Pos=Names.empty()?string::npos:Names[0].find_last_of(__T("\\/"));
if (PathSeparator_Pos!=string::npos && PathSeparator_Pos)
{
Ztring PathToRemove=Names[0].substr(0, PathSeparator_Pos);
bool IsOk=true;
for (size_t Pos=0; Pos<Names.size(); Pos++)
if (Names[Pos].find(PathToRemove))
{
IsOk=false;
break;
}
if (IsOk)
{
for (size_t Pos=0; Pos<Names.size(); Pos++)
{
Names[Pos].erase(0, PathSeparator_Pos+1);
Ztring AbsoluteName;
if (MI->File_Name.find(__T("://"))==string::npos)
AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name);
else
{
size_t Pos_Path=MI->File_Name.find_last_of('/');
if (Pos_Path!=Ztring::npos)
AbsoluteName=MI->File_Name.substr(0, Pos_Path);
}
if (!AbsoluteName.empty())
AbsoluteName+=ZenLib::PathSeparator;
AbsoluteName+=Names[Pos];
#ifdef __WINDOWS__
if (AbsoluteName.find(__T("://"))==string::npos)
AbsoluteName.FindAndReplace(__T("/"), __T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization local file
else
AbsoluteName.FindAndReplace(__T("\\"), __T("/"), 0, Ztring_Recursive); //Names[Pos] normalization with protocol (so "/" in all cases)
#endif //__WINDOWS__
AbsoluteNames.push_back(AbsoluteName);
}
if (!File::Exists(AbsoluteNames[0]))
{
AbsoluteNames.clear();
Names=Sequences[Sequences_Current]->FileNames;
//Configuring file name (this time, we try to test local files)
size_t PathSeparator_Pos=Names[0].find_last_of(__T("\\/"));
if (PathSeparator_Pos!=string::npos && PathSeparator_Pos)
PathSeparator_Pos=Names[0].find_last_of(__T("\\/"), PathSeparator_Pos-1);
if (PathSeparator_Pos!=string::npos && PathSeparator_Pos)
{
Ztring PathToRemove=Names[0].substr(0, PathSeparator_Pos);
bool IsOk=true;
for (size_t Pos=0; Pos<Names.size(); Pos++)
if (Names[Pos].find(PathToRemove))
{
IsOk=false;
break;
}
if (IsOk)
for (size_t Pos=0; Pos<Names.size(); Pos++)
{
Names[Pos].erase(0, PathSeparator_Pos+1);
Ztring AbsoluteName;
if (MI->File_Name.find(__T("://"))==string::npos)
AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name);
else
{
size_t Pos_Path=MI->File_Name.find_last_of('/');
if (Pos_Path!=Ztring::npos)
AbsoluteName=MI->File_Name.substr(0, Pos_Path);
}
if (!AbsoluteName.empty())
AbsoluteName+=ZenLib::PathSeparator;
AbsoluteName+=Names[Pos];
#ifdef __WINDOWS__
AbsoluteName.FindAndReplace(__T("/"), __T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization
#endif //__WINDOWS__
AbsoluteNames.push_back(AbsoluteName);
}
}
if (!AbsoluteNames.empty() && !File::Exists(AbsoluteNames[0]))
AbsoluteNames.clear();
}
}
}
}
}
Sequences[Sequences_Current]->Source=Sequences[Sequences_Current]->FileNames.Read(0);
if (Sequences[Sequences_Current]->StreamKind!=Stream_Max && !Sequences[Sequences_Current]->Source.empty())
{
if (Sequences[Sequences_Current]->StreamPos==(size_t)-1)
Sequences[Sequences_Current]->StreamPos=Stream_Prepare(Sequences[Sequences_Current]->StreamKind);
MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "Source", Sequences[Sequences_Current]->Source);
}
if (!AbsoluteNames.empty())
Sequences[Sequences_Current]->FileNames=AbsoluteNames;
if (!AbsoluteNames.empty() && AbsoluteNames[0]==MI->File_Name)
{
Sequences[Sequences_Current]->IsCircular=true;
Sequences[Sequences_Current]->FileNames.clear();
Sequences[Sequences_Current]->Status.set(File__Analyze::IsFinished);
}
else if (!AbsoluteNames.empty())
Sequences[Sequences_Current]->FileNames=AbsoluteNames;
else
{
Sequences[Sequences_Current]->Status.set(File__Analyze::IsFinished);
#if MEDIAINFO_EVENTS
Config->Event_SubFile_Missing(Sequences[Sequences_Current]->Source);
#endif //MEDIAINFO_EVENTS
if (Sequences[Sequences_Current]->StreamKind!=Stream_Max && !Sequences[Sequences_Current]->Source.empty())
{
MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "Source_Info", "Missing");
if (MI->Retrieve(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, General_ID).empty() && Sequences[Sequences_Current]->StreamID!=(int64u)-1)
MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, General_ID, Sequences[Sequences_Current]->StreamID);
for (std::map<string, Ztring>::iterator Info=Sequences[Sequences_Current]->Infos.begin(); Info!=Sequences[Sequences_Current]->Infos.end(); ++Info)
{
if (Info->first=="CodecID")
MI->CodecID_Fill(Info->second, Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, InfoCodecID_Format_Mpeg4);
else
MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, Info->first.c_str(), Info->second);
}
}
}
if (FilesForStorage)
{
for (size_t Pos=0; Pos<Sequences[Sequences_Current]->FileNames.size(); Pos++)
{
if (Pos==Sequences[Sequences_Current]->Resources.size())
Sequences[Sequences_Current]->Resources.push_back(new resource);
Sequences[Sequences_Current]->Resources[Pos]->FileNames.clear();
Sequences[Sequences_Current]->Resources[Pos]->FileNames.push_back(Sequences[Sequences_Current]->FileNames[Pos]);
}
Sequences[Sequences_Current]->FileNames.resize(1);
}
Sequences_Current++;
}
CountOfReferencesToParse=Sequences.size();
#if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
if (Config->NextPacket_Get())
{
Demux_Interleave=Config->File_Demux_Interleave_Get();
if (Demux_Interleave)
{
for (sequences::iterator ReferenceSource=Sequences.begin(); ReferenceSource!=Sequences.end(); ++ReferenceSource)
if ((*ReferenceSource)->FileNames.empty())
CountOfReferencesToParse--;
DTS_Interval=250000000LL; // 250 milliseconds
}
}
else
Demux_Interleave=false;
//Using the frame rate from the first stream having a frame rate
if (!FrameRate)
for (sequences::iterator ReferenceFrameRate=Sequences.begin(); ReferenceFrameRate!=Sequences.end(); ++ReferenceFrameRate)
if ((*ReferenceFrameRate)->FrameRate)
{
FrameRate=(*ReferenceFrameRate)->FrameRate;
break;
}
if (Config->NextPacket_Get())
{
Sequences_Current=0;
while (Sequences_Current<Sequences.size())
{
ParseReference(); //Init
Sequences_Current++;
}
//Cleanup
for (size_t Pos=0; Pos<Sequences.size(); Pos++)
if (Sequences[Pos]->Status[File__Analyze::IsFinished])
{
Sequences.erase(Sequences.begin()+Pos);
Pos--;
}
CountOfReferencesToParse=Sequences.size();
if (Sequences.empty())
return;
//File size handling
if (MI->Config->File_Size!=MI->File_Size)
{
MI->Fill(Stream_General, 0, General_FileSize, MI->Config->File_Size, 10, true);
MI->Fill(Stream_General, 0, General_StreamSize, MI->File_Size, 10, true);
}
}
#endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
FileSize_Compute();
Sequences_Current=0;
CountOfReferences_ForReadSize=Sequences.size();
Init_Done=true;
#if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
if (Config->NextPacket_Get() && MI->Demux_EventWasSent_Accept_Specific)
{
MI->Config->Demux_EventWasSent=true;
return;
}
#endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
}
while (Sequences_Current<Sequences.size())
{
#if MEDIAINFO_NEXTPACKET
if (!Sequences[Sequences_Current]->Status[File__Analyze::IsFinished])
#endif //MEDIAINFO_NEXTPACKET
ParseReference();
//State
int64u FileSize_Parsed=0;
#if MEDIAINFO_NEXTPACKET
DTS_Minimal=(int64u)-1;
#endif //MEDIAINFO_NEXTPACKET
for (sequences::iterator ReferenceTemp=Sequences.begin(); ReferenceTemp!=Sequences.end(); ++ReferenceTemp)
{
if ((*ReferenceTemp)->MI)
{
if ((*ReferenceTemp)->State<10000)
{
(*ReferenceTemp)->State=(*ReferenceTemp)->MI->State_Get();
if ((*ReferenceTemp)->State && (*ReferenceTemp)->MI->Config.File_Size!=(int64u)-1)
FileSize_Parsed+=(int64u)((*ReferenceTemp)->MI->Config.File_Size*(((float)(*ReferenceTemp)->State)/10000));
}
else
FileSize_Parsed+=(*ReferenceTemp)->MI->Config.File_Size;
#if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
//Minimal DTS
if (DTS_Interval!=(int64u)-1 && !Sequences[Sequences_Current]->Status[File__Analyze::IsFinished] && ((*ReferenceTemp)->Resources.empty() || (*ReferenceTemp)->Resources_Current<(*ReferenceTemp)->Resources.size()))
{
int64u DTS_Temp;
if (!(*ReferenceTemp)->Resources.empty() && (*ReferenceTemp)->Resources_Current)
{
if ((*ReferenceTemp)->Resources[(*ReferenceTemp)->Resources_Current]->MI->Info->FrameInfo.DTS!=(int64u)-1)
DTS_Temp=(*ReferenceTemp)->Resources[(*ReferenceTemp)->Resources_Current]->MI->Info->FrameInfo.DTS-(*ReferenceTemp)->Resources[(*ReferenceTemp)->Resources_Current]->MI->Info->Config->Demux_Offset_DTS_FromStream;
else
DTS_Temp=0;
}
else
{
if ((*ReferenceTemp)->MI->Info->FrameInfo.DTS!=(int64u)-1)
DTS_Temp=(*ReferenceTemp)->MI->Info->FrameInfo.DTS-(*ReferenceTemp)->MI->Info->Config->Demux_Offset_DTS_FromStream;
else
DTS_Temp=0;
}
if ((*ReferenceTemp)->Resources_Current<(*ReferenceTemp)->Resources.size())
DTS_Temp+=(*ReferenceTemp)->Resources[(*ReferenceTemp)->Resources_Current]->Demux_Offset_DTS;
if (DTS_Minimal>DTS_Temp)
DTS_Minimal=DTS_Temp;
}
#endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
}
else
FileSize_Parsed+=(*ReferenceTemp)->FileSize;
}
Config->State_Set(((float)FileSize_Parsed)/MI->Config->File_Size);
#if MEDIAINFO_EVENTS
struct MediaInfo_Event_General_SubFile_End_0 Event;
MI->Event_Prepare((struct MediaInfo_Event_Generic*)&Event);
Event.EventCode=MediaInfo_EventCode_Create(0, MediaInfo_Event_General_SubFile_End, 0);
Event.EventSize=sizeof(struct MediaInfo_Event_General_SubFile_End_0);
MI->Config->Event_Send(NULL, (const int8u*)&Event, Event.EventSize, MI->File_Name);
#endif //MEDIAINFO_EVENTS
#if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
if (Demux_Interleave && (Sequences[Sequences_Current]->MI==NULL || Sequences[Sequences_Current]->MI->Info==NULL || Sequences[Sequences_Current]->MI->Info->Demux_CurrentParser==NULL || Sequences[Sequences_Current]->MI->Info->Demux_CurrentParser->Demux_TotalBytes>=Sequences[Sequences_Current]->MI->Info->Demux_CurrentParser->Buffer_TotalBytes+Sequences[Sequences_Current]->MI->Info->Demux_CurrentParser->Buffer_Size))
{
size_t Reference_Next=Sequences_Current; ++Reference_Next;
if (Reference_Next==Sequences.size() && Config->NextPacket_Get() && CountOfReferencesToParse)
Sequences_Current=0;
else
Sequences_Current=Reference_Next;
if (Config->Demux_EventWasSent)
return;
}
else
{
if (Config->Demux_EventWasSent)
return;
Sequences_Current++;
if (Demux_Interleave && Sequences_Current == Sequences.size() && Config->NextPacket_Get() && CountOfReferencesToParse)
Sequences_Current = 0;
}
#else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
Sequences_Current++;
#endif //MEDIAINFO_DEMUX
}
//File size handling
FileSize_Compute();
if (MI->Config->File_Size!=MI->File_Size
#if MEDIAINFO_ADVANCED
&& !Config->File_IgnoreSequenceFileSize_Get()
#endif //MEDIAINFO_ADVANCED
)
{
MI->Fill(Stream_General, 0, General_FileSize, MI->Config->File_Size, 10, true);
MI->Fill(Stream_General, 0, General_StreamSize, MI->File_Size, 10, true);
}
#if MEDIAINFO_ADVANCED
if (Config->File_IgnoreSequenceFileSize_Get())
MI->Clear(Stream_General, 0, General_FileSize);
#endif //MEDIAINFO_ADVANCED
}
//---------------------------------------------------------------------------
bool File__ReferenceFilesHelper::ParseReference_Init()
{
//Configuration
Sequences[Sequences_Current]->MI=MI_Create();
if (Config->ParseSpeed>=1)
{
for (size_t Pos=0; Pos<Sequences[Sequences_Current]->Resources.size(); Pos++)
{
if (Sequences[Sequences_Current]->Resources[0]->EditRate)
{
#if MEDIAINFO_DEMUX
if (Pos==0)
{
Sequences[Sequences_Current]->Resources[0]->Demux_Offset_DTS=0;
Sequences[Sequences_Current]->Resources[0]->Demux_Offset_Frame=0;
}
if (Pos+1<Sequences[Sequences_Current]->Resources.size())
{
Sequences[Sequences_Current]->Resources[Pos+1]->Demux_Offset_DTS=float64_int64s(Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_DTS+(Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter-Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore)/Sequences[Sequences_Current]->Resources[0]->EditRate*1000000000);
Sequences[Sequences_Current]->Resources[Pos+1]->Demux_Offset_Frame=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_Frame+Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter-Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore;
}
#endif //MEDIAINFO_DEMUX
}
else
{
MediaInfo_Internal MI2;
MI2.Option(__T("File_KeepInfo"), __T("1"));
Ztring ParseSpeed_Save=MI2.Option(__T("ParseSpeed_Get"), __T("0"));
Ztring Demux_Save=MI2.Option(__T("Demux_Get"), __T(""));
MI2.Option(__T("ParseSpeed"), __T("0"));
MI2.Option(__T("Demux"), Ztring());
Sequences[Sequences_Current]->Resources[Pos]->FileNames.Separator_Set(0, ",");
size_t MiOpenResult=MI2.Open(Sequences[Sequences_Current]->Resources[Pos]->FileNames.Read());
MI2.Option(__T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
MI2.Option(__T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
if (MiOpenResult)
{
#if MEDIAINFO_DEMUX
int64u Duration=MI2.Get(Sequences[Sequences_Current]->StreamKind, 0, __T("Duration")).To_int64u()*1000000;
int64u FrameCount=MI2.Get(Sequences[Sequences_Current]->StreamKind, 0, __T("FrameCount")).To_int64u();
if (Pos==0)
{
int64u Delay=MI2.Get(Stream_Video, 0, Video_Delay).To_int64u()*1000000;
if (Sequences[Sequences_Current]->StreamKind==Stream_Video && Offset_Video_DTS==0)
Offset_Video_DTS=Delay;
Sequences[Sequences_Current]->Resources[0]->Demux_Offset_DTS=Offset_Video_DTS;
Sequences[Sequences_Current]->Resources[0]->Demux_Offset_Frame=0;
}
if (Pos+1<Sequences[Sequences_Current]->Resources.size())
{
Sequences[Sequences_Current]->Resources[Pos+1]->Demux_Offset_DTS=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_DTS+Duration;
Sequences[Sequences_Current]->Resources[Pos+1]->Demux_Offset_Frame=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_Frame+FrameCount;
}
else
Duration=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_DTS+Duration-Sequences[Sequences_Current]->Resources[0]->Demux_Offset_DTS;
#endif //MEDIAINFO_DEMUX
}
}
if (Pos)
{
Sequences[Sequences_Current]->Resources[Pos]->MI=MI_Create();
Sequences[Sequences_Current]->Resources[Pos]->MI->Config.File_IgnoreEditsBefore=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore;
if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter==(int64u)-1 && Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration!=(int64u)-1)
Sequences[Sequences_Current]->Resources[Pos]->MI->Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore+Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration;
else
Sequences[Sequences_Current]->Resources[Pos]->MI->Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter;
Sequences[Sequences_Current]->Resources[Pos]->MI->Config.File_EditRate=Sequences[Sequences_Current]->Resources[Pos]->EditRate;
#if MEDIAINFO_DEMUX
Sequences[Sequences_Current]->Resources[Pos]->MI->Config.Demux_Offset_Frame=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_Frame;
Sequences[Sequences_Current]->Resources[Pos]->MI->Config.Demux_Offset_DTS=Sequences[Sequences_Current]->Resources[Pos]->Demux_Offset_DTS;
#endif //MEDIAINFO_DEMUX
}
}
if (!Sequences[Sequences_Current]->Resources.empty())
{
Sequences[Sequences_Current]->MI->Config.File_IgnoreEditsBefore=Sequences[Sequences_Current]->Resources[0]->IgnoreEditsBefore;
if (Sequences[Sequences_Current]->Resources[0]->IgnoreEditsAfter==(int64u)-1 && Sequences[Sequences_Current]->Resources[0]->IgnoreEditsAfterDuration!=(int64u)-1)
Sequences[Sequences_Current]->MI->Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[0]->IgnoreEditsBefore+Sequences[Sequences_Current]->Resources[0]->IgnoreEditsAfterDuration;
else
Sequences[Sequences_Current]->MI->Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[0]->IgnoreEditsAfter;
Sequences[Sequences_Current]->MI->Config.File_EditRate=Sequences[Sequences_Current]->Resources[0]->EditRate;
#if MEDIAINFO_DEMUX
Sequences[Sequences_Current]->MI->Config.Demux_Offset_Frame=Sequences[Sequences_Current]->Resources[0]->Demux_Offset_Frame;
Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS=Sequences[Sequences_Current]->Resources[0]->Demux_Offset_DTS;
#endif //MEDIAINFO_DEMUX
}
}
if (Sequences[Sequences_Current]->IsCircular)
{
MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "Source_Info", "Circular");
if (!Config->File_KeepInfo_Get())
{
#if MEDIAINFO_DEMUX
if (CountOfReferencesToParse)
CountOfReferencesToParse--;
#endif //MEDIAINFO_DEMUX
Sequences[Sequences_Current]->StreamKind=Stream_Max;
Sequences[Sequences_Current]->StreamPos=(size_t)-1;
Sequences[Sequences_Current]->FileSize=Sequences[Sequences_Current]->MI->Config.File_Size;
delete Sequences[Sequences_Current]->MI; Sequences[Sequences_Current]->MI=NULL;
}
Sequences[Sequences_Current]->FileNames.clear();
Sequences[Sequences_Current]->Status.set(File__Analyze::IsFinished);
}
else
{
//Run
#if MEDIAINFO_EVENTS
SubFile_Start();
#endif //MEDIAINFO_EVENTS
if (!Sequences[Sequences_Current]->MI->Open(Sequences[Sequences_Current]->FileNames.Read()))
{
#if MEDIAINFO_EVENTS
Config->Event_SubFile_Missing(Sequences[Sequences_Current]->Source);
#endif //MEDIAINFO_EVENTS
if (Sequences[Sequences_Current]->StreamKind!=Stream_Max)
MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "Source_Info", "Missing", Unlimited, true, true);
if (!Config->File_KeepInfo_Get())
{
#if MEDIAINFO_DEMUX
if (CountOfReferencesToParse)
CountOfReferencesToParse--;
#endif //MEDIAINFO_DEMUX
Sequences[Sequences_Current]->StreamKind=Stream_Max;
Sequences[Sequences_Current]->StreamPos=(size_t)-1;
Sequences[Sequences_Current]->FileSize=Sequences[Sequences_Current]->MI->Config.File_Size;
delete Sequences[Sequences_Current]->MI; Sequences[Sequences_Current]->MI=NULL;
}
Sequences[Sequences_Current]->Status.set(File__Analyze::IsFinished);
}
if (Config->ParseSpeed>=1)
for (size_t Pos=1; Pos<Sequences[Sequences_Current]->Resources.size(); Pos++)
{
Sequences[Sequences_Current]->Resources[Pos]->FileNames.Separator_Set(0, ",");
Sequences[Sequences_Current]->Resources[Pos]->MI->Open(Sequences[Sequences_Current]->Resources[Pos]->FileNames.Read());
}
#if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
if (Config->NextPacket_Get())
return false;
#endif //MEDIAINFO_NEXTPACKET
}
return true;
}
//---------------------------------------------------------------------------
void File__ReferenceFilesHelper::ParseReference()
{
if (Sequences[Sequences_Current]->MI==NULL && !Sequences[Sequences_Current]->FileNames.empty())
{
if (!ParseReference_Init())
return;
}
if (Sequences[Sequences_Current]->MI)
{
#if MEDIAINFO_EVENTS && MEDIAINFO_NEXTPACKET
if (DTS_Interval!=(int64u)-1 && !Sequences[Sequences_Current]->Status[File__Analyze::IsFinished] && Sequences[Sequences_Current]->MI->Info->FrameInfo.DTS!=(int64u)-1 && DTS_Minimal!=(int64u)-1 && (Sequences[Sequences_Current]->Resources.empty() || Sequences[Sequences_Current]->Resources_Current<Sequences[Sequences_Current]->Resources.size()))
{
int64u DTS_Temp = 0;
#if MEDIAINFO_DEMUX
if (!Sequences[Sequences_Current]->Resources.empty() && Sequences[Sequences_Current]->Resources_Current)
{
if (Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Info->FrameInfo.DTS!=(int64u)-1)
DTS_Temp=Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Info->FrameInfo.DTS-Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Info->Config->Demux_Offset_DTS_FromStream;;
}
else
{
if (Sequences[Sequences_Current]->MI->Info->FrameInfo.DTS!=(int64u)-1)
DTS_Temp=Sequences[Sequences_Current]->MI->Info->FrameInfo.DTS-Sequences[Sequences_Current]->MI->Info->Config->Demux_Offset_DTS_FromStream;
}
#endif //MEDIAINFO_DEMUX
DTS_Temp+=Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->Demux_Offset_DTS;
if (!Sequences[Sequences_Current]->Resources.empty() && Sequences[Sequences_Current]->Resources_Current<Sequences[Sequences_Current]->Resources.size() && Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->EditRate && Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->IgnoreEditsBefore)
{
int64u TimeOffset=float64_int64s(((float64)Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->IgnoreEditsBefore)/Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->EditRate*1000000000);
if (DTS_Temp>TimeOffset)
DTS_Temp-=TimeOffset;
else
DTS_Temp=0;
}
if (DTS_Temp>DTS_Minimal+DTS_Interval)
return;
}
if (Config->Event_CallBackFunction_IsSet() && !Sequences[Sequences_Current]->Status[File__Analyze::IsFinished])
{
#if MEDIAINFO_DEMUX
SubFile_Start();
if (Sequences[Sequences_Current]->Resources_Current==0)
{
while ((Sequences[Sequences_Current]->Status=Sequences[Sequences_Current]->MI->Open_NextPacket())[8])
{
if (!Sequences[Sequences_Current]->FileSize_IsPresent && Sequences[Sequences_Current]->MI->Config.File_Size!=(int64u)-1)
{
Sequences[Sequences_Current]->FileSize_IsPresent=true;
if (CountOfReferences_ForReadSize)
{
CountOfReferences_ForReadSize--;
if (!CountOfReferences_ForReadSize)
CountOfReferences_ForReadSize_Run();
}
}
if (Config->Event_CallBackFunction_IsSet())
{
Config->Demux_EventWasSent=true;
return;
}
}
Sequences[Sequences_Current]->Resources_Current++;
if (Sequences[Sequences_Current]->Resources_Current<Sequences[Sequences_Current]->Resources.size() && Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI)
Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Open_Buffer_Seek(0, 0, (int64u)-1);
}
#if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
if (Config->ParseSpeed<1.0)
Sequences[Sequences_Current]->Resources_Current=Sequences[Sequences_Current]->Resources.size(); //No need to parse all files
#endif //MEDIAINFO_NEXTPACKET
while (Sequences[Sequences_Current]->Resources_Current<Sequences[Sequences_Current]->Resources.size())
{
while ((Sequences[Sequences_Current]->Status=Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Open_NextPacket())[8])
{
if (!Sequences[Sequences_Current]->FileSize_IsPresent && Sequences[Sequences_Current]->MI->Config.File_Size!=(int64u)-1)
{
Sequences[Sequences_Current]->FileSize_IsPresent=true;
if (CountOfReferences_ForReadSize)
{
CountOfReferences_ForReadSize--;
if (!CountOfReferences_ForReadSize)
CountOfReferences_ForReadSize_Run();
}
}
if (Config->Event_CallBackFunction_IsSet())
{
Config->Demux_EventWasSent=true;
return;
}
}
Sequences[Sequences_Current]->Resources_Current++;
if (Sequences[Sequences_Current]->Resources_Current<Sequences[Sequences_Current]->Resources.size() && Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI)
Sequences[Sequences_Current]->Resources[Sequences[Sequences_Current]->Resources_Current]->MI->Open_Buffer_Seek(0, 0, (int64u)-1);
}
if (CountOfReferencesToParse)
CountOfReferencesToParse--;
#endif //MEDIAINFO_DEMUX
}
#endif //MEDIAINFO_EVENTS && MEDIAINFO_NEXTPACKET
ParseReference_Finalize();
if (!Config->File_KeepInfo_Get())
{
Sequences[Sequences_Current]->StreamKind=Stream_Max;
Sequences[Sequences_Current]->StreamPos=(size_t)-1;
Sequences[Sequences_Current]->State=10000;
if (Sequences[Sequences_Current]->Resources.empty())
Sequences[Sequences_Current]->FileSize=Sequences[Sequences_Current]->MI->Config.File_Size;
else if (Sequences[Sequences_Current]->FileSize==(int64u)-1)
{
Sequences[Sequences_Current]->FileSize=0;
for (size_t Pos=0; Pos<Sequences[Sequences_Current]->Resources.size(); Pos++)
for (size_t Resource_FileNames_Pos=0; Resource_FileNames_Pos<Sequences[Sequences_Current]->Resources[Pos]->FileNames.size(); Resource_FileNames_Pos++)
Sequences[Sequences_Current]->FileSize+=File::Size_Get(Sequences[Sequences_Current]->Resources[Pos]->FileNames[Resource_FileNames_Pos]);
}
delete Sequences[Sequences_Current]->MI; Sequences[Sequences_Current]->MI=NULL;
}
}
}
//---------------------------------------------------------------------------
void File__ReferenceFilesHelper::ParseReference_Finalize ()
{
//Removing wrong initial value
if (Sequences[Sequences_Current]->MI->Count_Get(Sequences[Sequences_Current]->StreamKind)==0 && Sequences[Sequences_Current]->StreamPos!=(size_t)-1
&& Sequences[Sequences_Current]->MI->Count_Get(Stream_Video)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Audio)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Image)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Text)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Other))
{
MI->Stream_Erase(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos);
for (sequences::iterator ReferenceTemp=Sequences.begin(); ReferenceTemp!=Sequences.end(); ++ReferenceTemp)
if ((*ReferenceTemp)->StreamKind==Sequences[Sequences_Current]->StreamKind && (*ReferenceTemp)->StreamPos!=(size_t)-1 && (*ReferenceTemp)->StreamPos>Sequences[Sequences_Current]->StreamPos)
(*ReferenceTemp)->StreamPos--;
Sequences[Sequences_Current]->StreamPos=(size_t)-1;
}
bool StreamFound=false;
for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
{
Ztring Title_Temp;
for (size_t StreamPos=0; StreamPos<Sequences[Sequences_Current]->MI->Count_Get((stream_t)StreamKind); StreamPos++)
{
StreamKind_Last=(stream_t)StreamKind;
if (Sequences[Sequences_Current]->StreamPos!=(size_t)-1 && StreamKind_Last==Sequences[Sequences_Current]->StreamKind && StreamPos==0)
{
StreamPos_To=Sequences[Sequences_Current]->StreamPos;
StreamFound=true;
Title_Temp=MI->Retrieve_Const(StreamKind_Last, StreamPos_To-StreamPos, "Title");
}
else
{
size_t ToInsert=(size_t)-1;
for (sequences::iterator ReferencePos=Sequences.begin(); ReferencePos!=Sequences.end(); ++ReferencePos)
if ((*ReferencePos)->StreamKind==StreamKind_Last && Sequences[Sequences_Current]->StreamID<(*ReferencePos)->StreamID)
{
ToInsert=(*ReferencePos)->StreamPos;
break;
}
StreamPos_To=Stream_Prepare((stream_t)StreamKind, ToInsert);
if (StreamPos)
MI->Fill(StreamKind_Last, StreamPos_To, "Title", Title_Temp);
}
StreamPos_From=StreamPos;
ParseReference_Finalize_PerStream();
}
}
if (!StreamFound && Sequences[Sequences_Current]->StreamKind!=Stream_Max && Sequences[Sequences_Current]->StreamPos!=(size_t)-1 && Sequences[Sequences_Current]->MI->Info)
{
Ztring MuxingMode=MI->Retrieve(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "MuxingMode");
if (!MuxingMode.empty())
MuxingMode.insert(0, __T(" / "));
MI->Fill(Sequences[Sequences_Current]->StreamKind, Sequences[Sequences_Current]->StreamPos, "MuxingMode", Sequences[Sequences_Current]->MI->Info->Get(Stream_General, 0, General_Format)+MuxingMode, true);
}
}
//---------------------------------------------------------------------------
void File__ReferenceFilesHelper::ParseReference_Finalize_PerStream ()
{
//Hacks - Before
Ztring CodecID=MI->Retrieve(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_CodecID));
Ztring ID_Base;
if (HasMainFile_Filled && !Sequences[Sequences_Current]->IsMain)
{
ID_Base=Ztring::ToZtring(ID_Max+Sequences[Sequences_Current]->StreamID-1);
MI->Fill(StreamKind_Last, StreamPos_To, "SideCar_FilePos", Sequences[Sequences_Current]->StreamID-1);
MI->Fill_SetOptions(StreamKind_Last, StreamPos_To, "SideCar_FilePos", "N NT");
}
else if (Sequences[Sequences_Current]->StreamID!=(int64u)-1)
ID_Base=Ztring::ToZtring(Sequences[Sequences_Current]->StreamID);
Ztring ID=ID_Base;
Ztring ID_String=ID_Base;
Ztring MenuID;
Ztring MenuID_String;
if (!HasMainFile_Filled && Sequences[Sequences_Current]->IsMain)
{
MI->Fill(Stream_General, 0, General_Format, Sequences[Sequences_Current]->MI->Get(Stream_General, 0, General_Format) , true);
MI->Fill(Stream_General, 0, General_CompleteName, Sequences[Sequences_Current]->MI->Get(Stream_General, 0, General_CompleteName) , true);
MI->Fill(Stream_General, 0, General_FileExtension, Sequences[Sequences_Current]->MI->Get(Stream_General, 0, General_FileExtension) , true);
HasMainFile=true;
HasMainFile_Filled=true;
}
if (Sequences[Sequences_Current]->IsMain)
{
int64u ID_New=Sequences[Sequences_Current]->MI->Get(StreamKind_Last, StreamPos_From, General_ID).To_int64u();
if (ID_Max<ID_New)
ID_Max=ID_New;
}
MI->Clear(StreamKind_Last, StreamPos_To, General_ID);
MI->Merge(*Sequences[Sequences_Current]->MI->Info, StreamKind_Last, StreamPos_From, StreamPos_To);
if (!Sequences[Sequences_Current]->Resources.empty())
{
MI->Clear(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_BitRate));
MI->Clear(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_Duration));
MI->Clear(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_FrameCount));
MI->Clear(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_StreamSize));
float64 BitRate_Before=0;
int64u Duration_Temp=0;
int64u FrameCount_Temp=0;
int64u StreamSize_Temp=0;
int64u FileSize_Temp=0;
#if MEDIAINFO_ADVANCED
std::vector<string> Format_Profiles_FromStream, Format_Profiles_FromContainer, Format_Profiles_FromPlaylist;
#endif //MEDIAINFO_ADVANCED
for (size_t Pos=0; Pos<Sequences[Sequences_Current]->Resources.size(); Pos++)
{
MediaInfo_Internal MI2;
MI2.Option(__T("File_KeepInfo"), __T("1"));
Ztring ParseSpeed_Save=MI2.Option(__T("ParseSpeed_Get"), __T(""));
Ztring Demux_Save=MI2.Option(__T("Demux_Get"), __T(""));
MI2.Option(__T("ParseSpeed"), __T("0"));
MI2.Option(__T("Demux"), Ztring());
MI2.Config.File_IgnoreEditsBefore=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore;
if (Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter==(int64u)-1 && Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration!=(int64u)-1)
MI2.Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsBefore+Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfterDuration;
else
MI2.Config.File_IgnoreEditsAfter=Sequences[Sequences_Current]->Resources[Pos]->IgnoreEditsAfter;
MI2.Config.File_EditRate=Sequences[Sequences_Current]->Resources[Pos]->EditRate;
Sequences[Sequences_Current]->Resources[Pos]->FileNames.Separator_Set(0, ",");
size_t MiOpenResult=MI2.Open(Sequences[Sequences_Current]->Resources[Pos]->FileNames.Read());
MI2.Option(__T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
MI2.Option(__T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
if (MiOpenResult)
{
BitRate_Before=MI2.Get(StreamKind_Last, StreamPos_From, MI->Fill_Parameter(StreamKind_Last, Generic_BitRate)).To_float64();
Ztring Duration_Temp2=MI2.Get(StreamKind_Last, StreamPos_From, MI->Fill_Parameter(StreamKind_Last, Generic_Duration));
if (!Duration_Temp2.empty() && Duration_Temp!=(int64u)-1)
Duration_Temp+=Duration_Temp2.To_int64u();
else
Duration_Temp=(int64u)-1;
Ztring FrameCount_Temp2=MI2.Get(StreamKind_Last, StreamPos_From, MI->Fill_Parameter(StreamKind_Last, Generic_FrameCount));
if (!FrameCount_Temp2.empty() && FrameCount_Temp!=(int64u)-1)
FrameCount_Temp+=FrameCount_Temp2.To_int64u();
else
FrameCount_Temp=(int64u)-1;
Ztring StreamSize_Temp2=MI2.Get(StreamKind_Last, StreamPos_From, MI->Fill_Parameter(StreamKind_Last, Generic_StreamSize));
if (!StreamSize_Temp2.empty() && StreamSize_Temp!=(int64u)-1)
StreamSize_Temp+=StreamSize_Temp2.To_int64u();
else
StreamSize_Temp=(int64u)-1;
Ztring FileSize_Temp2=MI2.Get(Stream_General, 0, General_FileSize);
if (!FileSize_Temp2.empty() && FileSize_Temp!=(int64u)-1)
FileSize_Temp+=FileSize_Temp2.To_int64u();
else
FileSize_Temp=(int64u)-1;
}
else
{
Duration_Temp=(int64u)-1;
FrameCount_Temp=(int64u)-1;
StreamSize_Temp=(int64u)-1;
FileSize_Temp=(int64u)-1;
break;
}
#if MEDIAINFO_ADVANCED
//Profile
map<string, string>::iterator MetadataFromPlaylist_Item=Sequences[Sequences_Current]->Resources[Pos]->MetadataFromPlaylist.find("Format_Profile");
if (MetadataFromPlaylist_Item!=Sequences[Sequences_Current]->Resources[Pos]->MetadataFromPlaylist.end())
Format_Profiles_FromPlaylist.push_back(MetadataFromPlaylist_Item->second);
else
Format_Profiles_FromPlaylist.push_back(string());
Format_Profiles_FromContainer.push_back(MI2.Get(StreamKind_Last, StreamPos_From, __T("Format_Profile_FromContainer")).To_UTF8());
Format_Profiles_FromStream.push_back(MI2.Get(StreamKind_Last, StreamPos_From, MI->Fill_Parameter(StreamKind_Last, Generic_Format_Profile)).To_UTF8());
#endif //MEDIAINFO_ADVANCED
}
#if MEDIAINFO_ADVANCED
//Test of coherency between Playlist and Stream
//Test of same values for all resources
bool Format_Profile_NotSame=false;
bool Format_Profile_CoherencyIssue=false;
bool Format_Profile_FromContainer_IsPresent=false;
for (size_t Pos=0; Pos<Format_Profiles_FromStream.size(); Pos++)
{
if (Format_Profiles_FromStream[Pos]!=Format_Profiles_FromStream[0])
Format_Profile_NotSame=true;
if (!Format_Profiles_FromPlaylist[Pos].empty() && Format_Profiles_FromStream[Pos]!=Format_Profiles_FromPlaylist[Pos])
Format_Profile_CoherencyIssue=true;
if (!Format_Profiles_FromContainer[Pos].empty())
Format_Profile_FromContainer_IsPresent=true;
}
if (Format_Profile_NotSame)
{
MI->Clear(StreamKind_Last, StreamPos_To, "Format_Profile");
for (size_t Pos=0; Pos<Format_Profiles_FromStream.size(); Pos++)
MI->Fill(StreamKind_Last, StreamPos_To, "Format_Profile", Format_Profiles_FromStream[Pos]);
MI->Fill(StreamKind_Last, StreamPos_To, "Format_Profile_EssencesMismatch", "Yes");
}
if (Format_Profile_CoherencyIssue)
{
MI->Clear(StreamKind_Last, StreamPos_To, "Format_Profile_FromStream");
if (Format_Profile_FromContainer_IsPresent)
MI->Clear(StreamKind_Last, StreamPos_To, "Format_Profile_FromContainer");
MI->Clear(StreamKind_Last, StreamPos_To, "Format_Profile_FromPlaylist");
for (size_t Pos=0; Pos<Format_Profiles_FromStream.size(); Pos++)
{
MI->Fill(StreamKind_Last, StreamPos_To, "Format_Profile_FromStream", Format_Profiles_FromStream[Pos]);
if (Format_Profile_FromContainer_IsPresent)
MI->Fill(StreamKind_Last, StreamPos_To, "Format_Profile_FromContainer", Format_Profiles_FromContainer[Pos].empty()?Format_Profiles_FromStream[Pos]:Format_Profiles_FromContainer[Pos]);
MI->Fill(StreamKind_Last, StreamPos_To, "Format_Profile_FromPlaylist", Format_Profiles_FromPlaylist[Pos]);
}
}
else if (Format_Profile_FromContainer_IsPresent)
{
MI->Clear(StreamKind_Last, StreamPos_To, "Format_Profile_FromStream");
MI->Clear(StreamKind_Last, StreamPos_To, "Format_Profile_FromContainer");
for (size_t Pos=0; Pos<Format_Profiles_FromStream.size(); Pos++)
{
MI->Fill(StreamKind_Last, StreamPos_To, "Format_Profile_FromStream", Format_Profiles_FromStream[Pos]);
MI->Fill(StreamKind_Last, StreamPos_To, "Format_Profile_FromContainer", Format_Profiles_FromContainer[Pos].empty()?Format_Profiles_FromStream[Pos]:Format_Profiles_FromContainer[Pos]);
}
}
#endif //MEDIAINFO_ADVANCED
if (Duration_Temp!=(int64u)-1)
MI->Fill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_Duration), Duration_Temp, 10, true);
if (FrameCount_Temp!=(int64u)-1)
MI->Fill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_FrameCount), FrameCount_Temp, 10, true);
if (StreamSize_Temp!=(int64u)-1)
MI->Fill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_StreamSize), StreamSize_Temp, 10, true);
if (FileSize_Temp!=(int64u)-1)
Sequences[Sequences_Current]->FileSize=FileSize_Temp;
if (BitRate_Before && Duration_Temp)
{
float64 BitRate_After=((float64)StreamSize_Temp)*8000/Duration_Temp;
if (BitRate_Before>BitRate_After*0.999 && BitRate_Before<BitRate_After*1.001)
MI->Fill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_BitRate), BitRate_Before, 0, true); //In case of similar bitrate, there is great chance hte compute bit rate is different due to aproximation errors only, using the previous one. TODO: find a better way to detect it
}
}
//Frame rate if available from container
if (StreamKind_Last==Stream_Video && Sequences[Sequences_Current]->FrameRate)
MI->Fill(Stream_Video, StreamPos_To, Video_FrameRate, Sequences[Sequences_Current]->FrameRate, 3 , true);
//Hacks - After
if (!Sequences[Sequences_Current]->IsMain && CodecID!=MI->Retrieve(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_CodecID)))
{
if (!CodecID.empty())
CodecID+=__T(" / ");
CodecID+=MI->Retrieve(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_CodecID));
MI->Fill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_CodecID), CodecID, true);
}
if (!Sequences[Sequences_Current]->IsMain && Sequences[Sequences_Current]->MI->Count_Get(Stream_Video)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Audio)>1 && Sequences[Sequences_Current]->MI->Get(Stream_Video, 0, Video_Format)!=__T("DV"))
{
if (StreamKind_Last==Stream_Menu)
{
ZtringList List; List.Separator_Set(0, __T(" / ")); List.Write(MI->Retrieve(StreamKind_Last, StreamPos_To, "List"));
ZtringList List_String; List_String.Separator_Set(0, __T(" / ")); List_String.Write(MI->Retrieve(StreamKind_Last, StreamPos_To, "List/String"));
if (!ID_Base.empty())
for (size_t Pos=0; Pos<List.size(); Pos++)
{
List[Pos].insert(0, ID_Base+__T("-"));
List_String[Pos].insert(0, ID_Base+__T("-"));
}
MI->Fill(Stream_Menu, StreamPos_To, Menu_List, List.Read(), true);
MI->Fill(Stream_Menu, StreamPos_To, Menu_List_String, List_String.Read(), true);
}
else if (Sequences.size()>1 && Sequences[Sequences_Current]->MI->Count_Get(Stream_Menu)==0)
{
if (Sequences[Sequences_Current]->MenuPos==(size_t)-1)
{
Sequences[Sequences_Current]->MenuPos=MI->Stream_Prepare(Stream_Menu);
MI->Fill(Stream_Menu, Sequences[Sequences_Current]->MenuPos, General_ID, ID_Base);
MI->Fill(Stream_Menu, Sequences[Sequences_Current]->MenuPos, "Source", Sequences[Sequences_Current]->Source);
}
Ztring List=Sequences[Sequences_Current]->MI->Get(StreamKind_Last, StreamPos_From, General_ID);
Ztring List_String=Sequences[Sequences_Current]->MI->Get(StreamKind_Last, StreamPos_From, General_ID_String);
if (!ID_Base.empty())
{
List.insert(0, ID_Base+__T("-"));
List_String.insert(0, ID_Base+__T("-"));
}
MI->Fill(Stream_Menu, Sequences[Sequences_Current]->MenuPos, Menu_List, List);
MI->Fill(Stream_Menu, Sequences[Sequences_Current]->MenuPos, Menu_List_String, List_String);
}
}
if (!Sequences[Sequences_Current]->IsMain && (ContainerHasNoId || !Config->File_ID_OnlyRoot_Get() || Sequences[Sequences_Current]->MI->Get(Stream_General, 0, General_Format)==__T("SCC") || Sequences[Sequences_Current]->MI->Count_Get(Stream_Video)+Sequences[Sequences_Current]->MI->Count_Get(Stream_Audio)>1) && !MI->Retrieve(StreamKind_Last, StreamPos_To, General_ID).empty())
{
if (!ID.empty())
ID+=__T('-');
ID+=MI->Retrieve(StreamKind_Last, StreamPos_To, General_ID);
if (!ID_String.empty())
ID_String+=__T('-');
ID_String+=MI->Retrieve(StreamKind_Last, StreamPos_To, General_ID_String);
if (!MI->Retrieve(StreamKind_Last, StreamPos_To, "MenuID").empty())
{
if (!ID_Base.empty())
MenuID=ID_Base+__T('-');
MenuID+=MI->Retrieve(StreamKind_Last, StreamPos_To, "MenuID");
if (!ID_Base.empty())
MenuID_String=ID_Base+__T('-');
MenuID_String+=MI->Retrieve(StreamKind_Last, StreamPos_To, "MenuID/String");
}
else if (Sequences[Sequences_Current]->MenuPos!=(size_t)-1)
{
MenuID=ID_Base;
MenuID_String=ID_Base;
}
}
if (!Sequences[Sequences_Current]->IsMain)
{
MI->Fill(StreamKind_Last, StreamPos_To, General_ID, ID, true);
MI->Fill(StreamKind_Last, StreamPos_To, General_ID_String, ID_String, true);
MI->Fill(StreamKind_Last, StreamPos_To, "MenuID", MenuID, true);
MI->Fill(StreamKind_Last, StreamPos_To, "MenuID/String", MenuID_String, true);
if (!MI->Retrieve(StreamKind_Last, StreamPos_To, "Source").empty())
{
if (MI->Retrieve(StreamKind_Last, StreamPos_To, "Source_Original").empty() && Sequences[Sequences_Current]->Source!=MI->Retrieve(StreamKind_Last, StreamPos_To, "Source")) // TODO: better handling
{
MI->Fill(StreamKind_Last, StreamPos_To, "Source_Original", MI->Retrieve(StreamKind_Last, StreamPos_To, "Source"));
MI->Fill(StreamKind_Last, StreamPos_To, "Source_Original_Kind", MI->Retrieve(StreamKind_Last, StreamPos_To, "Source_Kind"));
MI->Fill(StreamKind_Last, StreamPos_To, "Source_Original_Info", MI->Retrieve(StreamKind_Last, StreamPos_To, "Source_Info"));
}
MI->Clear(StreamKind_Last, StreamPos_To, "Source");
MI->Clear(StreamKind_Last, StreamPos_To, "Source_Kind");
MI->Clear(StreamKind_Last, StreamPos_To, "Source_Info");
}
MI->Fill(StreamKind_Last, StreamPos_To, "Source", Sequences[Sequences_Current]->Source);
}
for (std::map<string, Ztring>::iterator Info=Sequences[Sequences_Current]->Infos.begin(); Info!=Sequences[Sequences_Current]->Infos.end(); ++Info)
if (MI->Retrieve(StreamKind_Last, StreamPos_To, Info->first.c_str()).empty())
MI->Fill(StreamKind_Last, StreamPos_To, Info->first.c_str(), Info->second);
//Others
if (!Sequences[Sequences_Current]->IsMain && Sequences[Sequences_Current]->MI->Info && MI->Retrieve(StreamKind_Last, StreamPos_To, Sequences[Sequences_Current]->MI->Info->Fill_Parameter(StreamKind_Last, Generic_Format))!=Sequences[Sequences_Current]->MI->Info->Get(Stream_General, 0, General_Format))
{
Ztring MuxingMode=MI->Retrieve(StreamKind_Last, StreamPos_To, "MuxingMode");
if (!MuxingMode.empty())
MuxingMode.insert(0, __T(" / "));
MI->Fill(StreamKind_Last, StreamPos_To, "MuxingMode", Sequences[Sequences_Current]->MI->Info->Get(Stream_General, 0, General_Format)+MuxingMode, true);
}
//Lists
#if MEDIAINFO_ADVANCED || MEDIAINFO_HASH
if (!Sequences[Sequences_Current]->List_Compute_Done && (Sequences[Sequences_Current]->MI->Count_Get(Stream_Menu)==0 || StreamKind_Last==Stream_Menu))
{
List_Compute();
Sequences[Sequences_Current]->List_Compute_Done=true;
}
#endif //MEDIAINFO_ADVANCED || MEDIAINFO_HASH
}
//---------------------------------------------------------------------------
#if MEDIAINFO_ADVANCED || MEDIAINFO_HASH
void File__ReferenceFilesHelper::List_Compute()
{
stream_t StreamKind=Sequences.size()>1?StreamKind_Last:Stream_General;
size_t StreamPos=Sequences.size()>1?StreamPos_To:0;
stream_t StreamKind_Target=Sequences[Sequences_Current]->MenuPos==(size_t)-1?StreamKind:Stream_Menu;
size_t StreamPos_Target=Sequences[Sequences_Current]->MenuPos==(size_t)-1?StreamPos:Sequences[Sequences_Current]->MenuPos;
//Hash
#if MEDIAINFO_HASH
if (!HasMainFile && Config->File_Hash_Get().to_ulong())
{
for (size_t Hash_Pos=0; Hash_Pos<HashWrapper::HashFunction_Max; ++Hash_Pos)
{
string Hash_Name(HashWrapper::Name((HashWrapper::HashFunction)Hash_Pos));
Ztring Hash_NameU; Hash_NameU.From_UTF8(Hash_Name.c_str());
if (!Sequences[Sequences_Current]->MI->Get(Stream_General, 0, Hash_NameU+__T("_Generated")).empty())
{
if (Sequences[Sequences_Current]->MI->Config.File_Names.size()==1)
{
if (MI->Retrieve(StreamKind_Target, StreamPos_Target, "Source").empty())
{
Ztring SourcePath;
Ztring SourceName=MI->Retrieve(Stream_General, 0, General_CompleteName);
if (SourceName.find(__T("://"))==string::npos)
SourcePath=ZenLib::FileName::Path_Get(SourceName);
else
{
size_t Pos_Path=SourceName.find_last_of('/');
if (Pos_Path!=Ztring::npos)
SourcePath=SourceName.substr(0, Pos_Path);
}
size_t SourcePath_Size=SourcePath.size()+1; //Path size + path separator size
Ztring Temp=Sequences[Sequences_Current]->MI->Config.File_Names[0];
if (!Config->File_IsReferenced_Get())
Temp.erase(0, SourcePath_Size);
MI->Fill(StreamKind_Target, StreamPos_Target, "Source", Temp);
}
MI->Fill(StreamKind_Target, StreamPos_Target, ("Source_"+Hash_Name+"_Generated").c_str(), Sequences[Sequences_Current]->MI->Get(Stream_General, 0, Hash_NameU+__T("_Generated")));
MI->Fill_SetOptions(StreamKind_Target, StreamPos_Target, ("Source_"+Hash_Name+"_Generated").c_str(), "N NT");
}
MI->Fill(StreamKind_Target, StreamPos_Target, ("Source_List_"+Hash_Name+"_Generated").c_str(), Sequences[Sequences_Current]->MI->Get(Stream_General, 0, Hash_NameU+__T("_Generated")));
MI->Fill_SetOptions(StreamKind_Target, StreamPos_Target, ("Source_List_"+Hash_Name+"_Generated").c_str(), "N NT");
}
if (!Sequences[Sequences_Current]->MI->Get(Stream_General, 0, __T("Source_List_")+Hash_NameU+__T("_Generated")).empty())
{
MI->Fill(StreamKind_Target, StreamPos_Target, ("Source_List_"+Hash_Name+"_Generated").c_str(), Sequences[Sequences_Current]->MI->Get(Stream_General, 0, __T("Source_List_")+Hash_NameU+__T("_Generated")));
MI->Fill_SetOptions(StreamKind_Target, StreamPos_Target, ("Source_List_"+Hash_Name+"_Generated").c_str(), "N NT");
}
else if (!Sequences[Sequences_Current]->MI->Get(StreamKind, StreamPos, __T("Source_List_")+Hash_NameU+__T("_Generated")).empty())
{
MI->Fill(StreamKind_Target, StreamPos_Target, ("Source_List_"+Hash_Name+"_Generated").c_str(), Sequences[Sequences_Current]->MI->Get(StreamKind, StreamPos, __T("Source_List_")+Hash_NameU+__T("_Generated")));
MI->Fill_SetOptions(StreamKind_Target, StreamPos_Target, ("Source_List_"+Hash_Name+"_Generated").c_str(), "N NT");
}
}
}
#endif //MEDIAINFO_HASH
//Source_List
#if MEDIAINFO_ADVANCED
if (!HasMainFile && Config->File_Source_List_Get())
{
Ztring SourcePath;
Ztring SourceName=MI->Retrieve(Stream_General, 0, General_CompleteName);
if (SourceName.find(__T("://"))==string::npos)
SourcePath=ZenLib::FileName::Path_Get(SourceName);
else
{
size_t Pos_Path=SourceName.find_last_of('/');
if (Pos_Path!=Ztring::npos)
SourcePath=SourceName.substr(0, Pos_Path);
}
size_t SourcePath_Size=SourcePath.size()+1; //Path size + path separator size
for (size_t Pos=0; Pos<Sequences[Sequences_Current]->FileNames.size(); Pos++)
{
Ztring Temp=Sequences[Sequences_Current]->FileNames[Pos];
if (!Config->File_IsReferenced_Get())
Temp.erase(0, SourcePath_Size);
MI->Fill(StreamKind_Target, StreamPos_Target, "Source_List", Temp);
}
if (!Sequences[Sequences_Current]->MI->Get(Stream_General, 0, __T("Source_List")).empty())
{
ZtringList List;
List.Separator_Set(0, __T(" / "));
List.Write(Sequences[Sequences_Current]->MI->Get(Stream_General, 0, __T("Source_List")));
for (size_t Pos=0; Pos<List.size(); Pos++)
{
Ztring Temp=List[Pos];
if (!Config->File_IsReferenced_Get())
Temp.erase(0, SourcePath_Size);
MI->Fill(StreamKind_Target, StreamPos_Target, "Source_List", Temp);
}
}
MI->Fill_SetOptions(StreamKind_Target, StreamPos_Target, "Source_List", "N NT");
}
#endif //MEDIAINFO_ADVANCED
}
#endif //MEDIAINFO_ADVANCED || MEDIAINFO_HASH
//---------------------------------------------------------------------------
MediaInfo_Internal* File__ReferenceFilesHelper::MI_Create()
{
//Configuration
MediaInfo_Internal* MI_Temp=new MediaInfo_Internal();
for (std::map<string, Ztring>::iterator Config_Item=Sequences[Sequences_Current]->Config.begin(); Config_Item!=Sequences[Sequences_Current]->Config.end(); ++Config_Item)
MI_Temp->Option(Ztring().From_UTF8(Config_Item->first.c_str()), Config_Item->second);
MI_Temp->Option(__T("File_IsReferenced"), __T("1"));
MI_Temp->Option(__T("File_FileNameFormat"), __T("CSV"));
MI_Temp->Option(__T("File_KeepInfo"), __T("1"));
MI_Temp->Option(__T("File_ID_OnlyRoot"), Config->File_ID_OnlyRoot_Get()?__T("1"):__T("0"));
#if defined(MEDIAINFO_DVDIF_YES)
MI_Temp->Option(__T("File_DvDif_DisableAudioIfIsInContainer"), Config->File_DvDif_DisableAudioIfIsInContainer_Get()?__T("1"):__T("0"));
#endif
if ((Sequences.size()>1 || Config->File_MpegTs_ForceMenu_Get()) && !Sequences[Sequences_Current]->IsMain && !HasMainFile)
MI_Temp->Option(__T("File_MpegTs_ForceMenu"), __T("1"));
#if MEDIAINFO_AES
MI_Temp->Option(__T("File_Encryption_Format"), MI->Retrieve(Stream_General, 0, "Encryption_Format"));
MI_Temp->Option(__T("File_Encryption_Key"), Ztring().From_UTF8(Base64::encode(MI->Config->Encryption_Key_Get())));
MI_Temp->Option(__T("File_Encryption_Method"), MI->Retrieve(Stream_General, 0, "Encryption_Method"));
MI_Temp->Option(__T("File_Encryption_Mode"), MI->Retrieve(Stream_General, 0, "Encryption_Mode"));
MI_Temp->Option(__T("File_Encryption_Padding"), MI->Retrieve(Stream_General, 0, "Encryption_Padding"));
MI_Temp->Option(__T("File_Encryption_InitializationVector"), MI->Retrieve(Stream_General, 0, "Encryption_InitializationVector"));
#endif //AES
#if MEDIAINFO_NEXTPACKET
if (Config->NextPacket_Get())
MI_Temp->Option(__T("File_NextPacket"), __T("1"));
if (Config->File_Demux_Interleave_Get())
MI_Temp->Option(__T("File_Demux_Interleave"), __T("1"));
#endif //MEDIAINFO_NEXTPACKET
#if MEDIAINFO_ADVANCED
if (Config->File_IgnoreSequenceFileSize_Get())
MI_Temp->Option(__T("File_IgnoreSequenceFileSize"), __T("1"));
if (Config->File_IgnoreSequenceFilesCount_Get())
MI_Temp->Option(__T("File_IgnoreSequenceFilesCount"), __T("1"));
if (Config->File_Source_List_Get())
MI_Temp->Option(__T("File_Source_List"), __T("1"));
#endif //MEDIAINFO_ADVANCED
#if MEDIAINFO_HASH
if (Config->File_Hash_Get().to_ulong())
MI_Temp->Option(__T("File_Hash"), Config->Option(__T("File_Hash_Get"), Ztring()));
#endif //MEDIAINFO_HASH
#if MEDIAINFO_EVENTS
MI_Temp->Config.Config_PerPackage=Config->Config_PerPackage;
if (Config->Event_CallBackFunction_IsSet())
{
MI_Temp->Option(__T("File_Event_CallBackFunction"), Config->Event_CallBackFunction_Get());
MI_Temp->Config.Config_PerPackage->Event_CallBackFunction_Set(Config->Event_CallBackFunction_Get());
}
MI_Temp->Config.File_Names_RootDirectory=FileName(MI->File_Name).Path_Get();
if (!Config->File_TestContinuousFileNames_Get() || Sequences[Sequences_Current]->FileNames.size()>1)
MI_Temp->Option(__T("File_TestContinuousFileNames"), __T("0"));
if (!Config->File_TestDirectory_Get())
MI_Temp->Option(__T("File_TestDirectory"), __T("0"));
ZtringListList SubFile_IDs;
if (Sequences[Sequences_Current]->IsMain)
HasMainFile=true;
if (HasMainFile && !Sequences[Sequences_Current]->IsMain)
{
ZtringList ID;
ID.push_back(Ztring::ToZtring((((int64u)MediaInfo_Parser_SideCar)<<56)|(Sequences[Sequences_Current]->StreamID-1)));
ID.push_back(Ztring::ToZtring(16));
ID.push_back(Ztring::ToZtring(MediaInfo_Parser_SideCar));
SubFile_IDs.push_back(ID);
}
else if (!Sequences[Sequences_Current]->IsMain)
for (size_t Pos=0; Pos<MI->StreamIDs_Size; Pos++)
{
ZtringList ID;
if (MI->StreamIDs_Width[Pos]==0)
ID.push_back(Ztring::ToZtring(-1));
else if (Pos+1==MI->StreamIDs_Size)
ID.push_back(Ztring::ToZtring(Sequences[Sequences_Current]->StreamID));
else
ID.push_back(Ztring::ToZtring(MI->StreamIDs[Pos]));
ID.push_back(Ztring::ToZtring(MI->StreamIDs_Width[Pos]));
ID.push_back(Ztring::ToZtring(MI->ParserIDs[Pos]));
SubFile_IDs.push_back(ID);
}
if (!SubFile_IDs.empty())
{
SubFile_IDs.Separator_Set(0, EOL);
SubFile_IDs.Separator_Set(1, __T(","));
MI_Temp->Option(__T("File_SubFile_IDs_Set"), SubFile_IDs.Read());
}
#endif //MEDIAINFO_EVENTS
#if MEDIAINFO_DEMUX
if (Config->Demux_Unpacketize_Get())
MI_Temp->Option(__T("File_Demux_Unpacketize"), __T("1"));
if (Config->Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get())
MI_Temp->Option(__T("File_Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10"), __T("1"));
if (Config->Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get())
MI_Temp->Option(__T("File_Demux_Hevc_Transcode_Iso14496_15_to_AnnexB"), __T("1"));
if (FrameRate)
MI_Temp->Option(__T("File_Demux_Rate"), Ztring::ToZtring(FrameRate));
else if (!Sequences[Sequences_Current]->Resources.empty() && Sequences[Sequences_Current]->Resources[0]->EditRate) //TODO: per Pos
MI_Temp->Option(__T("File_Demux_Rate"), Ztring::ToZtring(Sequences[Sequences_Current]->Resources[0]->EditRate));
switch (Config->Demux_InitData_Get())
{
case 0 : MI_Temp->Option(__T("File_Demux_InitData"), __T("Event")); break;
case 1 : MI_Temp->Option(__T("File_Demux_InitData"), __T("Field")); break;
default: ;
}
#endif //MEDIAINFO_DEMUX
#if MEDIAINFO_IBIUSAGE
if (!Sequences[Sequences_Current]->IbiStream.Infos.empty())
{
ibi Ibi;
Ibi.Streams[(int64u)-1]=new ibi::stream(Sequences[Sequences_Current]->IbiStream);
//IBI Creation
File_Ibi_Creation IbiCreation(Ibi);
Ztring IbiText=IbiCreation.Finish();
if (!IbiText.empty())
MI_Temp->Option(__T("File_Ibi"), IbiText);
}
#endif //MEDIAINFO_IBIUSAGE
return MI_Temp;
}
//---------------------------------------------------------------------------
void File__ReferenceFilesHelper::Read_Buffer_Unsynched()
{
MI->Open_Buffer_Unsynch();
for (size_t Sequences_Pos=0; Sequences_Pos<Sequences.size(); Sequences_Pos++)
if (Sequences[Sequences_Pos]->MI)
Sequences[Sequences_Pos]->MI->Open_Buffer_Unsynch();
#if MEDIAINFO_DEMUX
DTS_Minimal=(int64u)-1;
Config->Demux_EventWasSent=true; //We want not try to read new data from the file
#endif //MEDIAINFO_DEMUX
#if MEDIAINFO_EVENTS
if (Config->Config_PerPackage)
Config->Config_PerPackage->Unsynch();
#endif //MEDIAINFO_EVENTS
}
//---------------------------------------------------------------------------
#if MEDIAINFO_SEEK
Ztring Duration_Milliseconds2String(int64u DurationM)
{
Ztring DurationS;
DurationS+=L'0'+(Char)(DurationM/(10*60*60*1000)); DurationM%=10*60*60*1000;
DurationS+=L'0'+(Char)(DurationM/( 60*60*1000)); DurationM%= 60*60*1000;
DurationS+=L':';
DurationS+=L'0'+(Char)(DurationM/( 10*60*1000)); DurationM%= 10*60*1000;
DurationS+=L'0'+(Char)(DurationM/( 60*1000)); DurationM%= 60*1000;
DurationS+=L':';
DurationS+=L'0'+(Char)(DurationM/( 10*1000)); DurationM%= 10*1000;
DurationS+=L'0'+(Char)(DurationM/( 1000)); DurationM%= 1000;
DurationS+=L'.';
DurationS+=L'0'+(Char)(DurationM/( 100)); DurationM%= 100;
DurationS+=L'0'+(Char)(DurationM/( 10)); DurationM%= 10;
DurationS+=L'0'+(Char)(DurationM);
return DurationS;
}
size_t File__ReferenceFilesHelper::Seek (size_t Method, int64u Value, int64u ID)
{
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
if (Sequences[Sequences_Current]->MI==NULL && !Sequences[Sequences_Current]->FileNames.empty())
ParseReference_Init();
//Parsing
switch (Method)
{
case 0 :
#if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
{
if (Value)
{
if (Value>MI->Config->File_Size)
return 2; //Invalid value
//Init
if (!Duration)
{
Ztring FileName;
if (HasMainFile)
for (size_t Sequences_Pos = 0; Sequences_Pos < Sequences.size(); Sequences_Pos++)
if (Sequences[Sequences_Pos]->IsMain && !Sequences[Sequences_Pos]->FileNames.empty())
FileName=Sequences[Sequences_Pos]->FileNames[0];
if (FileName.empty())
FileName=MI->File_Name;
MediaInfo_Internal MI2;
MI2.Option(__T("File_KeepInfo"), __T("1"));
Ztring ParseSpeed_Save=MI2.Option(__T("ParseSpeed_Get"), __T(""));
Ztring Demux_Save=MI2.Option(__T("Demux_Get"), __T(""));
MI2.Option(__T("ParseSpeed"), __T("0"));
MI2.Option(__T("Demux"), Ztring());
size_t MiOpenResult=MI2.Open(FileName);
MI2.Option(__T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
MI2.Option(__T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
if (!MiOpenResult)
return (size_t)-1;
Duration=MI2.Get(Stream_General, 0, General_Duration).To_float64()/1000;
}
//Time percentage
float64 DurationF=Duration;
DurationF*=Value;
DurationF/=MI->Config->File_Size;
DurationF*=1000;
int64u DurationM=(int64u)DurationF;
CountOfReferencesToParse=Sequences.size();
bool HasProblem=false;
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
{
if (Sequences[Sequences_Current]->MI)
{
Ztring Result;
if (Sequences[Sequences_Current]->Resources.size()<=1 || DurationM<Sequences[Sequences_Current]->Resources[1]->Demux_Offset_DTS)
{
Sequences[Sequences_Current]->Resources_Current=0;
int64u DurationFTemp=DurationF;
if (Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1)
DurationFTemp+=Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream/1000000; // From nanoseconds to milliseconds
Ztring DurationS=Duration_Milliseconds2String((int64u)DurationFTemp);
Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), DurationS);
}
else
{
size_t Resources_Current_Temp=1;
while (Resources_Current_Temp<Sequences[Sequences_Current]->Resources.size() && DurationM>=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_DTS)
Resources_Current_Temp++;
Resources_Current_Temp--;
int64u DurationFTemp=DurationF;
if (Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1)
DurationFTemp+=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream/1000000; // From nanoseconds to milliseconds
Ztring DurationS=Duration_Milliseconds2String((int64u)DurationFTemp);
Result=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Option(__T("File_Seek"), DurationS);
if (Result.empty())
Sequences[Sequences_Current]->Resources_Current=Resources_Current_Temp;
}
if (!Result.empty())
HasProblem=true;
}
Sequences[Sequences_Current]->Status.reset();
}
Sequences_Current=0;
Open_Buffer_Unsynch();
return HasProblem?(size_t)-1:1; //Not supported value if there is a problem (TODO: better info)
}
CountOfReferencesToParse=Sequences.size();
bool HasProblem=false;
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
{
if (Sequences[Sequences_Current]->MI)
{
Sequences[Sequences_Current]->Resources_Current=0;
Ztring Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), Ztring::ToZtring(Value));
if (!Result.empty())
HasProblem=true;
}
Sequences[Sequences_Current]->Status.reset();
}
Sequences_Current=0;
Open_Buffer_Unsynch();
return HasProblem?(size_t)-1:1; //Not supported value if there is a problem (TODO: better info)
}
#else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
return (size_t)-1; //Not supported
#endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
case 1 :
#if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
{
//Init
if (!Duration)
{
Ztring FileName;
if (HasMainFile)
for (size_t Sequences_Pos = 0; Sequences_Pos < Sequences.size(); Sequences_Pos++)
if (Sequences[Sequences_Pos]->IsMain && !Sequences[Sequences_Pos]->FileNames.empty())
FileName=Sequences[Sequences_Pos]->FileNames[0];
if (FileName.empty())
FileName=MI->File_Name;
MediaInfo_Internal MI2;
MI2.Option(__T("File_KeepInfo"), __T("1"));
Ztring ParseSpeed_Save=MI2.Option(__T("ParseSpeed_Get"), __T(""));
Ztring Demux_Save=MI2.Option(__T("Demux_Get"), __T(""));
MI2.Option(__T("ParseSpeed"), __T("0"));
MI2.Option(__T("Demux"), Ztring());
size_t MiOpenResult=MI2.Open(FileName);
MI2.Option(__T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
MI2.Option(__T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
if (!MiOpenResult)
return (size_t)-1;
Duration=MI2.Get(Stream_General, 0, General_Duration).To_float64()/1000;
}
//Time percentage
float64 DurationF=Duration;
DurationF*=Value;
DurationF/=10; // divided by 10000 for 0.01 percentage then x1000 for milliseconds
CountOfReferencesToParse=Sequences.size();
bool HasProblem=false;
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
{
if (Sequences[Sequences_Current]->MI)
{
Ztring Result;
if (Sequences[Sequences_Current]->Resources.size()<2 || Duration<Sequences[Sequences_Current]->Resources[1]->Demux_Offset_DTS)
{
Sequences[Sequences_Current]->Resources_Current=0;
int64u DurationFTemp=DurationF;
if (Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1)
DurationFTemp+=Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream/1000000; // From nanoseconds to milliseconds
Ztring DurationS=Duration_Milliseconds2String((int64u)DurationFTemp);
Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), DurationS);
}
else
{
size_t Resources_Current_Temp=1;
while (Resources_Current_Temp<Sequences[Sequences_Current]->Resources.size() && Duration>=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_DTS)
Resources_Current_Temp++;
Resources_Current_Temp--;
int64u DurationFTemp=DurationF;
if (Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1)
DurationFTemp+=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream/1000000; // From nanoseconds to milliseconds
Ztring DurationS=Duration_Milliseconds2String((int64u)DurationFTemp);
Result=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Option(__T("File_Seek"), DurationS);
if (Result.empty())
Sequences[Sequences_Current]->Resources_Current=Resources_Current_Temp;
}
if (!Result.empty())
HasProblem=true;
}
Sequences[Sequences_Current]->Status.reset();
}
Sequences_Current=0;
Open_Buffer_Unsynch();
return HasProblem?2:1; //Invalid value if there is a problem (TODO: better info)
}
#else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
return (size_t)-1; //Not supported
#endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
case 2 : //Timestamp
#if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
{
CountOfReferencesToParse=Sequences.size();
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
{
if (Sequences[Sequences_Current]->MI)
{
Ztring Result;
if (Sequences[Sequences_Current]->Resources.size()<2 || Value<Sequences[Sequences_Current]->Resources[1]->Demux_Offset_DTS)
{
Sequences[Sequences_Current]->Resources_Current=0;
int64u ValueTemp=Value;
if (Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1)
ValueTemp+=Sequences[Sequences_Current]->MI->Config.Demux_Offset_DTS_FromStream;
Ztring Time; Time.Duration_From_Milliseconds(ValueTemp/1000000);
Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), Time);
}
else
{
size_t Resources_Current_Temp=1;
while (Resources_Current_Temp<Sequences[Sequences_Current]->Resources.size() && Value>=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_DTS)
Resources_Current_Temp++;
Resources_Current_Temp--;
int64u ValueTemp=Value;
if (Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream!=(int64u)-1)
ValueTemp+=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Config.Demux_Offset_DTS_FromStream;
Ztring Time; Time.Duration_From_Milliseconds(ValueTemp/1000000);
Result=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Option(__T("File_Seek"), Time);
if (Result.empty())
Sequences[Sequences_Current]->Resources_Current=Resources_Current_Temp;
}
if (!Result.empty())
return 2; //Invalid value
}
else
{
//There was a problem, removing Sequence
Sequences.clear();
return Seek(Method, Value, ID);
}
Sequences[Sequences_Current]->Status.reset();
}
Sequences_Current=0;
Open_Buffer_Unsynch();
return 1;
}
#else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
return (size_t)-1; //Not supported
#endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
case 3 : //FrameNumber
#if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
CountOfReferencesToParse=Sequences.size();
for (Sequences_Current=0; Sequences_Current<Sequences.size(); Sequences_Current++)
{
if (Sequences[Sequences_Current]->MI)
{
Ztring Result;
if (Sequences[Sequences_Current]->Resources.size()<2 || Value<Sequences[Sequences_Current]->Resources[1]->Demux_Offset_Frame)
{
Sequences[Sequences_Current]->Resources_Current=0;
Result=Sequences[Sequences_Current]->MI->Option(__T("File_Seek"), __T("Frame=")+Ztring::ToZtring(Value));
}
else
{
size_t Resources_Current_Temp=1;
while (Resources_Current_Temp<Sequences[Sequences_Current]->Resources.size() && Value>=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_Frame)
Resources_Current_Temp++;
Resources_Current_Temp--;
Result=Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->MI->Option(__T("File_Seek"), __T("Frame=")+Ztring::ToZtring(Value-Sequences[Sequences_Current]->Resources[Resources_Current_Temp]->Demux_Offset_Frame));
if (Result.empty())
Sequences[Sequences_Current]->Resources_Current=Resources_Current_Temp;
}
if (!Result.empty())
return 2; //Invalid value
}
Sequences[Sequences_Current]->Status.reset();
}
Sequences_Current=0;
Open_Buffer_Unsynch();
return 1;
#else //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
return (size_t)-1; //Not supported
#endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
default : return 0;
}
}
#endif //MEDIAINFO_SEEK
//***************************************************************************
// Helpers
//***************************************************************************
//---------------------------------------------------------------------------
size_t File__ReferenceFilesHelper::Stream_Prepare (stream_t StreamKind, size_t StreamPos)
{
size_t StreamPos_Last=MI->Stream_Prepare(StreamKind, StreamPos);
for (sequences::iterator ReferencePos=Sequences.begin(); ReferencePos!=Sequences.end(); ++ReferencePos)
if ((*ReferencePos)->StreamKind==StreamKind && (*ReferencePos)->StreamPos>=StreamPos_Last)
if ((*ReferencePos)->StreamPos!=(size_t)-1)
(*ReferencePos)->StreamPos++;
return StreamPos_Last;
}
//---------------------------------------------------------------------------
void File__ReferenceFilesHelper::FileSize_Compute ()
{
if (MI->Config==NULL)
return;
MI->Config->File_Size=MI->File_Size;
for (size_t Sequences_Pos=0; Sequences_Pos<Sequences.size(); Sequences_Pos++)
{
if (Sequences[Sequences_Pos]->FileSize!=(int64u)-1)
MI->Config->File_Size+=Sequences[Sequences_Pos]->FileSize;
else if (Sequences[Sequences_Pos]->MI && Sequences[Sequences_Pos]->MI->Config.File_Size!=(int64u)-1)
{
MI->Config->File_Size+=Sequences[Sequences_Pos]->MI->Config.File_Size;
#if MEDIAINFO_ADVANCED
if (!Config->File_IgnoreSequenceFileSize_Get())
#endif //MEDIAINFO_ADVANCED
{
if (!Sequences[Sequences_Pos]->Resources.empty())
for (size_t Pos=1; Pos<Sequences[Sequences_Pos]->Resources.size(); Pos++)
for (size_t Resource_FileNames_Pos=0; Resource_FileNames_Pos<Sequences[Sequences_Pos]->Resources[Pos]->FileNames.size(); Resource_FileNames_Pos++)
MI->Config->File_Size+=File::Size_Get(Sequences[Sequences_Pos]->Resources[Pos]->FileNames[Resource_FileNames_Pos]);
}
}
else
{
#if MEDIAINFO_ADVANCED
if (!Config->File_IgnoreSequenceFileSize_Get())
#endif //MEDIAINFO_ADVANCED
{
if (Sequences[Sequences_Pos]->Resources.empty())
for (size_t Pos=0; Pos<Sequences[Sequences_Pos]->FileNames.size(); Pos++)
MI->Config->File_Size+=File::Size_Get(Sequences[Sequences_Pos]->FileNames[Pos]);
else
for (size_t Pos=0; Pos<Sequences[Sequences_Pos]->Resources.size(); Pos++)
for (size_t Resource_FileNames_Pos=0; Resource_FileNames_Pos<Sequences[Sequences_Pos]->Resources[Pos]->FileNames.size(); Resource_FileNames_Pos++)
MI->Config->File_Size+=File::Size_Get(Sequences[Sequences_Pos]->Resources[Pos]->FileNames[Resource_FileNames_Pos]);
}
}
}
}
//---------------------------------------------------------------------------
void File__ReferenceFilesHelper::CountOfReferences_ForReadSize_Run ()
{
//Computing read buffer size
int64u File_Size_Total=0;
int64u Buffer_Read_Size_Total=MI->Config->File_Buffer_Read_Size_Get();
for (sequences::iterator Reference_Temp=Sequences.begin(); Reference_Temp!=Sequences.end(); ++Reference_Temp)
if ((*Reference_Temp)->MI && (*Reference_Temp)->MI->Config.File_Size!=(int64u)-1)
File_Size_Total+=(*Reference_Temp)->MI->Config.File_Size;
if (File_Size_Total)
for (sequences::iterator Reference_Temp=Sequences.begin(); Reference_Temp!=Sequences.end(); ++Reference_Temp)
if ((*Reference_Temp)->MI)
{
int64u Buffer_Read_Size_Temp=float64_int64s(((float64)(*Reference_Temp)->MI->Config.File_Size)/File_Size_Total*Buffer_Read_Size_Total);
int64u Buffer_Read_Size=1;
while (Buffer_Read_Size<Buffer_Read_Size_Temp)
Buffer_Read_Size<<=1;
(*Reference_Temp)->MI->Config.File_Buffer_Read_Size_Set((size_t)Buffer_Read_Size);
}
}
//---------------------------------------------------------------------------
#if MEDIAINFO_EVENTS
void File__ReferenceFilesHelper::SubFile_Start()
{
if (Sequences[Sequences_Current]->StreamID!=StreamID_Previous)
{
Ztring FileName_Absolute, FileName_Relative;
if (Sequences[Sequences_Current]->MI && Sequences[Sequences_Current]->MI->Config.File_Names_Pos && Sequences[Sequences_Current]->MI->Config.File_Names_Pos<Sequences[Sequences_Current]->MI->Config.File_Names.size())
FileName_Absolute=Sequences[Sequences_Current]->MI->Config.File_Names[Sequences[Sequences_Current]->MI->Config.File_Names_Pos-1];
else if (!Sequences[Sequences_Current]->FileNames.empty())
FileName_Absolute=Sequences[Sequences_Current]->FileNames[0];
else
FileName_Absolute=Sequences[Sequences_Current]->Source.c_str();
Sequences[Sequences_Current]->MI->Config.Event_SubFile_Start(FileName_Absolute);
StreamID_Previous=Sequences[Sequences_Current]->StreamID;
}
}
#endif //MEDIAINFO_EVENTS
} //NameSpace
#endif //MEDIAINFO_REFERENCES_YES
| 55.297685
| 428
| 0.55619
|
1aq
|
4b2ff01393557a498e3c78b7a9cd4368ccbf62c0
| 2,641
|
cc
|
C++
|
modules/planning/lattice/behavior/scenario_manager.cc
|
journey-wang/apollo
|
912880015d01442ed8fa414a9481f767cd9ea79e
|
[
"Apache-2.0"
] | 19
|
2018-07-26T03:17:32.000Z
|
2021-01-04T02:17:09.000Z
|
modules/planning/lattice/behavior/scenario_manager.cc
|
yangyi5678/apollo-2.5.0
|
e95bcca8912854a3acc42ec62813614cc5511784
|
[
"Apache-2.0"
] | 2
|
2022-01-27T16:14:38.000Z
|
2022-02-11T00:10:28.000Z
|
modules/planning/lattice/behavior/scenario_manager.cc
|
yangyi5678/apollo-2.5.0
|
e95bcca8912854a3acc42ec62813614cc5511784
|
[
"Apache-2.0"
] | 10
|
2018-10-17T03:18:16.000Z
|
2020-07-02T06:18:14.000Z
|
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file
**/
#include "modules/planning/lattice/behavior/scenario_manager.h"
#include "modules/planning/lattice/behavior/ego_vehicle_scenario.h"
#include "modules/planning/lattice/behavior/signal_light_scenario.h"
#include "modules/common/log.h"
namespace apollo {
namespace planning {
ScenarioManager::ScenarioManager() {}
void ScenarioManager::RegisterScenarios() {
scenarios_.clear();
scenarios_.resize(NUM_LEVELS);
// level 0 features
RegisterScenario<EgoVehicleScenario>(LEVEL0);
RegisterScenario<SignalLightScenario>(LEVEL0);
}
void ScenarioManager::Reset() {
scenarios_.clear();
indexed_scenarios_.clear();
}
int ScenarioManager::ComputeWorldDecision(
Frame* frame, ReferenceLineInfo* const reference_line_info,
PlanningTarget* planning_target) {
RegisterScenarios();
ADEBUG << "Register Scenarios Success";
for (auto& level_scenario : scenarios_) {
for (auto scenario : level_scenario) {
scenario->Reset();
if (!scenario->Init()) {
AERROR << "scenario[" << scenario->Name() << "] init failed";
} else {
ADEBUG << "scenario[" << scenario->Name() << "] init success";
}
// check if exists
if (!scenario->ScenarioExist()) {
AERROR << "scenario[" << scenario->Name() << "] not exists";
} else {
ADEBUG << "scenario[" << scenario->Name() << "] does exists";
}
// compute decision
if (0 ==
scenario->ComputeScenarioDecision(frame, reference_line_info,
planning_target)) {
ADEBUG << "scenario[" << scenario->Name()
<< "] Success in computing decision";
} else {
AERROR << "scenario[" << scenario->Name()
<< "] Failed in computing decision";
}
}
}
return 0;
}
} // namespace planning
} // namespace apollo
| 31.819277
| 79
| 0.617569
|
journey-wang
|
4b3027f86d5dab223488f15abb084cf4e246cee1
| 1,209
|
cpp
|
C++
|
main.cpp
|
jeanmira/Simulacao-de-Algoritmos-de-Escalonamento
|
96c17082c2fc3b47568a568d772d010627574f7f
|
[
"MIT"
] | null | null | null |
main.cpp
|
jeanmira/Simulacao-de-Algoritmos-de-Escalonamento
|
96c17082c2fc3b47568a568d772d010627574f7f
|
[
"MIT"
] | null | null | null |
main.cpp
|
jeanmira/Simulacao-de-Algoritmos-de-Escalonamento
|
96c17082c2fc3b47568a568d772d010627574f7f
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
#include "escalonamento.h"
#include "entrada.h"
#include "processo.h"
int main()
{
vector<int> dados;
int cont = 0;
// Coloque o nome do arquivo que deseja rodar aqui embaixo
Entrada arquivo("entrada1.txt");
arquivo.retornaMatriz(dados);
// arquivo.imprimiArquivo();
Escalonamento e;
// Cria os processos
for (int i = 0; i < dados.size() / 3; i++)
{
Processo aux(dados[i + (2 * cont)], dados[i + (2 * cont) + 1], dados[i + (2 * cont) + 2], i + 1);
e.setParametros(aux);
cont++;
}
// Escalonamento por FCFS (First Come, First Served)
e.fcfs();
e.imprimiDados();
// Escalonamento por Shortest Job First
e.sjf();
e.imprimiDados();
// Escalonamento por prioridade, sem preempção
e.psp();
e.imprimiDados();
// Escalonamento por prioridade, com preempção por prioridade
e.pcp();
e.imprimiDados();
//----- Escalonamento por Round-Robin com quantum = 2s, sem prioridade
e.rrsp(2);
e.imprimiDados();
//----- Escalonamento por Round-Robin com prioridade e envelhecimento (tq=2, α=1)
e.rrcp(2, 1);
e.imprimiDados();
return 0;
}
| 23.25
| 105
| 0.603805
|
jeanmira
|
4b323c6d711dd132702a039a3a96c18f981a5e6f
| 2,141
|
hpp
|
C++
|
tledit/source/ColorDeck.hpp
|
1pkg/dump
|
0ee579cb6a97ae64d5367cc624b2407d7d4b1c7b
|
[
"MIT"
] | null | null | null |
tledit/source/ColorDeck.hpp
|
1pkg/dump
|
0ee579cb6a97ae64d5367cc624b2407d7d4b1c7b
|
[
"MIT"
] | 3
|
2020-12-11T10:01:27.000Z
|
2022-02-13T22:12:05.000Z
|
tledit/source/ColorDeck.hpp
|
1pkg/dump
|
0ee579cb6a97ae64d5367cc624b2407d7d4b1c7b
|
[
"MIT"
] | null | null | null |
#ifndef __COLOR__DECK__HPP__
#define __COLOR__DECK__HPP__
#include "Color.hpp"
#include <sstream>
#include <unordered_map>
struct Coordinate {
short x, y;
bool operator==(Coordinate const &second) const {
return ((x == second.x) && (y == second.y));
}
Coordinate(short x, short y) : x(x), y(y) {}
Coordinate() : x(0), y(0) {}
};
namespace std {
template <> struct hash<Coordinate> {
std::size_t operator()(const Coordinate &coord) const {
return ((hash<int>()(coord.x) | (hash<int>()(coord.y))));
}
};
} // namespace std
class ColorDeck {
std::unordered_map<Coordinate, Color> _deck;
unsigned short _lenght;
unsigned short _width;
public:
ColorDeck();
ColorDeck(unsigned short lenght, unsigned short _width);
unsigned short getLen() const;
unsigned short getWidth() const;
void grow();
void compress();
// throwable
void setItem(Coordinate index, const Color &color);
Color getItem(Coordinate index) const;
Color &getItem(Coordinate index);
// nonthrowable
void setItem(Coordinate index, const Color &color, bool &fail);
Color getItem(Coordinate index, bool &fail) const;
Color &getItem(Coordinate index, bool &fail);
void deleteItem(Coordinate index);
void clear();
bool empty() const;
std::stringstream ColorDeck::serialize() const;
static ColorDeck unserialize(std::stringstream &stream, unsigned short lenght,
unsigned short width);
std::unordered_map<Coordinate, Color>::iterator begin();
std::unordered_map<Coordinate, Color>::iterator end();
};
inline unsigned short ColorDeck::getLen() const { return _lenght; }
inline unsigned short ColorDeck::getWidth() const { return _width; }
inline void ColorDeck::clear() { _deck.clear(); }
inline bool ColorDeck::empty() const { return _deck.empty(); }
inline std::unordered_map<Coordinate, Color>::iterator ColorDeck::begin() {
return _deck.begin();
}
inline std::unordered_map<Coordinate, Color>::iterator ColorDeck::end() {
return _deck.end();
}
#endif // __COLOR__DECK__HPP__
| 25.488095
| 81
| 0.668379
|
1pkg
|
4b32661c809d34e2d2d1bfd201bfc29ce10d9461
| 2,650
|
hpp
|
C++
|
libcaf_io/caf/io/accept_handle.hpp
|
v2nero/actor-framework
|
c2f811809143d32c598471a20363238b0882a761
|
[
"BSL-1.0",
"BSD-3-Clause"
] | 1
|
2020-07-16T19:01:52.000Z
|
2020-07-16T19:01:52.000Z
|
libcaf_io/caf/io/accept_handle.hpp
|
Boubou818/actor-framework
|
da90ef78b26da5d225f039072e616da415c48494
|
[
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null |
libcaf_io/caf/io/accept_handle.hpp
|
Boubou818/actor-framework
|
da90ef78b26da5d225f039072e616da415c48494
|
[
"BSL-1.0",
"BSD-3-Clause"
] | 1
|
2021-02-19T11:25:15.000Z
|
2021-02-19T11:25:15.000Z
|
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#pragma once
#include <functional>
#include "caf/error.hpp"
#include "caf/io/handle.hpp"
#include "caf/meta/type_name.hpp"
namespace caf {
namespace io {
struct invalid_accept_handle_t {
constexpr invalid_accept_handle_t() {
// nop
}
};
constexpr invalid_accept_handle_t invalid_accept_handle
= invalid_accept_handle_t{};
/// Generic handle type for managing incoming connections.
class accept_handle : public handle<accept_handle, invalid_accept_handle_t> {
public:
friend class handle<accept_handle, invalid_accept_handle_t>;
using super = handle<accept_handle, invalid_accept_handle_t>;
constexpr accept_handle() {
// nop
}
constexpr accept_handle(const invalid_accept_handle_t&) {
// nop
}
template <class Inspector>
friend typename Inspector::result_type inspect(Inspector& f,
accept_handle& x) {
return f(meta::type_name("accept_handle"), x.id_);
}
private:
inline accept_handle(int64_t handle_id) : super(handle_id) {
// nop
}
};
} // namespace ios
} // namespace caf
namespace std{
template<>
struct hash<caf::io::accept_handle> {
size_t operator()(const caf::io::accept_handle& hdl) const {
hash<int64_t> f;
return f(hdl.id());
}
};
} // namespace std
| 31.927711
| 80
| 0.475094
|
v2nero
|
4b3477de9c54b5151e943f048543aaa4f45f6ddf
| 4,935
|
cpp
|
C++
|
src/brpc/builtin/get_js_service.cpp
|
wu-hanqing/incubator-brpc
|
7de0d7eaf6fca2b73b9f6018eb1b9128ce0a8f21
|
[
"Apache-2.0"
] | 5,379
|
2019-03-02T14:35:09.000Z
|
2022-03-31T14:19:19.000Z
|
src/brpc/builtin/get_js_service.cpp
|
RichPure/incubator-brpc
|
846f7998799dd3c9103ef743fecc3c75d6dcb7ef
|
[
"BSL-1.0",
"Apache-2.0"
] | 921
|
2019-03-02T00:57:34.000Z
|
2022-03-30T08:58:23.000Z
|
src/brpc/builtin/get_js_service.cpp
|
RichPure/incubator-brpc
|
846f7998799dd3c9103ef743fecc3c75d6dcb7ef
|
[
"BSL-1.0",
"Apache-2.0"
] | 1,641
|
2019-03-02T06:53:17.000Z
|
2022-03-31T11:35:07.000Z
|
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "butil/macros.h" // ARRAY_SIZE
#include "butil/iobuf.h" // butil::IOBuf
#include "brpc/controller.h" // Controller
#include "brpc/builtin/sorttable_js.h"
#include "brpc/builtin/jquery_min_js.h"
#include "brpc/builtin/flot_min_js.h"
#include "brpc/builtin/viz_min_js.h"
#include "brpc/builtin/get_js_service.h"
#include "brpc/builtin/common.h"
namespace brpc {
static const char* g_last_modified = "Wed, 16 Sep 2015 01:25:30 GMT";
static void SetExpires(HttpHeader* header, time_t seconds) {
char buf[256];
time_t now = time(0);
Time2GMT(now, buf, sizeof(buf));
header->SetHeader("Date", buf);
Time2GMT(now + seconds, buf, sizeof(buf));
header->SetHeader("Expires", buf);
}
void GetJsService::sorttable(
::google::protobuf::RpcController* controller,
const GetJsRequest* /*request*/,
GetJsResponse* /*response*/,
::google::protobuf::Closure* done) {
ClosureGuard done_guard(done);
Controller *cntl = (Controller*)controller;
cntl->http_response().set_content_type("application/javascript");
SetExpires(&cntl->http_response(), 80000);
cntl->response_attachment().append(sorttable_js_iobuf());
}
void GetJsService::jquery_min(
::google::protobuf::RpcController* controller,
const GetJsRequest* /*request*/,
GetJsResponse* /*response*/,
::google::protobuf::Closure* done) {
ClosureGuard done_guard(done);
Controller *cntl = (Controller*)controller;
cntl->http_response().set_content_type("application/javascript");
SetExpires(&cntl->http_response(), 600);
const std::string* ims =
cntl->http_request().GetHeader("If-Modified-Since");
if (ims != NULL && *ims == g_last_modified) {
cntl->http_response().set_status_code(HTTP_STATUS_NOT_MODIFIED);
return;
}
cntl->http_response().SetHeader("Last-Modified", g_last_modified);
if (SupportGzip(cntl)) {
cntl->http_response().SetHeader("Content-Encoding", "gzip");
cntl->response_attachment().append(jquery_min_js_iobuf_gzip());
} else {
cntl->response_attachment().append(jquery_min_js_iobuf());
}
}
void GetJsService::flot_min(
::google::protobuf::RpcController* controller,
const GetJsRequest* /*request*/,
GetJsResponse* /*response*/,
::google::protobuf::Closure* done) {
ClosureGuard done_guard(done);
Controller *cntl = (Controller*)controller;
cntl->http_response().set_content_type("application/javascript");
SetExpires(&cntl->http_response(), 80000);
const std::string* ims =
cntl->http_request().GetHeader("If-Modified-Since");
if (ims != NULL && *ims == g_last_modified) {
cntl->http_response().set_status_code(HTTP_STATUS_NOT_MODIFIED);
return;
}
cntl->http_response().SetHeader("Last-Modified", g_last_modified);
if (SupportGzip(cntl)) {
cntl->http_response().SetHeader("Content-Encoding", "gzip");
cntl->response_attachment().append(flot_min_js_iobuf_gzip());
} else {
cntl->response_attachment().append(flot_min_js_iobuf());
}
}
void GetJsService::viz_min(
::google::protobuf::RpcController* controller,
const GetJsRequest* /*request*/,
GetJsResponse* /*response*/,
::google::protobuf::Closure* done) {
ClosureGuard done_guard(done);
Controller *cntl = (Controller*)controller;
cntl->http_response().set_content_type("application/javascript");
SetExpires(&cntl->http_response(), 80000);
const std::string* ims =
cntl->http_request().GetHeader("If-Modified-Since");
if (ims != NULL && *ims == g_last_modified) {
cntl->http_response().set_status_code(HTTP_STATUS_NOT_MODIFIED);
return;
}
cntl->http_response().SetHeader("Last-Modified", g_last_modified);
if (SupportGzip(cntl)) {
cntl->http_response().SetHeader("Content-Encoding", "gzip");
cntl->response_attachment().append(viz_min_js_iobuf_gzip());
} else {
cntl->response_attachment().append(viz_min_js_iobuf());
}
}
} // namespace brpc
| 37.105263
| 72
| 0.682675
|
wu-hanqing
|
4b34dc1ec698372f6d448ae9c507596a6dd84ed0
| 7,444
|
cpp
|
C++
|
third-party/luabind/src/object_rep.cpp
|
wangfeilong321/vr-jugglua
|
5dbefe4c32dd3ddf498dab555373b767c3464df4
|
[
"BSL-1.0"
] | 7
|
2015-03-28T04:24:48.000Z
|
2021-07-16T06:17:31.000Z
|
third-party/luabind/src/object_rep.cpp
|
vancegroup/vr-jugglua
|
5dbefe4c32dd3ddf498dab555373b767c3464df4
|
[
"BSL-1.0"
] | null | null | null |
third-party/luabind/src/object_rep.cpp
|
vancegroup/vr-jugglua
|
5dbefe4c32dd3ddf498dab555373b767c3464df4
|
[
"BSL-1.0"
] | 3
|
2015-06-17T14:43:43.000Z
|
2021-07-16T06:17:40.000Z
|
// Copyright (c) 2003 Daniel Wallin and Arvid Norberg
// 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.
#define LUABIND_BUILDING
#include <luabind/detail/object_rep.hpp>
#include <luabind/detail/class_rep.hpp>
namespace luabind { namespace detail
{
// dest is a function that is called to delete the c++ object this struct holds
object_rep::object_rep(instance_holder* instance, class_rep* crep)
: m_instance(instance)
, m_classrep(crep)
, m_dependency_cnt(0)
{}
object_rep::~object_rep()
{
if (!m_instance)
return;
m_instance->~instance_holder();
deallocate(m_instance);
}
void object_rep::add_dependency(lua_State* L, int index)
{
assert(m_dependency_cnt < sizeof(object_rep));
void* key = (char*)this + m_dependency_cnt;
lua_pushlightuserdata(L, key);
lua_pushvalue(L, index);
lua_rawset(L, LUA_REGISTRYINDEX);
++m_dependency_cnt;
}
void object_rep::release_dependency_refs(lua_State* L)
{
for (std::size_t i = 0; i < m_dependency_cnt; ++i)
{
void* key = (char*)this + i;
lua_pushlightuserdata(L, key);
lua_pushnil(L);
lua_rawset(L, LUA_REGISTRYINDEX);
}
}
int destroy_instance(lua_State* L)
{
object_rep* instance = static_cast<object_rep*>(lua_touserdata(L, 1));
lua_pushstring(L, "__finalize");
lua_gettable(L, 1);
if (lua_isnil(L, -1))
{
lua_pop(L, 1);
}
else
{
lua_pushvalue(L, 1);
lua_call(L, 1, 0);
}
instance->release_dependency_refs(L);
instance->~object_rep();
return 0;
}
namespace
{
int set_instance_value(lua_State* L)
{
lua_getfenv(L, 1);
lua_pushvalue(L, 2);
lua_rawget(L, -2);
if (lua_isnil(L, -1) && lua_getmetatable(L, -2))
{
lua_pushvalue(L, 2);
lua_rawget(L, -2);
lua_replace(L, -3);
lua_pop(L, 1);
}
if (lua_tocfunction(L, -1) == &property_tag)
{
// this member is a property, extract the "set" function and call it.
lua_getupvalue(L, -1, 2);
if (lua_isnil(L, -1))
{
lua_pushfstring(L, "property '%s' is read only", lua_tostring(L, 2));
lua_error(L);
}
lua_pushvalue(L, 1);
lua_pushvalue(L, 3);
lua_call(L, 2, 0);
return 0;
}
lua_pop(L, 1);
if (!lua_getmetatable(L, 4))
{
lua_newtable(L);
lua_pushvalue(L, -1);
lua_setfenv(L, 1);
lua_pushvalue(L, 4);
lua_setmetatable(L, -2);
}
else
{
lua_pop(L, 1);
}
lua_pushvalue(L, 2);
lua_pushvalue(L, 3);
lua_rawset(L, -3);
return 0;
}
int get_instance_value(lua_State* L)
{
lua_getfenv(L, 1);
lua_pushvalue(L, 2);
lua_rawget(L, -2);
if (lua_isnil(L, -1) && lua_getmetatable(L, -2))
{
lua_pushvalue(L, 2);
lua_rawget(L, -2);
}
if (lua_tocfunction(L, -1) == &property_tag)
{
// this member is a property, extract the "get" function and call it.
lua_getupvalue(L, -1, 1);
lua_pushvalue(L, 1);
lua_call(L, 1, 1);
}
return 1;
}
int dispatch_operator(lua_State* L)
{
for (int i = 0; i < 2; ++i)
{
if (get_instance(L, 1 + i))
{
int nargs = lua_gettop(L);
lua_pushvalue(L, lua_upvalueindex(1));
lua_gettable(L, 1 + i);
if (lua_isnil(L, -1))
{
lua_pop(L, 1);
continue;
}
lua_insert(L, 1); // move the function to the bottom
nargs = lua_toboolean(L, lua_upvalueindex(2)) ? 1 : nargs;
if (lua_toboolean(L, lua_upvalueindex(2))) // remove trailing nil
lua_remove(L, 3);
lua_call(L, nargs, 1);
return 1;
}
}
lua_pop(L, lua_gettop(L));
lua_pushstring(L, "No such operator defined");
lua_error(L);
return 0;
}
} // namespace unnamed
LUABIND_API void push_instance_metatable(lua_State* L)
{
lua_newtable(L);
// This is used as a tag to determine if a userdata is a luabind
// instance. We use a numeric key and a cclosure for fast comparison.
lua_pushnumber(L, 1);
lua_pushcclosure(L, get_instance_value, 0);
lua_rawset(L, -3);
lua_pushcclosure(L, destroy_instance, 0);
lua_setfield(L, -2, "__gc");
lua_pushcclosure(L, get_instance_value, 0);
lua_setfield(L, -2, "__index");
lua_pushcclosure(L, set_instance_value, 0);
lua_setfield(L, -2, "__newindex");
for (int op = 0; op < number_of_operators; ++op)
{
lua_pushstring(L, get_operator_name(op));
lua_pushvalue(L, -1);
lua_pushboolean(L, op == op_unm || op == op_len);
lua_pushcclosure(L, &dispatch_operator, 2);
lua_settable(L, -3);
}
}
LUABIND_API object_rep* get_instance(lua_State* L, int index)
{
object_rep* result = static_cast<object_rep*>(lua_touserdata(L, index));
if (!result || !lua_getmetatable(L, index))
return 0;
lua_rawgeti(L, -1, 1);
if (lua_tocfunction(L, -1) != &get_instance_value)
result = 0;
lua_pop(L, 2);
return result;
}
LUABIND_API object_rep* push_new_instance(lua_State* L, class_rep* cls)
{
void* storage = lua_newuserdata(L, sizeof(object_rep));
object_rep* result = new (storage) object_rep(0, cls);
cls->get_table(L);
lua_setfenv(L, -2);
lua_rawgeti(L, LUA_REGISTRYINDEX, cls->metatable_ref());
lua_setmetatable(L, -2);
return result;
}
}}
| 27.776119
| 87
| 0.545809
|
wangfeilong321
|
4b36f23c207111984be90ca8dd812014be861063
| 366,273
|
cpp
|
C++
|
Temp/il2cppOutput/il2cppOutput/Il2CppCompilerCalculateTypeValues_18Table.cpp
|
18555851781/FurnitureAR_IOS
|
dc8df0cbeb2e4ca3da04a85056d5ceac1c698311
|
[
"MIT"
] | null | null | null |
Temp/il2cppOutput/il2cppOutput/Il2CppCompilerCalculateTypeValues_18Table.cpp
|
18555851781/FurnitureAR_IOS
|
dc8df0cbeb2e4ca3da04a85056d5ceac1c698311
|
[
"MIT"
] | null | null | null |
Temp/il2cppOutput/il2cppOutput/Il2CppCompilerCalculateTypeValues_18Table.cpp
|
18555851781/FurnitureAR_IOS
|
dc8df0cbeb2e4ca3da04a85056d5ceac1c698311
|
[
"MIT"
] | null | null | null |
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <limits>
#include <assert.h>
#include <stdint.h>
#include "il2cpp-class-internals.h"
#include "codegen/il2cpp-codegen.h"
#include "il2cpp-object-internals.h"
// UnityEngine.Vector3[]
struct Vector3U5BU5D_t1718750761;
// UnityEngine.UI.Dropdown/DropdownItem
struct DropdownItem_t1451952895;
// UnityEngine.UI.Dropdown
struct Dropdown_t2274391225;
// System.Collections.Generic.Dictionary`2<UnityEngine.Font,System.Collections.Generic.HashSet`1<UnityEngine.UI.Text>>
struct Dictionary_2_t369343732;
// System.Action`1<UnityEngine.Font>
struct Action_1_t2129269699;
// System.Collections.Generic.List`1<UnityEngine.UI.StencilMaterial/MatEntry>
struct List_1_t134214538;
// System.Collections.Generic.Dictionary`2<UnityEngine.Canvas,UnityEngine.UI.Collections.IndexedSet`1<UnityEngine.UI.Graphic>>
struct Dictionary_2_t2296117448;
// System.Collections.Generic.List`1<UnityEngine.UI.Graphic>
struct List_1_t3132410353;
// UnityEngine.EventSystems.PointerEventData
struct PointerEventData_t3807901092;
// UnityEngine.UI.Scrollbar
struct Scrollbar_t1494447233;
// UnityEngine.UI.Collections.IndexedSet`1<UnityEngine.UI.IClipper>
struct IndexedSet_1_t2673511092;
// UnityEngine.UI.Button
struct Button_t4055032469;
// UnityEngine.UI.Collections.IndexedSet`1<UnityEngine.UI.ICanvasElement>
struct IndexedSet_1_t3571286806;
// System.Comparison`1<UnityEngine.UI.ICanvasElement>
struct Comparison_1_t1896830045;
// UnityEngine.UI.InputField
struct InputField_t3762917431;
// UnityEngine.Events.InvokableCallList
struct InvokableCallList_t2498835369;
// UnityEngine.Events.PersistentCallGroup
struct PersistentCallGroup_t3050769227;
// System.String
struct String_t;
// System.Collections.Generic.List`1<UnityEngine.UI.Dropdown/OptionData>
struct List_1_t447389798;
// UnityEngine.Sprite
struct Sprite_t280657092;
// System.Char[]
struct CharU5BU5D_t3528271667;
// System.Object[]
struct ObjectU5BU5D_t2843939325;
// System.Void
struct Void_t1185182177;
// System.Byte
struct Byte_t1134296376;
// System.Double
struct Double_t594665363;
// System.UInt16
struct UInt16_t2177724958;
// System.Reflection.MethodInfo
struct MethodInfo_t;
// System.DelegateData
struct DelegateData_t1677132599;
// UnityEngine.Font
struct Font_t1956802104;
// UnityEngine.UI.Selectable
struct Selectable_t3250028441;
// UnityEngine.Material
struct Material_t340375123;
// System.IAsyncResult
struct IAsyncResult_t767004451;
// System.AsyncCallback
struct AsyncCallback_t3962456242;
// UnityEngine.UI.Text
struct Text_t1901882714;
// UnityEngine.UI.Image
struct Image_t2670269651;
// UnityEngine.RectTransform
struct RectTransform_t3704657025;
// UnityEngine.UI.Toggle
struct Toggle_t2735377061;
// UnityEngine.RectOffset
struct RectOffset_t1369453676;
// System.Collections.Generic.List`1<UnityEngine.RectTransform>
struct List_1_t881764471;
// System.Collections.Generic.List`1<UnityEngine.UI.Selectable>
struct List_1_t427135887;
// UnityEngine.UI.AnimationTriggers
struct AnimationTriggers_t2532145056;
// UnityEngine.UI.Graphic
struct Graphic_t1660335611;
// System.Collections.Generic.List`1<UnityEngine.CanvasGroup>
struct List_1_t1260619206;
// UnityEngine.Texture2D
struct Texture2D_t3840446185;
// UnityEngine.CanvasRenderer
struct CanvasRenderer_t2598313366;
// UnityEngine.Canvas
struct Canvas_t3310196443;
// UnityEngine.Events.UnityAction
struct UnityAction_t3245792599;
// UnityEngine.Mesh
struct Mesh_t3648964284;
// UnityEngine.UI.VertexHelper
struct VertexHelper_t2453304189;
// UnityEngine.UI.CoroutineTween.TweenRunner`1<UnityEngine.UI.CoroutineTween.ColorTween>
struct TweenRunner_1_t3055525458;
// UnityEngine.UI.RectangularVertexClipper
struct RectangularVertexClipper_t626611136;
// System.Collections.Generic.HashSet`1<UnityEngine.UI.IClippable>
struct HashSet_1_t4099546121;
// System.Collections.Generic.List`1<UnityEngine.UI.RectMask2D>
struct List_1_t651996883;
// UnityEngine.UI.ScrollRect/ScrollRectEvent
struct ScrollRectEvent_t343079324;
// System.Collections.Generic.List`1<UnityEngine.UI.Toggle>
struct List_1_t4207451803;
// System.Predicate`1<UnityEngine.UI.Toggle>
struct Predicate_1_t3560671185;
// System.Func`2<UnityEngine.UI.Toggle,System.Boolean>
struct Func_2_t3446800538;
// UnityEngine.UI.Slider/SliderEvent
struct SliderEvent_t3180273144;
// UnityEngine.Transform
struct Transform_t3600365921;
// UnityEngine.UI.Dropdown/OptionDataList
struct OptionDataList_t1438173104;
// UnityEngine.UI.Dropdown/DropdownEvent
struct DropdownEvent_t4040729994;
// UnityEngine.GameObject
struct GameObject_t1113636619;
// System.Collections.Generic.List`1<UnityEngine.UI.Dropdown/DropdownItem>
struct List_1_t2924027637;
// UnityEngine.UI.CoroutineTween.TweenRunner`1<UnityEngine.UI.CoroutineTween.FloatTween>
struct TweenRunner_1_t3520241082;
// UnityEngine.UI.Dropdown/OptionData
struct OptionData_t3270282352;
// UnityEngine.TouchScreenKeyboard
struct TouchScreenKeyboard_t731888065;
// UnityEngine.UI.InputField/SubmitEvent
struct SubmitEvent_t648412432;
// UnityEngine.UI.InputField/OnChangeEvent
struct OnChangeEvent_t467195904;
// UnityEngine.UI.InputField/OnValidateInput
struct OnValidateInput_t2355412304;
// UnityEngine.UIVertex[]
struct UIVertexU5BU5D_t1981460040;
// UnityEngine.TextGenerator
struct TextGenerator_t3211863866;
// UnityEngine.Coroutine
struct Coroutine_t3829159415;
// UnityEngine.Event
struct Event_t2956885303;
// UnityEngine.UI.RectMask2D
struct RectMask2D_t3474889437;
// UnityEngine.UI.MaskableGraphic/CullStateChangedEvent
struct CullStateChangedEvent_t3661388177;
// UnityEngine.UI.Scrollbar/ScrollEvent
struct ScrollEvent_t149898510;
// System.Comparison`1<UnityEngine.UI.Graphic>
struct Comparison_1_t1435266790;
// UnityEngine.UI.ToggleGroup
struct ToggleGroup_t123837990;
// UnityEngine.UI.Toggle/ToggleEvent
struct ToggleEvent_t1873685584;
// UnityEngine.UI.FontData
struct FontData_t746620069;
// UnityEngine.Vector2[]
struct Vector2U5BU5D_t1457185986;
// System.Collections.Generic.List`1<UnityEngine.UI.Image>
struct List_1_t4142344393;
// System.Action`1<UnityEngine.U2D.SpriteAtlas>
struct Action_1_t819399007;
// UnityEngine.Texture
struct Texture_t3661962703;
#ifndef RUNTIMEOBJECT_H
#define RUNTIMEOBJECT_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Object
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEOBJECT_H
#ifndef RECTANGULARVERTEXCLIPPER_T626611136_H
#define RECTANGULARVERTEXCLIPPER_T626611136_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.RectangularVertexClipper
struct RectangularVertexClipper_t626611136 : public RuntimeObject
{
public:
// UnityEngine.Vector3[] UnityEngine.UI.RectangularVertexClipper::m_WorldCorners
Vector3U5BU5D_t1718750761* ___m_WorldCorners_0;
// UnityEngine.Vector3[] UnityEngine.UI.RectangularVertexClipper::m_CanvasCorners
Vector3U5BU5D_t1718750761* ___m_CanvasCorners_1;
public:
inline static int32_t get_offset_of_m_WorldCorners_0() { return static_cast<int32_t>(offsetof(RectangularVertexClipper_t626611136, ___m_WorldCorners_0)); }
inline Vector3U5BU5D_t1718750761* get_m_WorldCorners_0() const { return ___m_WorldCorners_0; }
inline Vector3U5BU5D_t1718750761** get_address_of_m_WorldCorners_0() { return &___m_WorldCorners_0; }
inline void set_m_WorldCorners_0(Vector3U5BU5D_t1718750761* value)
{
___m_WorldCorners_0 = value;
Il2CppCodeGenWriteBarrier((&___m_WorldCorners_0), value);
}
inline static int32_t get_offset_of_m_CanvasCorners_1() { return static_cast<int32_t>(offsetof(RectangularVertexClipper_t626611136, ___m_CanvasCorners_1)); }
inline Vector3U5BU5D_t1718750761* get_m_CanvasCorners_1() const { return ___m_CanvasCorners_1; }
inline Vector3U5BU5D_t1718750761** get_address_of_m_CanvasCorners_1() { return &___m_CanvasCorners_1; }
inline void set_m_CanvasCorners_1(Vector3U5BU5D_t1718750761* value)
{
___m_CanvasCorners_1 = value;
Il2CppCodeGenWriteBarrier((&___m_CanvasCorners_1), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RECTANGULARVERTEXCLIPPER_T626611136_H
#ifndef U3CSHOWU3EC__ANONSTOREY1_T1106527198_H
#define U3CSHOWU3EC__ANONSTOREY1_T1106527198_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Dropdown/<Show>c__AnonStorey1
struct U3CShowU3Ec__AnonStorey1_t1106527198 : public RuntimeObject
{
public:
// UnityEngine.UI.Dropdown/DropdownItem UnityEngine.UI.Dropdown/<Show>c__AnonStorey1::item
DropdownItem_t1451952895 * ___item_0;
// UnityEngine.UI.Dropdown UnityEngine.UI.Dropdown/<Show>c__AnonStorey1::$this
Dropdown_t2274391225 * ___U24this_1;
public:
inline static int32_t get_offset_of_item_0() { return static_cast<int32_t>(offsetof(U3CShowU3Ec__AnonStorey1_t1106527198, ___item_0)); }
inline DropdownItem_t1451952895 * get_item_0() const { return ___item_0; }
inline DropdownItem_t1451952895 ** get_address_of_item_0() { return &___item_0; }
inline void set_item_0(DropdownItem_t1451952895 * value)
{
___item_0 = value;
Il2CppCodeGenWriteBarrier((&___item_0), value);
}
inline static int32_t get_offset_of_U24this_1() { return static_cast<int32_t>(offsetof(U3CShowU3Ec__AnonStorey1_t1106527198, ___U24this_1)); }
inline Dropdown_t2274391225 * get_U24this_1() const { return ___U24this_1; }
inline Dropdown_t2274391225 ** get_address_of_U24this_1() { return &___U24this_1; }
inline void set_U24this_1(Dropdown_t2274391225 * value)
{
___U24this_1 = value;
Il2CppCodeGenWriteBarrier((&___U24this_1), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // U3CSHOWU3EC__ANONSTOREY1_T1106527198_H
#ifndef U3CDELAYEDDESTROYDROPDOWNLISTU3EC__ITERATOR0_T3853912249_H
#define U3CDELAYEDDESTROYDROPDOWNLISTU3EC__ITERATOR0_T3853912249_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Dropdown/<DelayedDestroyDropdownList>c__Iterator0
struct U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249 : public RuntimeObject
{
public:
// System.Single UnityEngine.UI.Dropdown/<DelayedDestroyDropdownList>c__Iterator0::delay
float ___delay_0;
// UnityEngine.UI.Dropdown UnityEngine.UI.Dropdown/<DelayedDestroyDropdownList>c__Iterator0::$this
Dropdown_t2274391225 * ___U24this_1;
// System.Object UnityEngine.UI.Dropdown/<DelayedDestroyDropdownList>c__Iterator0::$current
RuntimeObject * ___U24current_2;
// System.Boolean UnityEngine.UI.Dropdown/<DelayedDestroyDropdownList>c__Iterator0::$disposing
bool ___U24disposing_3;
// System.Int32 UnityEngine.UI.Dropdown/<DelayedDestroyDropdownList>c__Iterator0::$PC
int32_t ___U24PC_4;
public:
inline static int32_t get_offset_of_delay_0() { return static_cast<int32_t>(offsetof(U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249, ___delay_0)); }
inline float get_delay_0() const { return ___delay_0; }
inline float* get_address_of_delay_0() { return &___delay_0; }
inline void set_delay_0(float value)
{
___delay_0 = value;
}
inline static int32_t get_offset_of_U24this_1() { return static_cast<int32_t>(offsetof(U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249, ___U24this_1)); }
inline Dropdown_t2274391225 * get_U24this_1() const { return ___U24this_1; }
inline Dropdown_t2274391225 ** get_address_of_U24this_1() { return &___U24this_1; }
inline void set_U24this_1(Dropdown_t2274391225 * value)
{
___U24this_1 = value;
Il2CppCodeGenWriteBarrier((&___U24this_1), value);
}
inline static int32_t get_offset_of_U24current_2() { return static_cast<int32_t>(offsetof(U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249, ___U24current_2)); }
inline RuntimeObject * get_U24current_2() const { return ___U24current_2; }
inline RuntimeObject ** get_address_of_U24current_2() { return &___U24current_2; }
inline void set_U24current_2(RuntimeObject * value)
{
___U24current_2 = value;
Il2CppCodeGenWriteBarrier((&___U24current_2), value);
}
inline static int32_t get_offset_of_U24disposing_3() { return static_cast<int32_t>(offsetof(U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249, ___U24disposing_3)); }
inline bool get_U24disposing_3() const { return ___U24disposing_3; }
inline bool* get_address_of_U24disposing_3() { return &___U24disposing_3; }
inline void set_U24disposing_3(bool value)
{
___U24disposing_3 = value;
}
inline static int32_t get_offset_of_U24PC_4() { return static_cast<int32_t>(offsetof(U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249, ___U24PC_4)); }
inline int32_t get_U24PC_4() const { return ___U24PC_4; }
inline int32_t* get_address_of_U24PC_4() { return &___U24PC_4; }
inline void set_U24PC_4(int32_t value)
{
___U24PC_4 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // U3CDELAYEDDESTROYDROPDOWNLISTU3EC__ITERATOR0_T3853912249_H
#ifndef FONTUPDATETRACKER_T1839077620_H
#define FONTUPDATETRACKER_T1839077620_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.FontUpdateTracker
struct FontUpdateTracker_t1839077620 : public RuntimeObject
{
public:
public:
};
struct FontUpdateTracker_t1839077620_StaticFields
{
public:
// System.Collections.Generic.Dictionary`2<UnityEngine.Font,System.Collections.Generic.HashSet`1<UnityEngine.UI.Text>> UnityEngine.UI.FontUpdateTracker::m_Tracked
Dictionary_2_t369343732 * ___m_Tracked_0;
// System.Action`1<UnityEngine.Font> UnityEngine.UI.FontUpdateTracker::<>f__mg$cache0
Action_1_t2129269699 * ___U3CU3Ef__mgU24cache0_1;
// System.Action`1<UnityEngine.Font> UnityEngine.UI.FontUpdateTracker::<>f__mg$cache1
Action_1_t2129269699 * ___U3CU3Ef__mgU24cache1_2;
public:
inline static int32_t get_offset_of_m_Tracked_0() { return static_cast<int32_t>(offsetof(FontUpdateTracker_t1839077620_StaticFields, ___m_Tracked_0)); }
inline Dictionary_2_t369343732 * get_m_Tracked_0() const { return ___m_Tracked_0; }
inline Dictionary_2_t369343732 ** get_address_of_m_Tracked_0() { return &___m_Tracked_0; }
inline void set_m_Tracked_0(Dictionary_2_t369343732 * value)
{
___m_Tracked_0 = value;
Il2CppCodeGenWriteBarrier((&___m_Tracked_0), value);
}
inline static int32_t get_offset_of_U3CU3Ef__mgU24cache0_1() { return static_cast<int32_t>(offsetof(FontUpdateTracker_t1839077620_StaticFields, ___U3CU3Ef__mgU24cache0_1)); }
inline Action_1_t2129269699 * get_U3CU3Ef__mgU24cache0_1() const { return ___U3CU3Ef__mgU24cache0_1; }
inline Action_1_t2129269699 ** get_address_of_U3CU3Ef__mgU24cache0_1() { return &___U3CU3Ef__mgU24cache0_1; }
inline void set_U3CU3Ef__mgU24cache0_1(Action_1_t2129269699 * value)
{
___U3CU3Ef__mgU24cache0_1 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__mgU24cache0_1), value);
}
inline static int32_t get_offset_of_U3CU3Ef__mgU24cache1_2() { return static_cast<int32_t>(offsetof(FontUpdateTracker_t1839077620_StaticFields, ___U3CU3Ef__mgU24cache1_2)); }
inline Action_1_t2129269699 * get_U3CU3Ef__mgU24cache1_2() const { return ___U3CU3Ef__mgU24cache1_2; }
inline Action_1_t2129269699 ** get_address_of_U3CU3Ef__mgU24cache1_2() { return &___U3CU3Ef__mgU24cache1_2; }
inline void set_U3CU3Ef__mgU24cache1_2(Action_1_t2129269699 * value)
{
___U3CU3Ef__mgU24cache1_2 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__mgU24cache1_2), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // FONTUPDATETRACKER_T1839077620_H
#ifndef STENCILMATERIAL_T3850132571_H
#define STENCILMATERIAL_T3850132571_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.StencilMaterial
struct StencilMaterial_t3850132571 : public RuntimeObject
{
public:
public:
};
struct StencilMaterial_t3850132571_StaticFields
{
public:
// System.Collections.Generic.List`1<UnityEngine.UI.StencilMaterial/MatEntry> UnityEngine.UI.StencilMaterial::m_List
List_1_t134214538 * ___m_List_0;
public:
inline static int32_t get_offset_of_m_List_0() { return static_cast<int32_t>(offsetof(StencilMaterial_t3850132571_StaticFields, ___m_List_0)); }
inline List_1_t134214538 * get_m_List_0() const { return ___m_List_0; }
inline List_1_t134214538 ** get_address_of_m_List_0() { return &___m_List_0; }
inline void set_m_List_0(List_1_t134214538 * value)
{
___m_List_0 = value;
Il2CppCodeGenWriteBarrier((&___m_List_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // STENCILMATERIAL_T3850132571_H
#ifndef GRAPHICREGISTRY_T3479976429_H
#define GRAPHICREGISTRY_T3479976429_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.GraphicRegistry
struct GraphicRegistry_t3479976429 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<UnityEngine.Canvas,UnityEngine.UI.Collections.IndexedSet`1<UnityEngine.UI.Graphic>> UnityEngine.UI.GraphicRegistry::m_Graphics
Dictionary_2_t2296117448 * ___m_Graphics_1;
public:
inline static int32_t get_offset_of_m_Graphics_1() { return static_cast<int32_t>(offsetof(GraphicRegistry_t3479976429, ___m_Graphics_1)); }
inline Dictionary_2_t2296117448 * get_m_Graphics_1() const { return ___m_Graphics_1; }
inline Dictionary_2_t2296117448 ** get_address_of_m_Graphics_1() { return &___m_Graphics_1; }
inline void set_m_Graphics_1(Dictionary_2_t2296117448 * value)
{
___m_Graphics_1 = value;
Il2CppCodeGenWriteBarrier((&___m_Graphics_1), value);
}
};
struct GraphicRegistry_t3479976429_StaticFields
{
public:
// UnityEngine.UI.GraphicRegistry UnityEngine.UI.GraphicRegistry::s_Instance
GraphicRegistry_t3479976429 * ___s_Instance_0;
// System.Collections.Generic.List`1<UnityEngine.UI.Graphic> UnityEngine.UI.GraphicRegistry::s_EmptyList
List_1_t3132410353 * ___s_EmptyList_2;
public:
inline static int32_t get_offset_of_s_Instance_0() { return static_cast<int32_t>(offsetof(GraphicRegistry_t3479976429_StaticFields, ___s_Instance_0)); }
inline GraphicRegistry_t3479976429 * get_s_Instance_0() const { return ___s_Instance_0; }
inline GraphicRegistry_t3479976429 ** get_address_of_s_Instance_0() { return &___s_Instance_0; }
inline void set_s_Instance_0(GraphicRegistry_t3479976429 * value)
{
___s_Instance_0 = value;
Il2CppCodeGenWriteBarrier((&___s_Instance_0), value);
}
inline static int32_t get_offset_of_s_EmptyList_2() { return static_cast<int32_t>(offsetof(GraphicRegistry_t3479976429_StaticFields, ___s_EmptyList_2)); }
inline List_1_t3132410353 * get_s_EmptyList_2() const { return ___s_EmptyList_2; }
inline List_1_t3132410353 ** get_address_of_s_EmptyList_2() { return &___s_EmptyList_2; }
inline void set_s_EmptyList_2(List_1_t3132410353 * value)
{
___s_EmptyList_2 = value;
Il2CppCodeGenWriteBarrier((&___s_EmptyList_2), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // GRAPHICREGISTRY_T3479976429_H
#ifndef CLIPPING_T312708592_H
#define CLIPPING_T312708592_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Clipping
struct Clipping_t312708592 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CLIPPING_T312708592_H
#ifndef U3CCLICKREPEATU3EC__ITERATOR0_T3442648935_H
#define U3CCLICKREPEATU3EC__ITERATOR0_T3442648935_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Scrollbar/<ClickRepeat>c__Iterator0
struct U3CClickRepeatU3Ec__Iterator0_t3442648935 : public RuntimeObject
{
public:
// UnityEngine.EventSystems.PointerEventData UnityEngine.UI.Scrollbar/<ClickRepeat>c__Iterator0::eventData
PointerEventData_t3807901092 * ___eventData_0;
// UnityEngine.UI.Scrollbar UnityEngine.UI.Scrollbar/<ClickRepeat>c__Iterator0::$this
Scrollbar_t1494447233 * ___U24this_1;
// System.Object UnityEngine.UI.Scrollbar/<ClickRepeat>c__Iterator0::$current
RuntimeObject * ___U24current_2;
// System.Boolean UnityEngine.UI.Scrollbar/<ClickRepeat>c__Iterator0::$disposing
bool ___U24disposing_3;
// System.Int32 UnityEngine.UI.Scrollbar/<ClickRepeat>c__Iterator0::$PC
int32_t ___U24PC_4;
public:
inline static int32_t get_offset_of_eventData_0() { return static_cast<int32_t>(offsetof(U3CClickRepeatU3Ec__Iterator0_t3442648935, ___eventData_0)); }
inline PointerEventData_t3807901092 * get_eventData_0() const { return ___eventData_0; }
inline PointerEventData_t3807901092 ** get_address_of_eventData_0() { return &___eventData_0; }
inline void set_eventData_0(PointerEventData_t3807901092 * value)
{
___eventData_0 = value;
Il2CppCodeGenWriteBarrier((&___eventData_0), value);
}
inline static int32_t get_offset_of_U24this_1() { return static_cast<int32_t>(offsetof(U3CClickRepeatU3Ec__Iterator0_t3442648935, ___U24this_1)); }
inline Scrollbar_t1494447233 * get_U24this_1() const { return ___U24this_1; }
inline Scrollbar_t1494447233 ** get_address_of_U24this_1() { return &___U24this_1; }
inline void set_U24this_1(Scrollbar_t1494447233 * value)
{
___U24this_1 = value;
Il2CppCodeGenWriteBarrier((&___U24this_1), value);
}
inline static int32_t get_offset_of_U24current_2() { return static_cast<int32_t>(offsetof(U3CClickRepeatU3Ec__Iterator0_t3442648935, ___U24current_2)); }
inline RuntimeObject * get_U24current_2() const { return ___U24current_2; }
inline RuntimeObject ** get_address_of_U24current_2() { return &___U24current_2; }
inline void set_U24current_2(RuntimeObject * value)
{
___U24current_2 = value;
Il2CppCodeGenWriteBarrier((&___U24current_2), value);
}
inline static int32_t get_offset_of_U24disposing_3() { return static_cast<int32_t>(offsetof(U3CClickRepeatU3Ec__Iterator0_t3442648935, ___U24disposing_3)); }
inline bool get_U24disposing_3() const { return ___U24disposing_3; }
inline bool* get_address_of_U24disposing_3() { return &___U24disposing_3; }
inline void set_U24disposing_3(bool value)
{
___U24disposing_3 = value;
}
inline static int32_t get_offset_of_U24PC_4() { return static_cast<int32_t>(offsetof(U3CClickRepeatU3Ec__Iterator0_t3442648935, ___U24PC_4)); }
inline int32_t get_U24PC_4() const { return ___U24PC_4; }
inline int32_t* get_address_of_U24PC_4() { return &___U24PC_4; }
inline void set_U24PC_4(int32_t value)
{
___U24PC_4 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // U3CCLICKREPEATU3EC__ITERATOR0_T3442648935_H
#ifndef CLIPPERREGISTRY_T2428680409_H
#define CLIPPERREGISTRY_T2428680409_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.ClipperRegistry
struct ClipperRegistry_t2428680409 : public RuntimeObject
{
public:
// UnityEngine.UI.Collections.IndexedSet`1<UnityEngine.UI.IClipper> UnityEngine.UI.ClipperRegistry::m_Clippers
IndexedSet_1_t2673511092 * ___m_Clippers_1;
public:
inline static int32_t get_offset_of_m_Clippers_1() { return static_cast<int32_t>(offsetof(ClipperRegistry_t2428680409, ___m_Clippers_1)); }
inline IndexedSet_1_t2673511092 * get_m_Clippers_1() const { return ___m_Clippers_1; }
inline IndexedSet_1_t2673511092 ** get_address_of_m_Clippers_1() { return &___m_Clippers_1; }
inline void set_m_Clippers_1(IndexedSet_1_t2673511092 * value)
{
___m_Clippers_1 = value;
Il2CppCodeGenWriteBarrier((&___m_Clippers_1), value);
}
};
struct ClipperRegistry_t2428680409_StaticFields
{
public:
// UnityEngine.UI.ClipperRegistry UnityEngine.UI.ClipperRegistry::s_Instance
ClipperRegistry_t2428680409 * ___s_Instance_0;
public:
inline static int32_t get_offset_of_s_Instance_0() { return static_cast<int32_t>(offsetof(ClipperRegistry_t2428680409_StaticFields, ___s_Instance_0)); }
inline ClipperRegistry_t2428680409 * get_s_Instance_0() const { return ___s_Instance_0; }
inline ClipperRegistry_t2428680409 ** get_address_of_s_Instance_0() { return &___s_Instance_0; }
inline void set_s_Instance_0(ClipperRegistry_t2428680409 * value)
{
___s_Instance_0 = value;
Il2CppCodeGenWriteBarrier((&___s_Instance_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CLIPPERREGISTRY_T2428680409_H
#ifndef MISC_T1447421763_H
#define MISC_T1447421763_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Misc
struct Misc_t1447421763 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MISC_T1447421763_H
#ifndef VALUETYPE_T3640485471_H
#define VALUETYPE_T3640485471_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.ValueType
struct ValueType_t3640485471 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_com
{
};
#endif // VALUETYPE_T3640485471_H
#ifndef U3CONFINISHSUBMITU3EC__ITERATOR0_T3413438900_H
#define U3CONFINISHSUBMITU3EC__ITERATOR0_T3413438900_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Button/<OnFinishSubmit>c__Iterator0
struct U3COnFinishSubmitU3Ec__Iterator0_t3413438900 : public RuntimeObject
{
public:
// System.Single UnityEngine.UI.Button/<OnFinishSubmit>c__Iterator0::<fadeTime>__0
float ___U3CfadeTimeU3E__0_0;
// System.Single UnityEngine.UI.Button/<OnFinishSubmit>c__Iterator0::<elapsedTime>__0
float ___U3CelapsedTimeU3E__0_1;
// UnityEngine.UI.Button UnityEngine.UI.Button/<OnFinishSubmit>c__Iterator0::$this
Button_t4055032469 * ___U24this_2;
// System.Object UnityEngine.UI.Button/<OnFinishSubmit>c__Iterator0::$current
RuntimeObject * ___U24current_3;
// System.Boolean UnityEngine.UI.Button/<OnFinishSubmit>c__Iterator0::$disposing
bool ___U24disposing_4;
// System.Int32 UnityEngine.UI.Button/<OnFinishSubmit>c__Iterator0::$PC
int32_t ___U24PC_5;
public:
inline static int32_t get_offset_of_U3CfadeTimeU3E__0_0() { return static_cast<int32_t>(offsetof(U3COnFinishSubmitU3Ec__Iterator0_t3413438900, ___U3CfadeTimeU3E__0_0)); }
inline float get_U3CfadeTimeU3E__0_0() const { return ___U3CfadeTimeU3E__0_0; }
inline float* get_address_of_U3CfadeTimeU3E__0_0() { return &___U3CfadeTimeU3E__0_0; }
inline void set_U3CfadeTimeU3E__0_0(float value)
{
___U3CfadeTimeU3E__0_0 = value;
}
inline static int32_t get_offset_of_U3CelapsedTimeU3E__0_1() { return static_cast<int32_t>(offsetof(U3COnFinishSubmitU3Ec__Iterator0_t3413438900, ___U3CelapsedTimeU3E__0_1)); }
inline float get_U3CelapsedTimeU3E__0_1() const { return ___U3CelapsedTimeU3E__0_1; }
inline float* get_address_of_U3CelapsedTimeU3E__0_1() { return &___U3CelapsedTimeU3E__0_1; }
inline void set_U3CelapsedTimeU3E__0_1(float value)
{
___U3CelapsedTimeU3E__0_1 = value;
}
inline static int32_t get_offset_of_U24this_2() { return static_cast<int32_t>(offsetof(U3COnFinishSubmitU3Ec__Iterator0_t3413438900, ___U24this_2)); }
inline Button_t4055032469 * get_U24this_2() const { return ___U24this_2; }
inline Button_t4055032469 ** get_address_of_U24this_2() { return &___U24this_2; }
inline void set_U24this_2(Button_t4055032469 * value)
{
___U24this_2 = value;
Il2CppCodeGenWriteBarrier((&___U24this_2), value);
}
inline static int32_t get_offset_of_U24current_3() { return static_cast<int32_t>(offsetof(U3COnFinishSubmitU3Ec__Iterator0_t3413438900, ___U24current_3)); }
inline RuntimeObject * get_U24current_3() const { return ___U24current_3; }
inline RuntimeObject ** get_address_of_U24current_3() { return &___U24current_3; }
inline void set_U24current_3(RuntimeObject * value)
{
___U24current_3 = value;
Il2CppCodeGenWriteBarrier((&___U24current_3), value);
}
inline static int32_t get_offset_of_U24disposing_4() { return static_cast<int32_t>(offsetof(U3COnFinishSubmitU3Ec__Iterator0_t3413438900, ___U24disposing_4)); }
inline bool get_U24disposing_4() const { return ___U24disposing_4; }
inline bool* get_address_of_U24disposing_4() { return &___U24disposing_4; }
inline void set_U24disposing_4(bool value)
{
___U24disposing_4 = value;
}
inline static int32_t get_offset_of_U24PC_5() { return static_cast<int32_t>(offsetof(U3COnFinishSubmitU3Ec__Iterator0_t3413438900, ___U24PC_5)); }
inline int32_t get_U24PC_5() const { return ___U24PC_5; }
inline int32_t* get_address_of_U24PC_5() { return &___U24PC_5; }
inline void set_U24PC_5(int32_t value)
{
___U24PC_5 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // U3CONFINISHSUBMITU3EC__ITERATOR0_T3413438900_H
#ifndef CANVASUPDATEREGISTRY_T2720824592_H
#define CANVASUPDATEREGISTRY_T2720824592_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.CanvasUpdateRegistry
struct CanvasUpdateRegistry_t2720824592 : public RuntimeObject
{
public:
// System.Boolean UnityEngine.UI.CanvasUpdateRegistry::m_PerformingLayoutUpdate
bool ___m_PerformingLayoutUpdate_1;
// System.Boolean UnityEngine.UI.CanvasUpdateRegistry::m_PerformingGraphicUpdate
bool ___m_PerformingGraphicUpdate_2;
// UnityEngine.UI.Collections.IndexedSet`1<UnityEngine.UI.ICanvasElement> UnityEngine.UI.CanvasUpdateRegistry::m_LayoutRebuildQueue
IndexedSet_1_t3571286806 * ___m_LayoutRebuildQueue_3;
// UnityEngine.UI.Collections.IndexedSet`1<UnityEngine.UI.ICanvasElement> UnityEngine.UI.CanvasUpdateRegistry::m_GraphicRebuildQueue
IndexedSet_1_t3571286806 * ___m_GraphicRebuildQueue_4;
public:
inline static int32_t get_offset_of_m_PerformingLayoutUpdate_1() { return static_cast<int32_t>(offsetof(CanvasUpdateRegistry_t2720824592, ___m_PerformingLayoutUpdate_1)); }
inline bool get_m_PerformingLayoutUpdate_1() const { return ___m_PerformingLayoutUpdate_1; }
inline bool* get_address_of_m_PerformingLayoutUpdate_1() { return &___m_PerformingLayoutUpdate_1; }
inline void set_m_PerformingLayoutUpdate_1(bool value)
{
___m_PerformingLayoutUpdate_1 = value;
}
inline static int32_t get_offset_of_m_PerformingGraphicUpdate_2() { return static_cast<int32_t>(offsetof(CanvasUpdateRegistry_t2720824592, ___m_PerformingGraphicUpdate_2)); }
inline bool get_m_PerformingGraphicUpdate_2() const { return ___m_PerformingGraphicUpdate_2; }
inline bool* get_address_of_m_PerformingGraphicUpdate_2() { return &___m_PerformingGraphicUpdate_2; }
inline void set_m_PerformingGraphicUpdate_2(bool value)
{
___m_PerformingGraphicUpdate_2 = value;
}
inline static int32_t get_offset_of_m_LayoutRebuildQueue_3() { return static_cast<int32_t>(offsetof(CanvasUpdateRegistry_t2720824592, ___m_LayoutRebuildQueue_3)); }
inline IndexedSet_1_t3571286806 * get_m_LayoutRebuildQueue_3() const { return ___m_LayoutRebuildQueue_3; }
inline IndexedSet_1_t3571286806 ** get_address_of_m_LayoutRebuildQueue_3() { return &___m_LayoutRebuildQueue_3; }
inline void set_m_LayoutRebuildQueue_3(IndexedSet_1_t3571286806 * value)
{
___m_LayoutRebuildQueue_3 = value;
Il2CppCodeGenWriteBarrier((&___m_LayoutRebuildQueue_3), value);
}
inline static int32_t get_offset_of_m_GraphicRebuildQueue_4() { return static_cast<int32_t>(offsetof(CanvasUpdateRegistry_t2720824592, ___m_GraphicRebuildQueue_4)); }
inline IndexedSet_1_t3571286806 * get_m_GraphicRebuildQueue_4() const { return ___m_GraphicRebuildQueue_4; }
inline IndexedSet_1_t3571286806 ** get_address_of_m_GraphicRebuildQueue_4() { return &___m_GraphicRebuildQueue_4; }
inline void set_m_GraphicRebuildQueue_4(IndexedSet_1_t3571286806 * value)
{
___m_GraphicRebuildQueue_4 = value;
Il2CppCodeGenWriteBarrier((&___m_GraphicRebuildQueue_4), value);
}
};
struct CanvasUpdateRegistry_t2720824592_StaticFields
{
public:
// UnityEngine.UI.CanvasUpdateRegistry UnityEngine.UI.CanvasUpdateRegistry::s_Instance
CanvasUpdateRegistry_t2720824592 * ___s_Instance_0;
// System.Comparison`1<UnityEngine.UI.ICanvasElement> UnityEngine.UI.CanvasUpdateRegistry::s_SortLayoutFunction
Comparison_1_t1896830045 * ___s_SortLayoutFunction_5;
// System.Comparison`1<UnityEngine.UI.ICanvasElement> UnityEngine.UI.CanvasUpdateRegistry::<>f__mg$cache0
Comparison_1_t1896830045 * ___U3CU3Ef__mgU24cache0_6;
public:
inline static int32_t get_offset_of_s_Instance_0() { return static_cast<int32_t>(offsetof(CanvasUpdateRegistry_t2720824592_StaticFields, ___s_Instance_0)); }
inline CanvasUpdateRegistry_t2720824592 * get_s_Instance_0() const { return ___s_Instance_0; }
inline CanvasUpdateRegistry_t2720824592 ** get_address_of_s_Instance_0() { return &___s_Instance_0; }
inline void set_s_Instance_0(CanvasUpdateRegistry_t2720824592 * value)
{
___s_Instance_0 = value;
Il2CppCodeGenWriteBarrier((&___s_Instance_0), value);
}
inline static int32_t get_offset_of_s_SortLayoutFunction_5() { return static_cast<int32_t>(offsetof(CanvasUpdateRegistry_t2720824592_StaticFields, ___s_SortLayoutFunction_5)); }
inline Comparison_1_t1896830045 * get_s_SortLayoutFunction_5() const { return ___s_SortLayoutFunction_5; }
inline Comparison_1_t1896830045 ** get_address_of_s_SortLayoutFunction_5() { return &___s_SortLayoutFunction_5; }
inline void set_s_SortLayoutFunction_5(Comparison_1_t1896830045 * value)
{
___s_SortLayoutFunction_5 = value;
Il2CppCodeGenWriteBarrier((&___s_SortLayoutFunction_5), value);
}
inline static int32_t get_offset_of_U3CU3Ef__mgU24cache0_6() { return static_cast<int32_t>(offsetof(CanvasUpdateRegistry_t2720824592_StaticFields, ___U3CU3Ef__mgU24cache0_6)); }
inline Comparison_1_t1896830045 * get_U3CU3Ef__mgU24cache0_6() const { return ___U3CU3Ef__mgU24cache0_6; }
inline Comparison_1_t1896830045 ** get_address_of_U3CU3Ef__mgU24cache0_6() { return &___U3CU3Ef__mgU24cache0_6; }
inline void set_U3CU3Ef__mgU24cache0_6(Comparison_1_t1896830045 * value)
{
___U3CU3Ef__mgU24cache0_6 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__mgU24cache0_6), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CANVASUPDATEREGISTRY_T2720824592_H
#ifndef SETPROPERTYUTILITY_T3359423571_H
#define SETPROPERTYUTILITY_T3359423571_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.SetPropertyUtility
struct SetPropertyUtility_t3359423571 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SETPROPERTYUTILITY_T3359423571_H
#ifndef U3CCARETBLINKU3EC__ITERATOR0_T2589889038_H
#define U3CCARETBLINKU3EC__ITERATOR0_T2589889038_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/<CaretBlink>c__Iterator0
struct U3CCaretBlinkU3Ec__Iterator0_t2589889038 : public RuntimeObject
{
public:
// System.Single UnityEngine.UI.InputField/<CaretBlink>c__Iterator0::<blinkPeriod>__1
float ___U3CblinkPeriodU3E__1_0;
// System.Boolean UnityEngine.UI.InputField/<CaretBlink>c__Iterator0::<blinkState>__1
bool ___U3CblinkStateU3E__1_1;
// UnityEngine.UI.InputField UnityEngine.UI.InputField/<CaretBlink>c__Iterator0::$this
InputField_t3762917431 * ___U24this_2;
// System.Object UnityEngine.UI.InputField/<CaretBlink>c__Iterator0::$current
RuntimeObject * ___U24current_3;
// System.Boolean UnityEngine.UI.InputField/<CaretBlink>c__Iterator0::$disposing
bool ___U24disposing_4;
// System.Int32 UnityEngine.UI.InputField/<CaretBlink>c__Iterator0::$PC
int32_t ___U24PC_5;
public:
inline static int32_t get_offset_of_U3CblinkPeriodU3E__1_0() { return static_cast<int32_t>(offsetof(U3CCaretBlinkU3Ec__Iterator0_t2589889038, ___U3CblinkPeriodU3E__1_0)); }
inline float get_U3CblinkPeriodU3E__1_0() const { return ___U3CblinkPeriodU3E__1_0; }
inline float* get_address_of_U3CblinkPeriodU3E__1_0() { return &___U3CblinkPeriodU3E__1_0; }
inline void set_U3CblinkPeriodU3E__1_0(float value)
{
___U3CblinkPeriodU3E__1_0 = value;
}
inline static int32_t get_offset_of_U3CblinkStateU3E__1_1() { return static_cast<int32_t>(offsetof(U3CCaretBlinkU3Ec__Iterator0_t2589889038, ___U3CblinkStateU3E__1_1)); }
inline bool get_U3CblinkStateU3E__1_1() const { return ___U3CblinkStateU3E__1_1; }
inline bool* get_address_of_U3CblinkStateU3E__1_1() { return &___U3CblinkStateU3E__1_1; }
inline void set_U3CblinkStateU3E__1_1(bool value)
{
___U3CblinkStateU3E__1_1 = value;
}
inline static int32_t get_offset_of_U24this_2() { return static_cast<int32_t>(offsetof(U3CCaretBlinkU3Ec__Iterator0_t2589889038, ___U24this_2)); }
inline InputField_t3762917431 * get_U24this_2() const { return ___U24this_2; }
inline InputField_t3762917431 ** get_address_of_U24this_2() { return &___U24this_2; }
inline void set_U24this_2(InputField_t3762917431 * value)
{
___U24this_2 = value;
Il2CppCodeGenWriteBarrier((&___U24this_2), value);
}
inline static int32_t get_offset_of_U24current_3() { return static_cast<int32_t>(offsetof(U3CCaretBlinkU3Ec__Iterator0_t2589889038, ___U24current_3)); }
inline RuntimeObject * get_U24current_3() const { return ___U24current_3; }
inline RuntimeObject ** get_address_of_U24current_3() { return &___U24current_3; }
inline void set_U24current_3(RuntimeObject * value)
{
___U24current_3 = value;
Il2CppCodeGenWriteBarrier((&___U24current_3), value);
}
inline static int32_t get_offset_of_U24disposing_4() { return static_cast<int32_t>(offsetof(U3CCaretBlinkU3Ec__Iterator0_t2589889038, ___U24disposing_4)); }
inline bool get_U24disposing_4() const { return ___U24disposing_4; }
inline bool* get_address_of_U24disposing_4() { return &___U24disposing_4; }
inline void set_U24disposing_4(bool value)
{
___U24disposing_4 = value;
}
inline static int32_t get_offset_of_U24PC_5() { return static_cast<int32_t>(offsetof(U3CCaretBlinkU3Ec__Iterator0_t2589889038, ___U24PC_5)); }
inline int32_t get_U24PC_5() const { return ___U24PC_5; }
inline int32_t* get_address_of_U24PC_5() { return &___U24PC_5; }
inline void set_U24PC_5(int32_t value)
{
___U24PC_5 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // U3CCARETBLINKU3EC__ITERATOR0_T2589889038_H
#ifndef MASKUTILITIES_T4151184739_H
#define MASKUTILITIES_T4151184739_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.MaskUtilities
struct MaskUtilities_t4151184739 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MASKUTILITIES_T4151184739_H
#ifndef UNITYEVENTBASE_T3960448221_H
#define UNITYEVENTBASE_T3960448221_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Events.UnityEventBase
struct UnityEventBase_t3960448221 : public RuntimeObject
{
public:
// UnityEngine.Events.InvokableCallList UnityEngine.Events.UnityEventBase::m_Calls
InvokableCallList_t2498835369 * ___m_Calls_0;
// UnityEngine.Events.PersistentCallGroup UnityEngine.Events.UnityEventBase::m_PersistentCalls
PersistentCallGroup_t3050769227 * ___m_PersistentCalls_1;
// System.String UnityEngine.Events.UnityEventBase::m_TypeName
String_t* ___m_TypeName_2;
// System.Boolean UnityEngine.Events.UnityEventBase::m_CallsDirty
bool ___m_CallsDirty_3;
public:
inline static int32_t get_offset_of_m_Calls_0() { return static_cast<int32_t>(offsetof(UnityEventBase_t3960448221, ___m_Calls_0)); }
inline InvokableCallList_t2498835369 * get_m_Calls_0() const { return ___m_Calls_0; }
inline InvokableCallList_t2498835369 ** get_address_of_m_Calls_0() { return &___m_Calls_0; }
inline void set_m_Calls_0(InvokableCallList_t2498835369 * value)
{
___m_Calls_0 = value;
Il2CppCodeGenWriteBarrier((&___m_Calls_0), value);
}
inline static int32_t get_offset_of_m_PersistentCalls_1() { return static_cast<int32_t>(offsetof(UnityEventBase_t3960448221, ___m_PersistentCalls_1)); }
inline PersistentCallGroup_t3050769227 * get_m_PersistentCalls_1() const { return ___m_PersistentCalls_1; }
inline PersistentCallGroup_t3050769227 ** get_address_of_m_PersistentCalls_1() { return &___m_PersistentCalls_1; }
inline void set_m_PersistentCalls_1(PersistentCallGroup_t3050769227 * value)
{
___m_PersistentCalls_1 = value;
Il2CppCodeGenWriteBarrier((&___m_PersistentCalls_1), value);
}
inline static int32_t get_offset_of_m_TypeName_2() { return static_cast<int32_t>(offsetof(UnityEventBase_t3960448221, ___m_TypeName_2)); }
inline String_t* get_m_TypeName_2() const { return ___m_TypeName_2; }
inline String_t** get_address_of_m_TypeName_2() { return &___m_TypeName_2; }
inline void set_m_TypeName_2(String_t* value)
{
___m_TypeName_2 = value;
Il2CppCodeGenWriteBarrier((&___m_TypeName_2), value);
}
inline static int32_t get_offset_of_m_CallsDirty_3() { return static_cast<int32_t>(offsetof(UnityEventBase_t3960448221, ___m_CallsDirty_3)); }
inline bool get_m_CallsDirty_3() const { return ___m_CallsDirty_3; }
inline bool* get_address_of_m_CallsDirty_3() { return &___m_CallsDirty_3; }
inline void set_m_CallsDirty_3(bool value)
{
___m_CallsDirty_3 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNITYEVENTBASE_T3960448221_H
#ifndef OPTIONDATALIST_T1438173104_H
#define OPTIONDATALIST_T1438173104_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Dropdown/OptionDataList
struct OptionDataList_t1438173104 : public RuntimeObject
{
public:
// System.Collections.Generic.List`1<UnityEngine.UI.Dropdown/OptionData> UnityEngine.UI.Dropdown/OptionDataList::m_Options
List_1_t447389798 * ___m_Options_0;
public:
inline static int32_t get_offset_of_m_Options_0() { return static_cast<int32_t>(offsetof(OptionDataList_t1438173104, ___m_Options_0)); }
inline List_1_t447389798 * get_m_Options_0() const { return ___m_Options_0; }
inline List_1_t447389798 ** get_address_of_m_Options_0() { return &___m_Options_0; }
inline void set_m_Options_0(List_1_t447389798 * value)
{
___m_Options_0 = value;
Il2CppCodeGenWriteBarrier((&___m_Options_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // OPTIONDATALIST_T1438173104_H
#ifndef OPTIONDATA_T3270282352_H
#define OPTIONDATA_T3270282352_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Dropdown/OptionData
struct OptionData_t3270282352 : public RuntimeObject
{
public:
// System.String UnityEngine.UI.Dropdown/OptionData::m_Text
String_t* ___m_Text_0;
// UnityEngine.Sprite UnityEngine.UI.Dropdown/OptionData::m_Image
Sprite_t280657092 * ___m_Image_1;
public:
inline static int32_t get_offset_of_m_Text_0() { return static_cast<int32_t>(offsetof(OptionData_t3270282352, ___m_Text_0)); }
inline String_t* get_m_Text_0() const { return ___m_Text_0; }
inline String_t** get_address_of_m_Text_0() { return &___m_Text_0; }
inline void set_m_Text_0(String_t* value)
{
___m_Text_0 = value;
Il2CppCodeGenWriteBarrier((&___m_Text_0), value);
}
inline static int32_t get_offset_of_m_Image_1() { return static_cast<int32_t>(offsetof(OptionData_t3270282352, ___m_Image_1)); }
inline Sprite_t280657092 * get_m_Image_1() const { return ___m_Image_1; }
inline Sprite_t280657092 ** get_address_of_m_Image_1() { return &___m_Image_1; }
inline void set_m_Image_1(Sprite_t280657092 * value)
{
___m_Image_1 = value;
Il2CppCodeGenWriteBarrier((&___m_Image_1), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // OPTIONDATA_T3270282352_H
#ifndef COLOR_T2555686324_H
#define COLOR_T2555686324_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Color
struct Color_t2555686324
{
public:
// System.Single UnityEngine.Color::r
float ___r_0;
// System.Single UnityEngine.Color::g
float ___g_1;
// System.Single UnityEngine.Color::b
float ___b_2;
// System.Single UnityEngine.Color::a
float ___a_3;
public:
inline static int32_t get_offset_of_r_0() { return static_cast<int32_t>(offsetof(Color_t2555686324, ___r_0)); }
inline float get_r_0() const { return ___r_0; }
inline float* get_address_of_r_0() { return &___r_0; }
inline void set_r_0(float value)
{
___r_0 = value;
}
inline static int32_t get_offset_of_g_1() { return static_cast<int32_t>(offsetof(Color_t2555686324, ___g_1)); }
inline float get_g_1() const { return ___g_1; }
inline float* get_address_of_g_1() { return &___g_1; }
inline void set_g_1(float value)
{
___g_1 = value;
}
inline static int32_t get_offset_of_b_2() { return static_cast<int32_t>(offsetof(Color_t2555686324, ___b_2)); }
inline float get_b_2() const { return ___b_2; }
inline float* get_address_of_b_2() { return &___b_2; }
inline void set_b_2(float value)
{
___b_2 = value;
}
inline static int32_t get_offset_of_a_3() { return static_cast<int32_t>(offsetof(Color_t2555686324, ___a_3)); }
inline float get_a_3() const { return ___a_3; }
inline float* get_address_of_a_3() { return &___a_3; }
inline void set_a_3(float value)
{
___a_3 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // COLOR_T2555686324_H
#ifndef ENUM_T4135868527_H
#define ENUM_T4135868527_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Enum
struct Enum_t4135868527 : public ValueType_t3640485471
{
public:
public:
};
struct Enum_t4135868527_StaticFields
{
public:
// System.Char[] System.Enum::split_char
CharU5BU5D_t3528271667* ___split_char_0;
public:
inline static int32_t get_offset_of_split_char_0() { return static_cast<int32_t>(offsetof(Enum_t4135868527_StaticFields, ___split_char_0)); }
inline CharU5BU5D_t3528271667* get_split_char_0() const { return ___split_char_0; }
inline CharU5BU5D_t3528271667** get_address_of_split_char_0() { return &___split_char_0; }
inline void set_split_char_0(CharU5BU5D_t3528271667* value)
{
___split_char_0 = value;
Il2CppCodeGenWriteBarrier((&___split_char_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.Enum
struct Enum_t4135868527_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.Enum
struct Enum_t4135868527_marshaled_com
{
};
#endif // ENUM_T4135868527_H
#ifndef UNITYEVENT_T2581268647_H
#define UNITYEVENT_T2581268647_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Events.UnityEvent
struct UnityEvent_t2581268647 : public UnityEventBase_t3960448221
{
public:
// System.Object[] UnityEngine.Events.UnityEvent::m_InvokeArray
ObjectU5BU5D_t2843939325* ___m_InvokeArray_4;
public:
inline static int32_t get_offset_of_m_InvokeArray_4() { return static_cast<int32_t>(offsetof(UnityEvent_t2581268647, ___m_InvokeArray_4)); }
inline ObjectU5BU5D_t2843939325* get_m_InvokeArray_4() const { return ___m_InvokeArray_4; }
inline ObjectU5BU5D_t2843939325** get_address_of_m_InvokeArray_4() { return &___m_InvokeArray_4; }
inline void set_m_InvokeArray_4(ObjectU5BU5D_t2843939325* value)
{
___m_InvokeArray_4 = value;
Il2CppCodeGenWriteBarrier((&___m_InvokeArray_4), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNITYEVENT_T2581268647_H
#ifndef VECTOR2_T2156229523_H
#define VECTOR2_T2156229523_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Vector2
struct Vector2_t2156229523
{
public:
// System.Single UnityEngine.Vector2::x
float ___x_0;
// System.Single UnityEngine.Vector2::y
float ___y_1;
public:
inline static int32_t get_offset_of_x_0() { return static_cast<int32_t>(offsetof(Vector2_t2156229523, ___x_0)); }
inline float get_x_0() const { return ___x_0; }
inline float* get_address_of_x_0() { return &___x_0; }
inline void set_x_0(float value)
{
___x_0 = value;
}
inline static int32_t get_offset_of_y_1() { return static_cast<int32_t>(offsetof(Vector2_t2156229523, ___y_1)); }
inline float get_y_1() const { return ___y_1; }
inline float* get_address_of_y_1() { return &___y_1; }
inline void set_y_1(float value)
{
___y_1 = value;
}
};
struct Vector2_t2156229523_StaticFields
{
public:
// UnityEngine.Vector2 UnityEngine.Vector2::zeroVector
Vector2_t2156229523 ___zeroVector_2;
// UnityEngine.Vector2 UnityEngine.Vector2::oneVector
Vector2_t2156229523 ___oneVector_3;
// UnityEngine.Vector2 UnityEngine.Vector2::upVector
Vector2_t2156229523 ___upVector_4;
// UnityEngine.Vector2 UnityEngine.Vector2::downVector
Vector2_t2156229523 ___downVector_5;
// UnityEngine.Vector2 UnityEngine.Vector2::leftVector
Vector2_t2156229523 ___leftVector_6;
// UnityEngine.Vector2 UnityEngine.Vector2::rightVector
Vector2_t2156229523 ___rightVector_7;
// UnityEngine.Vector2 UnityEngine.Vector2::positiveInfinityVector
Vector2_t2156229523 ___positiveInfinityVector_8;
// UnityEngine.Vector2 UnityEngine.Vector2::negativeInfinityVector
Vector2_t2156229523 ___negativeInfinityVector_9;
public:
inline static int32_t get_offset_of_zeroVector_2() { return static_cast<int32_t>(offsetof(Vector2_t2156229523_StaticFields, ___zeroVector_2)); }
inline Vector2_t2156229523 get_zeroVector_2() const { return ___zeroVector_2; }
inline Vector2_t2156229523 * get_address_of_zeroVector_2() { return &___zeroVector_2; }
inline void set_zeroVector_2(Vector2_t2156229523 value)
{
___zeroVector_2 = value;
}
inline static int32_t get_offset_of_oneVector_3() { return static_cast<int32_t>(offsetof(Vector2_t2156229523_StaticFields, ___oneVector_3)); }
inline Vector2_t2156229523 get_oneVector_3() const { return ___oneVector_3; }
inline Vector2_t2156229523 * get_address_of_oneVector_3() { return &___oneVector_3; }
inline void set_oneVector_3(Vector2_t2156229523 value)
{
___oneVector_3 = value;
}
inline static int32_t get_offset_of_upVector_4() { return static_cast<int32_t>(offsetof(Vector2_t2156229523_StaticFields, ___upVector_4)); }
inline Vector2_t2156229523 get_upVector_4() const { return ___upVector_4; }
inline Vector2_t2156229523 * get_address_of_upVector_4() { return &___upVector_4; }
inline void set_upVector_4(Vector2_t2156229523 value)
{
___upVector_4 = value;
}
inline static int32_t get_offset_of_downVector_5() { return static_cast<int32_t>(offsetof(Vector2_t2156229523_StaticFields, ___downVector_5)); }
inline Vector2_t2156229523 get_downVector_5() const { return ___downVector_5; }
inline Vector2_t2156229523 * get_address_of_downVector_5() { return &___downVector_5; }
inline void set_downVector_5(Vector2_t2156229523 value)
{
___downVector_5 = value;
}
inline static int32_t get_offset_of_leftVector_6() { return static_cast<int32_t>(offsetof(Vector2_t2156229523_StaticFields, ___leftVector_6)); }
inline Vector2_t2156229523 get_leftVector_6() const { return ___leftVector_6; }
inline Vector2_t2156229523 * get_address_of_leftVector_6() { return &___leftVector_6; }
inline void set_leftVector_6(Vector2_t2156229523 value)
{
___leftVector_6 = value;
}
inline static int32_t get_offset_of_rightVector_7() { return static_cast<int32_t>(offsetof(Vector2_t2156229523_StaticFields, ___rightVector_7)); }
inline Vector2_t2156229523 get_rightVector_7() const { return ___rightVector_7; }
inline Vector2_t2156229523 * get_address_of_rightVector_7() { return &___rightVector_7; }
inline void set_rightVector_7(Vector2_t2156229523 value)
{
___rightVector_7 = value;
}
inline static int32_t get_offset_of_positiveInfinityVector_8() { return static_cast<int32_t>(offsetof(Vector2_t2156229523_StaticFields, ___positiveInfinityVector_8)); }
inline Vector2_t2156229523 get_positiveInfinityVector_8() const { return ___positiveInfinityVector_8; }
inline Vector2_t2156229523 * get_address_of_positiveInfinityVector_8() { return &___positiveInfinityVector_8; }
inline void set_positiveInfinityVector_8(Vector2_t2156229523 value)
{
___positiveInfinityVector_8 = value;
}
inline static int32_t get_offset_of_negativeInfinityVector_9() { return static_cast<int32_t>(offsetof(Vector2_t2156229523_StaticFields, ___negativeInfinityVector_9)); }
inline Vector2_t2156229523 get_negativeInfinityVector_9() const { return ___negativeInfinityVector_9; }
inline Vector2_t2156229523 * get_address_of_negativeInfinityVector_9() { return &___negativeInfinityVector_9; }
inline void set_negativeInfinityVector_9(Vector2_t2156229523 value)
{
___negativeInfinityVector_9 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // VECTOR2_T2156229523_H
#ifndef LAYERMASK_T3493934918_H
#define LAYERMASK_T3493934918_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.LayerMask
struct LayerMask_t3493934918
{
public:
// System.Int32 UnityEngine.LayerMask::m_Mask
int32_t ___m_Mask_0;
public:
inline static int32_t get_offset_of_m_Mask_0() { return static_cast<int32_t>(offsetof(LayerMask_t3493934918, ___m_Mask_0)); }
inline int32_t get_m_Mask_0() const { return ___m_Mask_0; }
inline int32_t* get_address_of_m_Mask_0() { return &___m_Mask_0; }
inline void set_m_Mask_0(int32_t value)
{
___m_Mask_0 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // LAYERMASK_T3493934918_H
#ifndef UNITYEVENT_1_T3832605257_H
#define UNITYEVENT_1_T3832605257_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Events.UnityEvent`1<System.Int32>
struct UnityEvent_1_t3832605257 : public UnityEventBase_t3960448221
{
public:
// System.Object[] UnityEngine.Events.UnityEvent`1::m_InvokeArray
ObjectU5BU5D_t2843939325* ___m_InvokeArray_4;
public:
inline static int32_t get_offset_of_m_InvokeArray_4() { return static_cast<int32_t>(offsetof(UnityEvent_1_t3832605257, ___m_InvokeArray_4)); }
inline ObjectU5BU5D_t2843939325* get_m_InvokeArray_4() const { return ___m_InvokeArray_4; }
inline ObjectU5BU5D_t2843939325** get_address_of_m_InvokeArray_4() { return &___m_InvokeArray_4; }
inline void set_m_InvokeArray_4(ObjectU5BU5D_t2843939325* value)
{
___m_InvokeArray_4 = value;
Il2CppCodeGenWriteBarrier((&___m_InvokeArray_4), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNITYEVENT_1_T3832605257_H
#ifndef INTPTR_T_H
#define INTPTR_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.IntPtr
struct IntPtr_t
{
public:
// System.Void* System.IntPtr::m_value
void* ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(IntPtr_t, ___m_value_0)); }
inline void* get_m_value_0() const { return ___m_value_0; }
inline void** get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(void* value)
{
___m_value_0 = value;
}
};
struct IntPtr_t_StaticFields
{
public:
// System.IntPtr System.IntPtr::Zero
intptr_t ___Zero_1;
public:
inline static int32_t get_offset_of_Zero_1() { return static_cast<int32_t>(offsetof(IntPtr_t_StaticFields, ___Zero_1)); }
inline intptr_t get_Zero_1() const { return ___Zero_1; }
inline intptr_t* get_address_of_Zero_1() { return &___Zero_1; }
inline void set_Zero_1(intptr_t value)
{
___Zero_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INTPTR_T_H
#ifndef VECTOR3_T3722313464_H
#define VECTOR3_T3722313464_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Vector3
struct Vector3_t3722313464
{
public:
// System.Single UnityEngine.Vector3::x
float ___x_1;
// System.Single UnityEngine.Vector3::y
float ___y_2;
// System.Single UnityEngine.Vector3::z
float ___z_3;
public:
inline static int32_t get_offset_of_x_1() { return static_cast<int32_t>(offsetof(Vector3_t3722313464, ___x_1)); }
inline float get_x_1() const { return ___x_1; }
inline float* get_address_of_x_1() { return &___x_1; }
inline void set_x_1(float value)
{
___x_1 = value;
}
inline static int32_t get_offset_of_y_2() { return static_cast<int32_t>(offsetof(Vector3_t3722313464, ___y_2)); }
inline float get_y_2() const { return ___y_2; }
inline float* get_address_of_y_2() { return &___y_2; }
inline void set_y_2(float value)
{
___y_2 = value;
}
inline static int32_t get_offset_of_z_3() { return static_cast<int32_t>(offsetof(Vector3_t3722313464, ___z_3)); }
inline float get_z_3() const { return ___z_3; }
inline float* get_address_of_z_3() { return &___z_3; }
inline void set_z_3(float value)
{
___z_3 = value;
}
};
struct Vector3_t3722313464_StaticFields
{
public:
// UnityEngine.Vector3 UnityEngine.Vector3::zeroVector
Vector3_t3722313464 ___zeroVector_4;
// UnityEngine.Vector3 UnityEngine.Vector3::oneVector
Vector3_t3722313464 ___oneVector_5;
// UnityEngine.Vector3 UnityEngine.Vector3::upVector
Vector3_t3722313464 ___upVector_6;
// UnityEngine.Vector3 UnityEngine.Vector3::downVector
Vector3_t3722313464 ___downVector_7;
// UnityEngine.Vector3 UnityEngine.Vector3::leftVector
Vector3_t3722313464 ___leftVector_8;
// UnityEngine.Vector3 UnityEngine.Vector3::rightVector
Vector3_t3722313464 ___rightVector_9;
// UnityEngine.Vector3 UnityEngine.Vector3::forwardVector
Vector3_t3722313464 ___forwardVector_10;
// UnityEngine.Vector3 UnityEngine.Vector3::backVector
Vector3_t3722313464 ___backVector_11;
// UnityEngine.Vector3 UnityEngine.Vector3::positiveInfinityVector
Vector3_t3722313464 ___positiveInfinityVector_12;
// UnityEngine.Vector3 UnityEngine.Vector3::negativeInfinityVector
Vector3_t3722313464 ___negativeInfinityVector_13;
public:
inline static int32_t get_offset_of_zeroVector_4() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___zeroVector_4)); }
inline Vector3_t3722313464 get_zeroVector_4() const { return ___zeroVector_4; }
inline Vector3_t3722313464 * get_address_of_zeroVector_4() { return &___zeroVector_4; }
inline void set_zeroVector_4(Vector3_t3722313464 value)
{
___zeroVector_4 = value;
}
inline static int32_t get_offset_of_oneVector_5() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___oneVector_5)); }
inline Vector3_t3722313464 get_oneVector_5() const { return ___oneVector_5; }
inline Vector3_t3722313464 * get_address_of_oneVector_5() { return &___oneVector_5; }
inline void set_oneVector_5(Vector3_t3722313464 value)
{
___oneVector_5 = value;
}
inline static int32_t get_offset_of_upVector_6() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___upVector_6)); }
inline Vector3_t3722313464 get_upVector_6() const { return ___upVector_6; }
inline Vector3_t3722313464 * get_address_of_upVector_6() { return &___upVector_6; }
inline void set_upVector_6(Vector3_t3722313464 value)
{
___upVector_6 = value;
}
inline static int32_t get_offset_of_downVector_7() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___downVector_7)); }
inline Vector3_t3722313464 get_downVector_7() const { return ___downVector_7; }
inline Vector3_t3722313464 * get_address_of_downVector_7() { return &___downVector_7; }
inline void set_downVector_7(Vector3_t3722313464 value)
{
___downVector_7 = value;
}
inline static int32_t get_offset_of_leftVector_8() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___leftVector_8)); }
inline Vector3_t3722313464 get_leftVector_8() const { return ___leftVector_8; }
inline Vector3_t3722313464 * get_address_of_leftVector_8() { return &___leftVector_8; }
inline void set_leftVector_8(Vector3_t3722313464 value)
{
___leftVector_8 = value;
}
inline static int32_t get_offset_of_rightVector_9() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___rightVector_9)); }
inline Vector3_t3722313464 get_rightVector_9() const { return ___rightVector_9; }
inline Vector3_t3722313464 * get_address_of_rightVector_9() { return &___rightVector_9; }
inline void set_rightVector_9(Vector3_t3722313464 value)
{
___rightVector_9 = value;
}
inline static int32_t get_offset_of_forwardVector_10() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___forwardVector_10)); }
inline Vector3_t3722313464 get_forwardVector_10() const { return ___forwardVector_10; }
inline Vector3_t3722313464 * get_address_of_forwardVector_10() { return &___forwardVector_10; }
inline void set_forwardVector_10(Vector3_t3722313464 value)
{
___forwardVector_10 = value;
}
inline static int32_t get_offset_of_backVector_11() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___backVector_11)); }
inline Vector3_t3722313464 get_backVector_11() const { return ___backVector_11; }
inline Vector3_t3722313464 * get_address_of_backVector_11() { return &___backVector_11; }
inline void set_backVector_11(Vector3_t3722313464 value)
{
___backVector_11 = value;
}
inline static int32_t get_offset_of_positiveInfinityVector_12() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___positiveInfinityVector_12)); }
inline Vector3_t3722313464 get_positiveInfinityVector_12() const { return ___positiveInfinityVector_12; }
inline Vector3_t3722313464 * get_address_of_positiveInfinityVector_12() { return &___positiveInfinityVector_12; }
inline void set_positiveInfinityVector_12(Vector3_t3722313464 value)
{
___positiveInfinityVector_12 = value;
}
inline static int32_t get_offset_of_negativeInfinityVector_13() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___negativeInfinityVector_13)); }
inline Vector3_t3722313464 get_negativeInfinityVector_13() const { return ___negativeInfinityVector_13; }
inline Vector3_t3722313464 * get_address_of_negativeInfinityVector_13() { return &___negativeInfinityVector_13; }
inline void set_negativeInfinityVector_13(Vector3_t3722313464 value)
{
___negativeInfinityVector_13 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // VECTOR3_T3722313464_H
#ifndef RESOURCES_T1597885468_H
#define RESOURCES_T1597885468_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.DefaultControls/Resources
struct Resources_t1597885468
{
public:
// UnityEngine.Sprite UnityEngine.UI.DefaultControls/Resources::standard
Sprite_t280657092 * ___standard_0;
// UnityEngine.Sprite UnityEngine.UI.DefaultControls/Resources::background
Sprite_t280657092 * ___background_1;
// UnityEngine.Sprite UnityEngine.UI.DefaultControls/Resources::inputField
Sprite_t280657092 * ___inputField_2;
// UnityEngine.Sprite UnityEngine.UI.DefaultControls/Resources::knob
Sprite_t280657092 * ___knob_3;
// UnityEngine.Sprite UnityEngine.UI.DefaultControls/Resources::checkmark
Sprite_t280657092 * ___checkmark_4;
// UnityEngine.Sprite UnityEngine.UI.DefaultControls/Resources::dropdown
Sprite_t280657092 * ___dropdown_5;
// UnityEngine.Sprite UnityEngine.UI.DefaultControls/Resources::mask
Sprite_t280657092 * ___mask_6;
public:
inline static int32_t get_offset_of_standard_0() { return static_cast<int32_t>(offsetof(Resources_t1597885468, ___standard_0)); }
inline Sprite_t280657092 * get_standard_0() const { return ___standard_0; }
inline Sprite_t280657092 ** get_address_of_standard_0() { return &___standard_0; }
inline void set_standard_0(Sprite_t280657092 * value)
{
___standard_0 = value;
Il2CppCodeGenWriteBarrier((&___standard_0), value);
}
inline static int32_t get_offset_of_background_1() { return static_cast<int32_t>(offsetof(Resources_t1597885468, ___background_1)); }
inline Sprite_t280657092 * get_background_1() const { return ___background_1; }
inline Sprite_t280657092 ** get_address_of_background_1() { return &___background_1; }
inline void set_background_1(Sprite_t280657092 * value)
{
___background_1 = value;
Il2CppCodeGenWriteBarrier((&___background_1), value);
}
inline static int32_t get_offset_of_inputField_2() { return static_cast<int32_t>(offsetof(Resources_t1597885468, ___inputField_2)); }
inline Sprite_t280657092 * get_inputField_2() const { return ___inputField_2; }
inline Sprite_t280657092 ** get_address_of_inputField_2() { return &___inputField_2; }
inline void set_inputField_2(Sprite_t280657092 * value)
{
___inputField_2 = value;
Il2CppCodeGenWriteBarrier((&___inputField_2), value);
}
inline static int32_t get_offset_of_knob_3() { return static_cast<int32_t>(offsetof(Resources_t1597885468, ___knob_3)); }
inline Sprite_t280657092 * get_knob_3() const { return ___knob_3; }
inline Sprite_t280657092 ** get_address_of_knob_3() { return &___knob_3; }
inline void set_knob_3(Sprite_t280657092 * value)
{
___knob_3 = value;
Il2CppCodeGenWriteBarrier((&___knob_3), value);
}
inline static int32_t get_offset_of_checkmark_4() { return static_cast<int32_t>(offsetof(Resources_t1597885468, ___checkmark_4)); }
inline Sprite_t280657092 * get_checkmark_4() const { return ___checkmark_4; }
inline Sprite_t280657092 ** get_address_of_checkmark_4() { return &___checkmark_4; }
inline void set_checkmark_4(Sprite_t280657092 * value)
{
___checkmark_4 = value;
Il2CppCodeGenWriteBarrier((&___checkmark_4), value);
}
inline static int32_t get_offset_of_dropdown_5() { return static_cast<int32_t>(offsetof(Resources_t1597885468, ___dropdown_5)); }
inline Sprite_t280657092 * get_dropdown_5() const { return ___dropdown_5; }
inline Sprite_t280657092 ** get_address_of_dropdown_5() { return &___dropdown_5; }
inline void set_dropdown_5(Sprite_t280657092 * value)
{
___dropdown_5 = value;
Il2CppCodeGenWriteBarrier((&___dropdown_5), value);
}
inline static int32_t get_offset_of_mask_6() { return static_cast<int32_t>(offsetof(Resources_t1597885468, ___mask_6)); }
inline Sprite_t280657092 * get_mask_6() const { return ___mask_6; }
inline Sprite_t280657092 ** get_address_of_mask_6() { return &___mask_6; }
inline void set_mask_6(Sprite_t280657092 * value)
{
___mask_6 = value;
Il2CppCodeGenWriteBarrier((&___mask_6), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of UnityEngine.UI.DefaultControls/Resources
struct Resources_t1597885468_marshaled_pinvoke
{
Sprite_t280657092 * ___standard_0;
Sprite_t280657092 * ___background_1;
Sprite_t280657092 * ___inputField_2;
Sprite_t280657092 * ___knob_3;
Sprite_t280657092 * ___checkmark_4;
Sprite_t280657092 * ___dropdown_5;
Sprite_t280657092 * ___mask_6;
};
// Native definition for COM marshalling of UnityEngine.UI.DefaultControls/Resources
struct Resources_t1597885468_marshaled_com
{
Sprite_t280657092 * ___standard_0;
Sprite_t280657092 * ___background_1;
Sprite_t280657092 * ___inputField_2;
Sprite_t280657092 * ___knob_3;
Sprite_t280657092 * ___checkmark_4;
Sprite_t280657092 * ___dropdown_5;
Sprite_t280657092 * ___mask_6;
};
#endif // RESOURCES_T1597885468_H
#ifndef SPRITESTATE_T1362986479_H
#define SPRITESTATE_T1362986479_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.SpriteState
struct SpriteState_t1362986479
{
public:
// UnityEngine.Sprite UnityEngine.UI.SpriteState::m_HighlightedSprite
Sprite_t280657092 * ___m_HighlightedSprite_0;
// UnityEngine.Sprite UnityEngine.UI.SpriteState::m_PressedSprite
Sprite_t280657092 * ___m_PressedSprite_1;
// UnityEngine.Sprite UnityEngine.UI.SpriteState::m_DisabledSprite
Sprite_t280657092 * ___m_DisabledSprite_2;
public:
inline static int32_t get_offset_of_m_HighlightedSprite_0() { return static_cast<int32_t>(offsetof(SpriteState_t1362986479, ___m_HighlightedSprite_0)); }
inline Sprite_t280657092 * get_m_HighlightedSprite_0() const { return ___m_HighlightedSprite_0; }
inline Sprite_t280657092 ** get_address_of_m_HighlightedSprite_0() { return &___m_HighlightedSprite_0; }
inline void set_m_HighlightedSprite_0(Sprite_t280657092 * value)
{
___m_HighlightedSprite_0 = value;
Il2CppCodeGenWriteBarrier((&___m_HighlightedSprite_0), value);
}
inline static int32_t get_offset_of_m_PressedSprite_1() { return static_cast<int32_t>(offsetof(SpriteState_t1362986479, ___m_PressedSprite_1)); }
inline Sprite_t280657092 * get_m_PressedSprite_1() const { return ___m_PressedSprite_1; }
inline Sprite_t280657092 ** get_address_of_m_PressedSprite_1() { return &___m_PressedSprite_1; }
inline void set_m_PressedSprite_1(Sprite_t280657092 * value)
{
___m_PressedSprite_1 = value;
Il2CppCodeGenWriteBarrier((&___m_PressedSprite_1), value);
}
inline static int32_t get_offset_of_m_DisabledSprite_2() { return static_cast<int32_t>(offsetof(SpriteState_t1362986479, ___m_DisabledSprite_2)); }
inline Sprite_t280657092 * get_m_DisabledSprite_2() const { return ___m_DisabledSprite_2; }
inline Sprite_t280657092 ** get_address_of_m_DisabledSprite_2() { return &___m_DisabledSprite_2; }
inline void set_m_DisabledSprite_2(Sprite_t280657092 * value)
{
___m_DisabledSprite_2 = value;
Il2CppCodeGenWriteBarrier((&___m_DisabledSprite_2), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of UnityEngine.UI.SpriteState
struct SpriteState_t1362986479_marshaled_pinvoke
{
Sprite_t280657092 * ___m_HighlightedSprite_0;
Sprite_t280657092 * ___m_PressedSprite_1;
Sprite_t280657092 * ___m_DisabledSprite_2;
};
// Native definition for COM marshalling of UnityEngine.UI.SpriteState
struct SpriteState_t1362986479_marshaled_com
{
Sprite_t280657092 * ___m_HighlightedSprite_0;
Sprite_t280657092 * ___m_PressedSprite_1;
Sprite_t280657092 * ___m_DisabledSprite_2;
};
#endif // SPRITESTATE_T1362986479_H
#ifndef UNITYEVENT_1_T3037889027_H
#define UNITYEVENT_1_T3037889027_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Events.UnityEvent`1<UnityEngine.Vector2>
struct UnityEvent_1_t3037889027 : public UnityEventBase_t3960448221
{
public:
// System.Object[] UnityEngine.Events.UnityEvent`1::m_InvokeArray
ObjectU5BU5D_t2843939325* ___m_InvokeArray_4;
public:
inline static int32_t get_offset_of_m_InvokeArray_4() { return static_cast<int32_t>(offsetof(UnityEvent_1_t3037889027, ___m_InvokeArray_4)); }
inline ObjectU5BU5D_t2843939325* get_m_InvokeArray_4() const { return ___m_InvokeArray_4; }
inline ObjectU5BU5D_t2843939325** get_address_of_m_InvokeArray_4() { return &___m_InvokeArray_4; }
inline void set_m_InvokeArray_4(ObjectU5BU5D_t2843939325* value)
{
___m_InvokeArray_4 = value;
Il2CppCodeGenWriteBarrier((&___m_InvokeArray_4), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNITYEVENT_1_T3037889027_H
#ifndef UNITYEVENT_1_T2278926278_H
#define UNITYEVENT_1_T2278926278_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Events.UnityEvent`1<System.Single>
struct UnityEvent_1_t2278926278 : public UnityEventBase_t3960448221
{
public:
// System.Object[] UnityEngine.Events.UnityEvent`1::m_InvokeArray
ObjectU5BU5D_t2843939325* ___m_InvokeArray_4;
public:
inline static int32_t get_offset_of_m_InvokeArray_4() { return static_cast<int32_t>(offsetof(UnityEvent_1_t2278926278, ___m_InvokeArray_4)); }
inline ObjectU5BU5D_t2843939325* get_m_InvokeArray_4() const { return ___m_InvokeArray_4; }
inline ObjectU5BU5D_t2843939325** get_address_of_m_InvokeArray_4() { return &___m_InvokeArray_4; }
inline void set_m_InvokeArray_4(ObjectU5BU5D_t2843939325* value)
{
___m_InvokeArray_4 = value;
Il2CppCodeGenWriteBarrier((&___m_InvokeArray_4), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNITYEVENT_1_T2278926278_H
#ifndef INT32_T2950945753_H
#define INT32_T2950945753_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Int32
struct Int32_t2950945753
{
public:
// System.Int32 System.Int32::m_value
int32_t ___m_value_2;
public:
inline static int32_t get_offset_of_m_value_2() { return static_cast<int32_t>(offsetof(Int32_t2950945753, ___m_value_2)); }
inline int32_t get_m_value_2() const { return ___m_value_2; }
inline int32_t* get_address_of_m_value_2() { return &___m_value_2; }
inline void set_m_value_2(int32_t value)
{
___m_value_2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INT32_T2950945753_H
#ifndef CHAR_T3634460470_H
#define CHAR_T3634460470_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Char
struct Char_t3634460470
{
public:
// System.Char System.Char::m_value
Il2CppChar ___m_value_2;
public:
inline static int32_t get_offset_of_m_value_2() { return static_cast<int32_t>(offsetof(Char_t3634460470, ___m_value_2)); }
inline Il2CppChar get_m_value_2() const { return ___m_value_2; }
inline Il2CppChar* get_address_of_m_value_2() { return &___m_value_2; }
inline void set_m_value_2(Il2CppChar value)
{
___m_value_2 = value;
}
};
struct Char_t3634460470_StaticFields
{
public:
// System.Byte* System.Char::category_data
uint8_t* ___category_data_3;
// System.Byte* System.Char::numeric_data
uint8_t* ___numeric_data_4;
// System.Double* System.Char::numeric_data_values
double* ___numeric_data_values_5;
// System.UInt16* System.Char::to_lower_data_low
uint16_t* ___to_lower_data_low_6;
// System.UInt16* System.Char::to_lower_data_high
uint16_t* ___to_lower_data_high_7;
// System.UInt16* System.Char::to_upper_data_low
uint16_t* ___to_upper_data_low_8;
// System.UInt16* System.Char::to_upper_data_high
uint16_t* ___to_upper_data_high_9;
public:
inline static int32_t get_offset_of_category_data_3() { return static_cast<int32_t>(offsetof(Char_t3634460470_StaticFields, ___category_data_3)); }
inline uint8_t* get_category_data_3() const { return ___category_data_3; }
inline uint8_t** get_address_of_category_data_3() { return &___category_data_3; }
inline void set_category_data_3(uint8_t* value)
{
___category_data_3 = value;
}
inline static int32_t get_offset_of_numeric_data_4() { return static_cast<int32_t>(offsetof(Char_t3634460470_StaticFields, ___numeric_data_4)); }
inline uint8_t* get_numeric_data_4() const { return ___numeric_data_4; }
inline uint8_t** get_address_of_numeric_data_4() { return &___numeric_data_4; }
inline void set_numeric_data_4(uint8_t* value)
{
___numeric_data_4 = value;
}
inline static int32_t get_offset_of_numeric_data_values_5() { return static_cast<int32_t>(offsetof(Char_t3634460470_StaticFields, ___numeric_data_values_5)); }
inline double* get_numeric_data_values_5() const { return ___numeric_data_values_5; }
inline double** get_address_of_numeric_data_values_5() { return &___numeric_data_values_5; }
inline void set_numeric_data_values_5(double* value)
{
___numeric_data_values_5 = value;
}
inline static int32_t get_offset_of_to_lower_data_low_6() { return static_cast<int32_t>(offsetof(Char_t3634460470_StaticFields, ___to_lower_data_low_6)); }
inline uint16_t* get_to_lower_data_low_6() const { return ___to_lower_data_low_6; }
inline uint16_t** get_address_of_to_lower_data_low_6() { return &___to_lower_data_low_6; }
inline void set_to_lower_data_low_6(uint16_t* value)
{
___to_lower_data_low_6 = value;
}
inline static int32_t get_offset_of_to_lower_data_high_7() { return static_cast<int32_t>(offsetof(Char_t3634460470_StaticFields, ___to_lower_data_high_7)); }
inline uint16_t* get_to_lower_data_high_7() const { return ___to_lower_data_high_7; }
inline uint16_t** get_address_of_to_lower_data_high_7() { return &___to_lower_data_high_7; }
inline void set_to_lower_data_high_7(uint16_t* value)
{
___to_lower_data_high_7 = value;
}
inline static int32_t get_offset_of_to_upper_data_low_8() { return static_cast<int32_t>(offsetof(Char_t3634460470_StaticFields, ___to_upper_data_low_8)); }
inline uint16_t* get_to_upper_data_low_8() const { return ___to_upper_data_low_8; }
inline uint16_t** get_address_of_to_upper_data_low_8() { return &___to_upper_data_low_8; }
inline void set_to_upper_data_low_8(uint16_t* value)
{
___to_upper_data_low_8 = value;
}
inline static int32_t get_offset_of_to_upper_data_high_9() { return static_cast<int32_t>(offsetof(Char_t3634460470_StaticFields, ___to_upper_data_high_9)); }
inline uint16_t* get_to_upper_data_high_9() const { return ___to_upper_data_high_9; }
inline uint16_t** get_address_of_to_upper_data_high_9() { return &___to_upper_data_high_9; }
inline void set_to_upper_data_high_9(uint16_t* value)
{
___to_upper_data_high_9 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CHAR_T3634460470_H
#ifndef DRIVENRECTTRANSFORMTRACKER_T2562230146_H
#define DRIVENRECTTRANSFORMTRACKER_T2562230146_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.DrivenRectTransformTracker
struct DrivenRectTransformTracker_t2562230146
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DRIVENRECTTRANSFORMTRACKER_T2562230146_H
#ifndef RECT_T2360479859_H
#define RECT_T2360479859_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Rect
struct Rect_t2360479859
{
public:
// System.Single UnityEngine.Rect::m_XMin
float ___m_XMin_0;
// System.Single UnityEngine.Rect::m_YMin
float ___m_YMin_1;
// System.Single UnityEngine.Rect::m_Width
float ___m_Width_2;
// System.Single UnityEngine.Rect::m_Height
float ___m_Height_3;
public:
inline static int32_t get_offset_of_m_XMin_0() { return static_cast<int32_t>(offsetof(Rect_t2360479859, ___m_XMin_0)); }
inline float get_m_XMin_0() const { return ___m_XMin_0; }
inline float* get_address_of_m_XMin_0() { return &___m_XMin_0; }
inline void set_m_XMin_0(float value)
{
___m_XMin_0 = value;
}
inline static int32_t get_offset_of_m_YMin_1() { return static_cast<int32_t>(offsetof(Rect_t2360479859, ___m_YMin_1)); }
inline float get_m_YMin_1() const { return ___m_YMin_1; }
inline float* get_address_of_m_YMin_1() { return &___m_YMin_1; }
inline void set_m_YMin_1(float value)
{
___m_YMin_1 = value;
}
inline static int32_t get_offset_of_m_Width_2() { return static_cast<int32_t>(offsetof(Rect_t2360479859, ___m_Width_2)); }
inline float get_m_Width_2() const { return ___m_Width_2; }
inline float* get_address_of_m_Width_2() { return &___m_Width_2; }
inline void set_m_Width_2(float value)
{
___m_Width_2 = value;
}
inline static int32_t get_offset_of_m_Height_3() { return static_cast<int32_t>(offsetof(Rect_t2360479859, ___m_Height_3)); }
inline float get_m_Height_3() const { return ___m_Height_3; }
inline float* get_address_of_m_Height_3() { return &___m_Height_3; }
inline void set_m_Height_3(float value)
{
___m_Height_3 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RECT_T2360479859_H
#ifndef UNITYEVENT_1_T978947469_H
#define UNITYEVENT_1_T978947469_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Events.UnityEvent`1<System.Boolean>
struct UnityEvent_1_t978947469 : public UnityEventBase_t3960448221
{
public:
// System.Object[] UnityEngine.Events.UnityEvent`1::m_InvokeArray
ObjectU5BU5D_t2843939325* ___m_InvokeArray_4;
public:
inline static int32_t get_offset_of_m_InvokeArray_4() { return static_cast<int32_t>(offsetof(UnityEvent_1_t978947469, ___m_InvokeArray_4)); }
inline ObjectU5BU5D_t2843939325* get_m_InvokeArray_4() const { return ___m_InvokeArray_4; }
inline ObjectU5BU5D_t2843939325** get_address_of_m_InvokeArray_4() { return &___m_InvokeArray_4; }
inline void set_m_InvokeArray_4(ObjectU5BU5D_t2843939325* value)
{
___m_InvokeArray_4 = value;
Il2CppCodeGenWriteBarrier((&___m_InvokeArray_4), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNITYEVENT_1_T978947469_H
#ifndef UNITYEVENT_1_T2729110193_H
#define UNITYEVENT_1_T2729110193_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Events.UnityEvent`1<System.String>
struct UnityEvent_1_t2729110193 : public UnityEventBase_t3960448221
{
public:
// System.Object[] UnityEngine.Events.UnityEvent`1::m_InvokeArray
ObjectU5BU5D_t2843939325* ___m_InvokeArray_4;
public:
inline static int32_t get_offset_of_m_InvokeArray_4() { return static_cast<int32_t>(offsetof(UnityEvent_1_t2729110193, ___m_InvokeArray_4)); }
inline ObjectU5BU5D_t2843939325* get_m_InvokeArray_4() const { return ___m_InvokeArray_4; }
inline ObjectU5BU5D_t2843939325** get_address_of_m_InvokeArray_4() { return &___m_InvokeArray_4; }
inline void set_m_InvokeArray_4(ObjectU5BU5D_t2843939325* value)
{
___m_InvokeArray_4 = value;
Il2CppCodeGenWriteBarrier((&___m_InvokeArray_4), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNITYEVENT_1_T2729110193_H
#ifndef SCREENMATCHMODE_T3675272090_H
#define SCREENMATCHMODE_T3675272090_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.CanvasScaler/ScreenMatchMode
struct ScreenMatchMode_t3675272090
{
public:
// System.Int32 UnityEngine.UI.CanvasScaler/ScreenMatchMode::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(ScreenMatchMode_t3675272090, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SCREENMATCHMODE_T3675272090_H
#ifndef ASPECTMODE_T3417192999_H
#define ASPECTMODE_T3417192999_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.AspectRatioFitter/AspectMode
struct AspectMode_t3417192999
{
public:
// System.Int32 UnityEngine.UI.AspectRatioFitter/AspectMode::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(AspectMode_t3417192999, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ASPECTMODE_T3417192999_H
#ifndef SCALEMODE_T2604066427_H
#define SCALEMODE_T2604066427_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.CanvasScaler/ScaleMode
struct ScaleMode_t2604066427
{
public:
// System.Int32 UnityEngine.UI.CanvasScaler/ScaleMode::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(ScaleMode_t2604066427, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SCALEMODE_T2604066427_H
#ifndef TOGGLEEVENT_T1873685584_H
#define TOGGLEEVENT_T1873685584_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Toggle/ToggleEvent
struct ToggleEvent_t1873685584 : public UnityEvent_1_t978947469
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TOGGLEEVENT_T1873685584_H
#ifndef TOGGLETRANSITION_T3587297765_H
#define TOGGLETRANSITION_T3587297765_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Toggle/ToggleTransition
struct ToggleTransition_t3587297765
{
public:
// System.Int32 UnityEngine.UI.Toggle/ToggleTransition::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(ToggleTransition_t3587297765, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TOGGLETRANSITION_T3587297765_H
#ifndef BUTTONCLICKEDEVENT_T48803504_H
#define BUTTONCLICKEDEVENT_T48803504_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Button/ButtonClickedEvent
struct ButtonClickedEvent_t48803504 : public UnityEvent_t2581268647
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // BUTTONCLICKEDEVENT_T48803504_H
#ifndef AXIS_T809944411_H
#define AXIS_T809944411_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Slider/Axis
struct Axis_t809944411
{
public:
// System.Int32 UnityEngine.UI.Slider/Axis::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Axis_t809944411, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // AXIS_T809944411_H
#ifndef SLIDEREVENT_T3180273144_H
#define SLIDEREVENT_T3180273144_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Slider/SliderEvent
struct SliderEvent_t3180273144 : public UnityEvent_1_t2278926278
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SLIDEREVENT_T3180273144_H
#ifndef UNIT_T2218508340_H
#define UNIT_T2218508340_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.CanvasScaler/Unit
struct Unit_t2218508340
{
public:
// System.Int32 UnityEngine.UI.CanvasScaler/Unit::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Unit_t2218508340, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNIT_T2218508340_H
#ifndef TOUCHSCREENKEYBOARDTYPE_T1530597702_H
#define TOUCHSCREENKEYBOARDTYPE_T1530597702_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.TouchScreenKeyboardType
struct TouchScreenKeyboardType_t1530597702
{
public:
// System.Int32 UnityEngine.TouchScreenKeyboardType::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(TouchScreenKeyboardType_t1530597702, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TOUCHSCREENKEYBOARDTYPE_T1530597702_H
#ifndef BOUNDS_T2266837910_H
#define BOUNDS_T2266837910_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Bounds
struct Bounds_t2266837910
{
public:
// UnityEngine.Vector3 UnityEngine.Bounds::m_Center
Vector3_t3722313464 ___m_Center_0;
// UnityEngine.Vector3 UnityEngine.Bounds::m_Extents
Vector3_t3722313464 ___m_Extents_1;
public:
inline static int32_t get_offset_of_m_Center_0() { return static_cast<int32_t>(offsetof(Bounds_t2266837910, ___m_Center_0)); }
inline Vector3_t3722313464 get_m_Center_0() const { return ___m_Center_0; }
inline Vector3_t3722313464 * get_address_of_m_Center_0() { return &___m_Center_0; }
inline void set_m_Center_0(Vector3_t3722313464 value)
{
___m_Center_0 = value;
}
inline static int32_t get_offset_of_m_Extents_1() { return static_cast<int32_t>(offsetof(Bounds_t2266837910, ___m_Extents_1)); }
inline Vector3_t3722313464 get_m_Extents_1() const { return ___m_Extents_1; }
inline Vector3_t3722313464 * get_address_of_m_Extents_1() { return &___m_Extents_1; }
inline void set_m_Extents_1(Vector3_t3722313464 value)
{
___m_Extents_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // BOUNDS_T2266837910_H
#ifndef STENCILOP_T3446174106_H
#define STENCILOP_T3446174106_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Rendering.StencilOp
struct StencilOp_t3446174106
{
public:
// System.Int32 UnityEngine.Rendering.StencilOp::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(StencilOp_t3446174106, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // STENCILOP_T3446174106_H
#ifndef COMPAREFUNCTION_T2171731108_H
#define COMPAREFUNCTION_T2171731108_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Rendering.CompareFunction
struct CompareFunction_t2171731108
{
public:
// System.Int32 UnityEngine.Rendering.CompareFunction::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(CompareFunction_t2171731108, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // COMPAREFUNCTION_T2171731108_H
#ifndef COLORWRITEMASK_T4282245599_H
#define COLORWRITEMASK_T4282245599_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Rendering.ColorWriteMask
struct ColorWriteMask_t4282245599
{
public:
// System.Int32 UnityEngine.Rendering.ColorWriteMask::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(ColorWriteMask_t4282245599, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // COLORWRITEMASK_T4282245599_H
#ifndef DELEGATE_T1188392813_H
#define DELEGATE_T1188392813_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Delegate
struct Delegate_t1188392813 : public RuntimeObject
{
public:
// System.IntPtr System.Delegate::method_ptr
Il2CppMethodPointer ___method_ptr_0;
// System.IntPtr System.Delegate::invoke_impl
intptr_t ___invoke_impl_1;
// System.Object System.Delegate::m_target
RuntimeObject * ___m_target_2;
// System.IntPtr System.Delegate::method
intptr_t ___method_3;
// System.IntPtr System.Delegate::delegate_trampoline
intptr_t ___delegate_trampoline_4;
// System.IntPtr System.Delegate::method_code
intptr_t ___method_code_5;
// System.Reflection.MethodInfo System.Delegate::method_info
MethodInfo_t * ___method_info_6;
// System.Reflection.MethodInfo System.Delegate::original_method_info
MethodInfo_t * ___original_method_info_7;
// System.DelegateData System.Delegate::data
DelegateData_t1677132599 * ___data_8;
public:
inline static int32_t get_offset_of_method_ptr_0() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___method_ptr_0)); }
inline Il2CppMethodPointer get_method_ptr_0() const { return ___method_ptr_0; }
inline Il2CppMethodPointer* get_address_of_method_ptr_0() { return &___method_ptr_0; }
inline void set_method_ptr_0(Il2CppMethodPointer value)
{
___method_ptr_0 = value;
}
inline static int32_t get_offset_of_invoke_impl_1() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___invoke_impl_1)); }
inline intptr_t get_invoke_impl_1() const { return ___invoke_impl_1; }
inline intptr_t* get_address_of_invoke_impl_1() { return &___invoke_impl_1; }
inline void set_invoke_impl_1(intptr_t value)
{
___invoke_impl_1 = value;
}
inline static int32_t get_offset_of_m_target_2() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___m_target_2)); }
inline RuntimeObject * get_m_target_2() const { return ___m_target_2; }
inline RuntimeObject ** get_address_of_m_target_2() { return &___m_target_2; }
inline void set_m_target_2(RuntimeObject * value)
{
___m_target_2 = value;
Il2CppCodeGenWriteBarrier((&___m_target_2), value);
}
inline static int32_t get_offset_of_method_3() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___method_3)); }
inline intptr_t get_method_3() const { return ___method_3; }
inline intptr_t* get_address_of_method_3() { return &___method_3; }
inline void set_method_3(intptr_t value)
{
___method_3 = value;
}
inline static int32_t get_offset_of_delegate_trampoline_4() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___delegate_trampoline_4)); }
inline intptr_t get_delegate_trampoline_4() const { return ___delegate_trampoline_4; }
inline intptr_t* get_address_of_delegate_trampoline_4() { return &___delegate_trampoline_4; }
inline void set_delegate_trampoline_4(intptr_t value)
{
___delegate_trampoline_4 = value;
}
inline static int32_t get_offset_of_method_code_5() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___method_code_5)); }
inline intptr_t get_method_code_5() const { return ___method_code_5; }
inline intptr_t* get_address_of_method_code_5() { return &___method_code_5; }
inline void set_method_code_5(intptr_t value)
{
___method_code_5 = value;
}
inline static int32_t get_offset_of_method_info_6() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___method_info_6)); }
inline MethodInfo_t * get_method_info_6() const { return ___method_info_6; }
inline MethodInfo_t ** get_address_of_method_info_6() { return &___method_info_6; }
inline void set_method_info_6(MethodInfo_t * value)
{
___method_info_6 = value;
Il2CppCodeGenWriteBarrier((&___method_info_6), value);
}
inline static int32_t get_offset_of_original_method_info_7() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___original_method_info_7)); }
inline MethodInfo_t * get_original_method_info_7() const { return ___original_method_info_7; }
inline MethodInfo_t ** get_address_of_original_method_info_7() { return &___original_method_info_7; }
inline void set_original_method_info_7(MethodInfo_t * value)
{
___original_method_info_7 = value;
Il2CppCodeGenWriteBarrier((&___original_method_info_7), value);
}
inline static int32_t get_offset_of_data_8() { return static_cast<int32_t>(offsetof(Delegate_t1188392813, ___data_8)); }
inline DelegateData_t1677132599 * get_data_8() const { return ___data_8; }
inline DelegateData_t1677132599 ** get_address_of_data_8() { return &___data_8; }
inline void set_data_8(DelegateData_t1677132599 * value)
{
___data_8 = value;
Il2CppCodeGenWriteBarrier((&___data_8), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DELEGATE_T1188392813_H
#ifndef VERTICALWRAPMODE_T2936607737_H
#define VERTICALWRAPMODE_T2936607737_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.VerticalWrapMode
struct VerticalWrapMode_t2936607737
{
public:
// System.Int32 UnityEngine.VerticalWrapMode::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(VerticalWrapMode_t2936607737, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // VERTICALWRAPMODE_T2936607737_H
#ifndef FITMODE_T3267881214_H
#define FITMODE_T3267881214_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.ContentSizeFitter/FitMode
struct FitMode_t3267881214
{
public:
// System.Int32 UnityEngine.UI.ContentSizeFitter/FitMode::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(FitMode_t3267881214, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // FITMODE_T3267881214_H
#ifndef CORNER_T1493259673_H
#define CORNER_T1493259673_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.GridLayoutGroup/Corner
struct Corner_t1493259673
{
public:
// System.Int32 UnityEngine.UI.GridLayoutGroup/Corner::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Corner_t1493259673, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CORNER_T1493259673_H
#ifndef AXIS_T3613393006_H
#define AXIS_T3613393006_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.GridLayoutGroup/Axis
struct Axis_t3613393006
{
public:
// System.Int32 UnityEngine.UI.GridLayoutGroup/Axis::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Axis_t3613393006, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // AXIS_T3613393006_H
#ifndef CONSTRAINT_T814224393_H
#define CONSTRAINT_T814224393_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.GridLayoutGroup/Constraint
struct Constraint_t814224393
{
public:
// System.Int32 UnityEngine.UI.GridLayoutGroup/Constraint::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Constraint_t814224393, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CONSTRAINT_T814224393_H
#ifndef FONTSTYLE_T82229486_H
#define FONTSTYLE_T82229486_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.FontStyle
struct FontStyle_t82229486
{
public:
// System.Int32 UnityEngine.FontStyle::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(FontStyle_t82229486, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // FONTSTYLE_T82229486_H
#ifndef TEXTANCHOR_T2035777396_H
#define TEXTANCHOR_T2035777396_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.TextAnchor
struct TextAnchor_t2035777396
{
public:
// System.Int32 UnityEngine.TextAnchor::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(TextAnchor_t2035777396, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TEXTANCHOR_T2035777396_H
#ifndef HORIZONTALWRAPMODE_T2172737147_H
#define HORIZONTALWRAPMODE_T2172737147_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.HorizontalWrapMode
struct HorizontalWrapMode_t2172737147
{
public:
// System.Int32 UnityEngine.HorizontalWrapMode::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(HorizontalWrapMode_t2172737147, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // HORIZONTALWRAPMODE_T2172737147_H
#ifndef DIRECTION_T337909235_H
#define DIRECTION_T337909235_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Slider/Direction
struct Direction_t337909235
{
public:
// System.Int32 UnityEngine.UI.Slider/Direction::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Direction_t337909235, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DIRECTION_T337909235_H
#ifndef ORIGIN360_T707706162_H
#define ORIGIN360_T707706162_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Image/Origin360
struct Origin360_t707706162
{
public:
// System.Int32 UnityEngine.UI.Image/Origin360::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Origin360_t707706162, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ORIGIN360_T707706162_H
#ifndef CONTENTTYPE_T1787303396_H
#define CONTENTTYPE_T1787303396_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/ContentType
struct ContentType_t1787303396
{
public:
// System.Int32 UnityEngine.UI.InputField/ContentType::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(ContentType_t1787303396, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CONTENTTYPE_T1787303396_H
#ifndef INPUTTYPE_T1770400679_H
#define INPUTTYPE_T1770400679_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/InputType
struct InputType_t1770400679
{
public:
// System.Int32 UnityEngine.UI.InputField/InputType::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(InputType_t1770400679, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INPUTTYPE_T1770400679_H
#ifndef CHARACTERVALIDATION_T4051914437_H
#define CHARACTERVALIDATION_T4051914437_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/CharacterValidation
struct CharacterValidation_t4051914437
{
public:
// System.Int32 UnityEngine.UI.InputField/CharacterValidation::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(CharacterValidation_t4051914437, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CHARACTERVALIDATION_T4051914437_H
#ifndef LINETYPE_T4214648469_H
#define LINETYPE_T4214648469_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/LineType
struct LineType_t4214648469
{
public:
// System.Int32 UnityEngine.UI.InputField/LineType::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(LineType_t4214648469, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // LINETYPE_T4214648469_H
#ifndef SUBMITEVENT_T648412432_H
#define SUBMITEVENT_T648412432_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/SubmitEvent
struct SubmitEvent_t648412432 : public UnityEvent_1_t2729110193
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SUBMITEVENT_T648412432_H
#ifndef ONCHANGEEVENT_T467195904_H
#define ONCHANGEEVENT_T467195904_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/OnChangeEvent
struct OnChangeEvent_t467195904 : public UnityEvent_1_t2729110193
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ONCHANGEEVENT_T467195904_H
#ifndef EDITSTATE_T3741896775_H
#define EDITSTATE_T3741896775_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/EditState
struct EditState_t3741896775
{
public:
// System.Int32 UnityEngine.UI.InputField/EditState::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(EditState_t3741896775, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // EDITSTATE_T3741896775_H
#ifndef U3CMOUSEDRAGOUTSIDERECTU3EC__ITERATOR1_T3909241878_H
#define U3CMOUSEDRAGOUTSIDERECTU3EC__ITERATOR1_T3909241878_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/<MouseDragOutsideRect>c__Iterator1
struct U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878 : public RuntimeObject
{
public:
// UnityEngine.EventSystems.PointerEventData UnityEngine.UI.InputField/<MouseDragOutsideRect>c__Iterator1::eventData
PointerEventData_t3807901092 * ___eventData_0;
// UnityEngine.Vector2 UnityEngine.UI.InputField/<MouseDragOutsideRect>c__Iterator1::<localMousePos>__1
Vector2_t2156229523 ___U3ClocalMousePosU3E__1_1;
// UnityEngine.Rect UnityEngine.UI.InputField/<MouseDragOutsideRect>c__Iterator1::<rect>__1
Rect_t2360479859 ___U3CrectU3E__1_2;
// System.Single UnityEngine.UI.InputField/<MouseDragOutsideRect>c__Iterator1::<delay>__1
float ___U3CdelayU3E__1_3;
// UnityEngine.UI.InputField UnityEngine.UI.InputField/<MouseDragOutsideRect>c__Iterator1::$this
InputField_t3762917431 * ___U24this_4;
// System.Object UnityEngine.UI.InputField/<MouseDragOutsideRect>c__Iterator1::$current
RuntimeObject * ___U24current_5;
// System.Boolean UnityEngine.UI.InputField/<MouseDragOutsideRect>c__Iterator1::$disposing
bool ___U24disposing_6;
// System.Int32 UnityEngine.UI.InputField/<MouseDragOutsideRect>c__Iterator1::$PC
int32_t ___U24PC_7;
public:
inline static int32_t get_offset_of_eventData_0() { return static_cast<int32_t>(offsetof(U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878, ___eventData_0)); }
inline PointerEventData_t3807901092 * get_eventData_0() const { return ___eventData_0; }
inline PointerEventData_t3807901092 ** get_address_of_eventData_0() { return &___eventData_0; }
inline void set_eventData_0(PointerEventData_t3807901092 * value)
{
___eventData_0 = value;
Il2CppCodeGenWriteBarrier((&___eventData_0), value);
}
inline static int32_t get_offset_of_U3ClocalMousePosU3E__1_1() { return static_cast<int32_t>(offsetof(U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878, ___U3ClocalMousePosU3E__1_1)); }
inline Vector2_t2156229523 get_U3ClocalMousePosU3E__1_1() const { return ___U3ClocalMousePosU3E__1_1; }
inline Vector2_t2156229523 * get_address_of_U3ClocalMousePosU3E__1_1() { return &___U3ClocalMousePosU3E__1_1; }
inline void set_U3ClocalMousePosU3E__1_1(Vector2_t2156229523 value)
{
___U3ClocalMousePosU3E__1_1 = value;
}
inline static int32_t get_offset_of_U3CrectU3E__1_2() { return static_cast<int32_t>(offsetof(U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878, ___U3CrectU3E__1_2)); }
inline Rect_t2360479859 get_U3CrectU3E__1_2() const { return ___U3CrectU3E__1_2; }
inline Rect_t2360479859 * get_address_of_U3CrectU3E__1_2() { return &___U3CrectU3E__1_2; }
inline void set_U3CrectU3E__1_2(Rect_t2360479859 value)
{
___U3CrectU3E__1_2 = value;
}
inline static int32_t get_offset_of_U3CdelayU3E__1_3() { return static_cast<int32_t>(offsetof(U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878, ___U3CdelayU3E__1_3)); }
inline float get_U3CdelayU3E__1_3() const { return ___U3CdelayU3E__1_3; }
inline float* get_address_of_U3CdelayU3E__1_3() { return &___U3CdelayU3E__1_3; }
inline void set_U3CdelayU3E__1_3(float value)
{
___U3CdelayU3E__1_3 = value;
}
inline static int32_t get_offset_of_U24this_4() { return static_cast<int32_t>(offsetof(U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878, ___U24this_4)); }
inline InputField_t3762917431 * get_U24this_4() const { return ___U24this_4; }
inline InputField_t3762917431 ** get_address_of_U24this_4() { return &___U24this_4; }
inline void set_U24this_4(InputField_t3762917431 * value)
{
___U24this_4 = value;
Il2CppCodeGenWriteBarrier((&___U24this_4), value);
}
inline static int32_t get_offset_of_U24current_5() { return static_cast<int32_t>(offsetof(U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878, ___U24current_5)); }
inline RuntimeObject * get_U24current_5() const { return ___U24current_5; }
inline RuntimeObject ** get_address_of_U24current_5() { return &___U24current_5; }
inline void set_U24current_5(RuntimeObject * value)
{
___U24current_5 = value;
Il2CppCodeGenWriteBarrier((&___U24current_5), value);
}
inline static int32_t get_offset_of_U24disposing_6() { return static_cast<int32_t>(offsetof(U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878, ___U24disposing_6)); }
inline bool get_U24disposing_6() const { return ___U24disposing_6; }
inline bool* get_address_of_U24disposing_6() { return &___U24disposing_6; }
inline void set_U24disposing_6(bool value)
{
___U24disposing_6 = value;
}
inline static int32_t get_offset_of_U24PC_7() { return static_cast<int32_t>(offsetof(U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878, ___U24PC_7)); }
inline int32_t get_U24PC_7() const { return ___U24PC_7; }
inline int32_t* get_address_of_U24PC_7() { return &___U24PC_7; }
inline void set_U24PC_7(int32_t value)
{
___U24PC_7 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // U3CMOUSEDRAGOUTSIDERECTU3EC__ITERATOR1_T3909241878_H
#ifndef CULLSTATECHANGEDEVENT_T3661388177_H
#define CULLSTATECHANGEDEVENT_T3661388177_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.MaskableGraphic/CullStateChangedEvent
struct CullStateChangedEvent_t3661388177 : public UnityEvent_1_t978947469
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CULLSTATECHANGEDEVENT_T3661388177_H
#ifndef ORIGIN180_T325369132_H
#define ORIGIN180_T325369132_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Image/Origin180
struct Origin180_t325369132
{
public:
// System.Int32 UnityEngine.UI.Image/Origin180::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Origin180_t325369132, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ORIGIN180_T325369132_H
#ifndef CANVASUPDATE_T2572322932_H
#define CANVASUPDATE_T2572322932_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.CanvasUpdate
struct CanvasUpdate_t2572322932
{
public:
// System.Int32 UnityEngine.UI.CanvasUpdate::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(CanvasUpdate_t2572322932, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CANVASUPDATE_T2572322932_H
#ifndef COLORBLOCK_T2139031574_H
#define COLORBLOCK_T2139031574_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.ColorBlock
struct ColorBlock_t2139031574
{
public:
// UnityEngine.Color UnityEngine.UI.ColorBlock::m_NormalColor
Color_t2555686324 ___m_NormalColor_0;
// UnityEngine.Color UnityEngine.UI.ColorBlock::m_HighlightedColor
Color_t2555686324 ___m_HighlightedColor_1;
// UnityEngine.Color UnityEngine.UI.ColorBlock::m_PressedColor
Color_t2555686324 ___m_PressedColor_2;
// UnityEngine.Color UnityEngine.UI.ColorBlock::m_DisabledColor
Color_t2555686324 ___m_DisabledColor_3;
// System.Single UnityEngine.UI.ColorBlock::m_ColorMultiplier
float ___m_ColorMultiplier_4;
// System.Single UnityEngine.UI.ColorBlock::m_FadeDuration
float ___m_FadeDuration_5;
public:
inline static int32_t get_offset_of_m_NormalColor_0() { return static_cast<int32_t>(offsetof(ColorBlock_t2139031574, ___m_NormalColor_0)); }
inline Color_t2555686324 get_m_NormalColor_0() const { return ___m_NormalColor_0; }
inline Color_t2555686324 * get_address_of_m_NormalColor_0() { return &___m_NormalColor_0; }
inline void set_m_NormalColor_0(Color_t2555686324 value)
{
___m_NormalColor_0 = value;
}
inline static int32_t get_offset_of_m_HighlightedColor_1() { return static_cast<int32_t>(offsetof(ColorBlock_t2139031574, ___m_HighlightedColor_1)); }
inline Color_t2555686324 get_m_HighlightedColor_1() const { return ___m_HighlightedColor_1; }
inline Color_t2555686324 * get_address_of_m_HighlightedColor_1() { return &___m_HighlightedColor_1; }
inline void set_m_HighlightedColor_1(Color_t2555686324 value)
{
___m_HighlightedColor_1 = value;
}
inline static int32_t get_offset_of_m_PressedColor_2() { return static_cast<int32_t>(offsetof(ColorBlock_t2139031574, ___m_PressedColor_2)); }
inline Color_t2555686324 get_m_PressedColor_2() const { return ___m_PressedColor_2; }
inline Color_t2555686324 * get_address_of_m_PressedColor_2() { return &___m_PressedColor_2; }
inline void set_m_PressedColor_2(Color_t2555686324 value)
{
___m_PressedColor_2 = value;
}
inline static int32_t get_offset_of_m_DisabledColor_3() { return static_cast<int32_t>(offsetof(ColorBlock_t2139031574, ___m_DisabledColor_3)); }
inline Color_t2555686324 get_m_DisabledColor_3() const { return ___m_DisabledColor_3; }
inline Color_t2555686324 * get_address_of_m_DisabledColor_3() { return &___m_DisabledColor_3; }
inline void set_m_DisabledColor_3(Color_t2555686324 value)
{
___m_DisabledColor_3 = value;
}
inline static int32_t get_offset_of_m_ColorMultiplier_4() { return static_cast<int32_t>(offsetof(ColorBlock_t2139031574, ___m_ColorMultiplier_4)); }
inline float get_m_ColorMultiplier_4() const { return ___m_ColorMultiplier_4; }
inline float* get_address_of_m_ColorMultiplier_4() { return &___m_ColorMultiplier_4; }
inline void set_m_ColorMultiplier_4(float value)
{
___m_ColorMultiplier_4 = value;
}
inline static int32_t get_offset_of_m_FadeDuration_5() { return static_cast<int32_t>(offsetof(ColorBlock_t2139031574, ___m_FadeDuration_5)); }
inline float get_m_FadeDuration_5() const { return ___m_FadeDuration_5; }
inline float* get_address_of_m_FadeDuration_5() { return &___m_FadeDuration_5; }
inline void set_m_FadeDuration_5(float value)
{
___m_FadeDuration_5 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // COLORBLOCK_T2139031574_H
#ifndef DEFAULTCONTROLS_T4098465386_H
#define DEFAULTCONTROLS_T4098465386_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.DefaultControls
struct DefaultControls_t4098465386 : public RuntimeObject
{
public:
public:
};
struct DefaultControls_t4098465386_StaticFields
{
public:
// UnityEngine.Vector2 UnityEngine.UI.DefaultControls::s_ThickElementSize
Vector2_t2156229523 ___s_ThickElementSize_3;
// UnityEngine.Vector2 UnityEngine.UI.DefaultControls::s_ThinElementSize
Vector2_t2156229523 ___s_ThinElementSize_4;
// UnityEngine.Vector2 UnityEngine.UI.DefaultControls::s_ImageElementSize
Vector2_t2156229523 ___s_ImageElementSize_5;
// UnityEngine.Color UnityEngine.UI.DefaultControls::s_DefaultSelectableColor
Color_t2555686324 ___s_DefaultSelectableColor_6;
// UnityEngine.Color UnityEngine.UI.DefaultControls::s_PanelColor
Color_t2555686324 ___s_PanelColor_7;
// UnityEngine.Color UnityEngine.UI.DefaultControls::s_TextColor
Color_t2555686324 ___s_TextColor_8;
public:
inline static int32_t get_offset_of_s_ThickElementSize_3() { return static_cast<int32_t>(offsetof(DefaultControls_t4098465386_StaticFields, ___s_ThickElementSize_3)); }
inline Vector2_t2156229523 get_s_ThickElementSize_3() const { return ___s_ThickElementSize_3; }
inline Vector2_t2156229523 * get_address_of_s_ThickElementSize_3() { return &___s_ThickElementSize_3; }
inline void set_s_ThickElementSize_3(Vector2_t2156229523 value)
{
___s_ThickElementSize_3 = value;
}
inline static int32_t get_offset_of_s_ThinElementSize_4() { return static_cast<int32_t>(offsetof(DefaultControls_t4098465386_StaticFields, ___s_ThinElementSize_4)); }
inline Vector2_t2156229523 get_s_ThinElementSize_4() const { return ___s_ThinElementSize_4; }
inline Vector2_t2156229523 * get_address_of_s_ThinElementSize_4() { return &___s_ThinElementSize_4; }
inline void set_s_ThinElementSize_4(Vector2_t2156229523 value)
{
___s_ThinElementSize_4 = value;
}
inline static int32_t get_offset_of_s_ImageElementSize_5() { return static_cast<int32_t>(offsetof(DefaultControls_t4098465386_StaticFields, ___s_ImageElementSize_5)); }
inline Vector2_t2156229523 get_s_ImageElementSize_5() const { return ___s_ImageElementSize_5; }
inline Vector2_t2156229523 * get_address_of_s_ImageElementSize_5() { return &___s_ImageElementSize_5; }
inline void set_s_ImageElementSize_5(Vector2_t2156229523 value)
{
___s_ImageElementSize_5 = value;
}
inline static int32_t get_offset_of_s_DefaultSelectableColor_6() { return static_cast<int32_t>(offsetof(DefaultControls_t4098465386_StaticFields, ___s_DefaultSelectableColor_6)); }
inline Color_t2555686324 get_s_DefaultSelectableColor_6() const { return ___s_DefaultSelectableColor_6; }
inline Color_t2555686324 * get_address_of_s_DefaultSelectableColor_6() { return &___s_DefaultSelectableColor_6; }
inline void set_s_DefaultSelectableColor_6(Color_t2555686324 value)
{
___s_DefaultSelectableColor_6 = value;
}
inline static int32_t get_offset_of_s_PanelColor_7() { return static_cast<int32_t>(offsetof(DefaultControls_t4098465386_StaticFields, ___s_PanelColor_7)); }
inline Color_t2555686324 get_s_PanelColor_7() const { return ___s_PanelColor_7; }
inline Color_t2555686324 * get_address_of_s_PanelColor_7() { return &___s_PanelColor_7; }
inline void set_s_PanelColor_7(Color_t2555686324 value)
{
___s_PanelColor_7 = value;
}
inline static int32_t get_offset_of_s_TextColor_8() { return static_cast<int32_t>(offsetof(DefaultControls_t4098465386_StaticFields, ___s_TextColor_8)); }
inline Color_t2555686324 get_s_TextColor_8() const { return ___s_TextColor_8; }
inline Color_t2555686324 * get_address_of_s_TextColor_8() { return &___s_TextColor_8; }
inline void set_s_TextColor_8(Color_t2555686324 value)
{
___s_TextColor_8 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DEFAULTCONTROLS_T4098465386_H
#ifndef DROPDOWNEVENT_T4040729994_H
#define DROPDOWNEVENT_T4040729994_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Dropdown/DropdownEvent
struct DropdownEvent_t4040729994 : public UnityEvent_1_t3832605257
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DROPDOWNEVENT_T4040729994_H
#ifndef BLOCKINGOBJECTS_T612090948_H
#define BLOCKINGOBJECTS_T612090948_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.GraphicRaycaster/BlockingObjects
struct BlockingObjects_t612090948
{
public:
// System.Int32 UnityEngine.UI.GraphicRaycaster/BlockingObjects::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(BlockingObjects_t612090948, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // BLOCKINGOBJECTS_T612090948_H
#ifndef TYPE_T1152881528_H
#define TYPE_T1152881528_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Image/Type
struct Type_t1152881528
{
public:
// System.Int32 UnityEngine.UI.Image/Type::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Type_t1152881528, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TYPE_T1152881528_H
#ifndef FILLMETHOD_T1167457570_H
#define FILLMETHOD_T1167457570_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Image/FillMethod
struct FillMethod_t1167457570
{
public:
// System.Int32 UnityEngine.UI.Image/FillMethod::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(FillMethod_t1167457570, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // FILLMETHOD_T1167457570_H
#ifndef ORIGINHORIZONTAL_T1174417785_H
#define ORIGINHORIZONTAL_T1174417785_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Image/OriginHorizontal
struct OriginHorizontal_t1174417785
{
public:
// System.Int32 UnityEngine.UI.Image/OriginHorizontal::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(OriginHorizontal_t1174417785, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ORIGINHORIZONTAL_T1174417785_H
#ifndef ORIGINVERTICAL_T2256455259_H
#define ORIGINVERTICAL_T2256455259_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Image/OriginVertical
struct OriginVertical_t2256455259
{
public:
// System.Int32 UnityEngine.UI.Image/OriginVertical::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(OriginVertical_t2256455259, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ORIGINVERTICAL_T2256455259_H
#ifndef ORIGIN90_T1855765812_H
#define ORIGIN90_T1855765812_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Image/Origin90
struct Origin90_t1855765812
{
public:
// System.Int32 UnityEngine.UI.Image/Origin90::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Origin90_t1855765812, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ORIGIN90_T1855765812_H
#ifndef MODE_T1066900953_H
#define MODE_T1066900953_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Navigation/Mode
struct Mode_t1066900953
{
public:
// System.Int32 UnityEngine.UI.Navigation/Mode::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Mode_t1066900953, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MODE_T1066900953_H
#ifndef DIRECTION_T3470714353_H
#define DIRECTION_T3470714353_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Scrollbar/Direction
struct Direction_t3470714353
{
public:
// System.Int32 UnityEngine.UI.Scrollbar/Direction::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Direction_t3470714353, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DIRECTION_T3470714353_H
#ifndef SCROLLEVENT_T149898510_H
#define SCROLLEVENT_T149898510_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Scrollbar/ScrollEvent
struct ScrollEvent_t149898510 : public UnityEvent_1_t2278926278
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SCROLLEVENT_T149898510_H
#ifndef AXIS_T1697763317_H
#define AXIS_T1697763317_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Scrollbar/Axis
struct Axis_t1697763317
{
public:
// System.Int32 UnityEngine.UI.Scrollbar/Axis::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Axis_t1697763317, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // AXIS_T1697763317_H
#ifndef OBJECT_T631007953_H
#define OBJECT_T631007953_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Object
struct Object_t631007953 : public RuntimeObject
{
public:
// System.IntPtr UnityEngine.Object::m_CachedPtr
intptr_t ___m_CachedPtr_0;
public:
inline static int32_t get_offset_of_m_CachedPtr_0() { return static_cast<int32_t>(offsetof(Object_t631007953, ___m_CachedPtr_0)); }
inline intptr_t get_m_CachedPtr_0() const { return ___m_CachedPtr_0; }
inline intptr_t* get_address_of_m_CachedPtr_0() { return &___m_CachedPtr_0; }
inline void set_m_CachedPtr_0(intptr_t value)
{
___m_CachedPtr_0 = value;
}
};
struct Object_t631007953_StaticFields
{
public:
// System.Int32 UnityEngine.Object::OffsetOfInstanceIDInCPlusPlusObject
int32_t ___OffsetOfInstanceIDInCPlusPlusObject_1;
public:
inline static int32_t get_offset_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return static_cast<int32_t>(offsetof(Object_t631007953_StaticFields, ___OffsetOfInstanceIDInCPlusPlusObject_1)); }
inline int32_t get_OffsetOfInstanceIDInCPlusPlusObject_1() const { return ___OffsetOfInstanceIDInCPlusPlusObject_1; }
inline int32_t* get_address_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return &___OffsetOfInstanceIDInCPlusPlusObject_1; }
inline void set_OffsetOfInstanceIDInCPlusPlusObject_1(int32_t value)
{
___OffsetOfInstanceIDInCPlusPlusObject_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of UnityEngine.Object
struct Object_t631007953_marshaled_pinvoke
{
intptr_t ___m_CachedPtr_0;
};
// Native definition for COM marshalling of UnityEngine.Object
struct Object_t631007953_marshaled_com
{
intptr_t ___m_CachedPtr_0;
};
#endif // OBJECT_T631007953_H
#ifndef MOVEMENTTYPE_T4072922106_H
#define MOVEMENTTYPE_T4072922106_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.ScrollRect/MovementType
struct MovementType_t4072922106
{
public:
// System.Int32 UnityEngine.UI.ScrollRect/MovementType::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(MovementType_t4072922106, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MOVEMENTTYPE_T4072922106_H
#ifndef SCROLLBARVISIBILITY_T705693775_H
#define SCROLLBARVISIBILITY_T705693775_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.ScrollRect/ScrollbarVisibility
struct ScrollbarVisibility_t705693775
{
public:
// System.Int32 UnityEngine.UI.ScrollRect/ScrollbarVisibility::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(ScrollbarVisibility_t705693775, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SCROLLBARVISIBILITY_T705693775_H
#ifndef SCROLLRECTEVENT_T343079324_H
#define SCROLLRECTEVENT_T343079324_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.ScrollRect/ScrollRectEvent
struct ScrollRectEvent_t343079324 : public UnityEvent_1_t3037889027
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SCROLLRECTEVENT_T343079324_H
#ifndef TRANSITION_T1769908631_H
#define TRANSITION_T1769908631_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Selectable/Transition
struct Transition_t1769908631
{
public:
// System.Int32 UnityEngine.UI.Selectable/Transition::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(Transition_t1769908631, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TRANSITION_T1769908631_H
#ifndef SELECTIONSTATE_T2656606514_H
#define SELECTIONSTATE_T2656606514_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Selectable/SelectionState
struct SelectionState_t2656606514
{
public:
// System.Int32 UnityEngine.UI.Selectable/SelectionState::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(SelectionState_t2656606514, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SELECTIONSTATE_T2656606514_H
#ifndef FONTDATA_T746620069_H
#define FONTDATA_T746620069_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.FontData
struct FontData_t746620069 : public RuntimeObject
{
public:
// UnityEngine.Font UnityEngine.UI.FontData::m_Font
Font_t1956802104 * ___m_Font_0;
// System.Int32 UnityEngine.UI.FontData::m_FontSize
int32_t ___m_FontSize_1;
// UnityEngine.FontStyle UnityEngine.UI.FontData::m_FontStyle
int32_t ___m_FontStyle_2;
// System.Boolean UnityEngine.UI.FontData::m_BestFit
bool ___m_BestFit_3;
// System.Int32 UnityEngine.UI.FontData::m_MinSize
int32_t ___m_MinSize_4;
// System.Int32 UnityEngine.UI.FontData::m_MaxSize
int32_t ___m_MaxSize_5;
// UnityEngine.TextAnchor UnityEngine.UI.FontData::m_Alignment
int32_t ___m_Alignment_6;
// System.Boolean UnityEngine.UI.FontData::m_AlignByGeometry
bool ___m_AlignByGeometry_7;
// System.Boolean UnityEngine.UI.FontData::m_RichText
bool ___m_RichText_8;
// UnityEngine.HorizontalWrapMode UnityEngine.UI.FontData::m_HorizontalOverflow
int32_t ___m_HorizontalOverflow_9;
// UnityEngine.VerticalWrapMode UnityEngine.UI.FontData::m_VerticalOverflow
int32_t ___m_VerticalOverflow_10;
// System.Single UnityEngine.UI.FontData::m_LineSpacing
float ___m_LineSpacing_11;
public:
inline static int32_t get_offset_of_m_Font_0() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_Font_0)); }
inline Font_t1956802104 * get_m_Font_0() const { return ___m_Font_0; }
inline Font_t1956802104 ** get_address_of_m_Font_0() { return &___m_Font_0; }
inline void set_m_Font_0(Font_t1956802104 * value)
{
___m_Font_0 = value;
Il2CppCodeGenWriteBarrier((&___m_Font_0), value);
}
inline static int32_t get_offset_of_m_FontSize_1() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_FontSize_1)); }
inline int32_t get_m_FontSize_1() const { return ___m_FontSize_1; }
inline int32_t* get_address_of_m_FontSize_1() { return &___m_FontSize_1; }
inline void set_m_FontSize_1(int32_t value)
{
___m_FontSize_1 = value;
}
inline static int32_t get_offset_of_m_FontStyle_2() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_FontStyle_2)); }
inline int32_t get_m_FontStyle_2() const { return ___m_FontStyle_2; }
inline int32_t* get_address_of_m_FontStyle_2() { return &___m_FontStyle_2; }
inline void set_m_FontStyle_2(int32_t value)
{
___m_FontStyle_2 = value;
}
inline static int32_t get_offset_of_m_BestFit_3() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_BestFit_3)); }
inline bool get_m_BestFit_3() const { return ___m_BestFit_3; }
inline bool* get_address_of_m_BestFit_3() { return &___m_BestFit_3; }
inline void set_m_BestFit_3(bool value)
{
___m_BestFit_3 = value;
}
inline static int32_t get_offset_of_m_MinSize_4() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_MinSize_4)); }
inline int32_t get_m_MinSize_4() const { return ___m_MinSize_4; }
inline int32_t* get_address_of_m_MinSize_4() { return &___m_MinSize_4; }
inline void set_m_MinSize_4(int32_t value)
{
___m_MinSize_4 = value;
}
inline static int32_t get_offset_of_m_MaxSize_5() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_MaxSize_5)); }
inline int32_t get_m_MaxSize_5() const { return ___m_MaxSize_5; }
inline int32_t* get_address_of_m_MaxSize_5() { return &___m_MaxSize_5; }
inline void set_m_MaxSize_5(int32_t value)
{
___m_MaxSize_5 = value;
}
inline static int32_t get_offset_of_m_Alignment_6() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_Alignment_6)); }
inline int32_t get_m_Alignment_6() const { return ___m_Alignment_6; }
inline int32_t* get_address_of_m_Alignment_6() { return &___m_Alignment_6; }
inline void set_m_Alignment_6(int32_t value)
{
___m_Alignment_6 = value;
}
inline static int32_t get_offset_of_m_AlignByGeometry_7() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_AlignByGeometry_7)); }
inline bool get_m_AlignByGeometry_7() const { return ___m_AlignByGeometry_7; }
inline bool* get_address_of_m_AlignByGeometry_7() { return &___m_AlignByGeometry_7; }
inline void set_m_AlignByGeometry_7(bool value)
{
___m_AlignByGeometry_7 = value;
}
inline static int32_t get_offset_of_m_RichText_8() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_RichText_8)); }
inline bool get_m_RichText_8() const { return ___m_RichText_8; }
inline bool* get_address_of_m_RichText_8() { return &___m_RichText_8; }
inline void set_m_RichText_8(bool value)
{
___m_RichText_8 = value;
}
inline static int32_t get_offset_of_m_HorizontalOverflow_9() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_HorizontalOverflow_9)); }
inline int32_t get_m_HorizontalOverflow_9() const { return ___m_HorizontalOverflow_9; }
inline int32_t* get_address_of_m_HorizontalOverflow_9() { return &___m_HorizontalOverflow_9; }
inline void set_m_HorizontalOverflow_9(int32_t value)
{
___m_HorizontalOverflow_9 = value;
}
inline static int32_t get_offset_of_m_VerticalOverflow_10() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_VerticalOverflow_10)); }
inline int32_t get_m_VerticalOverflow_10() const { return ___m_VerticalOverflow_10; }
inline int32_t* get_address_of_m_VerticalOverflow_10() { return &___m_VerticalOverflow_10; }
inline void set_m_VerticalOverflow_10(int32_t value)
{
___m_VerticalOverflow_10 = value;
}
inline static int32_t get_offset_of_m_LineSpacing_11() { return static_cast<int32_t>(offsetof(FontData_t746620069, ___m_LineSpacing_11)); }
inline float get_m_LineSpacing_11() const { return ___m_LineSpacing_11; }
inline float* get_address_of_m_LineSpacing_11() { return &___m_LineSpacing_11; }
inline void set_m_LineSpacing_11(float value)
{
___m_LineSpacing_11 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // FONTDATA_T746620069_H
#ifndef NAVIGATION_T3049316579_H
#define NAVIGATION_T3049316579_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Navigation
struct Navigation_t3049316579
{
public:
// UnityEngine.UI.Navigation/Mode UnityEngine.UI.Navigation::m_Mode
int32_t ___m_Mode_0;
// UnityEngine.UI.Selectable UnityEngine.UI.Navigation::m_SelectOnUp
Selectable_t3250028441 * ___m_SelectOnUp_1;
// UnityEngine.UI.Selectable UnityEngine.UI.Navigation::m_SelectOnDown
Selectable_t3250028441 * ___m_SelectOnDown_2;
// UnityEngine.UI.Selectable UnityEngine.UI.Navigation::m_SelectOnLeft
Selectable_t3250028441 * ___m_SelectOnLeft_3;
// UnityEngine.UI.Selectable UnityEngine.UI.Navigation::m_SelectOnRight
Selectable_t3250028441 * ___m_SelectOnRight_4;
public:
inline static int32_t get_offset_of_m_Mode_0() { return static_cast<int32_t>(offsetof(Navigation_t3049316579, ___m_Mode_0)); }
inline int32_t get_m_Mode_0() const { return ___m_Mode_0; }
inline int32_t* get_address_of_m_Mode_0() { return &___m_Mode_0; }
inline void set_m_Mode_0(int32_t value)
{
___m_Mode_0 = value;
}
inline static int32_t get_offset_of_m_SelectOnUp_1() { return static_cast<int32_t>(offsetof(Navigation_t3049316579, ___m_SelectOnUp_1)); }
inline Selectable_t3250028441 * get_m_SelectOnUp_1() const { return ___m_SelectOnUp_1; }
inline Selectable_t3250028441 ** get_address_of_m_SelectOnUp_1() { return &___m_SelectOnUp_1; }
inline void set_m_SelectOnUp_1(Selectable_t3250028441 * value)
{
___m_SelectOnUp_1 = value;
Il2CppCodeGenWriteBarrier((&___m_SelectOnUp_1), value);
}
inline static int32_t get_offset_of_m_SelectOnDown_2() { return static_cast<int32_t>(offsetof(Navigation_t3049316579, ___m_SelectOnDown_2)); }
inline Selectable_t3250028441 * get_m_SelectOnDown_2() const { return ___m_SelectOnDown_2; }
inline Selectable_t3250028441 ** get_address_of_m_SelectOnDown_2() { return &___m_SelectOnDown_2; }
inline void set_m_SelectOnDown_2(Selectable_t3250028441 * value)
{
___m_SelectOnDown_2 = value;
Il2CppCodeGenWriteBarrier((&___m_SelectOnDown_2), value);
}
inline static int32_t get_offset_of_m_SelectOnLeft_3() { return static_cast<int32_t>(offsetof(Navigation_t3049316579, ___m_SelectOnLeft_3)); }
inline Selectable_t3250028441 * get_m_SelectOnLeft_3() const { return ___m_SelectOnLeft_3; }
inline Selectable_t3250028441 ** get_address_of_m_SelectOnLeft_3() { return &___m_SelectOnLeft_3; }
inline void set_m_SelectOnLeft_3(Selectable_t3250028441 * value)
{
___m_SelectOnLeft_3 = value;
Il2CppCodeGenWriteBarrier((&___m_SelectOnLeft_3), value);
}
inline static int32_t get_offset_of_m_SelectOnRight_4() { return static_cast<int32_t>(offsetof(Navigation_t3049316579, ___m_SelectOnRight_4)); }
inline Selectable_t3250028441 * get_m_SelectOnRight_4() const { return ___m_SelectOnRight_4; }
inline Selectable_t3250028441 ** get_address_of_m_SelectOnRight_4() { return &___m_SelectOnRight_4; }
inline void set_m_SelectOnRight_4(Selectable_t3250028441 * value)
{
___m_SelectOnRight_4 = value;
Il2CppCodeGenWriteBarrier((&___m_SelectOnRight_4), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of UnityEngine.UI.Navigation
struct Navigation_t3049316579_marshaled_pinvoke
{
int32_t ___m_Mode_0;
Selectable_t3250028441 * ___m_SelectOnUp_1;
Selectable_t3250028441 * ___m_SelectOnDown_2;
Selectable_t3250028441 * ___m_SelectOnLeft_3;
Selectable_t3250028441 * ___m_SelectOnRight_4;
};
// Native definition for COM marshalling of UnityEngine.UI.Navigation
struct Navigation_t3049316579_marshaled_com
{
int32_t ___m_Mode_0;
Selectable_t3250028441 * ___m_SelectOnUp_1;
Selectable_t3250028441 * ___m_SelectOnDown_2;
Selectable_t3250028441 * ___m_SelectOnLeft_3;
Selectable_t3250028441 * ___m_SelectOnRight_4;
};
#endif // NAVIGATION_T3049316579_H
#ifndef COMPONENT_T1923634451_H
#define COMPONENT_T1923634451_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Component
struct Component_t1923634451 : public Object_t631007953
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // COMPONENT_T1923634451_H
#ifndef MATENTRY_T2957107092_H
#define MATENTRY_T2957107092_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.StencilMaterial/MatEntry
struct MatEntry_t2957107092 : public RuntimeObject
{
public:
// UnityEngine.Material UnityEngine.UI.StencilMaterial/MatEntry::baseMat
Material_t340375123 * ___baseMat_0;
// UnityEngine.Material UnityEngine.UI.StencilMaterial/MatEntry::customMat
Material_t340375123 * ___customMat_1;
// System.Int32 UnityEngine.UI.StencilMaterial/MatEntry::count
int32_t ___count_2;
// System.Int32 UnityEngine.UI.StencilMaterial/MatEntry::stencilId
int32_t ___stencilId_3;
// UnityEngine.Rendering.StencilOp UnityEngine.UI.StencilMaterial/MatEntry::operation
int32_t ___operation_4;
// UnityEngine.Rendering.CompareFunction UnityEngine.UI.StencilMaterial/MatEntry::compareFunction
int32_t ___compareFunction_5;
// System.Int32 UnityEngine.UI.StencilMaterial/MatEntry::readMask
int32_t ___readMask_6;
// System.Int32 UnityEngine.UI.StencilMaterial/MatEntry::writeMask
int32_t ___writeMask_7;
// System.Boolean UnityEngine.UI.StencilMaterial/MatEntry::useAlphaClip
bool ___useAlphaClip_8;
// UnityEngine.Rendering.ColorWriteMask UnityEngine.UI.StencilMaterial/MatEntry::colorMask
int32_t ___colorMask_9;
public:
inline static int32_t get_offset_of_baseMat_0() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___baseMat_0)); }
inline Material_t340375123 * get_baseMat_0() const { return ___baseMat_0; }
inline Material_t340375123 ** get_address_of_baseMat_0() { return &___baseMat_0; }
inline void set_baseMat_0(Material_t340375123 * value)
{
___baseMat_0 = value;
Il2CppCodeGenWriteBarrier((&___baseMat_0), value);
}
inline static int32_t get_offset_of_customMat_1() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___customMat_1)); }
inline Material_t340375123 * get_customMat_1() const { return ___customMat_1; }
inline Material_t340375123 ** get_address_of_customMat_1() { return &___customMat_1; }
inline void set_customMat_1(Material_t340375123 * value)
{
___customMat_1 = value;
Il2CppCodeGenWriteBarrier((&___customMat_1), value);
}
inline static int32_t get_offset_of_count_2() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___count_2)); }
inline int32_t get_count_2() const { return ___count_2; }
inline int32_t* get_address_of_count_2() { return &___count_2; }
inline void set_count_2(int32_t value)
{
___count_2 = value;
}
inline static int32_t get_offset_of_stencilId_3() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___stencilId_3)); }
inline int32_t get_stencilId_3() const { return ___stencilId_3; }
inline int32_t* get_address_of_stencilId_3() { return &___stencilId_3; }
inline void set_stencilId_3(int32_t value)
{
___stencilId_3 = value;
}
inline static int32_t get_offset_of_operation_4() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___operation_4)); }
inline int32_t get_operation_4() const { return ___operation_4; }
inline int32_t* get_address_of_operation_4() { return &___operation_4; }
inline void set_operation_4(int32_t value)
{
___operation_4 = value;
}
inline static int32_t get_offset_of_compareFunction_5() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___compareFunction_5)); }
inline int32_t get_compareFunction_5() const { return ___compareFunction_5; }
inline int32_t* get_address_of_compareFunction_5() { return &___compareFunction_5; }
inline void set_compareFunction_5(int32_t value)
{
___compareFunction_5 = value;
}
inline static int32_t get_offset_of_readMask_6() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___readMask_6)); }
inline int32_t get_readMask_6() const { return ___readMask_6; }
inline int32_t* get_address_of_readMask_6() { return &___readMask_6; }
inline void set_readMask_6(int32_t value)
{
___readMask_6 = value;
}
inline static int32_t get_offset_of_writeMask_7() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___writeMask_7)); }
inline int32_t get_writeMask_7() const { return ___writeMask_7; }
inline int32_t* get_address_of_writeMask_7() { return &___writeMask_7; }
inline void set_writeMask_7(int32_t value)
{
___writeMask_7 = value;
}
inline static int32_t get_offset_of_useAlphaClip_8() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___useAlphaClip_8)); }
inline bool get_useAlphaClip_8() const { return ___useAlphaClip_8; }
inline bool* get_address_of_useAlphaClip_8() { return &___useAlphaClip_8; }
inline void set_useAlphaClip_8(bool value)
{
___useAlphaClip_8 = value;
}
inline static int32_t get_offset_of_colorMask_9() { return static_cast<int32_t>(offsetof(MatEntry_t2957107092, ___colorMask_9)); }
inline int32_t get_colorMask_9() const { return ___colorMask_9; }
inline int32_t* get_address_of_colorMask_9() { return &___colorMask_9; }
inline void set_colorMask_9(int32_t value)
{
___colorMask_9 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MATENTRY_T2957107092_H
#ifndef MULTICASTDELEGATE_T_H
#define MULTICASTDELEGATE_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.MulticastDelegate
struct MulticastDelegate_t : public Delegate_t1188392813
{
public:
// System.MulticastDelegate System.MulticastDelegate::prev
MulticastDelegate_t * ___prev_9;
// System.MulticastDelegate System.MulticastDelegate::kpm_next
MulticastDelegate_t * ___kpm_next_10;
public:
inline static int32_t get_offset_of_prev_9() { return static_cast<int32_t>(offsetof(MulticastDelegate_t, ___prev_9)); }
inline MulticastDelegate_t * get_prev_9() const { return ___prev_9; }
inline MulticastDelegate_t ** get_address_of_prev_9() { return &___prev_9; }
inline void set_prev_9(MulticastDelegate_t * value)
{
___prev_9 = value;
Il2CppCodeGenWriteBarrier((&___prev_9), value);
}
inline static int32_t get_offset_of_kpm_next_10() { return static_cast<int32_t>(offsetof(MulticastDelegate_t, ___kpm_next_10)); }
inline MulticastDelegate_t * get_kpm_next_10() const { return ___kpm_next_10; }
inline MulticastDelegate_t ** get_address_of_kpm_next_10() { return &___kpm_next_10; }
inline void set_kpm_next_10(MulticastDelegate_t * value)
{
___kpm_next_10 = value;
Il2CppCodeGenWriteBarrier((&___kpm_next_10), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MULTICASTDELEGATE_T_H
#ifndef BEHAVIOUR_T1437897464_H
#define BEHAVIOUR_T1437897464_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Behaviour
struct Behaviour_t1437897464 : public Component_t1923634451
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // BEHAVIOUR_T1437897464_H
#ifndef ONVALIDATEINPUT_T2355412304_H
#define ONVALIDATEINPUT_T2355412304_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField/OnValidateInput
struct OnValidateInput_t2355412304 : public MulticastDelegate_t
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ONVALIDATEINPUT_T2355412304_H
#ifndef MONOBEHAVIOUR_T3962482529_H
#define MONOBEHAVIOUR_T3962482529_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.MonoBehaviour
struct MonoBehaviour_t3962482529 : public Behaviour_t1437897464
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MONOBEHAVIOUR_T3962482529_H
#ifndef UIBEHAVIOUR_T3495933518_H
#define UIBEHAVIOUR_T3495933518_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.EventSystems.UIBehaviour
struct UIBehaviour_t3495933518 : public MonoBehaviour_t3962482529
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UIBEHAVIOUR_T3495933518_H
#ifndef DROPDOWNITEM_T1451952895_H
#define DROPDOWNITEM_T1451952895_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Dropdown/DropdownItem
struct DropdownItem_t1451952895 : public MonoBehaviour_t3962482529
{
public:
// UnityEngine.UI.Text UnityEngine.UI.Dropdown/DropdownItem::m_Text
Text_t1901882714 * ___m_Text_2;
// UnityEngine.UI.Image UnityEngine.UI.Dropdown/DropdownItem::m_Image
Image_t2670269651 * ___m_Image_3;
// UnityEngine.RectTransform UnityEngine.UI.Dropdown/DropdownItem::m_RectTransform
RectTransform_t3704657025 * ___m_RectTransform_4;
// UnityEngine.UI.Toggle UnityEngine.UI.Dropdown/DropdownItem::m_Toggle
Toggle_t2735377061 * ___m_Toggle_5;
public:
inline static int32_t get_offset_of_m_Text_2() { return static_cast<int32_t>(offsetof(DropdownItem_t1451952895, ___m_Text_2)); }
inline Text_t1901882714 * get_m_Text_2() const { return ___m_Text_2; }
inline Text_t1901882714 ** get_address_of_m_Text_2() { return &___m_Text_2; }
inline void set_m_Text_2(Text_t1901882714 * value)
{
___m_Text_2 = value;
Il2CppCodeGenWriteBarrier((&___m_Text_2), value);
}
inline static int32_t get_offset_of_m_Image_3() { return static_cast<int32_t>(offsetof(DropdownItem_t1451952895, ___m_Image_3)); }
inline Image_t2670269651 * get_m_Image_3() const { return ___m_Image_3; }
inline Image_t2670269651 ** get_address_of_m_Image_3() { return &___m_Image_3; }
inline void set_m_Image_3(Image_t2670269651 * value)
{
___m_Image_3 = value;
Il2CppCodeGenWriteBarrier((&___m_Image_3), value);
}
inline static int32_t get_offset_of_m_RectTransform_4() { return static_cast<int32_t>(offsetof(DropdownItem_t1451952895, ___m_RectTransform_4)); }
inline RectTransform_t3704657025 * get_m_RectTransform_4() const { return ___m_RectTransform_4; }
inline RectTransform_t3704657025 ** get_address_of_m_RectTransform_4() { return &___m_RectTransform_4; }
inline void set_m_RectTransform_4(RectTransform_t3704657025 * value)
{
___m_RectTransform_4 = value;
Il2CppCodeGenWriteBarrier((&___m_RectTransform_4), value);
}
inline static int32_t get_offset_of_m_Toggle_5() { return static_cast<int32_t>(offsetof(DropdownItem_t1451952895, ___m_Toggle_5)); }
inline Toggle_t2735377061 * get_m_Toggle_5() const { return ___m_Toggle_5; }
inline Toggle_t2735377061 ** get_address_of_m_Toggle_5() { return &___m_Toggle_5; }
inline void set_m_Toggle_5(Toggle_t2735377061 * value)
{
___m_Toggle_5 = value;
Il2CppCodeGenWriteBarrier((&___m_Toggle_5), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DROPDOWNITEM_T1451952895_H
#ifndef LAYOUTGROUP_T2436138090_H
#define LAYOUTGROUP_T2436138090_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.LayoutGroup
struct LayoutGroup_t2436138090 : public UIBehaviour_t3495933518
{
public:
// UnityEngine.RectOffset UnityEngine.UI.LayoutGroup::m_Padding
RectOffset_t1369453676 * ___m_Padding_2;
// UnityEngine.TextAnchor UnityEngine.UI.LayoutGroup::m_ChildAlignment
int32_t ___m_ChildAlignment_3;
// UnityEngine.RectTransform UnityEngine.UI.LayoutGroup::m_Rect
RectTransform_t3704657025 * ___m_Rect_4;
// UnityEngine.DrivenRectTransformTracker UnityEngine.UI.LayoutGroup::m_Tracker
DrivenRectTransformTracker_t2562230146 ___m_Tracker_5;
// UnityEngine.Vector2 UnityEngine.UI.LayoutGroup::m_TotalMinSize
Vector2_t2156229523 ___m_TotalMinSize_6;
// UnityEngine.Vector2 UnityEngine.UI.LayoutGroup::m_TotalPreferredSize
Vector2_t2156229523 ___m_TotalPreferredSize_7;
// UnityEngine.Vector2 UnityEngine.UI.LayoutGroup::m_TotalFlexibleSize
Vector2_t2156229523 ___m_TotalFlexibleSize_8;
// System.Collections.Generic.List`1<UnityEngine.RectTransform> UnityEngine.UI.LayoutGroup::m_RectChildren
List_1_t881764471 * ___m_RectChildren_9;
public:
inline static int32_t get_offset_of_m_Padding_2() { return static_cast<int32_t>(offsetof(LayoutGroup_t2436138090, ___m_Padding_2)); }
inline RectOffset_t1369453676 * get_m_Padding_2() const { return ___m_Padding_2; }
inline RectOffset_t1369453676 ** get_address_of_m_Padding_2() { return &___m_Padding_2; }
inline void set_m_Padding_2(RectOffset_t1369453676 * value)
{
___m_Padding_2 = value;
Il2CppCodeGenWriteBarrier((&___m_Padding_2), value);
}
inline static int32_t get_offset_of_m_ChildAlignment_3() { return static_cast<int32_t>(offsetof(LayoutGroup_t2436138090, ___m_ChildAlignment_3)); }
inline int32_t get_m_ChildAlignment_3() const { return ___m_ChildAlignment_3; }
inline int32_t* get_address_of_m_ChildAlignment_3() { return &___m_ChildAlignment_3; }
inline void set_m_ChildAlignment_3(int32_t value)
{
___m_ChildAlignment_3 = value;
}
inline static int32_t get_offset_of_m_Rect_4() { return static_cast<int32_t>(offsetof(LayoutGroup_t2436138090, ___m_Rect_4)); }
inline RectTransform_t3704657025 * get_m_Rect_4() const { return ___m_Rect_4; }
inline RectTransform_t3704657025 ** get_address_of_m_Rect_4() { return &___m_Rect_4; }
inline void set_m_Rect_4(RectTransform_t3704657025 * value)
{
___m_Rect_4 = value;
Il2CppCodeGenWriteBarrier((&___m_Rect_4), value);
}
inline static int32_t get_offset_of_m_Tracker_5() { return static_cast<int32_t>(offsetof(LayoutGroup_t2436138090, ___m_Tracker_5)); }
inline DrivenRectTransformTracker_t2562230146 get_m_Tracker_5() const { return ___m_Tracker_5; }
inline DrivenRectTransformTracker_t2562230146 * get_address_of_m_Tracker_5() { return &___m_Tracker_5; }
inline void set_m_Tracker_5(DrivenRectTransformTracker_t2562230146 value)
{
___m_Tracker_5 = value;
}
inline static int32_t get_offset_of_m_TotalMinSize_6() { return static_cast<int32_t>(offsetof(LayoutGroup_t2436138090, ___m_TotalMinSize_6)); }
inline Vector2_t2156229523 get_m_TotalMinSize_6() const { return ___m_TotalMinSize_6; }
inline Vector2_t2156229523 * get_address_of_m_TotalMinSize_6() { return &___m_TotalMinSize_6; }
inline void set_m_TotalMinSize_6(Vector2_t2156229523 value)
{
___m_TotalMinSize_6 = value;
}
inline static int32_t get_offset_of_m_TotalPreferredSize_7() { return static_cast<int32_t>(offsetof(LayoutGroup_t2436138090, ___m_TotalPreferredSize_7)); }
inline Vector2_t2156229523 get_m_TotalPreferredSize_7() const { return ___m_TotalPreferredSize_7; }
inline Vector2_t2156229523 * get_address_of_m_TotalPreferredSize_7() { return &___m_TotalPreferredSize_7; }
inline void set_m_TotalPreferredSize_7(Vector2_t2156229523 value)
{
___m_TotalPreferredSize_7 = value;
}
inline static int32_t get_offset_of_m_TotalFlexibleSize_8() { return static_cast<int32_t>(offsetof(LayoutGroup_t2436138090, ___m_TotalFlexibleSize_8)); }
inline Vector2_t2156229523 get_m_TotalFlexibleSize_8() const { return ___m_TotalFlexibleSize_8; }
inline Vector2_t2156229523 * get_address_of_m_TotalFlexibleSize_8() { return &___m_TotalFlexibleSize_8; }
inline void set_m_TotalFlexibleSize_8(Vector2_t2156229523 value)
{
___m_TotalFlexibleSize_8 = value;
}
inline static int32_t get_offset_of_m_RectChildren_9() { return static_cast<int32_t>(offsetof(LayoutGroup_t2436138090, ___m_RectChildren_9)); }
inline List_1_t881764471 * get_m_RectChildren_9() const { return ___m_RectChildren_9; }
inline List_1_t881764471 ** get_address_of_m_RectChildren_9() { return &___m_RectChildren_9; }
inline void set_m_RectChildren_9(List_1_t881764471 * value)
{
___m_RectChildren_9 = value;
Il2CppCodeGenWriteBarrier((&___m_RectChildren_9), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // LAYOUTGROUP_T2436138090_H
#ifndef SELECTABLE_T3250028441_H
#define SELECTABLE_T3250028441_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Selectable
struct Selectable_t3250028441 : public UIBehaviour_t3495933518
{
public:
// UnityEngine.UI.Navigation UnityEngine.UI.Selectable::m_Navigation
Navigation_t3049316579 ___m_Navigation_3;
// UnityEngine.UI.Selectable/Transition UnityEngine.UI.Selectable::m_Transition
int32_t ___m_Transition_4;
// UnityEngine.UI.ColorBlock UnityEngine.UI.Selectable::m_Colors
ColorBlock_t2139031574 ___m_Colors_5;
// UnityEngine.UI.SpriteState UnityEngine.UI.Selectable::m_SpriteState
SpriteState_t1362986479 ___m_SpriteState_6;
// UnityEngine.UI.AnimationTriggers UnityEngine.UI.Selectable::m_AnimationTriggers
AnimationTriggers_t2532145056 * ___m_AnimationTriggers_7;
// System.Boolean UnityEngine.UI.Selectable::m_Interactable
bool ___m_Interactable_8;
// UnityEngine.UI.Graphic UnityEngine.UI.Selectable::m_TargetGraphic
Graphic_t1660335611 * ___m_TargetGraphic_9;
// System.Boolean UnityEngine.UI.Selectable::m_GroupsAllowInteraction
bool ___m_GroupsAllowInteraction_10;
// UnityEngine.UI.Selectable/SelectionState UnityEngine.UI.Selectable::m_CurrentSelectionState
int32_t ___m_CurrentSelectionState_11;
// System.Boolean UnityEngine.UI.Selectable::<isPointerInside>k__BackingField
bool ___U3CisPointerInsideU3Ek__BackingField_12;
// System.Boolean UnityEngine.UI.Selectable::<isPointerDown>k__BackingField
bool ___U3CisPointerDownU3Ek__BackingField_13;
// System.Boolean UnityEngine.UI.Selectable::<hasSelection>k__BackingField
bool ___U3ChasSelectionU3Ek__BackingField_14;
// System.Collections.Generic.List`1<UnityEngine.CanvasGroup> UnityEngine.UI.Selectable::m_CanvasGroupCache
List_1_t1260619206 * ___m_CanvasGroupCache_15;
public:
inline static int32_t get_offset_of_m_Navigation_3() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_Navigation_3)); }
inline Navigation_t3049316579 get_m_Navigation_3() const { return ___m_Navigation_3; }
inline Navigation_t3049316579 * get_address_of_m_Navigation_3() { return &___m_Navigation_3; }
inline void set_m_Navigation_3(Navigation_t3049316579 value)
{
___m_Navigation_3 = value;
}
inline static int32_t get_offset_of_m_Transition_4() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_Transition_4)); }
inline int32_t get_m_Transition_4() const { return ___m_Transition_4; }
inline int32_t* get_address_of_m_Transition_4() { return &___m_Transition_4; }
inline void set_m_Transition_4(int32_t value)
{
___m_Transition_4 = value;
}
inline static int32_t get_offset_of_m_Colors_5() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_Colors_5)); }
inline ColorBlock_t2139031574 get_m_Colors_5() const { return ___m_Colors_5; }
inline ColorBlock_t2139031574 * get_address_of_m_Colors_5() { return &___m_Colors_5; }
inline void set_m_Colors_5(ColorBlock_t2139031574 value)
{
___m_Colors_5 = value;
}
inline static int32_t get_offset_of_m_SpriteState_6() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_SpriteState_6)); }
inline SpriteState_t1362986479 get_m_SpriteState_6() const { return ___m_SpriteState_6; }
inline SpriteState_t1362986479 * get_address_of_m_SpriteState_6() { return &___m_SpriteState_6; }
inline void set_m_SpriteState_6(SpriteState_t1362986479 value)
{
___m_SpriteState_6 = value;
}
inline static int32_t get_offset_of_m_AnimationTriggers_7() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_AnimationTriggers_7)); }
inline AnimationTriggers_t2532145056 * get_m_AnimationTriggers_7() const { return ___m_AnimationTriggers_7; }
inline AnimationTriggers_t2532145056 ** get_address_of_m_AnimationTriggers_7() { return &___m_AnimationTriggers_7; }
inline void set_m_AnimationTriggers_7(AnimationTriggers_t2532145056 * value)
{
___m_AnimationTriggers_7 = value;
Il2CppCodeGenWriteBarrier((&___m_AnimationTriggers_7), value);
}
inline static int32_t get_offset_of_m_Interactable_8() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_Interactable_8)); }
inline bool get_m_Interactable_8() const { return ___m_Interactable_8; }
inline bool* get_address_of_m_Interactable_8() { return &___m_Interactable_8; }
inline void set_m_Interactable_8(bool value)
{
___m_Interactable_8 = value;
}
inline static int32_t get_offset_of_m_TargetGraphic_9() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_TargetGraphic_9)); }
inline Graphic_t1660335611 * get_m_TargetGraphic_9() const { return ___m_TargetGraphic_9; }
inline Graphic_t1660335611 ** get_address_of_m_TargetGraphic_9() { return &___m_TargetGraphic_9; }
inline void set_m_TargetGraphic_9(Graphic_t1660335611 * value)
{
___m_TargetGraphic_9 = value;
Il2CppCodeGenWriteBarrier((&___m_TargetGraphic_9), value);
}
inline static int32_t get_offset_of_m_GroupsAllowInteraction_10() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_GroupsAllowInteraction_10)); }
inline bool get_m_GroupsAllowInteraction_10() const { return ___m_GroupsAllowInteraction_10; }
inline bool* get_address_of_m_GroupsAllowInteraction_10() { return &___m_GroupsAllowInteraction_10; }
inline void set_m_GroupsAllowInteraction_10(bool value)
{
___m_GroupsAllowInteraction_10 = value;
}
inline static int32_t get_offset_of_m_CurrentSelectionState_11() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_CurrentSelectionState_11)); }
inline int32_t get_m_CurrentSelectionState_11() const { return ___m_CurrentSelectionState_11; }
inline int32_t* get_address_of_m_CurrentSelectionState_11() { return &___m_CurrentSelectionState_11; }
inline void set_m_CurrentSelectionState_11(int32_t value)
{
___m_CurrentSelectionState_11 = value;
}
inline static int32_t get_offset_of_U3CisPointerInsideU3Ek__BackingField_12() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___U3CisPointerInsideU3Ek__BackingField_12)); }
inline bool get_U3CisPointerInsideU3Ek__BackingField_12() const { return ___U3CisPointerInsideU3Ek__BackingField_12; }
inline bool* get_address_of_U3CisPointerInsideU3Ek__BackingField_12() { return &___U3CisPointerInsideU3Ek__BackingField_12; }
inline void set_U3CisPointerInsideU3Ek__BackingField_12(bool value)
{
___U3CisPointerInsideU3Ek__BackingField_12 = value;
}
inline static int32_t get_offset_of_U3CisPointerDownU3Ek__BackingField_13() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___U3CisPointerDownU3Ek__BackingField_13)); }
inline bool get_U3CisPointerDownU3Ek__BackingField_13() const { return ___U3CisPointerDownU3Ek__BackingField_13; }
inline bool* get_address_of_U3CisPointerDownU3Ek__BackingField_13() { return &___U3CisPointerDownU3Ek__BackingField_13; }
inline void set_U3CisPointerDownU3Ek__BackingField_13(bool value)
{
___U3CisPointerDownU3Ek__BackingField_13 = value;
}
inline static int32_t get_offset_of_U3ChasSelectionU3Ek__BackingField_14() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___U3ChasSelectionU3Ek__BackingField_14)); }
inline bool get_U3ChasSelectionU3Ek__BackingField_14() const { return ___U3ChasSelectionU3Ek__BackingField_14; }
inline bool* get_address_of_U3ChasSelectionU3Ek__BackingField_14() { return &___U3ChasSelectionU3Ek__BackingField_14; }
inline void set_U3ChasSelectionU3Ek__BackingField_14(bool value)
{
___U3ChasSelectionU3Ek__BackingField_14 = value;
}
inline static int32_t get_offset_of_m_CanvasGroupCache_15() { return static_cast<int32_t>(offsetof(Selectable_t3250028441, ___m_CanvasGroupCache_15)); }
inline List_1_t1260619206 * get_m_CanvasGroupCache_15() const { return ___m_CanvasGroupCache_15; }
inline List_1_t1260619206 ** get_address_of_m_CanvasGroupCache_15() { return &___m_CanvasGroupCache_15; }
inline void set_m_CanvasGroupCache_15(List_1_t1260619206 * value)
{
___m_CanvasGroupCache_15 = value;
Il2CppCodeGenWriteBarrier((&___m_CanvasGroupCache_15), value);
}
};
struct Selectable_t3250028441_StaticFields
{
public:
// System.Collections.Generic.List`1<UnityEngine.UI.Selectable> UnityEngine.UI.Selectable::s_List
List_1_t427135887 * ___s_List_2;
public:
inline static int32_t get_offset_of_s_List_2() { return static_cast<int32_t>(offsetof(Selectable_t3250028441_StaticFields, ___s_List_2)); }
inline List_1_t427135887 * get_s_List_2() const { return ___s_List_2; }
inline List_1_t427135887 ** get_address_of_s_List_2() { return &___s_List_2; }
inline void set_s_List_2(List_1_t427135887 * value)
{
___s_List_2 = value;
Il2CppCodeGenWriteBarrier((&___s_List_2), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SELECTABLE_T3250028441_H
#ifndef GRAPHIC_T1660335611_H
#define GRAPHIC_T1660335611_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Graphic
struct Graphic_t1660335611 : public UIBehaviour_t3495933518
{
public:
// UnityEngine.Material UnityEngine.UI.Graphic::m_Material
Material_t340375123 * ___m_Material_4;
// UnityEngine.Color UnityEngine.UI.Graphic::m_Color
Color_t2555686324 ___m_Color_5;
// System.Boolean UnityEngine.UI.Graphic::m_RaycastTarget
bool ___m_RaycastTarget_6;
// UnityEngine.RectTransform UnityEngine.UI.Graphic::m_RectTransform
RectTransform_t3704657025 * ___m_RectTransform_7;
// UnityEngine.CanvasRenderer UnityEngine.UI.Graphic::m_CanvasRenderer
CanvasRenderer_t2598313366 * ___m_CanvasRenderer_8;
// UnityEngine.Canvas UnityEngine.UI.Graphic::m_Canvas
Canvas_t3310196443 * ___m_Canvas_9;
// System.Boolean UnityEngine.UI.Graphic::m_VertsDirty
bool ___m_VertsDirty_10;
// System.Boolean UnityEngine.UI.Graphic::m_MaterialDirty
bool ___m_MaterialDirty_11;
// UnityEngine.Events.UnityAction UnityEngine.UI.Graphic::m_OnDirtyLayoutCallback
UnityAction_t3245792599 * ___m_OnDirtyLayoutCallback_12;
// UnityEngine.Events.UnityAction UnityEngine.UI.Graphic::m_OnDirtyVertsCallback
UnityAction_t3245792599 * ___m_OnDirtyVertsCallback_13;
// UnityEngine.Events.UnityAction UnityEngine.UI.Graphic::m_OnDirtyMaterialCallback
UnityAction_t3245792599 * ___m_OnDirtyMaterialCallback_14;
// UnityEngine.UI.CoroutineTween.TweenRunner`1<UnityEngine.UI.CoroutineTween.ColorTween> UnityEngine.UI.Graphic::m_ColorTweenRunner
TweenRunner_1_t3055525458 * ___m_ColorTweenRunner_17;
// System.Boolean UnityEngine.UI.Graphic::<useLegacyMeshGeneration>k__BackingField
bool ___U3CuseLegacyMeshGenerationU3Ek__BackingField_18;
public:
inline static int32_t get_offset_of_m_Material_4() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_Material_4)); }
inline Material_t340375123 * get_m_Material_4() const { return ___m_Material_4; }
inline Material_t340375123 ** get_address_of_m_Material_4() { return &___m_Material_4; }
inline void set_m_Material_4(Material_t340375123 * value)
{
___m_Material_4 = value;
Il2CppCodeGenWriteBarrier((&___m_Material_4), value);
}
inline static int32_t get_offset_of_m_Color_5() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_Color_5)); }
inline Color_t2555686324 get_m_Color_5() const { return ___m_Color_5; }
inline Color_t2555686324 * get_address_of_m_Color_5() { return &___m_Color_5; }
inline void set_m_Color_5(Color_t2555686324 value)
{
___m_Color_5 = value;
}
inline static int32_t get_offset_of_m_RaycastTarget_6() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_RaycastTarget_6)); }
inline bool get_m_RaycastTarget_6() const { return ___m_RaycastTarget_6; }
inline bool* get_address_of_m_RaycastTarget_6() { return &___m_RaycastTarget_6; }
inline void set_m_RaycastTarget_6(bool value)
{
___m_RaycastTarget_6 = value;
}
inline static int32_t get_offset_of_m_RectTransform_7() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_RectTransform_7)); }
inline RectTransform_t3704657025 * get_m_RectTransform_7() const { return ___m_RectTransform_7; }
inline RectTransform_t3704657025 ** get_address_of_m_RectTransform_7() { return &___m_RectTransform_7; }
inline void set_m_RectTransform_7(RectTransform_t3704657025 * value)
{
___m_RectTransform_7 = value;
Il2CppCodeGenWriteBarrier((&___m_RectTransform_7), value);
}
inline static int32_t get_offset_of_m_CanvasRenderer_8() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_CanvasRenderer_8)); }
inline CanvasRenderer_t2598313366 * get_m_CanvasRenderer_8() const { return ___m_CanvasRenderer_8; }
inline CanvasRenderer_t2598313366 ** get_address_of_m_CanvasRenderer_8() { return &___m_CanvasRenderer_8; }
inline void set_m_CanvasRenderer_8(CanvasRenderer_t2598313366 * value)
{
___m_CanvasRenderer_8 = value;
Il2CppCodeGenWriteBarrier((&___m_CanvasRenderer_8), value);
}
inline static int32_t get_offset_of_m_Canvas_9() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_Canvas_9)); }
inline Canvas_t3310196443 * get_m_Canvas_9() const { return ___m_Canvas_9; }
inline Canvas_t3310196443 ** get_address_of_m_Canvas_9() { return &___m_Canvas_9; }
inline void set_m_Canvas_9(Canvas_t3310196443 * value)
{
___m_Canvas_9 = value;
Il2CppCodeGenWriteBarrier((&___m_Canvas_9), value);
}
inline static int32_t get_offset_of_m_VertsDirty_10() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_VertsDirty_10)); }
inline bool get_m_VertsDirty_10() const { return ___m_VertsDirty_10; }
inline bool* get_address_of_m_VertsDirty_10() { return &___m_VertsDirty_10; }
inline void set_m_VertsDirty_10(bool value)
{
___m_VertsDirty_10 = value;
}
inline static int32_t get_offset_of_m_MaterialDirty_11() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_MaterialDirty_11)); }
inline bool get_m_MaterialDirty_11() const { return ___m_MaterialDirty_11; }
inline bool* get_address_of_m_MaterialDirty_11() { return &___m_MaterialDirty_11; }
inline void set_m_MaterialDirty_11(bool value)
{
___m_MaterialDirty_11 = value;
}
inline static int32_t get_offset_of_m_OnDirtyLayoutCallback_12() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_OnDirtyLayoutCallback_12)); }
inline UnityAction_t3245792599 * get_m_OnDirtyLayoutCallback_12() const { return ___m_OnDirtyLayoutCallback_12; }
inline UnityAction_t3245792599 ** get_address_of_m_OnDirtyLayoutCallback_12() { return &___m_OnDirtyLayoutCallback_12; }
inline void set_m_OnDirtyLayoutCallback_12(UnityAction_t3245792599 * value)
{
___m_OnDirtyLayoutCallback_12 = value;
Il2CppCodeGenWriteBarrier((&___m_OnDirtyLayoutCallback_12), value);
}
inline static int32_t get_offset_of_m_OnDirtyVertsCallback_13() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_OnDirtyVertsCallback_13)); }
inline UnityAction_t3245792599 * get_m_OnDirtyVertsCallback_13() const { return ___m_OnDirtyVertsCallback_13; }
inline UnityAction_t3245792599 ** get_address_of_m_OnDirtyVertsCallback_13() { return &___m_OnDirtyVertsCallback_13; }
inline void set_m_OnDirtyVertsCallback_13(UnityAction_t3245792599 * value)
{
___m_OnDirtyVertsCallback_13 = value;
Il2CppCodeGenWriteBarrier((&___m_OnDirtyVertsCallback_13), value);
}
inline static int32_t get_offset_of_m_OnDirtyMaterialCallback_14() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_OnDirtyMaterialCallback_14)); }
inline UnityAction_t3245792599 * get_m_OnDirtyMaterialCallback_14() const { return ___m_OnDirtyMaterialCallback_14; }
inline UnityAction_t3245792599 ** get_address_of_m_OnDirtyMaterialCallback_14() { return &___m_OnDirtyMaterialCallback_14; }
inline void set_m_OnDirtyMaterialCallback_14(UnityAction_t3245792599 * value)
{
___m_OnDirtyMaterialCallback_14 = value;
Il2CppCodeGenWriteBarrier((&___m_OnDirtyMaterialCallback_14), value);
}
inline static int32_t get_offset_of_m_ColorTweenRunner_17() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___m_ColorTweenRunner_17)); }
inline TweenRunner_1_t3055525458 * get_m_ColorTweenRunner_17() const { return ___m_ColorTweenRunner_17; }
inline TweenRunner_1_t3055525458 ** get_address_of_m_ColorTweenRunner_17() { return &___m_ColorTweenRunner_17; }
inline void set_m_ColorTweenRunner_17(TweenRunner_1_t3055525458 * value)
{
___m_ColorTweenRunner_17 = value;
Il2CppCodeGenWriteBarrier((&___m_ColorTweenRunner_17), value);
}
inline static int32_t get_offset_of_U3CuseLegacyMeshGenerationU3Ek__BackingField_18() { return static_cast<int32_t>(offsetof(Graphic_t1660335611, ___U3CuseLegacyMeshGenerationU3Ek__BackingField_18)); }
inline bool get_U3CuseLegacyMeshGenerationU3Ek__BackingField_18() const { return ___U3CuseLegacyMeshGenerationU3Ek__BackingField_18; }
inline bool* get_address_of_U3CuseLegacyMeshGenerationU3Ek__BackingField_18() { return &___U3CuseLegacyMeshGenerationU3Ek__BackingField_18; }
inline void set_U3CuseLegacyMeshGenerationU3Ek__BackingField_18(bool value)
{
___U3CuseLegacyMeshGenerationU3Ek__BackingField_18 = value;
}
};
struct Graphic_t1660335611_StaticFields
{
public:
// UnityEngine.Material UnityEngine.UI.Graphic::s_DefaultUI
Material_t340375123 * ___s_DefaultUI_2;
// UnityEngine.Texture2D UnityEngine.UI.Graphic::s_WhiteTexture
Texture2D_t3840446185 * ___s_WhiteTexture_3;
// UnityEngine.Mesh UnityEngine.UI.Graphic::s_Mesh
Mesh_t3648964284 * ___s_Mesh_15;
// UnityEngine.UI.VertexHelper UnityEngine.UI.Graphic::s_VertexHelper
VertexHelper_t2453304189 * ___s_VertexHelper_16;
public:
inline static int32_t get_offset_of_s_DefaultUI_2() { return static_cast<int32_t>(offsetof(Graphic_t1660335611_StaticFields, ___s_DefaultUI_2)); }
inline Material_t340375123 * get_s_DefaultUI_2() const { return ___s_DefaultUI_2; }
inline Material_t340375123 ** get_address_of_s_DefaultUI_2() { return &___s_DefaultUI_2; }
inline void set_s_DefaultUI_2(Material_t340375123 * value)
{
___s_DefaultUI_2 = value;
Il2CppCodeGenWriteBarrier((&___s_DefaultUI_2), value);
}
inline static int32_t get_offset_of_s_WhiteTexture_3() { return static_cast<int32_t>(offsetof(Graphic_t1660335611_StaticFields, ___s_WhiteTexture_3)); }
inline Texture2D_t3840446185 * get_s_WhiteTexture_3() const { return ___s_WhiteTexture_3; }
inline Texture2D_t3840446185 ** get_address_of_s_WhiteTexture_3() { return &___s_WhiteTexture_3; }
inline void set_s_WhiteTexture_3(Texture2D_t3840446185 * value)
{
___s_WhiteTexture_3 = value;
Il2CppCodeGenWriteBarrier((&___s_WhiteTexture_3), value);
}
inline static int32_t get_offset_of_s_Mesh_15() { return static_cast<int32_t>(offsetof(Graphic_t1660335611_StaticFields, ___s_Mesh_15)); }
inline Mesh_t3648964284 * get_s_Mesh_15() const { return ___s_Mesh_15; }
inline Mesh_t3648964284 ** get_address_of_s_Mesh_15() { return &___s_Mesh_15; }
inline void set_s_Mesh_15(Mesh_t3648964284 * value)
{
___s_Mesh_15 = value;
Il2CppCodeGenWriteBarrier((&___s_Mesh_15), value);
}
inline static int32_t get_offset_of_s_VertexHelper_16() { return static_cast<int32_t>(offsetof(Graphic_t1660335611_StaticFields, ___s_VertexHelper_16)); }
inline VertexHelper_t2453304189 * get_s_VertexHelper_16() const { return ___s_VertexHelper_16; }
inline VertexHelper_t2453304189 ** get_address_of_s_VertexHelper_16() { return &___s_VertexHelper_16; }
inline void set_s_VertexHelper_16(VertexHelper_t2453304189 * value)
{
___s_VertexHelper_16 = value;
Il2CppCodeGenWriteBarrier((&___s_VertexHelper_16), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // GRAPHIC_T1660335611_H
#ifndef CONTENTSIZEFITTER_T3850442145_H
#define CONTENTSIZEFITTER_T3850442145_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.ContentSizeFitter
struct ContentSizeFitter_t3850442145 : public UIBehaviour_t3495933518
{
public:
// UnityEngine.UI.ContentSizeFitter/FitMode UnityEngine.UI.ContentSizeFitter::m_HorizontalFit
int32_t ___m_HorizontalFit_2;
// UnityEngine.UI.ContentSizeFitter/FitMode UnityEngine.UI.ContentSizeFitter::m_VerticalFit
int32_t ___m_VerticalFit_3;
// UnityEngine.RectTransform UnityEngine.UI.ContentSizeFitter::m_Rect
RectTransform_t3704657025 * ___m_Rect_4;
// UnityEngine.DrivenRectTransformTracker UnityEngine.UI.ContentSizeFitter::m_Tracker
DrivenRectTransformTracker_t2562230146 ___m_Tracker_5;
public:
inline static int32_t get_offset_of_m_HorizontalFit_2() { return static_cast<int32_t>(offsetof(ContentSizeFitter_t3850442145, ___m_HorizontalFit_2)); }
inline int32_t get_m_HorizontalFit_2() const { return ___m_HorizontalFit_2; }
inline int32_t* get_address_of_m_HorizontalFit_2() { return &___m_HorizontalFit_2; }
inline void set_m_HorizontalFit_2(int32_t value)
{
___m_HorizontalFit_2 = value;
}
inline static int32_t get_offset_of_m_VerticalFit_3() { return static_cast<int32_t>(offsetof(ContentSizeFitter_t3850442145, ___m_VerticalFit_3)); }
inline int32_t get_m_VerticalFit_3() const { return ___m_VerticalFit_3; }
inline int32_t* get_address_of_m_VerticalFit_3() { return &___m_VerticalFit_3; }
inline void set_m_VerticalFit_3(int32_t value)
{
___m_VerticalFit_3 = value;
}
inline static int32_t get_offset_of_m_Rect_4() { return static_cast<int32_t>(offsetof(ContentSizeFitter_t3850442145, ___m_Rect_4)); }
inline RectTransform_t3704657025 * get_m_Rect_4() const { return ___m_Rect_4; }
inline RectTransform_t3704657025 ** get_address_of_m_Rect_4() { return &___m_Rect_4; }
inline void set_m_Rect_4(RectTransform_t3704657025 * value)
{
___m_Rect_4 = value;
Il2CppCodeGenWriteBarrier((&___m_Rect_4), value);
}
inline static int32_t get_offset_of_m_Tracker_5() { return static_cast<int32_t>(offsetof(ContentSizeFitter_t3850442145, ___m_Tracker_5)); }
inline DrivenRectTransformTracker_t2562230146 get_m_Tracker_5() const { return ___m_Tracker_5; }
inline DrivenRectTransformTracker_t2562230146 * get_address_of_m_Tracker_5() { return &___m_Tracker_5; }
inline void set_m_Tracker_5(DrivenRectTransformTracker_t2562230146 value)
{
___m_Tracker_5 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CONTENTSIZEFITTER_T3850442145_H
#ifndef CANVASSCALER_T2767979955_H
#define CANVASSCALER_T2767979955_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.CanvasScaler
struct CanvasScaler_t2767979955 : public UIBehaviour_t3495933518
{
public:
// UnityEngine.UI.CanvasScaler/ScaleMode UnityEngine.UI.CanvasScaler::m_UiScaleMode
int32_t ___m_UiScaleMode_2;
// System.Single UnityEngine.UI.CanvasScaler::m_ReferencePixelsPerUnit
float ___m_ReferencePixelsPerUnit_3;
// System.Single UnityEngine.UI.CanvasScaler::m_ScaleFactor
float ___m_ScaleFactor_4;
// UnityEngine.Vector2 UnityEngine.UI.CanvasScaler::m_ReferenceResolution
Vector2_t2156229523 ___m_ReferenceResolution_5;
// UnityEngine.UI.CanvasScaler/ScreenMatchMode UnityEngine.UI.CanvasScaler::m_ScreenMatchMode
int32_t ___m_ScreenMatchMode_6;
// System.Single UnityEngine.UI.CanvasScaler::m_MatchWidthOrHeight
float ___m_MatchWidthOrHeight_7;
// UnityEngine.UI.CanvasScaler/Unit UnityEngine.UI.CanvasScaler::m_PhysicalUnit
int32_t ___m_PhysicalUnit_9;
// System.Single UnityEngine.UI.CanvasScaler::m_FallbackScreenDPI
float ___m_FallbackScreenDPI_10;
// System.Single UnityEngine.UI.CanvasScaler::m_DefaultSpriteDPI
float ___m_DefaultSpriteDPI_11;
// System.Single UnityEngine.UI.CanvasScaler::m_DynamicPixelsPerUnit
float ___m_DynamicPixelsPerUnit_12;
// UnityEngine.Canvas UnityEngine.UI.CanvasScaler::m_Canvas
Canvas_t3310196443 * ___m_Canvas_13;
// System.Single UnityEngine.UI.CanvasScaler::m_PrevScaleFactor
float ___m_PrevScaleFactor_14;
// System.Single UnityEngine.UI.CanvasScaler::m_PrevReferencePixelsPerUnit
float ___m_PrevReferencePixelsPerUnit_15;
public:
inline static int32_t get_offset_of_m_UiScaleMode_2() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_UiScaleMode_2)); }
inline int32_t get_m_UiScaleMode_2() const { return ___m_UiScaleMode_2; }
inline int32_t* get_address_of_m_UiScaleMode_2() { return &___m_UiScaleMode_2; }
inline void set_m_UiScaleMode_2(int32_t value)
{
___m_UiScaleMode_2 = value;
}
inline static int32_t get_offset_of_m_ReferencePixelsPerUnit_3() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_ReferencePixelsPerUnit_3)); }
inline float get_m_ReferencePixelsPerUnit_3() const { return ___m_ReferencePixelsPerUnit_3; }
inline float* get_address_of_m_ReferencePixelsPerUnit_3() { return &___m_ReferencePixelsPerUnit_3; }
inline void set_m_ReferencePixelsPerUnit_3(float value)
{
___m_ReferencePixelsPerUnit_3 = value;
}
inline static int32_t get_offset_of_m_ScaleFactor_4() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_ScaleFactor_4)); }
inline float get_m_ScaleFactor_4() const { return ___m_ScaleFactor_4; }
inline float* get_address_of_m_ScaleFactor_4() { return &___m_ScaleFactor_4; }
inline void set_m_ScaleFactor_4(float value)
{
___m_ScaleFactor_4 = value;
}
inline static int32_t get_offset_of_m_ReferenceResolution_5() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_ReferenceResolution_5)); }
inline Vector2_t2156229523 get_m_ReferenceResolution_5() const { return ___m_ReferenceResolution_5; }
inline Vector2_t2156229523 * get_address_of_m_ReferenceResolution_5() { return &___m_ReferenceResolution_5; }
inline void set_m_ReferenceResolution_5(Vector2_t2156229523 value)
{
___m_ReferenceResolution_5 = value;
}
inline static int32_t get_offset_of_m_ScreenMatchMode_6() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_ScreenMatchMode_6)); }
inline int32_t get_m_ScreenMatchMode_6() const { return ___m_ScreenMatchMode_6; }
inline int32_t* get_address_of_m_ScreenMatchMode_6() { return &___m_ScreenMatchMode_6; }
inline void set_m_ScreenMatchMode_6(int32_t value)
{
___m_ScreenMatchMode_6 = value;
}
inline static int32_t get_offset_of_m_MatchWidthOrHeight_7() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_MatchWidthOrHeight_7)); }
inline float get_m_MatchWidthOrHeight_7() const { return ___m_MatchWidthOrHeight_7; }
inline float* get_address_of_m_MatchWidthOrHeight_7() { return &___m_MatchWidthOrHeight_7; }
inline void set_m_MatchWidthOrHeight_7(float value)
{
___m_MatchWidthOrHeight_7 = value;
}
inline static int32_t get_offset_of_m_PhysicalUnit_9() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_PhysicalUnit_9)); }
inline int32_t get_m_PhysicalUnit_9() const { return ___m_PhysicalUnit_9; }
inline int32_t* get_address_of_m_PhysicalUnit_9() { return &___m_PhysicalUnit_9; }
inline void set_m_PhysicalUnit_9(int32_t value)
{
___m_PhysicalUnit_9 = value;
}
inline static int32_t get_offset_of_m_FallbackScreenDPI_10() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_FallbackScreenDPI_10)); }
inline float get_m_FallbackScreenDPI_10() const { return ___m_FallbackScreenDPI_10; }
inline float* get_address_of_m_FallbackScreenDPI_10() { return &___m_FallbackScreenDPI_10; }
inline void set_m_FallbackScreenDPI_10(float value)
{
___m_FallbackScreenDPI_10 = value;
}
inline static int32_t get_offset_of_m_DefaultSpriteDPI_11() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_DefaultSpriteDPI_11)); }
inline float get_m_DefaultSpriteDPI_11() const { return ___m_DefaultSpriteDPI_11; }
inline float* get_address_of_m_DefaultSpriteDPI_11() { return &___m_DefaultSpriteDPI_11; }
inline void set_m_DefaultSpriteDPI_11(float value)
{
___m_DefaultSpriteDPI_11 = value;
}
inline static int32_t get_offset_of_m_DynamicPixelsPerUnit_12() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_DynamicPixelsPerUnit_12)); }
inline float get_m_DynamicPixelsPerUnit_12() const { return ___m_DynamicPixelsPerUnit_12; }
inline float* get_address_of_m_DynamicPixelsPerUnit_12() { return &___m_DynamicPixelsPerUnit_12; }
inline void set_m_DynamicPixelsPerUnit_12(float value)
{
___m_DynamicPixelsPerUnit_12 = value;
}
inline static int32_t get_offset_of_m_Canvas_13() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_Canvas_13)); }
inline Canvas_t3310196443 * get_m_Canvas_13() const { return ___m_Canvas_13; }
inline Canvas_t3310196443 ** get_address_of_m_Canvas_13() { return &___m_Canvas_13; }
inline void set_m_Canvas_13(Canvas_t3310196443 * value)
{
___m_Canvas_13 = value;
Il2CppCodeGenWriteBarrier((&___m_Canvas_13), value);
}
inline static int32_t get_offset_of_m_PrevScaleFactor_14() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_PrevScaleFactor_14)); }
inline float get_m_PrevScaleFactor_14() const { return ___m_PrevScaleFactor_14; }
inline float* get_address_of_m_PrevScaleFactor_14() { return &___m_PrevScaleFactor_14; }
inline void set_m_PrevScaleFactor_14(float value)
{
___m_PrevScaleFactor_14 = value;
}
inline static int32_t get_offset_of_m_PrevReferencePixelsPerUnit_15() { return static_cast<int32_t>(offsetof(CanvasScaler_t2767979955, ___m_PrevReferencePixelsPerUnit_15)); }
inline float get_m_PrevReferencePixelsPerUnit_15() const { return ___m_PrevReferencePixelsPerUnit_15; }
inline float* get_address_of_m_PrevReferencePixelsPerUnit_15() { return &___m_PrevReferencePixelsPerUnit_15; }
inline void set_m_PrevReferencePixelsPerUnit_15(float value)
{
___m_PrevReferencePixelsPerUnit_15 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CANVASSCALER_T2767979955_H
#ifndef RECTMASK2D_T3474889437_H
#define RECTMASK2D_T3474889437_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.RectMask2D
struct RectMask2D_t3474889437 : public UIBehaviour_t3495933518
{
public:
// UnityEngine.UI.RectangularVertexClipper UnityEngine.UI.RectMask2D::m_VertexClipper
RectangularVertexClipper_t626611136 * ___m_VertexClipper_2;
// UnityEngine.RectTransform UnityEngine.UI.RectMask2D::m_RectTransform
RectTransform_t3704657025 * ___m_RectTransform_3;
// System.Collections.Generic.HashSet`1<UnityEngine.UI.IClippable> UnityEngine.UI.RectMask2D::m_ClipTargets
HashSet_1_t4099546121 * ___m_ClipTargets_4;
// System.Boolean UnityEngine.UI.RectMask2D::m_ShouldRecalculateClipRects
bool ___m_ShouldRecalculateClipRects_5;
// System.Collections.Generic.List`1<UnityEngine.UI.RectMask2D> UnityEngine.UI.RectMask2D::m_Clippers
List_1_t651996883 * ___m_Clippers_6;
// UnityEngine.Rect UnityEngine.UI.RectMask2D::m_LastClipRectCanvasSpace
Rect_t2360479859 ___m_LastClipRectCanvasSpace_7;
// System.Boolean UnityEngine.UI.RectMask2D::m_ForceClip
bool ___m_ForceClip_8;
// UnityEngine.Canvas UnityEngine.UI.RectMask2D::m_Canvas
Canvas_t3310196443 * ___m_Canvas_9;
// UnityEngine.Vector3[] UnityEngine.UI.RectMask2D::m_Corners
Vector3U5BU5D_t1718750761* ___m_Corners_10;
public:
inline static int32_t get_offset_of_m_VertexClipper_2() { return static_cast<int32_t>(offsetof(RectMask2D_t3474889437, ___m_VertexClipper_2)); }
inline RectangularVertexClipper_t626611136 * get_m_VertexClipper_2() const { return ___m_VertexClipper_2; }
inline RectangularVertexClipper_t626611136 ** get_address_of_m_VertexClipper_2() { return &___m_VertexClipper_2; }
inline void set_m_VertexClipper_2(RectangularVertexClipper_t626611136 * value)
{
___m_VertexClipper_2 = value;
Il2CppCodeGenWriteBarrier((&___m_VertexClipper_2), value);
}
inline static int32_t get_offset_of_m_RectTransform_3() { return static_cast<int32_t>(offsetof(RectMask2D_t3474889437, ___m_RectTransform_3)); }
inline RectTransform_t3704657025 * get_m_RectTransform_3() const { return ___m_RectTransform_3; }
inline RectTransform_t3704657025 ** get_address_of_m_RectTransform_3() { return &___m_RectTransform_3; }
inline void set_m_RectTransform_3(RectTransform_t3704657025 * value)
{
___m_RectTransform_3 = value;
Il2CppCodeGenWriteBarrier((&___m_RectTransform_3), value);
}
inline static int32_t get_offset_of_m_ClipTargets_4() { return static_cast<int32_t>(offsetof(RectMask2D_t3474889437, ___m_ClipTargets_4)); }
inline HashSet_1_t4099546121 * get_m_ClipTargets_4() const { return ___m_ClipTargets_4; }
inline HashSet_1_t4099546121 ** get_address_of_m_ClipTargets_4() { return &___m_ClipTargets_4; }
inline void set_m_ClipTargets_4(HashSet_1_t4099546121 * value)
{
___m_ClipTargets_4 = value;
Il2CppCodeGenWriteBarrier((&___m_ClipTargets_4), value);
}
inline static int32_t get_offset_of_m_ShouldRecalculateClipRects_5() { return static_cast<int32_t>(offsetof(RectMask2D_t3474889437, ___m_ShouldRecalculateClipRects_5)); }
inline bool get_m_ShouldRecalculateClipRects_5() const { return ___m_ShouldRecalculateClipRects_5; }
inline bool* get_address_of_m_ShouldRecalculateClipRects_5() { return &___m_ShouldRecalculateClipRects_5; }
inline void set_m_ShouldRecalculateClipRects_5(bool value)
{
___m_ShouldRecalculateClipRects_5 = value;
}
inline static int32_t get_offset_of_m_Clippers_6() { return static_cast<int32_t>(offsetof(RectMask2D_t3474889437, ___m_Clippers_6)); }
inline List_1_t651996883 * get_m_Clippers_6() const { return ___m_Clippers_6; }
inline List_1_t651996883 ** get_address_of_m_Clippers_6() { return &___m_Clippers_6; }
inline void set_m_Clippers_6(List_1_t651996883 * value)
{
___m_Clippers_6 = value;
Il2CppCodeGenWriteBarrier((&___m_Clippers_6), value);
}
inline static int32_t get_offset_of_m_LastClipRectCanvasSpace_7() { return static_cast<int32_t>(offsetof(RectMask2D_t3474889437, ___m_LastClipRectCanvasSpace_7)); }
inline Rect_t2360479859 get_m_LastClipRectCanvasSpace_7() const { return ___m_LastClipRectCanvasSpace_7; }
inline Rect_t2360479859 * get_address_of_m_LastClipRectCanvasSpace_7() { return &___m_LastClipRectCanvasSpace_7; }
inline void set_m_LastClipRectCanvasSpace_7(Rect_t2360479859 value)
{
___m_LastClipRectCanvasSpace_7 = value;
}
inline static int32_t get_offset_of_m_ForceClip_8() { return static_cast<int32_t>(offsetof(RectMask2D_t3474889437, ___m_ForceClip_8)); }
inline bool get_m_ForceClip_8() const { return ___m_ForceClip_8; }
inline bool* get_address_of_m_ForceClip_8() { return &___m_ForceClip_8; }
inline void set_m_ForceClip_8(bool value)
{
___m_ForceClip_8 = value;
}
inline static int32_t get_offset_of_m_Canvas_9() { return static_cast<int32_t>(offsetof(RectMask2D_t3474889437, ___m_Canvas_9)); }
inline Canvas_t3310196443 * get_m_Canvas_9() const { return ___m_Canvas_9; }
inline Canvas_t3310196443 ** get_address_of_m_Canvas_9() { return &___m_Canvas_9; }
inline void set_m_Canvas_9(Canvas_t3310196443 * value)
{
___m_Canvas_9 = value;
Il2CppCodeGenWriteBarrier((&___m_Canvas_9), value);
}
inline static int32_t get_offset_of_m_Corners_10() { return static_cast<int32_t>(offsetof(RectMask2D_t3474889437, ___m_Corners_10)); }
inline Vector3U5BU5D_t1718750761* get_m_Corners_10() const { return ___m_Corners_10; }
inline Vector3U5BU5D_t1718750761** get_address_of_m_Corners_10() { return &___m_Corners_10; }
inline void set_m_Corners_10(Vector3U5BU5D_t1718750761* value)
{
___m_Corners_10 = value;
Il2CppCodeGenWriteBarrier((&___m_Corners_10), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RECTMASK2D_T3474889437_H
#ifndef ASPECTRATIOFITTER_T3312407083_H
#define ASPECTRATIOFITTER_T3312407083_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.AspectRatioFitter
struct AspectRatioFitter_t3312407083 : public UIBehaviour_t3495933518
{
public:
// UnityEngine.UI.AspectRatioFitter/AspectMode UnityEngine.UI.AspectRatioFitter::m_AspectMode
int32_t ___m_AspectMode_2;
// System.Single UnityEngine.UI.AspectRatioFitter::m_AspectRatio
float ___m_AspectRatio_3;
// UnityEngine.RectTransform UnityEngine.UI.AspectRatioFitter::m_Rect
RectTransform_t3704657025 * ___m_Rect_4;
// System.Boolean UnityEngine.UI.AspectRatioFitter::m_DelayedSetDirty
bool ___m_DelayedSetDirty_5;
// UnityEngine.DrivenRectTransformTracker UnityEngine.UI.AspectRatioFitter::m_Tracker
DrivenRectTransformTracker_t2562230146 ___m_Tracker_6;
public:
inline static int32_t get_offset_of_m_AspectMode_2() { return static_cast<int32_t>(offsetof(AspectRatioFitter_t3312407083, ___m_AspectMode_2)); }
inline int32_t get_m_AspectMode_2() const { return ___m_AspectMode_2; }
inline int32_t* get_address_of_m_AspectMode_2() { return &___m_AspectMode_2; }
inline void set_m_AspectMode_2(int32_t value)
{
___m_AspectMode_2 = value;
}
inline static int32_t get_offset_of_m_AspectRatio_3() { return static_cast<int32_t>(offsetof(AspectRatioFitter_t3312407083, ___m_AspectRatio_3)); }
inline float get_m_AspectRatio_3() const { return ___m_AspectRatio_3; }
inline float* get_address_of_m_AspectRatio_3() { return &___m_AspectRatio_3; }
inline void set_m_AspectRatio_3(float value)
{
___m_AspectRatio_3 = value;
}
inline static int32_t get_offset_of_m_Rect_4() { return static_cast<int32_t>(offsetof(AspectRatioFitter_t3312407083, ___m_Rect_4)); }
inline RectTransform_t3704657025 * get_m_Rect_4() const { return ___m_Rect_4; }
inline RectTransform_t3704657025 ** get_address_of_m_Rect_4() { return &___m_Rect_4; }
inline void set_m_Rect_4(RectTransform_t3704657025 * value)
{
___m_Rect_4 = value;
Il2CppCodeGenWriteBarrier((&___m_Rect_4), value);
}
inline static int32_t get_offset_of_m_DelayedSetDirty_5() { return static_cast<int32_t>(offsetof(AspectRatioFitter_t3312407083, ___m_DelayedSetDirty_5)); }
inline bool get_m_DelayedSetDirty_5() const { return ___m_DelayedSetDirty_5; }
inline bool* get_address_of_m_DelayedSetDirty_5() { return &___m_DelayedSetDirty_5; }
inline void set_m_DelayedSetDirty_5(bool value)
{
___m_DelayedSetDirty_5 = value;
}
inline static int32_t get_offset_of_m_Tracker_6() { return static_cast<int32_t>(offsetof(AspectRatioFitter_t3312407083, ___m_Tracker_6)); }
inline DrivenRectTransformTracker_t2562230146 get_m_Tracker_6() const { return ___m_Tracker_6; }
inline DrivenRectTransformTracker_t2562230146 * get_address_of_m_Tracker_6() { return &___m_Tracker_6; }
inline void set_m_Tracker_6(DrivenRectTransformTracker_t2562230146 value)
{
___m_Tracker_6 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ASPECTRATIOFITTER_T3312407083_H
#ifndef MASK_T1803652131_H
#define MASK_T1803652131_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Mask
struct Mask_t1803652131 : public UIBehaviour_t3495933518
{
public:
// UnityEngine.RectTransform UnityEngine.UI.Mask::m_RectTransform
RectTransform_t3704657025 * ___m_RectTransform_2;
// System.Boolean UnityEngine.UI.Mask::m_ShowMaskGraphic
bool ___m_ShowMaskGraphic_3;
// UnityEngine.UI.Graphic UnityEngine.UI.Mask::m_Graphic
Graphic_t1660335611 * ___m_Graphic_4;
// UnityEngine.Material UnityEngine.UI.Mask::m_MaskMaterial
Material_t340375123 * ___m_MaskMaterial_5;
// UnityEngine.Material UnityEngine.UI.Mask::m_UnmaskMaterial
Material_t340375123 * ___m_UnmaskMaterial_6;
public:
inline static int32_t get_offset_of_m_RectTransform_2() { return static_cast<int32_t>(offsetof(Mask_t1803652131, ___m_RectTransform_2)); }
inline RectTransform_t3704657025 * get_m_RectTransform_2() const { return ___m_RectTransform_2; }
inline RectTransform_t3704657025 ** get_address_of_m_RectTransform_2() { return &___m_RectTransform_2; }
inline void set_m_RectTransform_2(RectTransform_t3704657025 * value)
{
___m_RectTransform_2 = value;
Il2CppCodeGenWriteBarrier((&___m_RectTransform_2), value);
}
inline static int32_t get_offset_of_m_ShowMaskGraphic_3() { return static_cast<int32_t>(offsetof(Mask_t1803652131, ___m_ShowMaskGraphic_3)); }
inline bool get_m_ShowMaskGraphic_3() const { return ___m_ShowMaskGraphic_3; }
inline bool* get_address_of_m_ShowMaskGraphic_3() { return &___m_ShowMaskGraphic_3; }
inline void set_m_ShowMaskGraphic_3(bool value)
{
___m_ShowMaskGraphic_3 = value;
}
inline static int32_t get_offset_of_m_Graphic_4() { return static_cast<int32_t>(offsetof(Mask_t1803652131, ___m_Graphic_4)); }
inline Graphic_t1660335611 * get_m_Graphic_4() const { return ___m_Graphic_4; }
inline Graphic_t1660335611 ** get_address_of_m_Graphic_4() { return &___m_Graphic_4; }
inline void set_m_Graphic_4(Graphic_t1660335611 * value)
{
___m_Graphic_4 = value;
Il2CppCodeGenWriteBarrier((&___m_Graphic_4), value);
}
inline static int32_t get_offset_of_m_MaskMaterial_5() { return static_cast<int32_t>(offsetof(Mask_t1803652131, ___m_MaskMaterial_5)); }
inline Material_t340375123 * get_m_MaskMaterial_5() const { return ___m_MaskMaterial_5; }
inline Material_t340375123 ** get_address_of_m_MaskMaterial_5() { return &___m_MaskMaterial_5; }
inline void set_m_MaskMaterial_5(Material_t340375123 * value)
{
___m_MaskMaterial_5 = value;
Il2CppCodeGenWriteBarrier((&___m_MaskMaterial_5), value);
}
inline static int32_t get_offset_of_m_UnmaskMaterial_6() { return static_cast<int32_t>(offsetof(Mask_t1803652131, ___m_UnmaskMaterial_6)); }
inline Material_t340375123 * get_m_UnmaskMaterial_6() const { return ___m_UnmaskMaterial_6; }
inline Material_t340375123 ** get_address_of_m_UnmaskMaterial_6() { return &___m_UnmaskMaterial_6; }
inline void set_m_UnmaskMaterial_6(Material_t340375123 * value)
{
___m_UnmaskMaterial_6 = value;
Il2CppCodeGenWriteBarrier((&___m_UnmaskMaterial_6), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MASK_T1803652131_H
#ifndef BASERAYCASTER_T4150874583_H
#define BASERAYCASTER_T4150874583_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.EventSystems.BaseRaycaster
struct BaseRaycaster_t4150874583 : public UIBehaviour_t3495933518
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // BASERAYCASTER_T4150874583_H
#ifndef SCROLLRECT_T4137855814_H
#define SCROLLRECT_T4137855814_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.ScrollRect
struct ScrollRect_t4137855814 : public UIBehaviour_t3495933518
{
public:
// UnityEngine.RectTransform UnityEngine.UI.ScrollRect::m_Content
RectTransform_t3704657025 * ___m_Content_2;
// System.Boolean UnityEngine.UI.ScrollRect::m_Horizontal
bool ___m_Horizontal_3;
// System.Boolean UnityEngine.UI.ScrollRect::m_Vertical
bool ___m_Vertical_4;
// UnityEngine.UI.ScrollRect/MovementType UnityEngine.UI.ScrollRect::m_MovementType
int32_t ___m_MovementType_5;
// System.Single UnityEngine.UI.ScrollRect::m_Elasticity
float ___m_Elasticity_6;
// System.Boolean UnityEngine.UI.ScrollRect::m_Inertia
bool ___m_Inertia_7;
// System.Single UnityEngine.UI.ScrollRect::m_DecelerationRate
float ___m_DecelerationRate_8;
// System.Single UnityEngine.UI.ScrollRect::m_ScrollSensitivity
float ___m_ScrollSensitivity_9;
// UnityEngine.RectTransform UnityEngine.UI.ScrollRect::m_Viewport
RectTransform_t3704657025 * ___m_Viewport_10;
// UnityEngine.UI.Scrollbar UnityEngine.UI.ScrollRect::m_HorizontalScrollbar
Scrollbar_t1494447233 * ___m_HorizontalScrollbar_11;
// UnityEngine.UI.Scrollbar UnityEngine.UI.ScrollRect::m_VerticalScrollbar
Scrollbar_t1494447233 * ___m_VerticalScrollbar_12;
// UnityEngine.UI.ScrollRect/ScrollbarVisibility UnityEngine.UI.ScrollRect::m_HorizontalScrollbarVisibility
int32_t ___m_HorizontalScrollbarVisibility_13;
// UnityEngine.UI.ScrollRect/ScrollbarVisibility UnityEngine.UI.ScrollRect::m_VerticalScrollbarVisibility
int32_t ___m_VerticalScrollbarVisibility_14;
// System.Single UnityEngine.UI.ScrollRect::m_HorizontalScrollbarSpacing
float ___m_HorizontalScrollbarSpacing_15;
// System.Single UnityEngine.UI.ScrollRect::m_VerticalScrollbarSpacing
float ___m_VerticalScrollbarSpacing_16;
// UnityEngine.UI.ScrollRect/ScrollRectEvent UnityEngine.UI.ScrollRect::m_OnValueChanged
ScrollRectEvent_t343079324 * ___m_OnValueChanged_17;
// UnityEngine.Vector2 UnityEngine.UI.ScrollRect::m_PointerStartLocalCursor
Vector2_t2156229523 ___m_PointerStartLocalCursor_18;
// UnityEngine.Vector2 UnityEngine.UI.ScrollRect::m_ContentStartPosition
Vector2_t2156229523 ___m_ContentStartPosition_19;
// UnityEngine.RectTransform UnityEngine.UI.ScrollRect::m_ViewRect
RectTransform_t3704657025 * ___m_ViewRect_20;
// UnityEngine.Bounds UnityEngine.UI.ScrollRect::m_ContentBounds
Bounds_t2266837910 ___m_ContentBounds_21;
// UnityEngine.Bounds UnityEngine.UI.ScrollRect::m_ViewBounds
Bounds_t2266837910 ___m_ViewBounds_22;
// UnityEngine.Vector2 UnityEngine.UI.ScrollRect::m_Velocity
Vector2_t2156229523 ___m_Velocity_23;
// System.Boolean UnityEngine.UI.ScrollRect::m_Dragging
bool ___m_Dragging_24;
// UnityEngine.Vector2 UnityEngine.UI.ScrollRect::m_PrevPosition
Vector2_t2156229523 ___m_PrevPosition_25;
// UnityEngine.Bounds UnityEngine.UI.ScrollRect::m_PrevContentBounds
Bounds_t2266837910 ___m_PrevContentBounds_26;
// UnityEngine.Bounds UnityEngine.UI.ScrollRect::m_PrevViewBounds
Bounds_t2266837910 ___m_PrevViewBounds_27;
// System.Boolean UnityEngine.UI.ScrollRect::m_HasRebuiltLayout
bool ___m_HasRebuiltLayout_28;
// System.Boolean UnityEngine.UI.ScrollRect::m_HSliderExpand
bool ___m_HSliderExpand_29;
// System.Boolean UnityEngine.UI.ScrollRect::m_VSliderExpand
bool ___m_VSliderExpand_30;
// System.Single UnityEngine.UI.ScrollRect::m_HSliderHeight
float ___m_HSliderHeight_31;
// System.Single UnityEngine.UI.ScrollRect::m_VSliderWidth
float ___m_VSliderWidth_32;
// UnityEngine.RectTransform UnityEngine.UI.ScrollRect::m_Rect
RectTransform_t3704657025 * ___m_Rect_33;
// UnityEngine.RectTransform UnityEngine.UI.ScrollRect::m_HorizontalScrollbarRect
RectTransform_t3704657025 * ___m_HorizontalScrollbarRect_34;
// UnityEngine.RectTransform UnityEngine.UI.ScrollRect::m_VerticalScrollbarRect
RectTransform_t3704657025 * ___m_VerticalScrollbarRect_35;
// UnityEngine.DrivenRectTransformTracker UnityEngine.UI.ScrollRect::m_Tracker
DrivenRectTransformTracker_t2562230146 ___m_Tracker_36;
// UnityEngine.Vector3[] UnityEngine.UI.ScrollRect::m_Corners
Vector3U5BU5D_t1718750761* ___m_Corners_37;
public:
inline static int32_t get_offset_of_m_Content_2() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Content_2)); }
inline RectTransform_t3704657025 * get_m_Content_2() const { return ___m_Content_2; }
inline RectTransform_t3704657025 ** get_address_of_m_Content_2() { return &___m_Content_2; }
inline void set_m_Content_2(RectTransform_t3704657025 * value)
{
___m_Content_2 = value;
Il2CppCodeGenWriteBarrier((&___m_Content_2), value);
}
inline static int32_t get_offset_of_m_Horizontal_3() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Horizontal_3)); }
inline bool get_m_Horizontal_3() const { return ___m_Horizontal_3; }
inline bool* get_address_of_m_Horizontal_3() { return &___m_Horizontal_3; }
inline void set_m_Horizontal_3(bool value)
{
___m_Horizontal_3 = value;
}
inline static int32_t get_offset_of_m_Vertical_4() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Vertical_4)); }
inline bool get_m_Vertical_4() const { return ___m_Vertical_4; }
inline bool* get_address_of_m_Vertical_4() { return &___m_Vertical_4; }
inline void set_m_Vertical_4(bool value)
{
___m_Vertical_4 = value;
}
inline static int32_t get_offset_of_m_MovementType_5() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_MovementType_5)); }
inline int32_t get_m_MovementType_5() const { return ___m_MovementType_5; }
inline int32_t* get_address_of_m_MovementType_5() { return &___m_MovementType_5; }
inline void set_m_MovementType_5(int32_t value)
{
___m_MovementType_5 = value;
}
inline static int32_t get_offset_of_m_Elasticity_6() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Elasticity_6)); }
inline float get_m_Elasticity_6() const { return ___m_Elasticity_6; }
inline float* get_address_of_m_Elasticity_6() { return &___m_Elasticity_6; }
inline void set_m_Elasticity_6(float value)
{
___m_Elasticity_6 = value;
}
inline static int32_t get_offset_of_m_Inertia_7() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Inertia_7)); }
inline bool get_m_Inertia_7() const { return ___m_Inertia_7; }
inline bool* get_address_of_m_Inertia_7() { return &___m_Inertia_7; }
inline void set_m_Inertia_7(bool value)
{
___m_Inertia_7 = value;
}
inline static int32_t get_offset_of_m_DecelerationRate_8() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_DecelerationRate_8)); }
inline float get_m_DecelerationRate_8() const { return ___m_DecelerationRate_8; }
inline float* get_address_of_m_DecelerationRate_8() { return &___m_DecelerationRate_8; }
inline void set_m_DecelerationRate_8(float value)
{
___m_DecelerationRate_8 = value;
}
inline static int32_t get_offset_of_m_ScrollSensitivity_9() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_ScrollSensitivity_9)); }
inline float get_m_ScrollSensitivity_9() const { return ___m_ScrollSensitivity_9; }
inline float* get_address_of_m_ScrollSensitivity_9() { return &___m_ScrollSensitivity_9; }
inline void set_m_ScrollSensitivity_9(float value)
{
___m_ScrollSensitivity_9 = value;
}
inline static int32_t get_offset_of_m_Viewport_10() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Viewport_10)); }
inline RectTransform_t3704657025 * get_m_Viewport_10() const { return ___m_Viewport_10; }
inline RectTransform_t3704657025 ** get_address_of_m_Viewport_10() { return &___m_Viewport_10; }
inline void set_m_Viewport_10(RectTransform_t3704657025 * value)
{
___m_Viewport_10 = value;
Il2CppCodeGenWriteBarrier((&___m_Viewport_10), value);
}
inline static int32_t get_offset_of_m_HorizontalScrollbar_11() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_HorizontalScrollbar_11)); }
inline Scrollbar_t1494447233 * get_m_HorizontalScrollbar_11() const { return ___m_HorizontalScrollbar_11; }
inline Scrollbar_t1494447233 ** get_address_of_m_HorizontalScrollbar_11() { return &___m_HorizontalScrollbar_11; }
inline void set_m_HorizontalScrollbar_11(Scrollbar_t1494447233 * value)
{
___m_HorizontalScrollbar_11 = value;
Il2CppCodeGenWriteBarrier((&___m_HorizontalScrollbar_11), value);
}
inline static int32_t get_offset_of_m_VerticalScrollbar_12() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_VerticalScrollbar_12)); }
inline Scrollbar_t1494447233 * get_m_VerticalScrollbar_12() const { return ___m_VerticalScrollbar_12; }
inline Scrollbar_t1494447233 ** get_address_of_m_VerticalScrollbar_12() { return &___m_VerticalScrollbar_12; }
inline void set_m_VerticalScrollbar_12(Scrollbar_t1494447233 * value)
{
___m_VerticalScrollbar_12 = value;
Il2CppCodeGenWriteBarrier((&___m_VerticalScrollbar_12), value);
}
inline static int32_t get_offset_of_m_HorizontalScrollbarVisibility_13() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_HorizontalScrollbarVisibility_13)); }
inline int32_t get_m_HorizontalScrollbarVisibility_13() const { return ___m_HorizontalScrollbarVisibility_13; }
inline int32_t* get_address_of_m_HorizontalScrollbarVisibility_13() { return &___m_HorizontalScrollbarVisibility_13; }
inline void set_m_HorizontalScrollbarVisibility_13(int32_t value)
{
___m_HorizontalScrollbarVisibility_13 = value;
}
inline static int32_t get_offset_of_m_VerticalScrollbarVisibility_14() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_VerticalScrollbarVisibility_14)); }
inline int32_t get_m_VerticalScrollbarVisibility_14() const { return ___m_VerticalScrollbarVisibility_14; }
inline int32_t* get_address_of_m_VerticalScrollbarVisibility_14() { return &___m_VerticalScrollbarVisibility_14; }
inline void set_m_VerticalScrollbarVisibility_14(int32_t value)
{
___m_VerticalScrollbarVisibility_14 = value;
}
inline static int32_t get_offset_of_m_HorizontalScrollbarSpacing_15() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_HorizontalScrollbarSpacing_15)); }
inline float get_m_HorizontalScrollbarSpacing_15() const { return ___m_HorizontalScrollbarSpacing_15; }
inline float* get_address_of_m_HorizontalScrollbarSpacing_15() { return &___m_HorizontalScrollbarSpacing_15; }
inline void set_m_HorizontalScrollbarSpacing_15(float value)
{
___m_HorizontalScrollbarSpacing_15 = value;
}
inline static int32_t get_offset_of_m_VerticalScrollbarSpacing_16() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_VerticalScrollbarSpacing_16)); }
inline float get_m_VerticalScrollbarSpacing_16() const { return ___m_VerticalScrollbarSpacing_16; }
inline float* get_address_of_m_VerticalScrollbarSpacing_16() { return &___m_VerticalScrollbarSpacing_16; }
inline void set_m_VerticalScrollbarSpacing_16(float value)
{
___m_VerticalScrollbarSpacing_16 = value;
}
inline static int32_t get_offset_of_m_OnValueChanged_17() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_OnValueChanged_17)); }
inline ScrollRectEvent_t343079324 * get_m_OnValueChanged_17() const { return ___m_OnValueChanged_17; }
inline ScrollRectEvent_t343079324 ** get_address_of_m_OnValueChanged_17() { return &___m_OnValueChanged_17; }
inline void set_m_OnValueChanged_17(ScrollRectEvent_t343079324 * value)
{
___m_OnValueChanged_17 = value;
Il2CppCodeGenWriteBarrier((&___m_OnValueChanged_17), value);
}
inline static int32_t get_offset_of_m_PointerStartLocalCursor_18() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_PointerStartLocalCursor_18)); }
inline Vector2_t2156229523 get_m_PointerStartLocalCursor_18() const { return ___m_PointerStartLocalCursor_18; }
inline Vector2_t2156229523 * get_address_of_m_PointerStartLocalCursor_18() { return &___m_PointerStartLocalCursor_18; }
inline void set_m_PointerStartLocalCursor_18(Vector2_t2156229523 value)
{
___m_PointerStartLocalCursor_18 = value;
}
inline static int32_t get_offset_of_m_ContentStartPosition_19() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_ContentStartPosition_19)); }
inline Vector2_t2156229523 get_m_ContentStartPosition_19() const { return ___m_ContentStartPosition_19; }
inline Vector2_t2156229523 * get_address_of_m_ContentStartPosition_19() { return &___m_ContentStartPosition_19; }
inline void set_m_ContentStartPosition_19(Vector2_t2156229523 value)
{
___m_ContentStartPosition_19 = value;
}
inline static int32_t get_offset_of_m_ViewRect_20() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_ViewRect_20)); }
inline RectTransform_t3704657025 * get_m_ViewRect_20() const { return ___m_ViewRect_20; }
inline RectTransform_t3704657025 ** get_address_of_m_ViewRect_20() { return &___m_ViewRect_20; }
inline void set_m_ViewRect_20(RectTransform_t3704657025 * value)
{
___m_ViewRect_20 = value;
Il2CppCodeGenWriteBarrier((&___m_ViewRect_20), value);
}
inline static int32_t get_offset_of_m_ContentBounds_21() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_ContentBounds_21)); }
inline Bounds_t2266837910 get_m_ContentBounds_21() const { return ___m_ContentBounds_21; }
inline Bounds_t2266837910 * get_address_of_m_ContentBounds_21() { return &___m_ContentBounds_21; }
inline void set_m_ContentBounds_21(Bounds_t2266837910 value)
{
___m_ContentBounds_21 = value;
}
inline static int32_t get_offset_of_m_ViewBounds_22() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_ViewBounds_22)); }
inline Bounds_t2266837910 get_m_ViewBounds_22() const { return ___m_ViewBounds_22; }
inline Bounds_t2266837910 * get_address_of_m_ViewBounds_22() { return &___m_ViewBounds_22; }
inline void set_m_ViewBounds_22(Bounds_t2266837910 value)
{
___m_ViewBounds_22 = value;
}
inline static int32_t get_offset_of_m_Velocity_23() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Velocity_23)); }
inline Vector2_t2156229523 get_m_Velocity_23() const { return ___m_Velocity_23; }
inline Vector2_t2156229523 * get_address_of_m_Velocity_23() { return &___m_Velocity_23; }
inline void set_m_Velocity_23(Vector2_t2156229523 value)
{
___m_Velocity_23 = value;
}
inline static int32_t get_offset_of_m_Dragging_24() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Dragging_24)); }
inline bool get_m_Dragging_24() const { return ___m_Dragging_24; }
inline bool* get_address_of_m_Dragging_24() { return &___m_Dragging_24; }
inline void set_m_Dragging_24(bool value)
{
___m_Dragging_24 = value;
}
inline static int32_t get_offset_of_m_PrevPosition_25() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_PrevPosition_25)); }
inline Vector2_t2156229523 get_m_PrevPosition_25() const { return ___m_PrevPosition_25; }
inline Vector2_t2156229523 * get_address_of_m_PrevPosition_25() { return &___m_PrevPosition_25; }
inline void set_m_PrevPosition_25(Vector2_t2156229523 value)
{
___m_PrevPosition_25 = value;
}
inline static int32_t get_offset_of_m_PrevContentBounds_26() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_PrevContentBounds_26)); }
inline Bounds_t2266837910 get_m_PrevContentBounds_26() const { return ___m_PrevContentBounds_26; }
inline Bounds_t2266837910 * get_address_of_m_PrevContentBounds_26() { return &___m_PrevContentBounds_26; }
inline void set_m_PrevContentBounds_26(Bounds_t2266837910 value)
{
___m_PrevContentBounds_26 = value;
}
inline static int32_t get_offset_of_m_PrevViewBounds_27() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_PrevViewBounds_27)); }
inline Bounds_t2266837910 get_m_PrevViewBounds_27() const { return ___m_PrevViewBounds_27; }
inline Bounds_t2266837910 * get_address_of_m_PrevViewBounds_27() { return &___m_PrevViewBounds_27; }
inline void set_m_PrevViewBounds_27(Bounds_t2266837910 value)
{
___m_PrevViewBounds_27 = value;
}
inline static int32_t get_offset_of_m_HasRebuiltLayout_28() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_HasRebuiltLayout_28)); }
inline bool get_m_HasRebuiltLayout_28() const { return ___m_HasRebuiltLayout_28; }
inline bool* get_address_of_m_HasRebuiltLayout_28() { return &___m_HasRebuiltLayout_28; }
inline void set_m_HasRebuiltLayout_28(bool value)
{
___m_HasRebuiltLayout_28 = value;
}
inline static int32_t get_offset_of_m_HSliderExpand_29() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_HSliderExpand_29)); }
inline bool get_m_HSliderExpand_29() const { return ___m_HSliderExpand_29; }
inline bool* get_address_of_m_HSliderExpand_29() { return &___m_HSliderExpand_29; }
inline void set_m_HSliderExpand_29(bool value)
{
___m_HSliderExpand_29 = value;
}
inline static int32_t get_offset_of_m_VSliderExpand_30() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_VSliderExpand_30)); }
inline bool get_m_VSliderExpand_30() const { return ___m_VSliderExpand_30; }
inline bool* get_address_of_m_VSliderExpand_30() { return &___m_VSliderExpand_30; }
inline void set_m_VSliderExpand_30(bool value)
{
___m_VSliderExpand_30 = value;
}
inline static int32_t get_offset_of_m_HSliderHeight_31() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_HSliderHeight_31)); }
inline float get_m_HSliderHeight_31() const { return ___m_HSliderHeight_31; }
inline float* get_address_of_m_HSliderHeight_31() { return &___m_HSliderHeight_31; }
inline void set_m_HSliderHeight_31(float value)
{
___m_HSliderHeight_31 = value;
}
inline static int32_t get_offset_of_m_VSliderWidth_32() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_VSliderWidth_32)); }
inline float get_m_VSliderWidth_32() const { return ___m_VSliderWidth_32; }
inline float* get_address_of_m_VSliderWidth_32() { return &___m_VSliderWidth_32; }
inline void set_m_VSliderWidth_32(float value)
{
___m_VSliderWidth_32 = value;
}
inline static int32_t get_offset_of_m_Rect_33() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Rect_33)); }
inline RectTransform_t3704657025 * get_m_Rect_33() const { return ___m_Rect_33; }
inline RectTransform_t3704657025 ** get_address_of_m_Rect_33() { return &___m_Rect_33; }
inline void set_m_Rect_33(RectTransform_t3704657025 * value)
{
___m_Rect_33 = value;
Il2CppCodeGenWriteBarrier((&___m_Rect_33), value);
}
inline static int32_t get_offset_of_m_HorizontalScrollbarRect_34() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_HorizontalScrollbarRect_34)); }
inline RectTransform_t3704657025 * get_m_HorizontalScrollbarRect_34() const { return ___m_HorizontalScrollbarRect_34; }
inline RectTransform_t3704657025 ** get_address_of_m_HorizontalScrollbarRect_34() { return &___m_HorizontalScrollbarRect_34; }
inline void set_m_HorizontalScrollbarRect_34(RectTransform_t3704657025 * value)
{
___m_HorizontalScrollbarRect_34 = value;
Il2CppCodeGenWriteBarrier((&___m_HorizontalScrollbarRect_34), value);
}
inline static int32_t get_offset_of_m_VerticalScrollbarRect_35() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_VerticalScrollbarRect_35)); }
inline RectTransform_t3704657025 * get_m_VerticalScrollbarRect_35() const { return ___m_VerticalScrollbarRect_35; }
inline RectTransform_t3704657025 ** get_address_of_m_VerticalScrollbarRect_35() { return &___m_VerticalScrollbarRect_35; }
inline void set_m_VerticalScrollbarRect_35(RectTransform_t3704657025 * value)
{
___m_VerticalScrollbarRect_35 = value;
Il2CppCodeGenWriteBarrier((&___m_VerticalScrollbarRect_35), value);
}
inline static int32_t get_offset_of_m_Tracker_36() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Tracker_36)); }
inline DrivenRectTransformTracker_t2562230146 get_m_Tracker_36() const { return ___m_Tracker_36; }
inline DrivenRectTransformTracker_t2562230146 * get_address_of_m_Tracker_36() { return &___m_Tracker_36; }
inline void set_m_Tracker_36(DrivenRectTransformTracker_t2562230146 value)
{
___m_Tracker_36 = value;
}
inline static int32_t get_offset_of_m_Corners_37() { return static_cast<int32_t>(offsetof(ScrollRect_t4137855814, ___m_Corners_37)); }
inline Vector3U5BU5D_t1718750761* get_m_Corners_37() const { return ___m_Corners_37; }
inline Vector3U5BU5D_t1718750761** get_address_of_m_Corners_37() { return &___m_Corners_37; }
inline void set_m_Corners_37(Vector3U5BU5D_t1718750761* value)
{
___m_Corners_37 = value;
Il2CppCodeGenWriteBarrier((&___m_Corners_37), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SCROLLRECT_T4137855814_H
#ifndef TOGGLEGROUP_T123837990_H
#define TOGGLEGROUP_T123837990_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.ToggleGroup
struct ToggleGroup_t123837990 : public UIBehaviour_t3495933518
{
public:
// System.Boolean UnityEngine.UI.ToggleGroup::m_AllowSwitchOff
bool ___m_AllowSwitchOff_2;
// System.Collections.Generic.List`1<UnityEngine.UI.Toggle> UnityEngine.UI.ToggleGroup::m_Toggles
List_1_t4207451803 * ___m_Toggles_3;
public:
inline static int32_t get_offset_of_m_AllowSwitchOff_2() { return static_cast<int32_t>(offsetof(ToggleGroup_t123837990, ___m_AllowSwitchOff_2)); }
inline bool get_m_AllowSwitchOff_2() const { return ___m_AllowSwitchOff_2; }
inline bool* get_address_of_m_AllowSwitchOff_2() { return &___m_AllowSwitchOff_2; }
inline void set_m_AllowSwitchOff_2(bool value)
{
___m_AllowSwitchOff_2 = value;
}
inline static int32_t get_offset_of_m_Toggles_3() { return static_cast<int32_t>(offsetof(ToggleGroup_t123837990, ___m_Toggles_3)); }
inline List_1_t4207451803 * get_m_Toggles_3() const { return ___m_Toggles_3; }
inline List_1_t4207451803 ** get_address_of_m_Toggles_3() { return &___m_Toggles_3; }
inline void set_m_Toggles_3(List_1_t4207451803 * value)
{
___m_Toggles_3 = value;
Il2CppCodeGenWriteBarrier((&___m_Toggles_3), value);
}
};
struct ToggleGroup_t123837990_StaticFields
{
public:
// System.Predicate`1<UnityEngine.UI.Toggle> UnityEngine.UI.ToggleGroup::<>f__am$cache0
Predicate_1_t3560671185 * ___U3CU3Ef__amU24cache0_4;
// System.Func`2<UnityEngine.UI.Toggle,System.Boolean> UnityEngine.UI.ToggleGroup::<>f__am$cache1
Func_2_t3446800538 * ___U3CU3Ef__amU24cache1_5;
public:
inline static int32_t get_offset_of_U3CU3Ef__amU24cache0_4() { return static_cast<int32_t>(offsetof(ToggleGroup_t123837990_StaticFields, ___U3CU3Ef__amU24cache0_4)); }
inline Predicate_1_t3560671185 * get_U3CU3Ef__amU24cache0_4() const { return ___U3CU3Ef__amU24cache0_4; }
inline Predicate_1_t3560671185 ** get_address_of_U3CU3Ef__amU24cache0_4() { return &___U3CU3Ef__amU24cache0_4; }
inline void set_U3CU3Ef__amU24cache0_4(Predicate_1_t3560671185 * value)
{
___U3CU3Ef__amU24cache0_4 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__amU24cache0_4), value);
}
inline static int32_t get_offset_of_U3CU3Ef__amU24cache1_5() { return static_cast<int32_t>(offsetof(ToggleGroup_t123837990_StaticFields, ___U3CU3Ef__amU24cache1_5)); }
inline Func_2_t3446800538 * get_U3CU3Ef__amU24cache1_5() const { return ___U3CU3Ef__amU24cache1_5; }
inline Func_2_t3446800538 ** get_address_of_U3CU3Ef__amU24cache1_5() { return &___U3CU3Ef__amU24cache1_5; }
inline void set_U3CU3Ef__amU24cache1_5(Func_2_t3446800538 * value)
{
___U3CU3Ef__amU24cache1_5 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__amU24cache1_5), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TOGGLEGROUP_T123837990_H
#ifndef SLIDER_T3903728902_H
#define SLIDER_T3903728902_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Slider
struct Slider_t3903728902 : public Selectable_t3250028441
{
public:
// UnityEngine.RectTransform UnityEngine.UI.Slider::m_FillRect
RectTransform_t3704657025 * ___m_FillRect_16;
// UnityEngine.RectTransform UnityEngine.UI.Slider::m_HandleRect
RectTransform_t3704657025 * ___m_HandleRect_17;
// UnityEngine.UI.Slider/Direction UnityEngine.UI.Slider::m_Direction
int32_t ___m_Direction_18;
// System.Single UnityEngine.UI.Slider::m_MinValue
float ___m_MinValue_19;
// System.Single UnityEngine.UI.Slider::m_MaxValue
float ___m_MaxValue_20;
// System.Boolean UnityEngine.UI.Slider::m_WholeNumbers
bool ___m_WholeNumbers_21;
// System.Single UnityEngine.UI.Slider::m_Value
float ___m_Value_22;
// UnityEngine.UI.Slider/SliderEvent UnityEngine.UI.Slider::m_OnValueChanged
SliderEvent_t3180273144 * ___m_OnValueChanged_23;
// UnityEngine.UI.Image UnityEngine.UI.Slider::m_FillImage
Image_t2670269651 * ___m_FillImage_24;
// UnityEngine.Transform UnityEngine.UI.Slider::m_FillTransform
Transform_t3600365921 * ___m_FillTransform_25;
// UnityEngine.RectTransform UnityEngine.UI.Slider::m_FillContainerRect
RectTransform_t3704657025 * ___m_FillContainerRect_26;
// UnityEngine.Transform UnityEngine.UI.Slider::m_HandleTransform
Transform_t3600365921 * ___m_HandleTransform_27;
// UnityEngine.RectTransform UnityEngine.UI.Slider::m_HandleContainerRect
RectTransform_t3704657025 * ___m_HandleContainerRect_28;
// UnityEngine.Vector2 UnityEngine.UI.Slider::m_Offset
Vector2_t2156229523 ___m_Offset_29;
// UnityEngine.DrivenRectTransformTracker UnityEngine.UI.Slider::m_Tracker
DrivenRectTransformTracker_t2562230146 ___m_Tracker_30;
public:
inline static int32_t get_offset_of_m_FillRect_16() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_FillRect_16)); }
inline RectTransform_t3704657025 * get_m_FillRect_16() const { return ___m_FillRect_16; }
inline RectTransform_t3704657025 ** get_address_of_m_FillRect_16() { return &___m_FillRect_16; }
inline void set_m_FillRect_16(RectTransform_t3704657025 * value)
{
___m_FillRect_16 = value;
Il2CppCodeGenWriteBarrier((&___m_FillRect_16), value);
}
inline static int32_t get_offset_of_m_HandleRect_17() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_HandleRect_17)); }
inline RectTransform_t3704657025 * get_m_HandleRect_17() const { return ___m_HandleRect_17; }
inline RectTransform_t3704657025 ** get_address_of_m_HandleRect_17() { return &___m_HandleRect_17; }
inline void set_m_HandleRect_17(RectTransform_t3704657025 * value)
{
___m_HandleRect_17 = value;
Il2CppCodeGenWriteBarrier((&___m_HandleRect_17), value);
}
inline static int32_t get_offset_of_m_Direction_18() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_Direction_18)); }
inline int32_t get_m_Direction_18() const { return ___m_Direction_18; }
inline int32_t* get_address_of_m_Direction_18() { return &___m_Direction_18; }
inline void set_m_Direction_18(int32_t value)
{
___m_Direction_18 = value;
}
inline static int32_t get_offset_of_m_MinValue_19() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_MinValue_19)); }
inline float get_m_MinValue_19() const { return ___m_MinValue_19; }
inline float* get_address_of_m_MinValue_19() { return &___m_MinValue_19; }
inline void set_m_MinValue_19(float value)
{
___m_MinValue_19 = value;
}
inline static int32_t get_offset_of_m_MaxValue_20() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_MaxValue_20)); }
inline float get_m_MaxValue_20() const { return ___m_MaxValue_20; }
inline float* get_address_of_m_MaxValue_20() { return &___m_MaxValue_20; }
inline void set_m_MaxValue_20(float value)
{
___m_MaxValue_20 = value;
}
inline static int32_t get_offset_of_m_WholeNumbers_21() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_WholeNumbers_21)); }
inline bool get_m_WholeNumbers_21() const { return ___m_WholeNumbers_21; }
inline bool* get_address_of_m_WholeNumbers_21() { return &___m_WholeNumbers_21; }
inline void set_m_WholeNumbers_21(bool value)
{
___m_WholeNumbers_21 = value;
}
inline static int32_t get_offset_of_m_Value_22() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_Value_22)); }
inline float get_m_Value_22() const { return ___m_Value_22; }
inline float* get_address_of_m_Value_22() { return &___m_Value_22; }
inline void set_m_Value_22(float value)
{
___m_Value_22 = value;
}
inline static int32_t get_offset_of_m_OnValueChanged_23() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_OnValueChanged_23)); }
inline SliderEvent_t3180273144 * get_m_OnValueChanged_23() const { return ___m_OnValueChanged_23; }
inline SliderEvent_t3180273144 ** get_address_of_m_OnValueChanged_23() { return &___m_OnValueChanged_23; }
inline void set_m_OnValueChanged_23(SliderEvent_t3180273144 * value)
{
___m_OnValueChanged_23 = value;
Il2CppCodeGenWriteBarrier((&___m_OnValueChanged_23), value);
}
inline static int32_t get_offset_of_m_FillImage_24() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_FillImage_24)); }
inline Image_t2670269651 * get_m_FillImage_24() const { return ___m_FillImage_24; }
inline Image_t2670269651 ** get_address_of_m_FillImage_24() { return &___m_FillImage_24; }
inline void set_m_FillImage_24(Image_t2670269651 * value)
{
___m_FillImage_24 = value;
Il2CppCodeGenWriteBarrier((&___m_FillImage_24), value);
}
inline static int32_t get_offset_of_m_FillTransform_25() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_FillTransform_25)); }
inline Transform_t3600365921 * get_m_FillTransform_25() const { return ___m_FillTransform_25; }
inline Transform_t3600365921 ** get_address_of_m_FillTransform_25() { return &___m_FillTransform_25; }
inline void set_m_FillTransform_25(Transform_t3600365921 * value)
{
___m_FillTransform_25 = value;
Il2CppCodeGenWriteBarrier((&___m_FillTransform_25), value);
}
inline static int32_t get_offset_of_m_FillContainerRect_26() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_FillContainerRect_26)); }
inline RectTransform_t3704657025 * get_m_FillContainerRect_26() const { return ___m_FillContainerRect_26; }
inline RectTransform_t3704657025 ** get_address_of_m_FillContainerRect_26() { return &___m_FillContainerRect_26; }
inline void set_m_FillContainerRect_26(RectTransform_t3704657025 * value)
{
___m_FillContainerRect_26 = value;
Il2CppCodeGenWriteBarrier((&___m_FillContainerRect_26), value);
}
inline static int32_t get_offset_of_m_HandleTransform_27() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_HandleTransform_27)); }
inline Transform_t3600365921 * get_m_HandleTransform_27() const { return ___m_HandleTransform_27; }
inline Transform_t3600365921 ** get_address_of_m_HandleTransform_27() { return &___m_HandleTransform_27; }
inline void set_m_HandleTransform_27(Transform_t3600365921 * value)
{
___m_HandleTransform_27 = value;
Il2CppCodeGenWriteBarrier((&___m_HandleTransform_27), value);
}
inline static int32_t get_offset_of_m_HandleContainerRect_28() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_HandleContainerRect_28)); }
inline RectTransform_t3704657025 * get_m_HandleContainerRect_28() const { return ___m_HandleContainerRect_28; }
inline RectTransform_t3704657025 ** get_address_of_m_HandleContainerRect_28() { return &___m_HandleContainerRect_28; }
inline void set_m_HandleContainerRect_28(RectTransform_t3704657025 * value)
{
___m_HandleContainerRect_28 = value;
Il2CppCodeGenWriteBarrier((&___m_HandleContainerRect_28), value);
}
inline static int32_t get_offset_of_m_Offset_29() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_Offset_29)); }
inline Vector2_t2156229523 get_m_Offset_29() const { return ___m_Offset_29; }
inline Vector2_t2156229523 * get_address_of_m_Offset_29() { return &___m_Offset_29; }
inline void set_m_Offset_29(Vector2_t2156229523 value)
{
___m_Offset_29 = value;
}
inline static int32_t get_offset_of_m_Tracker_30() { return static_cast<int32_t>(offsetof(Slider_t3903728902, ___m_Tracker_30)); }
inline DrivenRectTransformTracker_t2562230146 get_m_Tracker_30() const { return ___m_Tracker_30; }
inline DrivenRectTransformTracker_t2562230146 * get_address_of_m_Tracker_30() { return &___m_Tracker_30; }
inline void set_m_Tracker_30(DrivenRectTransformTracker_t2562230146 value)
{
___m_Tracker_30 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SLIDER_T3903728902_H
#ifndef DROPDOWN_T2274391225_H
#define DROPDOWN_T2274391225_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Dropdown
struct Dropdown_t2274391225 : public Selectable_t3250028441
{
public:
// UnityEngine.RectTransform UnityEngine.UI.Dropdown::m_Template
RectTransform_t3704657025 * ___m_Template_16;
// UnityEngine.UI.Text UnityEngine.UI.Dropdown::m_CaptionText
Text_t1901882714 * ___m_CaptionText_17;
// UnityEngine.UI.Image UnityEngine.UI.Dropdown::m_CaptionImage
Image_t2670269651 * ___m_CaptionImage_18;
// UnityEngine.UI.Text UnityEngine.UI.Dropdown::m_ItemText
Text_t1901882714 * ___m_ItemText_19;
// UnityEngine.UI.Image UnityEngine.UI.Dropdown::m_ItemImage
Image_t2670269651 * ___m_ItemImage_20;
// System.Int32 UnityEngine.UI.Dropdown::m_Value
int32_t ___m_Value_21;
// UnityEngine.UI.Dropdown/OptionDataList UnityEngine.UI.Dropdown::m_Options
OptionDataList_t1438173104 * ___m_Options_22;
// UnityEngine.UI.Dropdown/DropdownEvent UnityEngine.UI.Dropdown::m_OnValueChanged
DropdownEvent_t4040729994 * ___m_OnValueChanged_23;
// UnityEngine.GameObject UnityEngine.UI.Dropdown::m_Dropdown
GameObject_t1113636619 * ___m_Dropdown_24;
// UnityEngine.GameObject UnityEngine.UI.Dropdown::m_Blocker
GameObject_t1113636619 * ___m_Blocker_25;
// System.Collections.Generic.List`1<UnityEngine.UI.Dropdown/DropdownItem> UnityEngine.UI.Dropdown::m_Items
List_1_t2924027637 * ___m_Items_26;
// UnityEngine.UI.CoroutineTween.TweenRunner`1<UnityEngine.UI.CoroutineTween.FloatTween> UnityEngine.UI.Dropdown::m_AlphaTweenRunner
TweenRunner_1_t3520241082 * ___m_AlphaTweenRunner_27;
// System.Boolean UnityEngine.UI.Dropdown::validTemplate
bool ___validTemplate_28;
public:
inline static int32_t get_offset_of_m_Template_16() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_Template_16)); }
inline RectTransform_t3704657025 * get_m_Template_16() const { return ___m_Template_16; }
inline RectTransform_t3704657025 ** get_address_of_m_Template_16() { return &___m_Template_16; }
inline void set_m_Template_16(RectTransform_t3704657025 * value)
{
___m_Template_16 = value;
Il2CppCodeGenWriteBarrier((&___m_Template_16), value);
}
inline static int32_t get_offset_of_m_CaptionText_17() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_CaptionText_17)); }
inline Text_t1901882714 * get_m_CaptionText_17() const { return ___m_CaptionText_17; }
inline Text_t1901882714 ** get_address_of_m_CaptionText_17() { return &___m_CaptionText_17; }
inline void set_m_CaptionText_17(Text_t1901882714 * value)
{
___m_CaptionText_17 = value;
Il2CppCodeGenWriteBarrier((&___m_CaptionText_17), value);
}
inline static int32_t get_offset_of_m_CaptionImage_18() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_CaptionImage_18)); }
inline Image_t2670269651 * get_m_CaptionImage_18() const { return ___m_CaptionImage_18; }
inline Image_t2670269651 ** get_address_of_m_CaptionImage_18() { return &___m_CaptionImage_18; }
inline void set_m_CaptionImage_18(Image_t2670269651 * value)
{
___m_CaptionImage_18 = value;
Il2CppCodeGenWriteBarrier((&___m_CaptionImage_18), value);
}
inline static int32_t get_offset_of_m_ItemText_19() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_ItemText_19)); }
inline Text_t1901882714 * get_m_ItemText_19() const { return ___m_ItemText_19; }
inline Text_t1901882714 ** get_address_of_m_ItemText_19() { return &___m_ItemText_19; }
inline void set_m_ItemText_19(Text_t1901882714 * value)
{
___m_ItemText_19 = value;
Il2CppCodeGenWriteBarrier((&___m_ItemText_19), value);
}
inline static int32_t get_offset_of_m_ItemImage_20() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_ItemImage_20)); }
inline Image_t2670269651 * get_m_ItemImage_20() const { return ___m_ItemImage_20; }
inline Image_t2670269651 ** get_address_of_m_ItemImage_20() { return &___m_ItemImage_20; }
inline void set_m_ItemImage_20(Image_t2670269651 * value)
{
___m_ItemImage_20 = value;
Il2CppCodeGenWriteBarrier((&___m_ItemImage_20), value);
}
inline static int32_t get_offset_of_m_Value_21() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_Value_21)); }
inline int32_t get_m_Value_21() const { return ___m_Value_21; }
inline int32_t* get_address_of_m_Value_21() { return &___m_Value_21; }
inline void set_m_Value_21(int32_t value)
{
___m_Value_21 = value;
}
inline static int32_t get_offset_of_m_Options_22() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_Options_22)); }
inline OptionDataList_t1438173104 * get_m_Options_22() const { return ___m_Options_22; }
inline OptionDataList_t1438173104 ** get_address_of_m_Options_22() { return &___m_Options_22; }
inline void set_m_Options_22(OptionDataList_t1438173104 * value)
{
___m_Options_22 = value;
Il2CppCodeGenWriteBarrier((&___m_Options_22), value);
}
inline static int32_t get_offset_of_m_OnValueChanged_23() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_OnValueChanged_23)); }
inline DropdownEvent_t4040729994 * get_m_OnValueChanged_23() const { return ___m_OnValueChanged_23; }
inline DropdownEvent_t4040729994 ** get_address_of_m_OnValueChanged_23() { return &___m_OnValueChanged_23; }
inline void set_m_OnValueChanged_23(DropdownEvent_t4040729994 * value)
{
___m_OnValueChanged_23 = value;
Il2CppCodeGenWriteBarrier((&___m_OnValueChanged_23), value);
}
inline static int32_t get_offset_of_m_Dropdown_24() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_Dropdown_24)); }
inline GameObject_t1113636619 * get_m_Dropdown_24() const { return ___m_Dropdown_24; }
inline GameObject_t1113636619 ** get_address_of_m_Dropdown_24() { return &___m_Dropdown_24; }
inline void set_m_Dropdown_24(GameObject_t1113636619 * value)
{
___m_Dropdown_24 = value;
Il2CppCodeGenWriteBarrier((&___m_Dropdown_24), value);
}
inline static int32_t get_offset_of_m_Blocker_25() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_Blocker_25)); }
inline GameObject_t1113636619 * get_m_Blocker_25() const { return ___m_Blocker_25; }
inline GameObject_t1113636619 ** get_address_of_m_Blocker_25() { return &___m_Blocker_25; }
inline void set_m_Blocker_25(GameObject_t1113636619 * value)
{
___m_Blocker_25 = value;
Il2CppCodeGenWriteBarrier((&___m_Blocker_25), value);
}
inline static int32_t get_offset_of_m_Items_26() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_Items_26)); }
inline List_1_t2924027637 * get_m_Items_26() const { return ___m_Items_26; }
inline List_1_t2924027637 ** get_address_of_m_Items_26() { return &___m_Items_26; }
inline void set_m_Items_26(List_1_t2924027637 * value)
{
___m_Items_26 = value;
Il2CppCodeGenWriteBarrier((&___m_Items_26), value);
}
inline static int32_t get_offset_of_m_AlphaTweenRunner_27() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___m_AlphaTweenRunner_27)); }
inline TweenRunner_1_t3520241082 * get_m_AlphaTweenRunner_27() const { return ___m_AlphaTweenRunner_27; }
inline TweenRunner_1_t3520241082 ** get_address_of_m_AlphaTweenRunner_27() { return &___m_AlphaTweenRunner_27; }
inline void set_m_AlphaTweenRunner_27(TweenRunner_1_t3520241082 * value)
{
___m_AlphaTweenRunner_27 = value;
Il2CppCodeGenWriteBarrier((&___m_AlphaTweenRunner_27), value);
}
inline static int32_t get_offset_of_validTemplate_28() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225, ___validTemplate_28)); }
inline bool get_validTemplate_28() const { return ___validTemplate_28; }
inline bool* get_address_of_validTemplate_28() { return &___validTemplate_28; }
inline void set_validTemplate_28(bool value)
{
___validTemplate_28 = value;
}
};
struct Dropdown_t2274391225_StaticFields
{
public:
// UnityEngine.UI.Dropdown/OptionData UnityEngine.UI.Dropdown::s_NoOptionData
OptionData_t3270282352 * ___s_NoOptionData_29;
public:
inline static int32_t get_offset_of_s_NoOptionData_29() { return static_cast<int32_t>(offsetof(Dropdown_t2274391225_StaticFields, ___s_NoOptionData_29)); }
inline OptionData_t3270282352 * get_s_NoOptionData_29() const { return ___s_NoOptionData_29; }
inline OptionData_t3270282352 ** get_address_of_s_NoOptionData_29() { return &___s_NoOptionData_29; }
inline void set_s_NoOptionData_29(OptionData_t3270282352 * value)
{
___s_NoOptionData_29 = value;
Il2CppCodeGenWriteBarrier((&___s_NoOptionData_29), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DROPDOWN_T2274391225_H
#ifndef GRIDLAYOUTGROUP_T3046220461_H
#define GRIDLAYOUTGROUP_T3046220461_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.GridLayoutGroup
struct GridLayoutGroup_t3046220461 : public LayoutGroup_t2436138090
{
public:
// UnityEngine.UI.GridLayoutGroup/Corner UnityEngine.UI.GridLayoutGroup::m_StartCorner
int32_t ___m_StartCorner_10;
// UnityEngine.UI.GridLayoutGroup/Axis UnityEngine.UI.GridLayoutGroup::m_StartAxis
int32_t ___m_StartAxis_11;
// UnityEngine.Vector2 UnityEngine.UI.GridLayoutGroup::m_CellSize
Vector2_t2156229523 ___m_CellSize_12;
// UnityEngine.Vector2 UnityEngine.UI.GridLayoutGroup::m_Spacing
Vector2_t2156229523 ___m_Spacing_13;
// UnityEngine.UI.GridLayoutGroup/Constraint UnityEngine.UI.GridLayoutGroup::m_Constraint
int32_t ___m_Constraint_14;
// System.Int32 UnityEngine.UI.GridLayoutGroup::m_ConstraintCount
int32_t ___m_ConstraintCount_15;
public:
inline static int32_t get_offset_of_m_StartCorner_10() { return static_cast<int32_t>(offsetof(GridLayoutGroup_t3046220461, ___m_StartCorner_10)); }
inline int32_t get_m_StartCorner_10() const { return ___m_StartCorner_10; }
inline int32_t* get_address_of_m_StartCorner_10() { return &___m_StartCorner_10; }
inline void set_m_StartCorner_10(int32_t value)
{
___m_StartCorner_10 = value;
}
inline static int32_t get_offset_of_m_StartAxis_11() { return static_cast<int32_t>(offsetof(GridLayoutGroup_t3046220461, ___m_StartAxis_11)); }
inline int32_t get_m_StartAxis_11() const { return ___m_StartAxis_11; }
inline int32_t* get_address_of_m_StartAxis_11() { return &___m_StartAxis_11; }
inline void set_m_StartAxis_11(int32_t value)
{
___m_StartAxis_11 = value;
}
inline static int32_t get_offset_of_m_CellSize_12() { return static_cast<int32_t>(offsetof(GridLayoutGroup_t3046220461, ___m_CellSize_12)); }
inline Vector2_t2156229523 get_m_CellSize_12() const { return ___m_CellSize_12; }
inline Vector2_t2156229523 * get_address_of_m_CellSize_12() { return &___m_CellSize_12; }
inline void set_m_CellSize_12(Vector2_t2156229523 value)
{
___m_CellSize_12 = value;
}
inline static int32_t get_offset_of_m_Spacing_13() { return static_cast<int32_t>(offsetof(GridLayoutGroup_t3046220461, ___m_Spacing_13)); }
inline Vector2_t2156229523 get_m_Spacing_13() const { return ___m_Spacing_13; }
inline Vector2_t2156229523 * get_address_of_m_Spacing_13() { return &___m_Spacing_13; }
inline void set_m_Spacing_13(Vector2_t2156229523 value)
{
___m_Spacing_13 = value;
}
inline static int32_t get_offset_of_m_Constraint_14() { return static_cast<int32_t>(offsetof(GridLayoutGroup_t3046220461, ___m_Constraint_14)); }
inline int32_t get_m_Constraint_14() const { return ___m_Constraint_14; }
inline int32_t* get_address_of_m_Constraint_14() { return &___m_Constraint_14; }
inline void set_m_Constraint_14(int32_t value)
{
___m_Constraint_14 = value;
}
inline static int32_t get_offset_of_m_ConstraintCount_15() { return static_cast<int32_t>(offsetof(GridLayoutGroup_t3046220461, ___m_ConstraintCount_15)); }
inline int32_t get_m_ConstraintCount_15() const { return ___m_ConstraintCount_15; }
inline int32_t* get_address_of_m_ConstraintCount_15() { return &___m_ConstraintCount_15; }
inline void set_m_ConstraintCount_15(int32_t value)
{
___m_ConstraintCount_15 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // GRIDLAYOUTGROUP_T3046220461_H
#ifndef INPUTFIELD_T3762917431_H
#define INPUTFIELD_T3762917431_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.InputField
struct InputField_t3762917431 : public Selectable_t3250028441
{
public:
// UnityEngine.TouchScreenKeyboard UnityEngine.UI.InputField::m_Keyboard
TouchScreenKeyboard_t731888065 * ___m_Keyboard_16;
// UnityEngine.UI.Text UnityEngine.UI.InputField::m_TextComponent
Text_t1901882714 * ___m_TextComponent_18;
// UnityEngine.UI.Graphic UnityEngine.UI.InputField::m_Placeholder
Graphic_t1660335611 * ___m_Placeholder_19;
// UnityEngine.UI.InputField/ContentType UnityEngine.UI.InputField::m_ContentType
int32_t ___m_ContentType_20;
// UnityEngine.UI.InputField/InputType UnityEngine.UI.InputField::m_InputType
int32_t ___m_InputType_21;
// System.Char UnityEngine.UI.InputField::m_AsteriskChar
Il2CppChar ___m_AsteriskChar_22;
// UnityEngine.TouchScreenKeyboardType UnityEngine.UI.InputField::m_KeyboardType
int32_t ___m_KeyboardType_23;
// UnityEngine.UI.InputField/LineType UnityEngine.UI.InputField::m_LineType
int32_t ___m_LineType_24;
// System.Boolean UnityEngine.UI.InputField::m_HideMobileInput
bool ___m_HideMobileInput_25;
// UnityEngine.UI.InputField/CharacterValidation UnityEngine.UI.InputField::m_CharacterValidation
int32_t ___m_CharacterValidation_26;
// System.Int32 UnityEngine.UI.InputField::m_CharacterLimit
int32_t ___m_CharacterLimit_27;
// UnityEngine.UI.InputField/SubmitEvent UnityEngine.UI.InputField::m_OnEndEdit
SubmitEvent_t648412432 * ___m_OnEndEdit_28;
// UnityEngine.UI.InputField/OnChangeEvent UnityEngine.UI.InputField::m_OnValueChanged
OnChangeEvent_t467195904 * ___m_OnValueChanged_29;
// UnityEngine.UI.InputField/OnValidateInput UnityEngine.UI.InputField::m_OnValidateInput
OnValidateInput_t2355412304 * ___m_OnValidateInput_30;
// UnityEngine.Color UnityEngine.UI.InputField::m_CaretColor
Color_t2555686324 ___m_CaretColor_31;
// System.Boolean UnityEngine.UI.InputField::m_CustomCaretColor
bool ___m_CustomCaretColor_32;
// UnityEngine.Color UnityEngine.UI.InputField::m_SelectionColor
Color_t2555686324 ___m_SelectionColor_33;
// System.String UnityEngine.UI.InputField::m_Text
String_t* ___m_Text_34;
// System.Single UnityEngine.UI.InputField::m_CaretBlinkRate
float ___m_CaretBlinkRate_35;
// System.Int32 UnityEngine.UI.InputField::m_CaretWidth
int32_t ___m_CaretWidth_36;
// System.Boolean UnityEngine.UI.InputField::m_ReadOnly
bool ___m_ReadOnly_37;
// System.Int32 UnityEngine.UI.InputField::m_CaretPosition
int32_t ___m_CaretPosition_38;
// System.Int32 UnityEngine.UI.InputField::m_CaretSelectPosition
int32_t ___m_CaretSelectPosition_39;
// UnityEngine.RectTransform UnityEngine.UI.InputField::caretRectTrans
RectTransform_t3704657025 * ___caretRectTrans_40;
// UnityEngine.UIVertex[] UnityEngine.UI.InputField::m_CursorVerts
UIVertexU5BU5D_t1981460040* ___m_CursorVerts_41;
// UnityEngine.TextGenerator UnityEngine.UI.InputField::m_InputTextCache
TextGenerator_t3211863866 * ___m_InputTextCache_42;
// UnityEngine.CanvasRenderer UnityEngine.UI.InputField::m_CachedInputRenderer
CanvasRenderer_t2598313366 * ___m_CachedInputRenderer_43;
// System.Boolean UnityEngine.UI.InputField::m_PreventFontCallback
bool ___m_PreventFontCallback_44;
// UnityEngine.Mesh UnityEngine.UI.InputField::m_Mesh
Mesh_t3648964284 * ___m_Mesh_45;
// System.Boolean UnityEngine.UI.InputField::m_AllowInput
bool ___m_AllowInput_46;
// System.Boolean UnityEngine.UI.InputField::m_ShouldActivateNextUpdate
bool ___m_ShouldActivateNextUpdate_47;
// System.Boolean UnityEngine.UI.InputField::m_UpdateDrag
bool ___m_UpdateDrag_48;
// System.Boolean UnityEngine.UI.InputField::m_DragPositionOutOfBounds
bool ___m_DragPositionOutOfBounds_49;
// System.Boolean UnityEngine.UI.InputField::m_CaretVisible
bool ___m_CaretVisible_52;
// UnityEngine.Coroutine UnityEngine.UI.InputField::m_BlinkCoroutine
Coroutine_t3829159415 * ___m_BlinkCoroutine_53;
// System.Single UnityEngine.UI.InputField::m_BlinkStartTime
float ___m_BlinkStartTime_54;
// System.Int32 UnityEngine.UI.InputField::m_DrawStart
int32_t ___m_DrawStart_55;
// System.Int32 UnityEngine.UI.InputField::m_DrawEnd
int32_t ___m_DrawEnd_56;
// UnityEngine.Coroutine UnityEngine.UI.InputField::m_DragCoroutine
Coroutine_t3829159415 * ___m_DragCoroutine_57;
// System.String UnityEngine.UI.InputField::m_OriginalText
String_t* ___m_OriginalText_58;
// System.Boolean UnityEngine.UI.InputField::m_WasCanceled
bool ___m_WasCanceled_59;
// System.Boolean UnityEngine.UI.InputField::m_HasDoneFocusTransition
bool ___m_HasDoneFocusTransition_60;
// UnityEngine.Event UnityEngine.UI.InputField::m_ProcessingEvent
Event_t2956885303 * ___m_ProcessingEvent_62;
public:
inline static int32_t get_offset_of_m_Keyboard_16() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_Keyboard_16)); }
inline TouchScreenKeyboard_t731888065 * get_m_Keyboard_16() const { return ___m_Keyboard_16; }
inline TouchScreenKeyboard_t731888065 ** get_address_of_m_Keyboard_16() { return &___m_Keyboard_16; }
inline void set_m_Keyboard_16(TouchScreenKeyboard_t731888065 * value)
{
___m_Keyboard_16 = value;
Il2CppCodeGenWriteBarrier((&___m_Keyboard_16), value);
}
inline static int32_t get_offset_of_m_TextComponent_18() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_TextComponent_18)); }
inline Text_t1901882714 * get_m_TextComponent_18() const { return ___m_TextComponent_18; }
inline Text_t1901882714 ** get_address_of_m_TextComponent_18() { return &___m_TextComponent_18; }
inline void set_m_TextComponent_18(Text_t1901882714 * value)
{
___m_TextComponent_18 = value;
Il2CppCodeGenWriteBarrier((&___m_TextComponent_18), value);
}
inline static int32_t get_offset_of_m_Placeholder_19() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_Placeholder_19)); }
inline Graphic_t1660335611 * get_m_Placeholder_19() const { return ___m_Placeholder_19; }
inline Graphic_t1660335611 ** get_address_of_m_Placeholder_19() { return &___m_Placeholder_19; }
inline void set_m_Placeholder_19(Graphic_t1660335611 * value)
{
___m_Placeholder_19 = value;
Il2CppCodeGenWriteBarrier((&___m_Placeholder_19), value);
}
inline static int32_t get_offset_of_m_ContentType_20() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_ContentType_20)); }
inline int32_t get_m_ContentType_20() const { return ___m_ContentType_20; }
inline int32_t* get_address_of_m_ContentType_20() { return &___m_ContentType_20; }
inline void set_m_ContentType_20(int32_t value)
{
___m_ContentType_20 = value;
}
inline static int32_t get_offset_of_m_InputType_21() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_InputType_21)); }
inline int32_t get_m_InputType_21() const { return ___m_InputType_21; }
inline int32_t* get_address_of_m_InputType_21() { return &___m_InputType_21; }
inline void set_m_InputType_21(int32_t value)
{
___m_InputType_21 = value;
}
inline static int32_t get_offset_of_m_AsteriskChar_22() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_AsteriskChar_22)); }
inline Il2CppChar get_m_AsteriskChar_22() const { return ___m_AsteriskChar_22; }
inline Il2CppChar* get_address_of_m_AsteriskChar_22() { return &___m_AsteriskChar_22; }
inline void set_m_AsteriskChar_22(Il2CppChar value)
{
___m_AsteriskChar_22 = value;
}
inline static int32_t get_offset_of_m_KeyboardType_23() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_KeyboardType_23)); }
inline int32_t get_m_KeyboardType_23() const { return ___m_KeyboardType_23; }
inline int32_t* get_address_of_m_KeyboardType_23() { return &___m_KeyboardType_23; }
inline void set_m_KeyboardType_23(int32_t value)
{
___m_KeyboardType_23 = value;
}
inline static int32_t get_offset_of_m_LineType_24() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_LineType_24)); }
inline int32_t get_m_LineType_24() const { return ___m_LineType_24; }
inline int32_t* get_address_of_m_LineType_24() { return &___m_LineType_24; }
inline void set_m_LineType_24(int32_t value)
{
___m_LineType_24 = value;
}
inline static int32_t get_offset_of_m_HideMobileInput_25() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_HideMobileInput_25)); }
inline bool get_m_HideMobileInput_25() const { return ___m_HideMobileInput_25; }
inline bool* get_address_of_m_HideMobileInput_25() { return &___m_HideMobileInput_25; }
inline void set_m_HideMobileInput_25(bool value)
{
___m_HideMobileInput_25 = value;
}
inline static int32_t get_offset_of_m_CharacterValidation_26() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CharacterValidation_26)); }
inline int32_t get_m_CharacterValidation_26() const { return ___m_CharacterValidation_26; }
inline int32_t* get_address_of_m_CharacterValidation_26() { return &___m_CharacterValidation_26; }
inline void set_m_CharacterValidation_26(int32_t value)
{
___m_CharacterValidation_26 = value;
}
inline static int32_t get_offset_of_m_CharacterLimit_27() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CharacterLimit_27)); }
inline int32_t get_m_CharacterLimit_27() const { return ___m_CharacterLimit_27; }
inline int32_t* get_address_of_m_CharacterLimit_27() { return &___m_CharacterLimit_27; }
inline void set_m_CharacterLimit_27(int32_t value)
{
___m_CharacterLimit_27 = value;
}
inline static int32_t get_offset_of_m_OnEndEdit_28() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_OnEndEdit_28)); }
inline SubmitEvent_t648412432 * get_m_OnEndEdit_28() const { return ___m_OnEndEdit_28; }
inline SubmitEvent_t648412432 ** get_address_of_m_OnEndEdit_28() { return &___m_OnEndEdit_28; }
inline void set_m_OnEndEdit_28(SubmitEvent_t648412432 * value)
{
___m_OnEndEdit_28 = value;
Il2CppCodeGenWriteBarrier((&___m_OnEndEdit_28), value);
}
inline static int32_t get_offset_of_m_OnValueChanged_29() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_OnValueChanged_29)); }
inline OnChangeEvent_t467195904 * get_m_OnValueChanged_29() const { return ___m_OnValueChanged_29; }
inline OnChangeEvent_t467195904 ** get_address_of_m_OnValueChanged_29() { return &___m_OnValueChanged_29; }
inline void set_m_OnValueChanged_29(OnChangeEvent_t467195904 * value)
{
___m_OnValueChanged_29 = value;
Il2CppCodeGenWriteBarrier((&___m_OnValueChanged_29), value);
}
inline static int32_t get_offset_of_m_OnValidateInput_30() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_OnValidateInput_30)); }
inline OnValidateInput_t2355412304 * get_m_OnValidateInput_30() const { return ___m_OnValidateInput_30; }
inline OnValidateInput_t2355412304 ** get_address_of_m_OnValidateInput_30() { return &___m_OnValidateInput_30; }
inline void set_m_OnValidateInput_30(OnValidateInput_t2355412304 * value)
{
___m_OnValidateInput_30 = value;
Il2CppCodeGenWriteBarrier((&___m_OnValidateInput_30), value);
}
inline static int32_t get_offset_of_m_CaretColor_31() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CaretColor_31)); }
inline Color_t2555686324 get_m_CaretColor_31() const { return ___m_CaretColor_31; }
inline Color_t2555686324 * get_address_of_m_CaretColor_31() { return &___m_CaretColor_31; }
inline void set_m_CaretColor_31(Color_t2555686324 value)
{
___m_CaretColor_31 = value;
}
inline static int32_t get_offset_of_m_CustomCaretColor_32() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CustomCaretColor_32)); }
inline bool get_m_CustomCaretColor_32() const { return ___m_CustomCaretColor_32; }
inline bool* get_address_of_m_CustomCaretColor_32() { return &___m_CustomCaretColor_32; }
inline void set_m_CustomCaretColor_32(bool value)
{
___m_CustomCaretColor_32 = value;
}
inline static int32_t get_offset_of_m_SelectionColor_33() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_SelectionColor_33)); }
inline Color_t2555686324 get_m_SelectionColor_33() const { return ___m_SelectionColor_33; }
inline Color_t2555686324 * get_address_of_m_SelectionColor_33() { return &___m_SelectionColor_33; }
inline void set_m_SelectionColor_33(Color_t2555686324 value)
{
___m_SelectionColor_33 = value;
}
inline static int32_t get_offset_of_m_Text_34() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_Text_34)); }
inline String_t* get_m_Text_34() const { return ___m_Text_34; }
inline String_t** get_address_of_m_Text_34() { return &___m_Text_34; }
inline void set_m_Text_34(String_t* value)
{
___m_Text_34 = value;
Il2CppCodeGenWriteBarrier((&___m_Text_34), value);
}
inline static int32_t get_offset_of_m_CaretBlinkRate_35() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CaretBlinkRate_35)); }
inline float get_m_CaretBlinkRate_35() const { return ___m_CaretBlinkRate_35; }
inline float* get_address_of_m_CaretBlinkRate_35() { return &___m_CaretBlinkRate_35; }
inline void set_m_CaretBlinkRate_35(float value)
{
___m_CaretBlinkRate_35 = value;
}
inline static int32_t get_offset_of_m_CaretWidth_36() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CaretWidth_36)); }
inline int32_t get_m_CaretWidth_36() const { return ___m_CaretWidth_36; }
inline int32_t* get_address_of_m_CaretWidth_36() { return &___m_CaretWidth_36; }
inline void set_m_CaretWidth_36(int32_t value)
{
___m_CaretWidth_36 = value;
}
inline static int32_t get_offset_of_m_ReadOnly_37() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_ReadOnly_37)); }
inline bool get_m_ReadOnly_37() const { return ___m_ReadOnly_37; }
inline bool* get_address_of_m_ReadOnly_37() { return &___m_ReadOnly_37; }
inline void set_m_ReadOnly_37(bool value)
{
___m_ReadOnly_37 = value;
}
inline static int32_t get_offset_of_m_CaretPosition_38() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CaretPosition_38)); }
inline int32_t get_m_CaretPosition_38() const { return ___m_CaretPosition_38; }
inline int32_t* get_address_of_m_CaretPosition_38() { return &___m_CaretPosition_38; }
inline void set_m_CaretPosition_38(int32_t value)
{
___m_CaretPosition_38 = value;
}
inline static int32_t get_offset_of_m_CaretSelectPosition_39() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CaretSelectPosition_39)); }
inline int32_t get_m_CaretSelectPosition_39() const { return ___m_CaretSelectPosition_39; }
inline int32_t* get_address_of_m_CaretSelectPosition_39() { return &___m_CaretSelectPosition_39; }
inline void set_m_CaretSelectPosition_39(int32_t value)
{
___m_CaretSelectPosition_39 = value;
}
inline static int32_t get_offset_of_caretRectTrans_40() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___caretRectTrans_40)); }
inline RectTransform_t3704657025 * get_caretRectTrans_40() const { return ___caretRectTrans_40; }
inline RectTransform_t3704657025 ** get_address_of_caretRectTrans_40() { return &___caretRectTrans_40; }
inline void set_caretRectTrans_40(RectTransform_t3704657025 * value)
{
___caretRectTrans_40 = value;
Il2CppCodeGenWriteBarrier((&___caretRectTrans_40), value);
}
inline static int32_t get_offset_of_m_CursorVerts_41() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CursorVerts_41)); }
inline UIVertexU5BU5D_t1981460040* get_m_CursorVerts_41() const { return ___m_CursorVerts_41; }
inline UIVertexU5BU5D_t1981460040** get_address_of_m_CursorVerts_41() { return &___m_CursorVerts_41; }
inline void set_m_CursorVerts_41(UIVertexU5BU5D_t1981460040* value)
{
___m_CursorVerts_41 = value;
Il2CppCodeGenWriteBarrier((&___m_CursorVerts_41), value);
}
inline static int32_t get_offset_of_m_InputTextCache_42() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_InputTextCache_42)); }
inline TextGenerator_t3211863866 * get_m_InputTextCache_42() const { return ___m_InputTextCache_42; }
inline TextGenerator_t3211863866 ** get_address_of_m_InputTextCache_42() { return &___m_InputTextCache_42; }
inline void set_m_InputTextCache_42(TextGenerator_t3211863866 * value)
{
___m_InputTextCache_42 = value;
Il2CppCodeGenWriteBarrier((&___m_InputTextCache_42), value);
}
inline static int32_t get_offset_of_m_CachedInputRenderer_43() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CachedInputRenderer_43)); }
inline CanvasRenderer_t2598313366 * get_m_CachedInputRenderer_43() const { return ___m_CachedInputRenderer_43; }
inline CanvasRenderer_t2598313366 ** get_address_of_m_CachedInputRenderer_43() { return &___m_CachedInputRenderer_43; }
inline void set_m_CachedInputRenderer_43(CanvasRenderer_t2598313366 * value)
{
___m_CachedInputRenderer_43 = value;
Il2CppCodeGenWriteBarrier((&___m_CachedInputRenderer_43), value);
}
inline static int32_t get_offset_of_m_PreventFontCallback_44() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_PreventFontCallback_44)); }
inline bool get_m_PreventFontCallback_44() const { return ___m_PreventFontCallback_44; }
inline bool* get_address_of_m_PreventFontCallback_44() { return &___m_PreventFontCallback_44; }
inline void set_m_PreventFontCallback_44(bool value)
{
___m_PreventFontCallback_44 = value;
}
inline static int32_t get_offset_of_m_Mesh_45() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_Mesh_45)); }
inline Mesh_t3648964284 * get_m_Mesh_45() const { return ___m_Mesh_45; }
inline Mesh_t3648964284 ** get_address_of_m_Mesh_45() { return &___m_Mesh_45; }
inline void set_m_Mesh_45(Mesh_t3648964284 * value)
{
___m_Mesh_45 = value;
Il2CppCodeGenWriteBarrier((&___m_Mesh_45), value);
}
inline static int32_t get_offset_of_m_AllowInput_46() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_AllowInput_46)); }
inline bool get_m_AllowInput_46() const { return ___m_AllowInput_46; }
inline bool* get_address_of_m_AllowInput_46() { return &___m_AllowInput_46; }
inline void set_m_AllowInput_46(bool value)
{
___m_AllowInput_46 = value;
}
inline static int32_t get_offset_of_m_ShouldActivateNextUpdate_47() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_ShouldActivateNextUpdate_47)); }
inline bool get_m_ShouldActivateNextUpdate_47() const { return ___m_ShouldActivateNextUpdate_47; }
inline bool* get_address_of_m_ShouldActivateNextUpdate_47() { return &___m_ShouldActivateNextUpdate_47; }
inline void set_m_ShouldActivateNextUpdate_47(bool value)
{
___m_ShouldActivateNextUpdate_47 = value;
}
inline static int32_t get_offset_of_m_UpdateDrag_48() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_UpdateDrag_48)); }
inline bool get_m_UpdateDrag_48() const { return ___m_UpdateDrag_48; }
inline bool* get_address_of_m_UpdateDrag_48() { return &___m_UpdateDrag_48; }
inline void set_m_UpdateDrag_48(bool value)
{
___m_UpdateDrag_48 = value;
}
inline static int32_t get_offset_of_m_DragPositionOutOfBounds_49() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_DragPositionOutOfBounds_49)); }
inline bool get_m_DragPositionOutOfBounds_49() const { return ___m_DragPositionOutOfBounds_49; }
inline bool* get_address_of_m_DragPositionOutOfBounds_49() { return &___m_DragPositionOutOfBounds_49; }
inline void set_m_DragPositionOutOfBounds_49(bool value)
{
___m_DragPositionOutOfBounds_49 = value;
}
inline static int32_t get_offset_of_m_CaretVisible_52() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_CaretVisible_52)); }
inline bool get_m_CaretVisible_52() const { return ___m_CaretVisible_52; }
inline bool* get_address_of_m_CaretVisible_52() { return &___m_CaretVisible_52; }
inline void set_m_CaretVisible_52(bool value)
{
___m_CaretVisible_52 = value;
}
inline static int32_t get_offset_of_m_BlinkCoroutine_53() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_BlinkCoroutine_53)); }
inline Coroutine_t3829159415 * get_m_BlinkCoroutine_53() const { return ___m_BlinkCoroutine_53; }
inline Coroutine_t3829159415 ** get_address_of_m_BlinkCoroutine_53() { return &___m_BlinkCoroutine_53; }
inline void set_m_BlinkCoroutine_53(Coroutine_t3829159415 * value)
{
___m_BlinkCoroutine_53 = value;
Il2CppCodeGenWriteBarrier((&___m_BlinkCoroutine_53), value);
}
inline static int32_t get_offset_of_m_BlinkStartTime_54() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_BlinkStartTime_54)); }
inline float get_m_BlinkStartTime_54() const { return ___m_BlinkStartTime_54; }
inline float* get_address_of_m_BlinkStartTime_54() { return &___m_BlinkStartTime_54; }
inline void set_m_BlinkStartTime_54(float value)
{
___m_BlinkStartTime_54 = value;
}
inline static int32_t get_offset_of_m_DrawStart_55() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_DrawStart_55)); }
inline int32_t get_m_DrawStart_55() const { return ___m_DrawStart_55; }
inline int32_t* get_address_of_m_DrawStart_55() { return &___m_DrawStart_55; }
inline void set_m_DrawStart_55(int32_t value)
{
___m_DrawStart_55 = value;
}
inline static int32_t get_offset_of_m_DrawEnd_56() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_DrawEnd_56)); }
inline int32_t get_m_DrawEnd_56() const { return ___m_DrawEnd_56; }
inline int32_t* get_address_of_m_DrawEnd_56() { return &___m_DrawEnd_56; }
inline void set_m_DrawEnd_56(int32_t value)
{
___m_DrawEnd_56 = value;
}
inline static int32_t get_offset_of_m_DragCoroutine_57() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_DragCoroutine_57)); }
inline Coroutine_t3829159415 * get_m_DragCoroutine_57() const { return ___m_DragCoroutine_57; }
inline Coroutine_t3829159415 ** get_address_of_m_DragCoroutine_57() { return &___m_DragCoroutine_57; }
inline void set_m_DragCoroutine_57(Coroutine_t3829159415 * value)
{
___m_DragCoroutine_57 = value;
Il2CppCodeGenWriteBarrier((&___m_DragCoroutine_57), value);
}
inline static int32_t get_offset_of_m_OriginalText_58() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_OriginalText_58)); }
inline String_t* get_m_OriginalText_58() const { return ___m_OriginalText_58; }
inline String_t** get_address_of_m_OriginalText_58() { return &___m_OriginalText_58; }
inline void set_m_OriginalText_58(String_t* value)
{
___m_OriginalText_58 = value;
Il2CppCodeGenWriteBarrier((&___m_OriginalText_58), value);
}
inline static int32_t get_offset_of_m_WasCanceled_59() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_WasCanceled_59)); }
inline bool get_m_WasCanceled_59() const { return ___m_WasCanceled_59; }
inline bool* get_address_of_m_WasCanceled_59() { return &___m_WasCanceled_59; }
inline void set_m_WasCanceled_59(bool value)
{
___m_WasCanceled_59 = value;
}
inline static int32_t get_offset_of_m_HasDoneFocusTransition_60() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_HasDoneFocusTransition_60)); }
inline bool get_m_HasDoneFocusTransition_60() const { return ___m_HasDoneFocusTransition_60; }
inline bool* get_address_of_m_HasDoneFocusTransition_60() { return &___m_HasDoneFocusTransition_60; }
inline void set_m_HasDoneFocusTransition_60(bool value)
{
___m_HasDoneFocusTransition_60 = value;
}
inline static int32_t get_offset_of_m_ProcessingEvent_62() { return static_cast<int32_t>(offsetof(InputField_t3762917431, ___m_ProcessingEvent_62)); }
inline Event_t2956885303 * get_m_ProcessingEvent_62() const { return ___m_ProcessingEvent_62; }
inline Event_t2956885303 ** get_address_of_m_ProcessingEvent_62() { return &___m_ProcessingEvent_62; }
inline void set_m_ProcessingEvent_62(Event_t2956885303 * value)
{
___m_ProcessingEvent_62 = value;
Il2CppCodeGenWriteBarrier((&___m_ProcessingEvent_62), value);
}
};
struct InputField_t3762917431_StaticFields
{
public:
// System.Char[] UnityEngine.UI.InputField::kSeparators
CharU5BU5D_t3528271667* ___kSeparators_17;
public:
inline static int32_t get_offset_of_kSeparators_17() { return static_cast<int32_t>(offsetof(InputField_t3762917431_StaticFields, ___kSeparators_17)); }
inline CharU5BU5D_t3528271667* get_kSeparators_17() const { return ___kSeparators_17; }
inline CharU5BU5D_t3528271667** get_address_of_kSeparators_17() { return &___kSeparators_17; }
inline void set_kSeparators_17(CharU5BU5D_t3528271667* value)
{
___kSeparators_17 = value;
Il2CppCodeGenWriteBarrier((&___kSeparators_17), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INPUTFIELD_T3762917431_H
#ifndef HORIZONTALORVERTICALLAYOUTGROUP_T729725570_H
#define HORIZONTALORVERTICALLAYOUTGROUP_T729725570_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.HorizontalOrVerticalLayoutGroup
struct HorizontalOrVerticalLayoutGroup_t729725570 : public LayoutGroup_t2436138090
{
public:
// System.Single UnityEngine.UI.HorizontalOrVerticalLayoutGroup::m_Spacing
float ___m_Spacing_10;
// System.Boolean UnityEngine.UI.HorizontalOrVerticalLayoutGroup::m_ChildForceExpandWidth
bool ___m_ChildForceExpandWidth_11;
// System.Boolean UnityEngine.UI.HorizontalOrVerticalLayoutGroup::m_ChildForceExpandHeight
bool ___m_ChildForceExpandHeight_12;
// System.Boolean UnityEngine.UI.HorizontalOrVerticalLayoutGroup::m_ChildControlWidth
bool ___m_ChildControlWidth_13;
// System.Boolean UnityEngine.UI.HorizontalOrVerticalLayoutGroup::m_ChildControlHeight
bool ___m_ChildControlHeight_14;
public:
inline static int32_t get_offset_of_m_Spacing_10() { return static_cast<int32_t>(offsetof(HorizontalOrVerticalLayoutGroup_t729725570, ___m_Spacing_10)); }
inline float get_m_Spacing_10() const { return ___m_Spacing_10; }
inline float* get_address_of_m_Spacing_10() { return &___m_Spacing_10; }
inline void set_m_Spacing_10(float value)
{
___m_Spacing_10 = value;
}
inline static int32_t get_offset_of_m_ChildForceExpandWidth_11() { return static_cast<int32_t>(offsetof(HorizontalOrVerticalLayoutGroup_t729725570, ___m_ChildForceExpandWidth_11)); }
inline bool get_m_ChildForceExpandWidth_11() const { return ___m_ChildForceExpandWidth_11; }
inline bool* get_address_of_m_ChildForceExpandWidth_11() { return &___m_ChildForceExpandWidth_11; }
inline void set_m_ChildForceExpandWidth_11(bool value)
{
___m_ChildForceExpandWidth_11 = value;
}
inline static int32_t get_offset_of_m_ChildForceExpandHeight_12() { return static_cast<int32_t>(offsetof(HorizontalOrVerticalLayoutGroup_t729725570, ___m_ChildForceExpandHeight_12)); }
inline bool get_m_ChildForceExpandHeight_12() const { return ___m_ChildForceExpandHeight_12; }
inline bool* get_address_of_m_ChildForceExpandHeight_12() { return &___m_ChildForceExpandHeight_12; }
inline void set_m_ChildForceExpandHeight_12(bool value)
{
___m_ChildForceExpandHeight_12 = value;
}
inline static int32_t get_offset_of_m_ChildControlWidth_13() { return static_cast<int32_t>(offsetof(HorizontalOrVerticalLayoutGroup_t729725570, ___m_ChildControlWidth_13)); }
inline bool get_m_ChildControlWidth_13() const { return ___m_ChildControlWidth_13; }
inline bool* get_address_of_m_ChildControlWidth_13() { return &___m_ChildControlWidth_13; }
inline void set_m_ChildControlWidth_13(bool value)
{
___m_ChildControlWidth_13 = value;
}
inline static int32_t get_offset_of_m_ChildControlHeight_14() { return static_cast<int32_t>(offsetof(HorizontalOrVerticalLayoutGroup_t729725570, ___m_ChildControlHeight_14)); }
inline bool get_m_ChildControlHeight_14() const { return ___m_ChildControlHeight_14; }
inline bool* get_address_of_m_ChildControlHeight_14() { return &___m_ChildControlHeight_14; }
inline void set_m_ChildControlHeight_14(bool value)
{
___m_ChildControlHeight_14 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // HORIZONTALORVERTICALLAYOUTGROUP_T729725570_H
#ifndef MASKABLEGRAPHIC_T3839221559_H
#define MASKABLEGRAPHIC_T3839221559_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.MaskableGraphic
struct MaskableGraphic_t3839221559 : public Graphic_t1660335611
{
public:
// System.Boolean UnityEngine.UI.MaskableGraphic::m_ShouldRecalculateStencil
bool ___m_ShouldRecalculateStencil_19;
// UnityEngine.Material UnityEngine.UI.MaskableGraphic::m_MaskMaterial
Material_t340375123 * ___m_MaskMaterial_20;
// UnityEngine.UI.RectMask2D UnityEngine.UI.MaskableGraphic::m_ParentMask
RectMask2D_t3474889437 * ___m_ParentMask_21;
// System.Boolean UnityEngine.UI.MaskableGraphic::m_Maskable
bool ___m_Maskable_22;
// System.Boolean UnityEngine.UI.MaskableGraphic::m_IncludeForMasking
bool ___m_IncludeForMasking_23;
// UnityEngine.UI.MaskableGraphic/CullStateChangedEvent UnityEngine.UI.MaskableGraphic::m_OnCullStateChanged
CullStateChangedEvent_t3661388177 * ___m_OnCullStateChanged_24;
// System.Boolean UnityEngine.UI.MaskableGraphic::m_ShouldRecalculate
bool ___m_ShouldRecalculate_25;
// System.Int32 UnityEngine.UI.MaskableGraphic::m_StencilValue
int32_t ___m_StencilValue_26;
// UnityEngine.Vector3[] UnityEngine.UI.MaskableGraphic::m_Corners
Vector3U5BU5D_t1718750761* ___m_Corners_27;
public:
inline static int32_t get_offset_of_m_ShouldRecalculateStencil_19() { return static_cast<int32_t>(offsetof(MaskableGraphic_t3839221559, ___m_ShouldRecalculateStencil_19)); }
inline bool get_m_ShouldRecalculateStencil_19() const { return ___m_ShouldRecalculateStencil_19; }
inline bool* get_address_of_m_ShouldRecalculateStencil_19() { return &___m_ShouldRecalculateStencil_19; }
inline void set_m_ShouldRecalculateStencil_19(bool value)
{
___m_ShouldRecalculateStencil_19 = value;
}
inline static int32_t get_offset_of_m_MaskMaterial_20() { return static_cast<int32_t>(offsetof(MaskableGraphic_t3839221559, ___m_MaskMaterial_20)); }
inline Material_t340375123 * get_m_MaskMaterial_20() const { return ___m_MaskMaterial_20; }
inline Material_t340375123 ** get_address_of_m_MaskMaterial_20() { return &___m_MaskMaterial_20; }
inline void set_m_MaskMaterial_20(Material_t340375123 * value)
{
___m_MaskMaterial_20 = value;
Il2CppCodeGenWriteBarrier((&___m_MaskMaterial_20), value);
}
inline static int32_t get_offset_of_m_ParentMask_21() { return static_cast<int32_t>(offsetof(MaskableGraphic_t3839221559, ___m_ParentMask_21)); }
inline RectMask2D_t3474889437 * get_m_ParentMask_21() const { return ___m_ParentMask_21; }
inline RectMask2D_t3474889437 ** get_address_of_m_ParentMask_21() { return &___m_ParentMask_21; }
inline void set_m_ParentMask_21(RectMask2D_t3474889437 * value)
{
___m_ParentMask_21 = value;
Il2CppCodeGenWriteBarrier((&___m_ParentMask_21), value);
}
inline static int32_t get_offset_of_m_Maskable_22() { return static_cast<int32_t>(offsetof(MaskableGraphic_t3839221559, ___m_Maskable_22)); }
inline bool get_m_Maskable_22() const { return ___m_Maskable_22; }
inline bool* get_address_of_m_Maskable_22() { return &___m_Maskable_22; }
inline void set_m_Maskable_22(bool value)
{
___m_Maskable_22 = value;
}
inline static int32_t get_offset_of_m_IncludeForMasking_23() { return static_cast<int32_t>(offsetof(MaskableGraphic_t3839221559, ___m_IncludeForMasking_23)); }
inline bool get_m_IncludeForMasking_23() const { return ___m_IncludeForMasking_23; }
inline bool* get_address_of_m_IncludeForMasking_23() { return &___m_IncludeForMasking_23; }
inline void set_m_IncludeForMasking_23(bool value)
{
___m_IncludeForMasking_23 = value;
}
inline static int32_t get_offset_of_m_OnCullStateChanged_24() { return static_cast<int32_t>(offsetof(MaskableGraphic_t3839221559, ___m_OnCullStateChanged_24)); }
inline CullStateChangedEvent_t3661388177 * get_m_OnCullStateChanged_24() const { return ___m_OnCullStateChanged_24; }
inline CullStateChangedEvent_t3661388177 ** get_address_of_m_OnCullStateChanged_24() { return &___m_OnCullStateChanged_24; }
inline void set_m_OnCullStateChanged_24(CullStateChangedEvent_t3661388177 * value)
{
___m_OnCullStateChanged_24 = value;
Il2CppCodeGenWriteBarrier((&___m_OnCullStateChanged_24), value);
}
inline static int32_t get_offset_of_m_ShouldRecalculate_25() { return static_cast<int32_t>(offsetof(MaskableGraphic_t3839221559, ___m_ShouldRecalculate_25)); }
inline bool get_m_ShouldRecalculate_25() const { return ___m_ShouldRecalculate_25; }
inline bool* get_address_of_m_ShouldRecalculate_25() { return &___m_ShouldRecalculate_25; }
inline void set_m_ShouldRecalculate_25(bool value)
{
___m_ShouldRecalculate_25 = value;
}
inline static int32_t get_offset_of_m_StencilValue_26() { return static_cast<int32_t>(offsetof(MaskableGraphic_t3839221559, ___m_StencilValue_26)); }
inline int32_t get_m_StencilValue_26() const { return ___m_StencilValue_26; }
inline int32_t* get_address_of_m_StencilValue_26() { return &___m_StencilValue_26; }
inline void set_m_StencilValue_26(int32_t value)
{
___m_StencilValue_26 = value;
}
inline static int32_t get_offset_of_m_Corners_27() { return static_cast<int32_t>(offsetof(MaskableGraphic_t3839221559, ___m_Corners_27)); }
inline Vector3U5BU5D_t1718750761* get_m_Corners_27() const { return ___m_Corners_27; }
inline Vector3U5BU5D_t1718750761** get_address_of_m_Corners_27() { return &___m_Corners_27; }
inline void set_m_Corners_27(Vector3U5BU5D_t1718750761* value)
{
___m_Corners_27 = value;
Il2CppCodeGenWriteBarrier((&___m_Corners_27), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // MASKABLEGRAPHIC_T3839221559_H
#ifndef SCROLLBAR_T1494447233_H
#define SCROLLBAR_T1494447233_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Scrollbar
struct Scrollbar_t1494447233 : public Selectable_t3250028441
{
public:
// UnityEngine.RectTransform UnityEngine.UI.Scrollbar::m_HandleRect
RectTransform_t3704657025 * ___m_HandleRect_16;
// UnityEngine.UI.Scrollbar/Direction UnityEngine.UI.Scrollbar::m_Direction
int32_t ___m_Direction_17;
// System.Single UnityEngine.UI.Scrollbar::m_Value
float ___m_Value_18;
// System.Single UnityEngine.UI.Scrollbar::m_Size
float ___m_Size_19;
// System.Int32 UnityEngine.UI.Scrollbar::m_NumberOfSteps
int32_t ___m_NumberOfSteps_20;
// UnityEngine.UI.Scrollbar/ScrollEvent UnityEngine.UI.Scrollbar::m_OnValueChanged
ScrollEvent_t149898510 * ___m_OnValueChanged_21;
// UnityEngine.RectTransform UnityEngine.UI.Scrollbar::m_ContainerRect
RectTransform_t3704657025 * ___m_ContainerRect_22;
// UnityEngine.Vector2 UnityEngine.UI.Scrollbar::m_Offset
Vector2_t2156229523 ___m_Offset_23;
// UnityEngine.DrivenRectTransformTracker UnityEngine.UI.Scrollbar::m_Tracker
DrivenRectTransformTracker_t2562230146 ___m_Tracker_24;
// UnityEngine.Coroutine UnityEngine.UI.Scrollbar::m_PointerDownRepeat
Coroutine_t3829159415 * ___m_PointerDownRepeat_25;
// System.Boolean UnityEngine.UI.Scrollbar::isPointerDownAndNotDragging
bool ___isPointerDownAndNotDragging_26;
public:
inline static int32_t get_offset_of_m_HandleRect_16() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_HandleRect_16)); }
inline RectTransform_t3704657025 * get_m_HandleRect_16() const { return ___m_HandleRect_16; }
inline RectTransform_t3704657025 ** get_address_of_m_HandleRect_16() { return &___m_HandleRect_16; }
inline void set_m_HandleRect_16(RectTransform_t3704657025 * value)
{
___m_HandleRect_16 = value;
Il2CppCodeGenWriteBarrier((&___m_HandleRect_16), value);
}
inline static int32_t get_offset_of_m_Direction_17() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_Direction_17)); }
inline int32_t get_m_Direction_17() const { return ___m_Direction_17; }
inline int32_t* get_address_of_m_Direction_17() { return &___m_Direction_17; }
inline void set_m_Direction_17(int32_t value)
{
___m_Direction_17 = value;
}
inline static int32_t get_offset_of_m_Value_18() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_Value_18)); }
inline float get_m_Value_18() const { return ___m_Value_18; }
inline float* get_address_of_m_Value_18() { return &___m_Value_18; }
inline void set_m_Value_18(float value)
{
___m_Value_18 = value;
}
inline static int32_t get_offset_of_m_Size_19() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_Size_19)); }
inline float get_m_Size_19() const { return ___m_Size_19; }
inline float* get_address_of_m_Size_19() { return &___m_Size_19; }
inline void set_m_Size_19(float value)
{
___m_Size_19 = value;
}
inline static int32_t get_offset_of_m_NumberOfSteps_20() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_NumberOfSteps_20)); }
inline int32_t get_m_NumberOfSteps_20() const { return ___m_NumberOfSteps_20; }
inline int32_t* get_address_of_m_NumberOfSteps_20() { return &___m_NumberOfSteps_20; }
inline void set_m_NumberOfSteps_20(int32_t value)
{
___m_NumberOfSteps_20 = value;
}
inline static int32_t get_offset_of_m_OnValueChanged_21() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_OnValueChanged_21)); }
inline ScrollEvent_t149898510 * get_m_OnValueChanged_21() const { return ___m_OnValueChanged_21; }
inline ScrollEvent_t149898510 ** get_address_of_m_OnValueChanged_21() { return &___m_OnValueChanged_21; }
inline void set_m_OnValueChanged_21(ScrollEvent_t149898510 * value)
{
___m_OnValueChanged_21 = value;
Il2CppCodeGenWriteBarrier((&___m_OnValueChanged_21), value);
}
inline static int32_t get_offset_of_m_ContainerRect_22() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_ContainerRect_22)); }
inline RectTransform_t3704657025 * get_m_ContainerRect_22() const { return ___m_ContainerRect_22; }
inline RectTransform_t3704657025 ** get_address_of_m_ContainerRect_22() { return &___m_ContainerRect_22; }
inline void set_m_ContainerRect_22(RectTransform_t3704657025 * value)
{
___m_ContainerRect_22 = value;
Il2CppCodeGenWriteBarrier((&___m_ContainerRect_22), value);
}
inline static int32_t get_offset_of_m_Offset_23() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_Offset_23)); }
inline Vector2_t2156229523 get_m_Offset_23() const { return ___m_Offset_23; }
inline Vector2_t2156229523 * get_address_of_m_Offset_23() { return &___m_Offset_23; }
inline void set_m_Offset_23(Vector2_t2156229523 value)
{
___m_Offset_23 = value;
}
inline static int32_t get_offset_of_m_Tracker_24() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_Tracker_24)); }
inline DrivenRectTransformTracker_t2562230146 get_m_Tracker_24() const { return ___m_Tracker_24; }
inline DrivenRectTransformTracker_t2562230146 * get_address_of_m_Tracker_24() { return &___m_Tracker_24; }
inline void set_m_Tracker_24(DrivenRectTransformTracker_t2562230146 value)
{
___m_Tracker_24 = value;
}
inline static int32_t get_offset_of_m_PointerDownRepeat_25() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___m_PointerDownRepeat_25)); }
inline Coroutine_t3829159415 * get_m_PointerDownRepeat_25() const { return ___m_PointerDownRepeat_25; }
inline Coroutine_t3829159415 ** get_address_of_m_PointerDownRepeat_25() { return &___m_PointerDownRepeat_25; }
inline void set_m_PointerDownRepeat_25(Coroutine_t3829159415 * value)
{
___m_PointerDownRepeat_25 = value;
Il2CppCodeGenWriteBarrier((&___m_PointerDownRepeat_25), value);
}
inline static int32_t get_offset_of_isPointerDownAndNotDragging_26() { return static_cast<int32_t>(offsetof(Scrollbar_t1494447233, ___isPointerDownAndNotDragging_26)); }
inline bool get_isPointerDownAndNotDragging_26() const { return ___isPointerDownAndNotDragging_26; }
inline bool* get_address_of_isPointerDownAndNotDragging_26() { return &___isPointerDownAndNotDragging_26; }
inline void set_isPointerDownAndNotDragging_26(bool value)
{
___isPointerDownAndNotDragging_26 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SCROLLBAR_T1494447233_H
#ifndef GRAPHICRAYCASTER_T2999697109_H
#define GRAPHICRAYCASTER_T2999697109_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.GraphicRaycaster
struct GraphicRaycaster_t2999697109 : public BaseRaycaster_t4150874583
{
public:
// System.Boolean UnityEngine.UI.GraphicRaycaster::m_IgnoreReversedGraphics
bool ___m_IgnoreReversedGraphics_3;
// UnityEngine.UI.GraphicRaycaster/BlockingObjects UnityEngine.UI.GraphicRaycaster::m_BlockingObjects
int32_t ___m_BlockingObjects_4;
// UnityEngine.LayerMask UnityEngine.UI.GraphicRaycaster::m_BlockingMask
LayerMask_t3493934918 ___m_BlockingMask_5;
// UnityEngine.Canvas UnityEngine.UI.GraphicRaycaster::m_Canvas
Canvas_t3310196443 * ___m_Canvas_6;
// System.Collections.Generic.List`1<UnityEngine.UI.Graphic> UnityEngine.UI.GraphicRaycaster::m_RaycastResults
List_1_t3132410353 * ___m_RaycastResults_7;
public:
inline static int32_t get_offset_of_m_IgnoreReversedGraphics_3() { return static_cast<int32_t>(offsetof(GraphicRaycaster_t2999697109, ___m_IgnoreReversedGraphics_3)); }
inline bool get_m_IgnoreReversedGraphics_3() const { return ___m_IgnoreReversedGraphics_3; }
inline bool* get_address_of_m_IgnoreReversedGraphics_3() { return &___m_IgnoreReversedGraphics_3; }
inline void set_m_IgnoreReversedGraphics_3(bool value)
{
___m_IgnoreReversedGraphics_3 = value;
}
inline static int32_t get_offset_of_m_BlockingObjects_4() { return static_cast<int32_t>(offsetof(GraphicRaycaster_t2999697109, ___m_BlockingObjects_4)); }
inline int32_t get_m_BlockingObjects_4() const { return ___m_BlockingObjects_4; }
inline int32_t* get_address_of_m_BlockingObjects_4() { return &___m_BlockingObjects_4; }
inline void set_m_BlockingObjects_4(int32_t value)
{
___m_BlockingObjects_4 = value;
}
inline static int32_t get_offset_of_m_BlockingMask_5() { return static_cast<int32_t>(offsetof(GraphicRaycaster_t2999697109, ___m_BlockingMask_5)); }
inline LayerMask_t3493934918 get_m_BlockingMask_5() const { return ___m_BlockingMask_5; }
inline LayerMask_t3493934918 * get_address_of_m_BlockingMask_5() { return &___m_BlockingMask_5; }
inline void set_m_BlockingMask_5(LayerMask_t3493934918 value)
{
___m_BlockingMask_5 = value;
}
inline static int32_t get_offset_of_m_Canvas_6() { return static_cast<int32_t>(offsetof(GraphicRaycaster_t2999697109, ___m_Canvas_6)); }
inline Canvas_t3310196443 * get_m_Canvas_6() const { return ___m_Canvas_6; }
inline Canvas_t3310196443 ** get_address_of_m_Canvas_6() { return &___m_Canvas_6; }
inline void set_m_Canvas_6(Canvas_t3310196443 * value)
{
___m_Canvas_6 = value;
Il2CppCodeGenWriteBarrier((&___m_Canvas_6), value);
}
inline static int32_t get_offset_of_m_RaycastResults_7() { return static_cast<int32_t>(offsetof(GraphicRaycaster_t2999697109, ___m_RaycastResults_7)); }
inline List_1_t3132410353 * get_m_RaycastResults_7() const { return ___m_RaycastResults_7; }
inline List_1_t3132410353 ** get_address_of_m_RaycastResults_7() { return &___m_RaycastResults_7; }
inline void set_m_RaycastResults_7(List_1_t3132410353 * value)
{
___m_RaycastResults_7 = value;
Il2CppCodeGenWriteBarrier((&___m_RaycastResults_7), value);
}
};
struct GraphicRaycaster_t2999697109_StaticFields
{
public:
// System.Collections.Generic.List`1<UnityEngine.UI.Graphic> UnityEngine.UI.GraphicRaycaster::s_SortedGraphics
List_1_t3132410353 * ___s_SortedGraphics_8;
// System.Comparison`1<UnityEngine.UI.Graphic> UnityEngine.UI.GraphicRaycaster::<>f__am$cache0
Comparison_1_t1435266790 * ___U3CU3Ef__amU24cache0_9;
public:
inline static int32_t get_offset_of_s_SortedGraphics_8() { return static_cast<int32_t>(offsetof(GraphicRaycaster_t2999697109_StaticFields, ___s_SortedGraphics_8)); }
inline List_1_t3132410353 * get_s_SortedGraphics_8() const { return ___s_SortedGraphics_8; }
inline List_1_t3132410353 ** get_address_of_s_SortedGraphics_8() { return &___s_SortedGraphics_8; }
inline void set_s_SortedGraphics_8(List_1_t3132410353 * value)
{
___s_SortedGraphics_8 = value;
Il2CppCodeGenWriteBarrier((&___s_SortedGraphics_8), value);
}
inline static int32_t get_offset_of_U3CU3Ef__amU24cache0_9() { return static_cast<int32_t>(offsetof(GraphicRaycaster_t2999697109_StaticFields, ___U3CU3Ef__amU24cache0_9)); }
inline Comparison_1_t1435266790 * get_U3CU3Ef__amU24cache0_9() const { return ___U3CU3Ef__amU24cache0_9; }
inline Comparison_1_t1435266790 ** get_address_of_U3CU3Ef__amU24cache0_9() { return &___U3CU3Ef__amU24cache0_9; }
inline void set_U3CU3Ef__amU24cache0_9(Comparison_1_t1435266790 * value)
{
___U3CU3Ef__amU24cache0_9 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__amU24cache0_9), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // GRAPHICRAYCASTER_T2999697109_H
#ifndef TOGGLE_T2735377061_H
#define TOGGLE_T2735377061_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Toggle
struct Toggle_t2735377061 : public Selectable_t3250028441
{
public:
// UnityEngine.UI.Toggle/ToggleTransition UnityEngine.UI.Toggle::toggleTransition
int32_t ___toggleTransition_16;
// UnityEngine.UI.Graphic UnityEngine.UI.Toggle::graphic
Graphic_t1660335611 * ___graphic_17;
// UnityEngine.UI.ToggleGroup UnityEngine.UI.Toggle::m_Group
ToggleGroup_t123837990 * ___m_Group_18;
// UnityEngine.UI.Toggle/ToggleEvent UnityEngine.UI.Toggle::onValueChanged
ToggleEvent_t1873685584 * ___onValueChanged_19;
// System.Boolean UnityEngine.UI.Toggle::m_IsOn
bool ___m_IsOn_20;
public:
inline static int32_t get_offset_of_toggleTransition_16() { return static_cast<int32_t>(offsetof(Toggle_t2735377061, ___toggleTransition_16)); }
inline int32_t get_toggleTransition_16() const { return ___toggleTransition_16; }
inline int32_t* get_address_of_toggleTransition_16() { return &___toggleTransition_16; }
inline void set_toggleTransition_16(int32_t value)
{
___toggleTransition_16 = value;
}
inline static int32_t get_offset_of_graphic_17() { return static_cast<int32_t>(offsetof(Toggle_t2735377061, ___graphic_17)); }
inline Graphic_t1660335611 * get_graphic_17() const { return ___graphic_17; }
inline Graphic_t1660335611 ** get_address_of_graphic_17() { return &___graphic_17; }
inline void set_graphic_17(Graphic_t1660335611 * value)
{
___graphic_17 = value;
Il2CppCodeGenWriteBarrier((&___graphic_17), value);
}
inline static int32_t get_offset_of_m_Group_18() { return static_cast<int32_t>(offsetof(Toggle_t2735377061, ___m_Group_18)); }
inline ToggleGroup_t123837990 * get_m_Group_18() const { return ___m_Group_18; }
inline ToggleGroup_t123837990 ** get_address_of_m_Group_18() { return &___m_Group_18; }
inline void set_m_Group_18(ToggleGroup_t123837990 * value)
{
___m_Group_18 = value;
Il2CppCodeGenWriteBarrier((&___m_Group_18), value);
}
inline static int32_t get_offset_of_onValueChanged_19() { return static_cast<int32_t>(offsetof(Toggle_t2735377061, ___onValueChanged_19)); }
inline ToggleEvent_t1873685584 * get_onValueChanged_19() const { return ___onValueChanged_19; }
inline ToggleEvent_t1873685584 ** get_address_of_onValueChanged_19() { return &___onValueChanged_19; }
inline void set_onValueChanged_19(ToggleEvent_t1873685584 * value)
{
___onValueChanged_19 = value;
Il2CppCodeGenWriteBarrier((&___onValueChanged_19), value);
}
inline static int32_t get_offset_of_m_IsOn_20() { return static_cast<int32_t>(offsetof(Toggle_t2735377061, ___m_IsOn_20)); }
inline bool get_m_IsOn_20() const { return ___m_IsOn_20; }
inline bool* get_address_of_m_IsOn_20() { return &___m_IsOn_20; }
inline void set_m_IsOn_20(bool value)
{
___m_IsOn_20 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TOGGLE_T2735377061_H
#ifndef TEXT_T1901882714_H
#define TEXT_T1901882714_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Text
struct Text_t1901882714 : public MaskableGraphic_t3839221559
{
public:
// UnityEngine.UI.FontData UnityEngine.UI.Text::m_FontData
FontData_t746620069 * ___m_FontData_28;
// System.String UnityEngine.UI.Text::m_Text
String_t* ___m_Text_29;
// UnityEngine.TextGenerator UnityEngine.UI.Text::m_TextCache
TextGenerator_t3211863866 * ___m_TextCache_30;
// UnityEngine.TextGenerator UnityEngine.UI.Text::m_TextCacheForLayout
TextGenerator_t3211863866 * ___m_TextCacheForLayout_31;
// System.Boolean UnityEngine.UI.Text::m_DisableFontTextureRebuiltCallback
bool ___m_DisableFontTextureRebuiltCallback_33;
// UnityEngine.UIVertex[] UnityEngine.UI.Text::m_TempVerts
UIVertexU5BU5D_t1981460040* ___m_TempVerts_34;
public:
inline static int32_t get_offset_of_m_FontData_28() { return static_cast<int32_t>(offsetof(Text_t1901882714, ___m_FontData_28)); }
inline FontData_t746620069 * get_m_FontData_28() const { return ___m_FontData_28; }
inline FontData_t746620069 ** get_address_of_m_FontData_28() { return &___m_FontData_28; }
inline void set_m_FontData_28(FontData_t746620069 * value)
{
___m_FontData_28 = value;
Il2CppCodeGenWriteBarrier((&___m_FontData_28), value);
}
inline static int32_t get_offset_of_m_Text_29() { return static_cast<int32_t>(offsetof(Text_t1901882714, ___m_Text_29)); }
inline String_t* get_m_Text_29() const { return ___m_Text_29; }
inline String_t** get_address_of_m_Text_29() { return &___m_Text_29; }
inline void set_m_Text_29(String_t* value)
{
___m_Text_29 = value;
Il2CppCodeGenWriteBarrier((&___m_Text_29), value);
}
inline static int32_t get_offset_of_m_TextCache_30() { return static_cast<int32_t>(offsetof(Text_t1901882714, ___m_TextCache_30)); }
inline TextGenerator_t3211863866 * get_m_TextCache_30() const { return ___m_TextCache_30; }
inline TextGenerator_t3211863866 ** get_address_of_m_TextCache_30() { return &___m_TextCache_30; }
inline void set_m_TextCache_30(TextGenerator_t3211863866 * value)
{
___m_TextCache_30 = value;
Il2CppCodeGenWriteBarrier((&___m_TextCache_30), value);
}
inline static int32_t get_offset_of_m_TextCacheForLayout_31() { return static_cast<int32_t>(offsetof(Text_t1901882714, ___m_TextCacheForLayout_31)); }
inline TextGenerator_t3211863866 * get_m_TextCacheForLayout_31() const { return ___m_TextCacheForLayout_31; }
inline TextGenerator_t3211863866 ** get_address_of_m_TextCacheForLayout_31() { return &___m_TextCacheForLayout_31; }
inline void set_m_TextCacheForLayout_31(TextGenerator_t3211863866 * value)
{
___m_TextCacheForLayout_31 = value;
Il2CppCodeGenWriteBarrier((&___m_TextCacheForLayout_31), value);
}
inline static int32_t get_offset_of_m_DisableFontTextureRebuiltCallback_33() { return static_cast<int32_t>(offsetof(Text_t1901882714, ___m_DisableFontTextureRebuiltCallback_33)); }
inline bool get_m_DisableFontTextureRebuiltCallback_33() const { return ___m_DisableFontTextureRebuiltCallback_33; }
inline bool* get_address_of_m_DisableFontTextureRebuiltCallback_33() { return &___m_DisableFontTextureRebuiltCallback_33; }
inline void set_m_DisableFontTextureRebuiltCallback_33(bool value)
{
___m_DisableFontTextureRebuiltCallback_33 = value;
}
inline static int32_t get_offset_of_m_TempVerts_34() { return static_cast<int32_t>(offsetof(Text_t1901882714, ___m_TempVerts_34)); }
inline UIVertexU5BU5D_t1981460040* get_m_TempVerts_34() const { return ___m_TempVerts_34; }
inline UIVertexU5BU5D_t1981460040** get_address_of_m_TempVerts_34() { return &___m_TempVerts_34; }
inline void set_m_TempVerts_34(UIVertexU5BU5D_t1981460040* value)
{
___m_TempVerts_34 = value;
Il2CppCodeGenWriteBarrier((&___m_TempVerts_34), value);
}
};
struct Text_t1901882714_StaticFields
{
public:
// UnityEngine.Material UnityEngine.UI.Text::s_DefaultText
Material_t340375123 * ___s_DefaultText_32;
public:
inline static int32_t get_offset_of_s_DefaultText_32() { return static_cast<int32_t>(offsetof(Text_t1901882714_StaticFields, ___s_DefaultText_32)); }
inline Material_t340375123 * get_s_DefaultText_32() const { return ___s_DefaultText_32; }
inline Material_t340375123 ** get_address_of_s_DefaultText_32() { return &___s_DefaultText_32; }
inline void set_s_DefaultText_32(Material_t340375123 * value)
{
___s_DefaultText_32 = value;
Il2CppCodeGenWriteBarrier((&___s_DefaultText_32), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TEXT_T1901882714_H
#ifndef HORIZONTALLAYOUTGROUP_T2586782146_H
#define HORIZONTALLAYOUTGROUP_T2586782146_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.HorizontalLayoutGroup
struct HorizontalLayoutGroup_t2586782146 : public HorizontalOrVerticalLayoutGroup_t729725570
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // HORIZONTALLAYOUTGROUP_T2586782146_H
#ifndef IMAGE_T2670269651_H
#define IMAGE_T2670269651_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.Image
struct Image_t2670269651 : public MaskableGraphic_t3839221559
{
public:
// UnityEngine.Sprite UnityEngine.UI.Image::m_Sprite
Sprite_t280657092 * ___m_Sprite_29;
// UnityEngine.Sprite UnityEngine.UI.Image::m_OverrideSprite
Sprite_t280657092 * ___m_OverrideSprite_30;
// UnityEngine.UI.Image/Type UnityEngine.UI.Image::m_Type
int32_t ___m_Type_31;
// System.Boolean UnityEngine.UI.Image::m_PreserveAspect
bool ___m_PreserveAspect_32;
// System.Boolean UnityEngine.UI.Image::m_FillCenter
bool ___m_FillCenter_33;
// UnityEngine.UI.Image/FillMethod UnityEngine.UI.Image::m_FillMethod
int32_t ___m_FillMethod_34;
// System.Single UnityEngine.UI.Image::m_FillAmount
float ___m_FillAmount_35;
// System.Boolean UnityEngine.UI.Image::m_FillClockwise
bool ___m_FillClockwise_36;
// System.Int32 UnityEngine.UI.Image::m_FillOrigin
int32_t ___m_FillOrigin_37;
// System.Single UnityEngine.UI.Image::m_AlphaHitTestMinimumThreshold
float ___m_AlphaHitTestMinimumThreshold_38;
// System.Boolean UnityEngine.UI.Image::m_Tracked
bool ___m_Tracked_39;
public:
inline static int32_t get_offset_of_m_Sprite_29() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_Sprite_29)); }
inline Sprite_t280657092 * get_m_Sprite_29() const { return ___m_Sprite_29; }
inline Sprite_t280657092 ** get_address_of_m_Sprite_29() { return &___m_Sprite_29; }
inline void set_m_Sprite_29(Sprite_t280657092 * value)
{
___m_Sprite_29 = value;
Il2CppCodeGenWriteBarrier((&___m_Sprite_29), value);
}
inline static int32_t get_offset_of_m_OverrideSprite_30() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_OverrideSprite_30)); }
inline Sprite_t280657092 * get_m_OverrideSprite_30() const { return ___m_OverrideSprite_30; }
inline Sprite_t280657092 ** get_address_of_m_OverrideSprite_30() { return &___m_OverrideSprite_30; }
inline void set_m_OverrideSprite_30(Sprite_t280657092 * value)
{
___m_OverrideSprite_30 = value;
Il2CppCodeGenWriteBarrier((&___m_OverrideSprite_30), value);
}
inline static int32_t get_offset_of_m_Type_31() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_Type_31)); }
inline int32_t get_m_Type_31() const { return ___m_Type_31; }
inline int32_t* get_address_of_m_Type_31() { return &___m_Type_31; }
inline void set_m_Type_31(int32_t value)
{
___m_Type_31 = value;
}
inline static int32_t get_offset_of_m_PreserveAspect_32() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_PreserveAspect_32)); }
inline bool get_m_PreserveAspect_32() const { return ___m_PreserveAspect_32; }
inline bool* get_address_of_m_PreserveAspect_32() { return &___m_PreserveAspect_32; }
inline void set_m_PreserveAspect_32(bool value)
{
___m_PreserveAspect_32 = value;
}
inline static int32_t get_offset_of_m_FillCenter_33() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_FillCenter_33)); }
inline bool get_m_FillCenter_33() const { return ___m_FillCenter_33; }
inline bool* get_address_of_m_FillCenter_33() { return &___m_FillCenter_33; }
inline void set_m_FillCenter_33(bool value)
{
___m_FillCenter_33 = value;
}
inline static int32_t get_offset_of_m_FillMethod_34() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_FillMethod_34)); }
inline int32_t get_m_FillMethod_34() const { return ___m_FillMethod_34; }
inline int32_t* get_address_of_m_FillMethod_34() { return &___m_FillMethod_34; }
inline void set_m_FillMethod_34(int32_t value)
{
___m_FillMethod_34 = value;
}
inline static int32_t get_offset_of_m_FillAmount_35() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_FillAmount_35)); }
inline float get_m_FillAmount_35() const { return ___m_FillAmount_35; }
inline float* get_address_of_m_FillAmount_35() { return &___m_FillAmount_35; }
inline void set_m_FillAmount_35(float value)
{
___m_FillAmount_35 = value;
}
inline static int32_t get_offset_of_m_FillClockwise_36() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_FillClockwise_36)); }
inline bool get_m_FillClockwise_36() const { return ___m_FillClockwise_36; }
inline bool* get_address_of_m_FillClockwise_36() { return &___m_FillClockwise_36; }
inline void set_m_FillClockwise_36(bool value)
{
___m_FillClockwise_36 = value;
}
inline static int32_t get_offset_of_m_FillOrigin_37() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_FillOrigin_37)); }
inline int32_t get_m_FillOrigin_37() const { return ___m_FillOrigin_37; }
inline int32_t* get_address_of_m_FillOrigin_37() { return &___m_FillOrigin_37; }
inline void set_m_FillOrigin_37(int32_t value)
{
___m_FillOrigin_37 = value;
}
inline static int32_t get_offset_of_m_AlphaHitTestMinimumThreshold_38() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_AlphaHitTestMinimumThreshold_38)); }
inline float get_m_AlphaHitTestMinimumThreshold_38() const { return ___m_AlphaHitTestMinimumThreshold_38; }
inline float* get_address_of_m_AlphaHitTestMinimumThreshold_38() { return &___m_AlphaHitTestMinimumThreshold_38; }
inline void set_m_AlphaHitTestMinimumThreshold_38(float value)
{
___m_AlphaHitTestMinimumThreshold_38 = value;
}
inline static int32_t get_offset_of_m_Tracked_39() { return static_cast<int32_t>(offsetof(Image_t2670269651, ___m_Tracked_39)); }
inline bool get_m_Tracked_39() const { return ___m_Tracked_39; }
inline bool* get_address_of_m_Tracked_39() { return &___m_Tracked_39; }
inline void set_m_Tracked_39(bool value)
{
___m_Tracked_39 = value;
}
};
struct Image_t2670269651_StaticFields
{
public:
// UnityEngine.Material UnityEngine.UI.Image::s_ETC1DefaultUI
Material_t340375123 * ___s_ETC1DefaultUI_28;
// UnityEngine.Vector2[] UnityEngine.UI.Image::s_VertScratch
Vector2U5BU5D_t1457185986* ___s_VertScratch_40;
// UnityEngine.Vector2[] UnityEngine.UI.Image::s_UVScratch
Vector2U5BU5D_t1457185986* ___s_UVScratch_41;
// UnityEngine.Vector3[] UnityEngine.UI.Image::s_Xy
Vector3U5BU5D_t1718750761* ___s_Xy_42;
// UnityEngine.Vector3[] UnityEngine.UI.Image::s_Uv
Vector3U5BU5D_t1718750761* ___s_Uv_43;
// System.Collections.Generic.List`1<UnityEngine.UI.Image> UnityEngine.UI.Image::m_TrackedTexturelessImages
List_1_t4142344393 * ___m_TrackedTexturelessImages_44;
// System.Boolean UnityEngine.UI.Image::s_Initialized
bool ___s_Initialized_45;
// System.Action`1<UnityEngine.U2D.SpriteAtlas> UnityEngine.UI.Image::<>f__mg$cache0
Action_1_t819399007 * ___U3CU3Ef__mgU24cache0_46;
public:
inline static int32_t get_offset_of_s_ETC1DefaultUI_28() { return static_cast<int32_t>(offsetof(Image_t2670269651_StaticFields, ___s_ETC1DefaultUI_28)); }
inline Material_t340375123 * get_s_ETC1DefaultUI_28() const { return ___s_ETC1DefaultUI_28; }
inline Material_t340375123 ** get_address_of_s_ETC1DefaultUI_28() { return &___s_ETC1DefaultUI_28; }
inline void set_s_ETC1DefaultUI_28(Material_t340375123 * value)
{
___s_ETC1DefaultUI_28 = value;
Il2CppCodeGenWriteBarrier((&___s_ETC1DefaultUI_28), value);
}
inline static int32_t get_offset_of_s_VertScratch_40() { return static_cast<int32_t>(offsetof(Image_t2670269651_StaticFields, ___s_VertScratch_40)); }
inline Vector2U5BU5D_t1457185986* get_s_VertScratch_40() const { return ___s_VertScratch_40; }
inline Vector2U5BU5D_t1457185986** get_address_of_s_VertScratch_40() { return &___s_VertScratch_40; }
inline void set_s_VertScratch_40(Vector2U5BU5D_t1457185986* value)
{
___s_VertScratch_40 = value;
Il2CppCodeGenWriteBarrier((&___s_VertScratch_40), value);
}
inline static int32_t get_offset_of_s_UVScratch_41() { return static_cast<int32_t>(offsetof(Image_t2670269651_StaticFields, ___s_UVScratch_41)); }
inline Vector2U5BU5D_t1457185986* get_s_UVScratch_41() const { return ___s_UVScratch_41; }
inline Vector2U5BU5D_t1457185986** get_address_of_s_UVScratch_41() { return &___s_UVScratch_41; }
inline void set_s_UVScratch_41(Vector2U5BU5D_t1457185986* value)
{
___s_UVScratch_41 = value;
Il2CppCodeGenWriteBarrier((&___s_UVScratch_41), value);
}
inline static int32_t get_offset_of_s_Xy_42() { return static_cast<int32_t>(offsetof(Image_t2670269651_StaticFields, ___s_Xy_42)); }
inline Vector3U5BU5D_t1718750761* get_s_Xy_42() const { return ___s_Xy_42; }
inline Vector3U5BU5D_t1718750761** get_address_of_s_Xy_42() { return &___s_Xy_42; }
inline void set_s_Xy_42(Vector3U5BU5D_t1718750761* value)
{
___s_Xy_42 = value;
Il2CppCodeGenWriteBarrier((&___s_Xy_42), value);
}
inline static int32_t get_offset_of_s_Uv_43() { return static_cast<int32_t>(offsetof(Image_t2670269651_StaticFields, ___s_Uv_43)); }
inline Vector3U5BU5D_t1718750761* get_s_Uv_43() const { return ___s_Uv_43; }
inline Vector3U5BU5D_t1718750761** get_address_of_s_Uv_43() { return &___s_Uv_43; }
inline void set_s_Uv_43(Vector3U5BU5D_t1718750761* value)
{
___s_Uv_43 = value;
Il2CppCodeGenWriteBarrier((&___s_Uv_43), value);
}
inline static int32_t get_offset_of_m_TrackedTexturelessImages_44() { return static_cast<int32_t>(offsetof(Image_t2670269651_StaticFields, ___m_TrackedTexturelessImages_44)); }
inline List_1_t4142344393 * get_m_TrackedTexturelessImages_44() const { return ___m_TrackedTexturelessImages_44; }
inline List_1_t4142344393 ** get_address_of_m_TrackedTexturelessImages_44() { return &___m_TrackedTexturelessImages_44; }
inline void set_m_TrackedTexturelessImages_44(List_1_t4142344393 * value)
{
___m_TrackedTexturelessImages_44 = value;
Il2CppCodeGenWriteBarrier((&___m_TrackedTexturelessImages_44), value);
}
inline static int32_t get_offset_of_s_Initialized_45() { return static_cast<int32_t>(offsetof(Image_t2670269651_StaticFields, ___s_Initialized_45)); }
inline bool get_s_Initialized_45() const { return ___s_Initialized_45; }
inline bool* get_address_of_s_Initialized_45() { return &___s_Initialized_45; }
inline void set_s_Initialized_45(bool value)
{
___s_Initialized_45 = value;
}
inline static int32_t get_offset_of_U3CU3Ef__mgU24cache0_46() { return static_cast<int32_t>(offsetof(Image_t2670269651_StaticFields, ___U3CU3Ef__mgU24cache0_46)); }
inline Action_1_t819399007 * get_U3CU3Ef__mgU24cache0_46() const { return ___U3CU3Ef__mgU24cache0_46; }
inline Action_1_t819399007 ** get_address_of_U3CU3Ef__mgU24cache0_46() { return &___U3CU3Ef__mgU24cache0_46; }
inline void set_U3CU3Ef__mgU24cache0_46(Action_1_t819399007 * value)
{
___U3CU3Ef__mgU24cache0_46 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__mgU24cache0_46), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // IMAGE_T2670269651_H
#ifndef RAWIMAGE_T3182918964_H
#define RAWIMAGE_T3182918964_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.UI.RawImage
struct RawImage_t3182918964 : public MaskableGraphic_t3839221559
{
public:
// UnityEngine.Texture UnityEngine.UI.RawImage::m_Texture
Texture_t3661962703 * ___m_Texture_28;
// UnityEngine.Rect UnityEngine.UI.RawImage::m_UVRect
Rect_t2360479859 ___m_UVRect_29;
public:
inline static int32_t get_offset_of_m_Texture_28() { return static_cast<int32_t>(offsetof(RawImage_t3182918964, ___m_Texture_28)); }
inline Texture_t3661962703 * get_m_Texture_28() const { return ___m_Texture_28; }
inline Texture_t3661962703 ** get_address_of_m_Texture_28() { return &___m_Texture_28; }
inline void set_m_Texture_28(Texture_t3661962703 * value)
{
___m_Texture_28 = value;
Il2CppCodeGenWriteBarrier((&___m_Texture_28), value);
}
inline static int32_t get_offset_of_m_UVRect_29() { return static_cast<int32_t>(offsetof(RawImage_t3182918964, ___m_UVRect_29)); }
inline Rect_t2360479859 get_m_UVRect_29() const { return ___m_UVRect_29; }
inline Rect_t2360479859 * get_address_of_m_UVRect_29() { return &___m_UVRect_29; }
inline void set_m_UVRect_29(Rect_t2360479859 value)
{
___m_UVRect_29 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RAWIMAGE_T3182918964_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1800 = { sizeof (ButtonClickedEvent_t48803504), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1801 = { sizeof (U3COnFinishSubmitU3Ec__Iterator0_t3413438900), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1801[6] =
{
U3COnFinishSubmitU3Ec__Iterator0_t3413438900::get_offset_of_U3CfadeTimeU3E__0_0(),
U3COnFinishSubmitU3Ec__Iterator0_t3413438900::get_offset_of_U3CelapsedTimeU3E__0_1(),
U3COnFinishSubmitU3Ec__Iterator0_t3413438900::get_offset_of_U24this_2(),
U3COnFinishSubmitU3Ec__Iterator0_t3413438900::get_offset_of_U24current_3(),
U3COnFinishSubmitU3Ec__Iterator0_t3413438900::get_offset_of_U24disposing_4(),
U3COnFinishSubmitU3Ec__Iterator0_t3413438900::get_offset_of_U24PC_5(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1802 = { sizeof (CanvasUpdate_t2572322932)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1802[7] =
{
CanvasUpdate_t2572322932::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1803 = { 0, -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1804 = { sizeof (CanvasUpdateRegistry_t2720824592), -1, sizeof(CanvasUpdateRegistry_t2720824592_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1804[7] =
{
CanvasUpdateRegistry_t2720824592_StaticFields::get_offset_of_s_Instance_0(),
CanvasUpdateRegistry_t2720824592::get_offset_of_m_PerformingLayoutUpdate_1(),
CanvasUpdateRegistry_t2720824592::get_offset_of_m_PerformingGraphicUpdate_2(),
CanvasUpdateRegistry_t2720824592::get_offset_of_m_LayoutRebuildQueue_3(),
CanvasUpdateRegistry_t2720824592::get_offset_of_m_GraphicRebuildQueue_4(),
CanvasUpdateRegistry_t2720824592_StaticFields::get_offset_of_s_SortLayoutFunction_5(),
CanvasUpdateRegistry_t2720824592_StaticFields::get_offset_of_U3CU3Ef__mgU24cache0_6(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1805 = { sizeof (ColorBlock_t2139031574)+ sizeof (RuntimeObject), sizeof(ColorBlock_t2139031574 ), 0, 0 };
extern const int32_t g_FieldOffsetTable1805[6] =
{
ColorBlock_t2139031574::get_offset_of_m_NormalColor_0() + static_cast<int32_t>(sizeof(RuntimeObject)),
ColorBlock_t2139031574::get_offset_of_m_HighlightedColor_1() + static_cast<int32_t>(sizeof(RuntimeObject)),
ColorBlock_t2139031574::get_offset_of_m_PressedColor_2() + static_cast<int32_t>(sizeof(RuntimeObject)),
ColorBlock_t2139031574::get_offset_of_m_DisabledColor_3() + static_cast<int32_t>(sizeof(RuntimeObject)),
ColorBlock_t2139031574::get_offset_of_m_ColorMultiplier_4() + static_cast<int32_t>(sizeof(RuntimeObject)),
ColorBlock_t2139031574::get_offset_of_m_FadeDuration_5() + static_cast<int32_t>(sizeof(RuntimeObject)),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1806 = { sizeof (DefaultControls_t4098465386), -1, sizeof(DefaultControls_t4098465386_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1806[9] =
{
0,
0,
0,
DefaultControls_t4098465386_StaticFields::get_offset_of_s_ThickElementSize_3(),
DefaultControls_t4098465386_StaticFields::get_offset_of_s_ThinElementSize_4(),
DefaultControls_t4098465386_StaticFields::get_offset_of_s_ImageElementSize_5(),
DefaultControls_t4098465386_StaticFields::get_offset_of_s_DefaultSelectableColor_6(),
DefaultControls_t4098465386_StaticFields::get_offset_of_s_PanelColor_7(),
DefaultControls_t4098465386_StaticFields::get_offset_of_s_TextColor_8(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1807 = { sizeof (Resources_t1597885468)+ sizeof (RuntimeObject), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1807[7] =
{
Resources_t1597885468::get_offset_of_standard_0() + static_cast<int32_t>(sizeof(RuntimeObject)),
Resources_t1597885468::get_offset_of_background_1() + static_cast<int32_t>(sizeof(RuntimeObject)),
Resources_t1597885468::get_offset_of_inputField_2() + static_cast<int32_t>(sizeof(RuntimeObject)),
Resources_t1597885468::get_offset_of_knob_3() + static_cast<int32_t>(sizeof(RuntimeObject)),
Resources_t1597885468::get_offset_of_checkmark_4() + static_cast<int32_t>(sizeof(RuntimeObject)),
Resources_t1597885468::get_offset_of_dropdown_5() + static_cast<int32_t>(sizeof(RuntimeObject)),
Resources_t1597885468::get_offset_of_mask_6() + static_cast<int32_t>(sizeof(RuntimeObject)),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1808 = { sizeof (Dropdown_t2274391225), -1, sizeof(Dropdown_t2274391225_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1808[14] =
{
Dropdown_t2274391225::get_offset_of_m_Template_16(),
Dropdown_t2274391225::get_offset_of_m_CaptionText_17(),
Dropdown_t2274391225::get_offset_of_m_CaptionImage_18(),
Dropdown_t2274391225::get_offset_of_m_ItemText_19(),
Dropdown_t2274391225::get_offset_of_m_ItemImage_20(),
Dropdown_t2274391225::get_offset_of_m_Value_21(),
Dropdown_t2274391225::get_offset_of_m_Options_22(),
Dropdown_t2274391225::get_offset_of_m_OnValueChanged_23(),
Dropdown_t2274391225::get_offset_of_m_Dropdown_24(),
Dropdown_t2274391225::get_offset_of_m_Blocker_25(),
Dropdown_t2274391225::get_offset_of_m_Items_26(),
Dropdown_t2274391225::get_offset_of_m_AlphaTweenRunner_27(),
Dropdown_t2274391225::get_offset_of_validTemplate_28(),
Dropdown_t2274391225_StaticFields::get_offset_of_s_NoOptionData_29(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1809 = { sizeof (DropdownItem_t1451952895), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1809[4] =
{
DropdownItem_t1451952895::get_offset_of_m_Text_2(),
DropdownItem_t1451952895::get_offset_of_m_Image_3(),
DropdownItem_t1451952895::get_offset_of_m_RectTransform_4(),
DropdownItem_t1451952895::get_offset_of_m_Toggle_5(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1810 = { sizeof (OptionData_t3270282352), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1810[2] =
{
OptionData_t3270282352::get_offset_of_m_Text_0(),
OptionData_t3270282352::get_offset_of_m_Image_1(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1811 = { sizeof (OptionDataList_t1438173104), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1811[1] =
{
OptionDataList_t1438173104::get_offset_of_m_Options_0(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1812 = { sizeof (DropdownEvent_t4040729994), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1813 = { sizeof (U3CShowU3Ec__AnonStorey1_t1106527198), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1813[2] =
{
U3CShowU3Ec__AnonStorey1_t1106527198::get_offset_of_item_0(),
U3CShowU3Ec__AnonStorey1_t1106527198::get_offset_of_U24this_1(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1814 = { sizeof (U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1814[5] =
{
U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249::get_offset_of_delay_0(),
U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249::get_offset_of_U24this_1(),
U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249::get_offset_of_U24current_2(),
U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249::get_offset_of_U24disposing_3(),
U3CDelayedDestroyDropdownListU3Ec__Iterator0_t3853912249::get_offset_of_U24PC_4(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1815 = { sizeof (FontData_t746620069), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1815[12] =
{
FontData_t746620069::get_offset_of_m_Font_0(),
FontData_t746620069::get_offset_of_m_FontSize_1(),
FontData_t746620069::get_offset_of_m_FontStyle_2(),
FontData_t746620069::get_offset_of_m_BestFit_3(),
FontData_t746620069::get_offset_of_m_MinSize_4(),
FontData_t746620069::get_offset_of_m_MaxSize_5(),
FontData_t746620069::get_offset_of_m_Alignment_6(),
FontData_t746620069::get_offset_of_m_AlignByGeometry_7(),
FontData_t746620069::get_offset_of_m_RichText_8(),
FontData_t746620069::get_offset_of_m_HorizontalOverflow_9(),
FontData_t746620069::get_offset_of_m_VerticalOverflow_10(),
FontData_t746620069::get_offset_of_m_LineSpacing_11(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1816 = { sizeof (FontUpdateTracker_t1839077620), -1, sizeof(FontUpdateTracker_t1839077620_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1816[3] =
{
FontUpdateTracker_t1839077620_StaticFields::get_offset_of_m_Tracked_0(),
FontUpdateTracker_t1839077620_StaticFields::get_offset_of_U3CU3Ef__mgU24cache0_1(),
FontUpdateTracker_t1839077620_StaticFields::get_offset_of_U3CU3Ef__mgU24cache1_2(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1817 = { sizeof (Graphic_t1660335611), -1, sizeof(Graphic_t1660335611_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1817[17] =
{
Graphic_t1660335611_StaticFields::get_offset_of_s_DefaultUI_2(),
Graphic_t1660335611_StaticFields::get_offset_of_s_WhiteTexture_3(),
Graphic_t1660335611::get_offset_of_m_Material_4(),
Graphic_t1660335611::get_offset_of_m_Color_5(),
Graphic_t1660335611::get_offset_of_m_RaycastTarget_6(),
Graphic_t1660335611::get_offset_of_m_RectTransform_7(),
Graphic_t1660335611::get_offset_of_m_CanvasRenderer_8(),
Graphic_t1660335611::get_offset_of_m_Canvas_9(),
Graphic_t1660335611::get_offset_of_m_VertsDirty_10(),
Graphic_t1660335611::get_offset_of_m_MaterialDirty_11(),
Graphic_t1660335611::get_offset_of_m_OnDirtyLayoutCallback_12(),
Graphic_t1660335611::get_offset_of_m_OnDirtyVertsCallback_13(),
Graphic_t1660335611::get_offset_of_m_OnDirtyMaterialCallback_14(),
Graphic_t1660335611_StaticFields::get_offset_of_s_Mesh_15(),
Graphic_t1660335611_StaticFields::get_offset_of_s_VertexHelper_16(),
Graphic_t1660335611::get_offset_of_m_ColorTweenRunner_17(),
Graphic_t1660335611::get_offset_of_U3CuseLegacyMeshGenerationU3Ek__BackingField_18(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1818 = { sizeof (GraphicRaycaster_t2999697109), -1, sizeof(GraphicRaycaster_t2999697109_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1818[8] =
{
0,
GraphicRaycaster_t2999697109::get_offset_of_m_IgnoreReversedGraphics_3(),
GraphicRaycaster_t2999697109::get_offset_of_m_BlockingObjects_4(),
GraphicRaycaster_t2999697109::get_offset_of_m_BlockingMask_5(),
GraphicRaycaster_t2999697109::get_offset_of_m_Canvas_6(),
GraphicRaycaster_t2999697109::get_offset_of_m_RaycastResults_7(),
GraphicRaycaster_t2999697109_StaticFields::get_offset_of_s_SortedGraphics_8(),
GraphicRaycaster_t2999697109_StaticFields::get_offset_of_U3CU3Ef__amU24cache0_9(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1819 = { sizeof (BlockingObjects_t612090948)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1819[5] =
{
BlockingObjects_t612090948::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1820 = { sizeof (GraphicRegistry_t3479976429), -1, sizeof(GraphicRegistry_t3479976429_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1820[3] =
{
GraphicRegistry_t3479976429_StaticFields::get_offset_of_s_Instance_0(),
GraphicRegistry_t3479976429::get_offset_of_m_Graphics_1(),
GraphicRegistry_t3479976429_StaticFields::get_offset_of_s_EmptyList_2(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1821 = { 0, -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1822 = { sizeof (Image_t2670269651), -1, sizeof(Image_t2670269651_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1822[19] =
{
Image_t2670269651_StaticFields::get_offset_of_s_ETC1DefaultUI_28(),
Image_t2670269651::get_offset_of_m_Sprite_29(),
Image_t2670269651::get_offset_of_m_OverrideSprite_30(),
Image_t2670269651::get_offset_of_m_Type_31(),
Image_t2670269651::get_offset_of_m_PreserveAspect_32(),
Image_t2670269651::get_offset_of_m_FillCenter_33(),
Image_t2670269651::get_offset_of_m_FillMethod_34(),
Image_t2670269651::get_offset_of_m_FillAmount_35(),
Image_t2670269651::get_offset_of_m_FillClockwise_36(),
Image_t2670269651::get_offset_of_m_FillOrigin_37(),
Image_t2670269651::get_offset_of_m_AlphaHitTestMinimumThreshold_38(),
Image_t2670269651::get_offset_of_m_Tracked_39(),
Image_t2670269651_StaticFields::get_offset_of_s_VertScratch_40(),
Image_t2670269651_StaticFields::get_offset_of_s_UVScratch_41(),
Image_t2670269651_StaticFields::get_offset_of_s_Xy_42(),
Image_t2670269651_StaticFields::get_offset_of_s_Uv_43(),
Image_t2670269651_StaticFields::get_offset_of_m_TrackedTexturelessImages_44(),
Image_t2670269651_StaticFields::get_offset_of_s_Initialized_45(),
Image_t2670269651_StaticFields::get_offset_of_U3CU3Ef__mgU24cache0_46(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1823 = { sizeof (Type_t1152881528)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1823[5] =
{
Type_t1152881528::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1824 = { sizeof (FillMethod_t1167457570)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1824[6] =
{
FillMethod_t1167457570::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1825 = { sizeof (OriginHorizontal_t1174417785)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1825[3] =
{
OriginHorizontal_t1174417785::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1826 = { sizeof (OriginVertical_t2256455259)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1826[3] =
{
OriginVertical_t2256455259::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1827 = { sizeof (Origin90_t1855765812)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1827[5] =
{
Origin90_t1855765812::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1828 = { sizeof (Origin180_t325369132)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1828[5] =
{
Origin180_t325369132::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1829 = { sizeof (Origin360_t707706162)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1829[5] =
{
Origin360_t707706162::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1830 = { 0, -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1831 = { 0, -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1832 = { sizeof (InputField_t3762917431), -1, sizeof(InputField_t3762917431_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1832[48] =
{
InputField_t3762917431::get_offset_of_m_Keyboard_16(),
InputField_t3762917431_StaticFields::get_offset_of_kSeparators_17(),
InputField_t3762917431::get_offset_of_m_TextComponent_18(),
InputField_t3762917431::get_offset_of_m_Placeholder_19(),
InputField_t3762917431::get_offset_of_m_ContentType_20(),
InputField_t3762917431::get_offset_of_m_InputType_21(),
InputField_t3762917431::get_offset_of_m_AsteriskChar_22(),
InputField_t3762917431::get_offset_of_m_KeyboardType_23(),
InputField_t3762917431::get_offset_of_m_LineType_24(),
InputField_t3762917431::get_offset_of_m_HideMobileInput_25(),
InputField_t3762917431::get_offset_of_m_CharacterValidation_26(),
InputField_t3762917431::get_offset_of_m_CharacterLimit_27(),
InputField_t3762917431::get_offset_of_m_OnEndEdit_28(),
InputField_t3762917431::get_offset_of_m_OnValueChanged_29(),
InputField_t3762917431::get_offset_of_m_OnValidateInput_30(),
InputField_t3762917431::get_offset_of_m_CaretColor_31(),
InputField_t3762917431::get_offset_of_m_CustomCaretColor_32(),
InputField_t3762917431::get_offset_of_m_SelectionColor_33(),
InputField_t3762917431::get_offset_of_m_Text_34(),
InputField_t3762917431::get_offset_of_m_CaretBlinkRate_35(),
InputField_t3762917431::get_offset_of_m_CaretWidth_36(),
InputField_t3762917431::get_offset_of_m_ReadOnly_37(),
InputField_t3762917431::get_offset_of_m_CaretPosition_38(),
InputField_t3762917431::get_offset_of_m_CaretSelectPosition_39(),
InputField_t3762917431::get_offset_of_caretRectTrans_40(),
InputField_t3762917431::get_offset_of_m_CursorVerts_41(),
InputField_t3762917431::get_offset_of_m_InputTextCache_42(),
InputField_t3762917431::get_offset_of_m_CachedInputRenderer_43(),
InputField_t3762917431::get_offset_of_m_PreventFontCallback_44(),
InputField_t3762917431::get_offset_of_m_Mesh_45(),
InputField_t3762917431::get_offset_of_m_AllowInput_46(),
InputField_t3762917431::get_offset_of_m_ShouldActivateNextUpdate_47(),
InputField_t3762917431::get_offset_of_m_UpdateDrag_48(),
InputField_t3762917431::get_offset_of_m_DragPositionOutOfBounds_49(),
0,
0,
InputField_t3762917431::get_offset_of_m_CaretVisible_52(),
InputField_t3762917431::get_offset_of_m_BlinkCoroutine_53(),
InputField_t3762917431::get_offset_of_m_BlinkStartTime_54(),
InputField_t3762917431::get_offset_of_m_DrawStart_55(),
InputField_t3762917431::get_offset_of_m_DrawEnd_56(),
InputField_t3762917431::get_offset_of_m_DragCoroutine_57(),
InputField_t3762917431::get_offset_of_m_OriginalText_58(),
InputField_t3762917431::get_offset_of_m_WasCanceled_59(),
InputField_t3762917431::get_offset_of_m_HasDoneFocusTransition_60(),
0,
InputField_t3762917431::get_offset_of_m_ProcessingEvent_62(),
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1833 = { sizeof (ContentType_t1787303396)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1833[11] =
{
ContentType_t1787303396::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1834 = { sizeof (InputType_t1770400679)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1834[4] =
{
InputType_t1770400679::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1835 = { sizeof (CharacterValidation_t4051914437)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1835[7] =
{
CharacterValidation_t4051914437::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1836 = { sizeof (LineType_t4214648469)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1836[4] =
{
LineType_t4214648469::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1837 = { sizeof (OnValidateInput_t2355412304), sizeof(Il2CppMethodPointer), 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1838 = { sizeof (SubmitEvent_t648412432), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1839 = { sizeof (OnChangeEvent_t467195904), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1840 = { sizeof (EditState_t3741896775)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1840[3] =
{
EditState_t3741896775::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1841 = { sizeof (U3CCaretBlinkU3Ec__Iterator0_t2589889038), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1841[6] =
{
U3CCaretBlinkU3Ec__Iterator0_t2589889038::get_offset_of_U3CblinkPeriodU3E__1_0(),
U3CCaretBlinkU3Ec__Iterator0_t2589889038::get_offset_of_U3CblinkStateU3E__1_1(),
U3CCaretBlinkU3Ec__Iterator0_t2589889038::get_offset_of_U24this_2(),
U3CCaretBlinkU3Ec__Iterator0_t2589889038::get_offset_of_U24current_3(),
U3CCaretBlinkU3Ec__Iterator0_t2589889038::get_offset_of_U24disposing_4(),
U3CCaretBlinkU3Ec__Iterator0_t2589889038::get_offset_of_U24PC_5(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1842 = { sizeof (U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1842[8] =
{
U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878::get_offset_of_eventData_0(),
U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878::get_offset_of_U3ClocalMousePosU3E__1_1(),
U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878::get_offset_of_U3CrectU3E__1_2(),
U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878::get_offset_of_U3CdelayU3E__1_3(),
U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878::get_offset_of_U24this_4(),
U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878::get_offset_of_U24current_5(),
U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878::get_offset_of_U24disposing_6(),
U3CMouseDragOutsideRectU3Ec__Iterator1_t3909241878::get_offset_of_U24PC_7(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1843 = { sizeof (Mask_t1803652131), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1843[5] =
{
Mask_t1803652131::get_offset_of_m_RectTransform_2(),
Mask_t1803652131::get_offset_of_m_ShowMaskGraphic_3(),
Mask_t1803652131::get_offset_of_m_Graphic_4(),
Mask_t1803652131::get_offset_of_m_MaskMaterial_5(),
Mask_t1803652131::get_offset_of_m_UnmaskMaterial_6(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1844 = { sizeof (MaskableGraphic_t3839221559), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1844[9] =
{
MaskableGraphic_t3839221559::get_offset_of_m_ShouldRecalculateStencil_19(),
MaskableGraphic_t3839221559::get_offset_of_m_MaskMaterial_20(),
MaskableGraphic_t3839221559::get_offset_of_m_ParentMask_21(),
MaskableGraphic_t3839221559::get_offset_of_m_Maskable_22(),
MaskableGraphic_t3839221559::get_offset_of_m_IncludeForMasking_23(),
MaskableGraphic_t3839221559::get_offset_of_m_OnCullStateChanged_24(),
MaskableGraphic_t3839221559::get_offset_of_m_ShouldRecalculate_25(),
MaskableGraphic_t3839221559::get_offset_of_m_StencilValue_26(),
MaskableGraphic_t3839221559::get_offset_of_m_Corners_27(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1845 = { sizeof (CullStateChangedEvent_t3661388177), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1846 = { sizeof (MaskUtilities_t4151184739), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1847 = { sizeof (Misc_t1447421763), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1848 = { sizeof (Navigation_t3049316579)+ sizeof (RuntimeObject), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1848[5] =
{
Navigation_t3049316579::get_offset_of_m_Mode_0() + static_cast<int32_t>(sizeof(RuntimeObject)),
Navigation_t3049316579::get_offset_of_m_SelectOnUp_1() + static_cast<int32_t>(sizeof(RuntimeObject)),
Navigation_t3049316579::get_offset_of_m_SelectOnDown_2() + static_cast<int32_t>(sizeof(RuntimeObject)),
Navigation_t3049316579::get_offset_of_m_SelectOnLeft_3() + static_cast<int32_t>(sizeof(RuntimeObject)),
Navigation_t3049316579::get_offset_of_m_SelectOnRight_4() + static_cast<int32_t>(sizeof(RuntimeObject)),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1849 = { sizeof (Mode_t1066900953)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1849[6] =
{
Mode_t1066900953::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1850 = { sizeof (RawImage_t3182918964), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1850[2] =
{
RawImage_t3182918964::get_offset_of_m_Texture_28(),
RawImage_t3182918964::get_offset_of_m_UVRect_29(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1851 = { sizeof (RectMask2D_t3474889437), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1851[9] =
{
RectMask2D_t3474889437::get_offset_of_m_VertexClipper_2(),
RectMask2D_t3474889437::get_offset_of_m_RectTransform_3(),
RectMask2D_t3474889437::get_offset_of_m_ClipTargets_4(),
RectMask2D_t3474889437::get_offset_of_m_ShouldRecalculateClipRects_5(),
RectMask2D_t3474889437::get_offset_of_m_Clippers_6(),
RectMask2D_t3474889437::get_offset_of_m_LastClipRectCanvasSpace_7(),
RectMask2D_t3474889437::get_offset_of_m_ForceClip_8(),
RectMask2D_t3474889437::get_offset_of_m_Canvas_9(),
RectMask2D_t3474889437::get_offset_of_m_Corners_10(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1852 = { sizeof (Scrollbar_t1494447233), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1852[11] =
{
Scrollbar_t1494447233::get_offset_of_m_HandleRect_16(),
Scrollbar_t1494447233::get_offset_of_m_Direction_17(),
Scrollbar_t1494447233::get_offset_of_m_Value_18(),
Scrollbar_t1494447233::get_offset_of_m_Size_19(),
Scrollbar_t1494447233::get_offset_of_m_NumberOfSteps_20(),
Scrollbar_t1494447233::get_offset_of_m_OnValueChanged_21(),
Scrollbar_t1494447233::get_offset_of_m_ContainerRect_22(),
Scrollbar_t1494447233::get_offset_of_m_Offset_23(),
Scrollbar_t1494447233::get_offset_of_m_Tracker_24(),
Scrollbar_t1494447233::get_offset_of_m_PointerDownRepeat_25(),
Scrollbar_t1494447233::get_offset_of_isPointerDownAndNotDragging_26(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1853 = { sizeof (Direction_t3470714353)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1853[5] =
{
Direction_t3470714353::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1854 = { sizeof (ScrollEvent_t149898510), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1855 = { sizeof (Axis_t1697763317)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1855[3] =
{
Axis_t1697763317::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1856 = { sizeof (U3CClickRepeatU3Ec__Iterator0_t3442648935), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1856[5] =
{
U3CClickRepeatU3Ec__Iterator0_t3442648935::get_offset_of_eventData_0(),
U3CClickRepeatU3Ec__Iterator0_t3442648935::get_offset_of_U24this_1(),
U3CClickRepeatU3Ec__Iterator0_t3442648935::get_offset_of_U24current_2(),
U3CClickRepeatU3Ec__Iterator0_t3442648935::get_offset_of_U24disposing_3(),
U3CClickRepeatU3Ec__Iterator0_t3442648935::get_offset_of_U24PC_4(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1857 = { sizeof (ScrollRect_t4137855814), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1857[36] =
{
ScrollRect_t4137855814::get_offset_of_m_Content_2(),
ScrollRect_t4137855814::get_offset_of_m_Horizontal_3(),
ScrollRect_t4137855814::get_offset_of_m_Vertical_4(),
ScrollRect_t4137855814::get_offset_of_m_MovementType_5(),
ScrollRect_t4137855814::get_offset_of_m_Elasticity_6(),
ScrollRect_t4137855814::get_offset_of_m_Inertia_7(),
ScrollRect_t4137855814::get_offset_of_m_DecelerationRate_8(),
ScrollRect_t4137855814::get_offset_of_m_ScrollSensitivity_9(),
ScrollRect_t4137855814::get_offset_of_m_Viewport_10(),
ScrollRect_t4137855814::get_offset_of_m_HorizontalScrollbar_11(),
ScrollRect_t4137855814::get_offset_of_m_VerticalScrollbar_12(),
ScrollRect_t4137855814::get_offset_of_m_HorizontalScrollbarVisibility_13(),
ScrollRect_t4137855814::get_offset_of_m_VerticalScrollbarVisibility_14(),
ScrollRect_t4137855814::get_offset_of_m_HorizontalScrollbarSpacing_15(),
ScrollRect_t4137855814::get_offset_of_m_VerticalScrollbarSpacing_16(),
ScrollRect_t4137855814::get_offset_of_m_OnValueChanged_17(),
ScrollRect_t4137855814::get_offset_of_m_PointerStartLocalCursor_18(),
ScrollRect_t4137855814::get_offset_of_m_ContentStartPosition_19(),
ScrollRect_t4137855814::get_offset_of_m_ViewRect_20(),
ScrollRect_t4137855814::get_offset_of_m_ContentBounds_21(),
ScrollRect_t4137855814::get_offset_of_m_ViewBounds_22(),
ScrollRect_t4137855814::get_offset_of_m_Velocity_23(),
ScrollRect_t4137855814::get_offset_of_m_Dragging_24(),
ScrollRect_t4137855814::get_offset_of_m_PrevPosition_25(),
ScrollRect_t4137855814::get_offset_of_m_PrevContentBounds_26(),
ScrollRect_t4137855814::get_offset_of_m_PrevViewBounds_27(),
ScrollRect_t4137855814::get_offset_of_m_HasRebuiltLayout_28(),
ScrollRect_t4137855814::get_offset_of_m_HSliderExpand_29(),
ScrollRect_t4137855814::get_offset_of_m_VSliderExpand_30(),
ScrollRect_t4137855814::get_offset_of_m_HSliderHeight_31(),
ScrollRect_t4137855814::get_offset_of_m_VSliderWidth_32(),
ScrollRect_t4137855814::get_offset_of_m_Rect_33(),
ScrollRect_t4137855814::get_offset_of_m_HorizontalScrollbarRect_34(),
ScrollRect_t4137855814::get_offset_of_m_VerticalScrollbarRect_35(),
ScrollRect_t4137855814::get_offset_of_m_Tracker_36(),
ScrollRect_t4137855814::get_offset_of_m_Corners_37(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1858 = { sizeof (MovementType_t4072922106)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1858[4] =
{
MovementType_t4072922106::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1859 = { sizeof (ScrollbarVisibility_t705693775)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1859[4] =
{
ScrollbarVisibility_t705693775::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1860 = { sizeof (ScrollRectEvent_t343079324), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1861 = { sizeof (Selectable_t3250028441), -1, sizeof(Selectable_t3250028441_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1861[14] =
{
Selectable_t3250028441_StaticFields::get_offset_of_s_List_2(),
Selectable_t3250028441::get_offset_of_m_Navigation_3(),
Selectable_t3250028441::get_offset_of_m_Transition_4(),
Selectable_t3250028441::get_offset_of_m_Colors_5(),
Selectable_t3250028441::get_offset_of_m_SpriteState_6(),
Selectable_t3250028441::get_offset_of_m_AnimationTriggers_7(),
Selectable_t3250028441::get_offset_of_m_Interactable_8(),
Selectable_t3250028441::get_offset_of_m_TargetGraphic_9(),
Selectable_t3250028441::get_offset_of_m_GroupsAllowInteraction_10(),
Selectable_t3250028441::get_offset_of_m_CurrentSelectionState_11(),
Selectable_t3250028441::get_offset_of_U3CisPointerInsideU3Ek__BackingField_12(),
Selectable_t3250028441::get_offset_of_U3CisPointerDownU3Ek__BackingField_13(),
Selectable_t3250028441::get_offset_of_U3ChasSelectionU3Ek__BackingField_14(),
Selectable_t3250028441::get_offset_of_m_CanvasGroupCache_15(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1862 = { sizeof (Transition_t1769908631)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1862[5] =
{
Transition_t1769908631::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1863 = { sizeof (SelectionState_t2656606514)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1863[5] =
{
SelectionState_t2656606514::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1864 = { sizeof (SetPropertyUtility_t3359423571), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1865 = { sizeof (Slider_t3903728902), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1865[15] =
{
Slider_t3903728902::get_offset_of_m_FillRect_16(),
Slider_t3903728902::get_offset_of_m_HandleRect_17(),
Slider_t3903728902::get_offset_of_m_Direction_18(),
Slider_t3903728902::get_offset_of_m_MinValue_19(),
Slider_t3903728902::get_offset_of_m_MaxValue_20(),
Slider_t3903728902::get_offset_of_m_WholeNumbers_21(),
Slider_t3903728902::get_offset_of_m_Value_22(),
Slider_t3903728902::get_offset_of_m_OnValueChanged_23(),
Slider_t3903728902::get_offset_of_m_FillImage_24(),
Slider_t3903728902::get_offset_of_m_FillTransform_25(),
Slider_t3903728902::get_offset_of_m_FillContainerRect_26(),
Slider_t3903728902::get_offset_of_m_HandleTransform_27(),
Slider_t3903728902::get_offset_of_m_HandleContainerRect_28(),
Slider_t3903728902::get_offset_of_m_Offset_29(),
Slider_t3903728902::get_offset_of_m_Tracker_30(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1866 = { sizeof (Direction_t337909235)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1866[5] =
{
Direction_t337909235::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1867 = { sizeof (SliderEvent_t3180273144), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1868 = { sizeof (Axis_t809944411)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1868[3] =
{
Axis_t809944411::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1869 = { sizeof (SpriteState_t1362986479)+ sizeof (RuntimeObject), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1869[3] =
{
SpriteState_t1362986479::get_offset_of_m_HighlightedSprite_0() + static_cast<int32_t>(sizeof(RuntimeObject)),
SpriteState_t1362986479::get_offset_of_m_PressedSprite_1() + static_cast<int32_t>(sizeof(RuntimeObject)),
SpriteState_t1362986479::get_offset_of_m_DisabledSprite_2() + static_cast<int32_t>(sizeof(RuntimeObject)),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1870 = { sizeof (StencilMaterial_t3850132571), -1, sizeof(StencilMaterial_t3850132571_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1870[1] =
{
StencilMaterial_t3850132571_StaticFields::get_offset_of_m_List_0(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1871 = { sizeof (MatEntry_t2957107092), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1871[10] =
{
MatEntry_t2957107092::get_offset_of_baseMat_0(),
MatEntry_t2957107092::get_offset_of_customMat_1(),
MatEntry_t2957107092::get_offset_of_count_2(),
MatEntry_t2957107092::get_offset_of_stencilId_3(),
MatEntry_t2957107092::get_offset_of_operation_4(),
MatEntry_t2957107092::get_offset_of_compareFunction_5(),
MatEntry_t2957107092::get_offset_of_readMask_6(),
MatEntry_t2957107092::get_offset_of_writeMask_7(),
MatEntry_t2957107092::get_offset_of_useAlphaClip_8(),
MatEntry_t2957107092::get_offset_of_colorMask_9(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1872 = { sizeof (Text_t1901882714), -1, sizeof(Text_t1901882714_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1872[7] =
{
Text_t1901882714::get_offset_of_m_FontData_28(),
Text_t1901882714::get_offset_of_m_Text_29(),
Text_t1901882714::get_offset_of_m_TextCache_30(),
Text_t1901882714::get_offset_of_m_TextCacheForLayout_31(),
Text_t1901882714_StaticFields::get_offset_of_s_DefaultText_32(),
Text_t1901882714::get_offset_of_m_DisableFontTextureRebuiltCallback_33(),
Text_t1901882714::get_offset_of_m_TempVerts_34(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1873 = { sizeof (Toggle_t2735377061), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1873[5] =
{
Toggle_t2735377061::get_offset_of_toggleTransition_16(),
Toggle_t2735377061::get_offset_of_graphic_17(),
Toggle_t2735377061::get_offset_of_m_Group_18(),
Toggle_t2735377061::get_offset_of_onValueChanged_19(),
Toggle_t2735377061::get_offset_of_m_IsOn_20(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1874 = { sizeof (ToggleTransition_t3587297765)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1874[3] =
{
ToggleTransition_t3587297765::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1875 = { sizeof (ToggleEvent_t1873685584), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1876 = { sizeof (ToggleGroup_t123837990), -1, sizeof(ToggleGroup_t123837990_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1876[4] =
{
ToggleGroup_t123837990::get_offset_of_m_AllowSwitchOff_2(),
ToggleGroup_t123837990::get_offset_of_m_Toggles_3(),
ToggleGroup_t123837990_StaticFields::get_offset_of_U3CU3Ef__amU24cache0_4(),
ToggleGroup_t123837990_StaticFields::get_offset_of_U3CU3Ef__amU24cache1_5(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1877 = { sizeof (ClipperRegistry_t2428680409), -1, sizeof(ClipperRegistry_t2428680409_StaticFields), 0 };
extern const int32_t g_FieldOffsetTable1877[2] =
{
ClipperRegistry_t2428680409_StaticFields::get_offset_of_s_Instance_0(),
ClipperRegistry_t2428680409::get_offset_of_m_Clippers_1(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1878 = { sizeof (Clipping_t312708592), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1879 = { 0, -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1880 = { 0, -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1881 = { sizeof (RectangularVertexClipper_t626611136), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1881[2] =
{
RectangularVertexClipper_t626611136::get_offset_of_m_WorldCorners_0(),
RectangularVertexClipper_t626611136::get_offset_of_m_CanvasCorners_1(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1882 = { sizeof (AspectRatioFitter_t3312407083), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1882[5] =
{
AspectRatioFitter_t3312407083::get_offset_of_m_AspectMode_2(),
AspectRatioFitter_t3312407083::get_offset_of_m_AspectRatio_3(),
AspectRatioFitter_t3312407083::get_offset_of_m_Rect_4(),
AspectRatioFitter_t3312407083::get_offset_of_m_DelayedSetDirty_5(),
AspectRatioFitter_t3312407083::get_offset_of_m_Tracker_6(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1883 = { sizeof (AspectMode_t3417192999)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1883[6] =
{
AspectMode_t3417192999::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1884 = { sizeof (CanvasScaler_t2767979955), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1884[14] =
{
CanvasScaler_t2767979955::get_offset_of_m_UiScaleMode_2(),
CanvasScaler_t2767979955::get_offset_of_m_ReferencePixelsPerUnit_3(),
CanvasScaler_t2767979955::get_offset_of_m_ScaleFactor_4(),
CanvasScaler_t2767979955::get_offset_of_m_ReferenceResolution_5(),
CanvasScaler_t2767979955::get_offset_of_m_ScreenMatchMode_6(),
CanvasScaler_t2767979955::get_offset_of_m_MatchWidthOrHeight_7(),
0,
CanvasScaler_t2767979955::get_offset_of_m_PhysicalUnit_9(),
CanvasScaler_t2767979955::get_offset_of_m_FallbackScreenDPI_10(),
CanvasScaler_t2767979955::get_offset_of_m_DefaultSpriteDPI_11(),
CanvasScaler_t2767979955::get_offset_of_m_DynamicPixelsPerUnit_12(),
CanvasScaler_t2767979955::get_offset_of_m_Canvas_13(),
CanvasScaler_t2767979955::get_offset_of_m_PrevScaleFactor_14(),
CanvasScaler_t2767979955::get_offset_of_m_PrevReferencePixelsPerUnit_15(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1885 = { sizeof (ScaleMode_t2604066427)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1885[4] =
{
ScaleMode_t2604066427::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1886 = { sizeof (ScreenMatchMode_t3675272090)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1886[4] =
{
ScreenMatchMode_t3675272090::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1887 = { sizeof (Unit_t2218508340)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1887[6] =
{
Unit_t2218508340::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1888 = { sizeof (ContentSizeFitter_t3850442145), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1888[4] =
{
ContentSizeFitter_t3850442145::get_offset_of_m_HorizontalFit_2(),
ContentSizeFitter_t3850442145::get_offset_of_m_VerticalFit_3(),
ContentSizeFitter_t3850442145::get_offset_of_m_Rect_4(),
ContentSizeFitter_t3850442145::get_offset_of_m_Tracker_5(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1889 = { sizeof (FitMode_t3267881214)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1889[4] =
{
FitMode_t3267881214::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1890 = { sizeof (GridLayoutGroup_t3046220461), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1890[6] =
{
GridLayoutGroup_t3046220461::get_offset_of_m_StartCorner_10(),
GridLayoutGroup_t3046220461::get_offset_of_m_StartAxis_11(),
GridLayoutGroup_t3046220461::get_offset_of_m_CellSize_12(),
GridLayoutGroup_t3046220461::get_offset_of_m_Spacing_13(),
GridLayoutGroup_t3046220461::get_offset_of_m_Constraint_14(),
GridLayoutGroup_t3046220461::get_offset_of_m_ConstraintCount_15(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1891 = { sizeof (Corner_t1493259673)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1891[5] =
{
Corner_t1493259673::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1892 = { sizeof (Axis_t3613393006)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1892[3] =
{
Axis_t3613393006::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1893 = { sizeof (Constraint_t814224393)+ sizeof (RuntimeObject), sizeof(int32_t), 0, 0 };
extern const int32_t g_FieldOffsetTable1893[4] =
{
Constraint_t814224393::get_offset_of_value___1() + static_cast<int32_t>(sizeof(RuntimeObject)),
0,
0,
0,
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1894 = { sizeof (HorizontalLayoutGroup_t2586782146), -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1895 = { sizeof (HorizontalOrVerticalLayoutGroup_t729725570), -1, 0, 0 };
extern const int32_t g_FieldOffsetTable1895[5] =
{
HorizontalOrVerticalLayoutGroup_t729725570::get_offset_of_m_Spacing_10(),
HorizontalOrVerticalLayoutGroup_t729725570::get_offset_of_m_ChildForceExpandWidth_11(),
HorizontalOrVerticalLayoutGroup_t729725570::get_offset_of_m_ChildForceExpandHeight_12(),
HorizontalOrVerticalLayoutGroup_t729725570::get_offset_of_m_ChildControlWidth_13(),
HorizontalOrVerticalLayoutGroup_t729725570::get_offset_of_m_ChildControlHeight_14(),
};
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1896 = { 0, -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1897 = { 0, -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1898 = { 0, -1, 0, 0 };
extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1899 = { 0, -1, 0, 0 };
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| 42.555246
| 202
| 0.825802
|
18555851781
|
4b38c607e1eb68ba92f742921717d8b793c8e482
| 342
|
cpp
|
C++
|
test/verify/aoj-0233.test.cpp
|
neal2018/library
|
a19f3b29f3355e32f7e5f6768a7943db48fcdff7
|
[
"Unlicense"
] | 127
|
2019-07-22T03:52:01.000Z
|
2022-03-11T07:20:21.000Z
|
test/verify/aoj-0233.test.cpp
|
neal2018/library
|
a19f3b29f3355e32f7e5f6768a7943db48fcdff7
|
[
"Unlicense"
] | 39
|
2019-09-16T12:04:53.000Z
|
2022-03-29T15:43:35.000Z
|
test/verify/aoj-0233.test.cpp
|
neal2018/library
|
a19f3b29f3355e32f7e5f6768a7943db48fcdff7
|
[
"Unlicense"
] | 29
|
2019-08-10T11:27:06.000Z
|
2022-03-11T07:02:43.000Z
|
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0233"
#include "../../template/template.cpp"
#include "../../math/number-theory/convert-base.cpp"
int main() {
for(;;) {
int X;
cin >> X;
if(X == 0) break;
auto ret = convert_base(X, -10);
for(auto &p : ret) cout << p;
cout << endl;
}
}
| 20.117647
| 79
| 0.578947
|
neal2018
|
4b3a4a535b57389080c8265e4207fcec50d643a2
| 268
|
hpp
|
C++
|
tests/headers/derive-hash-and-blacklist.hpp
|
j-channings/rust-bindgen
|
56e8cf97c9368e0bc9f20f5f66ca2a3773ab97b3
|
[
"BSD-3-Clause"
] | 2
|
2021-10-10T14:41:25.000Z
|
2021-10-30T20:58:01.000Z
|
tests/headers/derive-hash-and-blacklist.hpp
|
j-channings/rust-bindgen
|
56e8cf97c9368e0bc9f20f5f66ca2a3773ab97b3
|
[
"BSD-3-Clause"
] | 3
|
2016-05-31T14:38:04.000Z
|
2016-07-18T21:18:09.000Z
|
tests/headers/derive-hash-and-blacklist.hpp
|
j-channings/rust-bindgen
|
56e8cf97c9368e0bc9f20f5f66ca2a3773ab97b3
|
[
"BSD-3-Clause"
] | 2
|
2016-05-30T18:46:14.000Z
|
2016-06-01T08:14:25.000Z
|
// bindgen-flags: --with-derive-hash --blacklist-type BlacklistMe --raw-line 'pub struct BlacklistMe(u8);'
struct BlacklistMe {};
/**
* Because this type contains a blacklisted type, it should not derive Hash.
*/
struct ShouldNotDeriveHash {
BlacklistMe a;
};
| 24.363636
| 106
| 0.720149
|
j-channings
|
4b3d19e970e47346c0d4e38ad5b6421170d75206
| 97,741
|
cpp
|
C++
|
src/SelbaWard/ConsoleScreen.cpp
|
Stellaris-code/Rayfun
|
2c9e5e2b0cd1636f0a046d6dce0efdce60f094cb
|
[
"WTFPL"
] | null | null | null |
src/SelbaWard/ConsoleScreen.cpp
|
Stellaris-code/Rayfun
|
2c9e5e2b0cd1636f0a046d6dce0efdce60f094cb
|
[
"WTFPL"
] | null | null | null |
src/SelbaWard/ConsoleScreen.cpp
|
Stellaris-code/Rayfun
|
2c9e5e2b0cd1636f0a046d6dce0efdce60f094cb
|
[
"WTFPL"
] | null | null | null |
//////////////////////////////////////////////////////////////////////////////
//
// Selba Ward (https://github.com/Hapaxia/SelbaWard)
// --
//
// Console Screen v2
//
// Copyright(c) 2014-2016 M.J.Silk
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions :
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software.If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
// M.J.Silk
// MJSilk2@gmail.com
//
//////////////////////////////////////////////////////////////////////////////
#include "SelbaWard/ConsoleScreen.hpp"
#include <random>
#include <functional>
#include <algorithm>
#include <SFML/Graphics/Texture.hpp>
namespace
{
const std::string exceptionPrefix{ "Console Screen: " };
const sf::PrimitiveType primitiveType{ sf::PrimitiveType::Quads };
const selbaward::ConsoleScreen::Color defaultColor(15);
const selbaward::ConsoleScreen::Color defaultBackgroundColor(0);
const selbaward::ConsoleScreen::Color defaultCursorColor(15);
const double unBrightAttributeMultiplier{ 0.5 };
const selbaward::ConsoleScreen::Cell defaultCell{ 0u, selbaward::ConsoleScreen::ColorPair(), selbaward::ConsoleScreen::StretchType::None, selbaward::ConsoleScreen::CellAttributes() };
selbaward::ConsoleScreen::Cell fakeCell = defaultCell;
std::mt19937 randomGenerator;
const std::uniform_int_distribution<unsigned short int> randomDistribution(0u, 255u);
std::function <unsigned short int()> getRandomByteValue;
inline void randomSeed()
{
std::random_device rd;
randomGenerator.seed(rd());
getRandomByteValue = std::bind(randomDistribution, randomGenerator);
}
inline unsigned char randomByte()
{
return static_cast<unsigned char>(getRandomByteValue());
}
inline float linearInterpolation(const float start, const float end, const float alpha)
{
return start * (1 - alpha) + end * alpha;
}
inline void makeColorUnBright(sf::Color& color)
{
color.r = static_cast<unsigned int>(unBrightAttributeMultiplier * color.r);
color.g = static_cast<unsigned int>(unBrightAttributeMultiplier * color.g);
color.b = static_cast<unsigned int>(unBrightAttributeMultiplier * color.b);
}
inline void swapColors(sf::Color& a, sf::Color& b)
{
sf::Color temp{ a };
a = b;
b = temp;
}
inline sf::Color sepiaColor(const float alpha)
{
// scaling sepia from grey (1.351, 1.203, 0.937). clamp component to <= 1. scaled to 0-255 range: (344.505, 306.765, 238.935)
const unsigned int r{ static_cast<unsigned int>(linearInterpolation(0.f, 344.505f, alpha)) };
const unsigned int g{ static_cast<unsigned int>(linearInterpolation(0.f, 306.765f, alpha)) };
const unsigned int b{ static_cast<unsigned int>(linearInterpolation(0.f, 238.935f, alpha)) };
return sf::Color((r > 255 ? 255 : r), (g > 255 ? 255 : g), (b > 255 ? 255 : b));
}
inline float relativeLuminance(const sf::Color& color)
{
return 0.2126f * (color.r / 255.f) + 0.7152f * (color.g / 255.f) + 0.0722f * (color.b / 255.f);
}
// contrasts RGB (black or white to contrast RGB's luminance) and keeps same alpha
inline sf::Color contrastedColor(const sf::Color& color)
{
sf::Color result{ sf::Color::Black };
if (relativeLuminance(color) < 0.33f)
result = sf::Color::White;
result.a = color.a;
return result;
}
// inverts RGB and keeps same alpha
inline sf::Color invertedColor(const sf::Color& color)
{
sf::Color result{ sf::Color::White - color };
result.a = color.a;
return result;
}
inline void addColorToPalette(std::vector<sf::Color>& palette, const sf::Color& color)
{
palette.emplace_back(color);
}
void addPaletteDefault(std::vector<sf::Color>& palette)
{
addColorToPalette(palette, sf::Color::Black);
addColorToPalette(palette, sf::Color(0, 0, 128)); // dark blue
addColorToPalette(palette, sf::Color(128, 0, 0)); // dark red
addColorToPalette(palette, sf::Color(128, 0, 128)); // dark magenta
addColorToPalette(palette, sf::Color(0, 128, 0)); // dark green
addColorToPalette(palette, sf::Color(0, 128, 128)); // dark cyan
addColorToPalette(palette, sf::Color(128, 128, 0)); // dark yellow
addColorToPalette(palette, sf::Color(128, 128, 128)); // dark white/medium grey
addColorToPalette(palette, sf::Color(64, 64, 64)); // light black/dark grey/grey
addColorToPalette(palette, sf::Color::Blue);
addColorToPalette(palette, sf::Color::Red);
addColorToPalette(palette, sf::Color::Magenta);
addColorToPalette(palette, sf::Color::Green);
addColorToPalette(palette, sf::Color::Cyan);
addColorToPalette(palette, sf::Color::Yellow);
addColorToPalette(palette, sf::Color::White);
}
void addPalette2ColorBlackWhite(std::vector<sf::Color>& palette)
{
addColorToPalette(palette, sf::Color::Black);
addColorToPalette(palette, sf::Color::White);
}
void addPalette2ColorWhiteBlack(std::vector<sf::Color>& palette)
{
addColorToPalette(palette, sf::Color::White);
addColorToPalette(palette, sf::Color::Black);
}
void addPalette16ColorGreenscale(std::vector<sf::Color>& palette)
{
for (unsigned int i{ 0 }; i < 16; ++i)
addColorToPalette(palette, sf::Color(0, i * 17, 0));
}
void addPalette16ColorGrayscale(std::vector<sf::Color>& palette)
{
for (unsigned int i{ 0 }; i < 16; ++i)
addColorToPalette(palette, sf::Color(i * 17, i * 17, i * 17));
}
void addPalette16ColorSepia(std::vector<sf::Color>& palette)
{
const unsigned int numberOfColors{ 16 };
for (unsigned int i{ 0 }; i < numberOfColors; ++i)
addColorToPalette(palette, sepiaColor(static_cast<float>(i) / (numberOfColors - 1)));
}
void addPalette16ColorCga(std::vector<sf::Color>& palette)
{
addColorToPalette(palette, sf::Color(0, 0, 0));
addColorToPalette(palette, sf::Color(0, 0, 170));
addColorToPalette(palette, sf::Color(170, 0, 0));
addColorToPalette(palette, sf::Color(170, 0, 170));
addColorToPalette(palette, sf::Color(0, 170, 0));
addColorToPalette(palette, sf::Color(0, 170, 170));
addColorToPalette(palette, sf::Color(170, 85, 0));
addColorToPalette(palette, sf::Color(170, 170, 170));
addColorToPalette(palette, sf::Color(85, 85, 85));
addColorToPalette(palette, sf::Color(85, 85, 255));
addColorToPalette(palette, sf::Color(255, 85, 0));
addColorToPalette(palette, sf::Color(255, 85, 255));
addColorToPalette(palette, sf::Color(85, 255, 85));
addColorToPalette(palette, sf::Color(85, 255, 255));
addColorToPalette(palette, sf::Color(255, 255, 85));
addColorToPalette(palette, sf::Color(255, 255, 255));
}
void addPalette16ColorWindows(std::vector<sf::Color>& palette)
{
addColorToPalette(palette, sf::Color(0, 0, 0));
addColorToPalette(palette, sf::Color(128, 0, 0));
addColorToPalette(palette, sf::Color(0, 128, 0));
addColorToPalette(palette, sf::Color(128, 128, 0));
addColorToPalette(palette, sf::Color(0, 0, 128));
addColorToPalette(palette, sf::Color(128, 0, 128));
addColorToPalette(palette, sf::Color(0, 128, 128));
addColorToPalette(palette, sf::Color(128, 128, 128));
addColorToPalette(palette, sf::Color(192, 192, 192));
addColorToPalette(palette, sf::Color(255, 0, 0));
addColorToPalette(palette, sf::Color(0, 0, 255));
addColorToPalette(palette, sf::Color(255, 255, 0));
addColorToPalette(palette, sf::Color(0, 255, 0));
addColorToPalette(palette, sf::Color(255, 0, 255));
addColorToPalette(palette, sf::Color(0, 255, 255));
addColorToPalette(palette, sf::Color(255, 255, 255));
}
void addPalette16ColorMac(std::vector<sf::Color>& palette)
{
addColorToPalette(palette, sf::Color(255, 255, 255));
addColorToPalette(palette, sf::Color(255, 255, 0));
addColorToPalette(palette, sf::Color(255, 102, 0));
addColorToPalette(palette, sf::Color(221, 0, 0));
addColorToPalette(palette, sf::Color(255, 0, 153));
addColorToPalette(palette, sf::Color(51, 0, 153));
addColorToPalette(palette, sf::Color(0, 0, 204));
addColorToPalette(palette, sf::Color(0, 153, 255));
addColorToPalette(palette, sf::Color(0, 170, 0));
addColorToPalette(palette, sf::Color(0, 102, 0));
addColorToPalette(palette, sf::Color(102, 51, 0));
addColorToPalette(palette, sf::Color(153, 102, 51));
addColorToPalette(palette, sf::Color(187, 187, 187));
addColorToPalette(palette, sf::Color(136, 136, 136));
addColorToPalette(palette, sf::Color(68, 68, 68));
addColorToPalette(palette, sf::Color(0, 0, 0));
}
void addPalette16ColorZxSpectrum(std::vector<sf::Color>& palette)
{
addColorToPalette(palette, sf::Color(0, 0, 0));
addColorToPalette(palette, sf::Color(0, 0, 128));
addColorToPalette(palette, sf::Color(128, 0, 0));
addColorToPalette(palette, sf::Color(128, 0, 128));
addColorToPalette(palette, sf::Color(0, 128, 0));
addColorToPalette(palette, sf::Color(0, 128, 128));
addColorToPalette(palette, sf::Color(128, 128, 0));
addColorToPalette(palette, sf::Color(128, 128, 128));
addColorToPalette(palette, sf::Color(0, 0, 0));
addColorToPalette(palette, sf::Color(0, 0, 255));
addColorToPalette(palette, sf::Color(255, 0, 0));
addColorToPalette(palette, sf::Color(255, 0, 255));
addColorToPalette(palette, sf::Color(0, 255, 0));
addColorToPalette(palette, sf::Color(0, 255, 255));
addColorToPalette(palette, sf::Color(255, 255, 0));
addColorToPalette(palette, sf::Color(255, 255, 255));
}
inline void addPalette16ColorCgaNonIbm(std::vector<sf::Color>& palette)
{
addPalette16ColorZxSpectrum(palette);
}
void addPalette16Color16Html(std::vector<sf::Color>& palette)
{
addColorToPalette(palette, sf::Color(0, 0, 0));
addColorToPalette(palette, sf::Color(196, 196, 196));
addColorToPalette(palette, sf::Color(128, 128, 128));
addColorToPalette(palette, sf::Color(255, 255, 255));
addColorToPalette(palette, sf::Color(128, 0, 0));
addColorToPalette(palette, sf::Color(255, 0, 0));
addColorToPalette(palette, sf::Color(128, 0, 128));
addColorToPalette(palette, sf::Color(255, 0, 255));
addColorToPalette(palette, sf::Color(0, 128, 0));
addColorToPalette(palette, sf::Color(0, 255, 0));
addColorToPalette(palette, sf::Color(128, 128, 0));
addColorToPalette(palette, sf::Color(255, 255, 0));
addColorToPalette(palette, sf::Color(0, 0, 128));
addColorToPalette(palette, sf::Color(0, 0, 255));
addColorToPalette(palette, sf::Color(0, 128, 128));
addColorToPalette(palette, sf::Color(0, 255, 255));
}
void addPalette216ColorWebSafe(std::vector<sf::Color>& palette)
{
for (unsigned int r{ 0u }; r < 6; ++r)
{
for (unsigned int g{ 0u }; g < 6; ++g)
{
for (unsigned int b{ 0u }; b < 6; ++b)
addColorToPalette(palette, sf::Color(r * 51, g * 51, b * 51));
}
}
}
void addPalette256ColorGreenscale(std::vector<sf::Color>& palette)
{
for (unsigned int i{ 0 }; i < 256; ++i)
addColorToPalette(palette, sf::Color(0, i, 0));
}
void addPalette256ColorGrayscale(std::vector<sf::Color>& palette)
{
for (unsigned int i{ 0 }; i < 256; ++i)
addColorToPalette(palette, sf::Color(i, i, i));
}
void addPalette256ColorSepia(std::vector<sf::Color>& palette)
{
const unsigned int numberOfColors{ 256 };
for (unsigned int i{ 0 }; i < numberOfColors; ++i)
addColorToPalette(palette, sepiaColor(static_cast<float>(i) / (numberOfColors - 1)));
}
} // namespace
namespace selbaward
{
ConsoleScreen& ConsoleScreen::operator<<(const std::string& string)
{
print(string);
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const Direct& direct)
{
if (direct == Direct::Begin)
{
m_is.directPrinting = true;
//m_directPrintProperties = m_cursorPrintProperties;
}
else
{
m_is.directPrinting = false;
resetPrintProperties(PrintType::Direct);
}
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const Location& location)
{
const unsigned int currentIndex{ priv_getCurrentPrintProperties().index };
priv_getCurrentPrintProperties().index = priv_getPrintIndex(location);
if (m_do.updateAutomatically)
{
priv_updateCell(currentIndex);
if (priv_getCurrentPrintProperties().index != currentIndex)
priv_updateCell(priv_getPrintIndex(location));
}
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const Offset& offset)
{
const Location location{ priv_cellLocation(priv_getCurrentPrintProperties().index) };
sf::Vector2i targetLocation{ sf::Vector2i(location) + offset };
while (targetLocation.y >= 0 && targetLocation.x < 0)
--targetLocation.y;
if (targetLocation.y < 0)
targetLocation = { 0, 0 };
return *this << Location(targetLocation);
}
ConsoleScreen& ConsoleScreen::operator<<(const Affect& affectMask)
{
priv_getCurrentPrintProperties().affectBitmask = affectMask;
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const unsigned int affectMask)
{
priv_getCurrentPrintProperties().affectBitmask = affectMask;
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const ColorType& colorType)
{
priv_getCurrentPrintProperties().colorType = colorType;
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const Color& color)
{
priv_getActiveColor() = color;
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const sf::Color& newColor)
{
if (m_is.rgbMode)
return *this << Color(newColor.r * 65536L + newColor.g * 256L + newColor.b);
Color color(m_palette.size());
if (m_do.addNewColorToPalette)
addColorToPalette(newColor);
else
{
color.id = priv_getIndexOfClosestPaletteColor(newColor);
if (color.id < 0)
color.id = 0;
}
return *this << color;
}
ConsoleScreen& ConsoleScreen::operator<<(const ColorPair& colorPair)
{
priv_getCurrentPrintProperties().colors = colorPair;
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const Fg& foregroundColor)
{
priv_getCurrentPrintProperties().colors.foreground = foregroundColor.color;
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const Bg& backgroundColor)
{
priv_getCurrentPrintProperties().colors.background = backgroundColor.color;
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const Wipe& length)
{
return *this << length.string;
}
ConsoleScreen& ConsoleScreen::operator<<(const StretchType& stretchType)
{
priv_getCurrentPrintProperties().stretch = stretchType;
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const CellAttributes& cellAttributes)
{
priv_getCurrentPrintProperties().attributes = cellAttributes;
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const MovementControl& movementControl)
{
PrintProperties& printProperties{ priv_getCurrentPrintProperties() };
const unsigned int currentIndex{ printProperties.index };
switch (movementControl.direction)
{
case Direction::Left:
if (printProperties.index > movementControl.amount)
printProperties.index -= movementControl.amount;
else
printProperties.index = 0;
break;
case Direction::Right:
printProperties.index += movementControl.amount;
break;
case Direction::Up:
{
const unsigned int lefts{ m_mode.x * movementControl.amount };
if (printProperties.index > lefts)
printProperties.index -= lefts;
else
printProperties.index = 0;
}
break;
case Direction::Down:
printProperties.index += m_mode.x * movementControl.amount;
break;
default:
;
}
if (printProperties.index >= m_cells.size())
{
if (m_is.directPrinting)
printProperties.index = m_cells.size() - 1;
else
priv_testCursorForScroll();
}
if (m_do.updateAutomatically)
{
priv_updateCell(currentIndex);
priv_updateCell(printProperties.index);
}
return *this;
}
ConsoleScreen& ConsoleScreen::operator<<(const CursorCommand& cursorCommand)
{
PrintProperties& printProperties{ priv_getCurrentPrintProperties() };
const unsigned int currentIndex{ printProperties.index };
const unsigned int maxIndex{ static_cast<unsigned int>(m_cells.size() - 1) };
switch (cursorCommand)
{
case CursorCommand::Newline:
printProperties.index += m_mode.x;
if (printProperties.stretch == StretchType::Both)
printProperties.index += m_mode.x;
printProperties.index -= printProperties.index % m_mode.x;
break;
case CursorCommand::Left:
if (printProperties.index > 0)
--printProperties.index;
break;
case CursorCommand::Right:
++printProperties.index;
break;
case CursorCommand::Up:
if (printProperties.index > m_mode.x)
printProperties.index -= m_mode.x;
else
printProperties.index = 0;
break;
case CursorCommand::Down:
printProperties.index += m_mode.x;
break;
case CursorCommand::Home:
printProperties.index = 0u;
break;
case CursorCommand::End:
printProperties.index = maxIndex;
break;
case CursorCommand::HomeLine:
printProperties.index -= printProperties.index % m_mode.x;
break;
case CursorCommand::EndLine:
printProperties.index -= printProperties.index % m_mode.x - (m_mode.x - 1);
break;
case CursorCommand::Tab:
{
const unsigned int col{ printProperties.index % m_mode.x };
const unsigned int rowStartIndex{ printProperties.index - col };
const unsigned int targetIndex{ rowStartIndex + (col / m_tabSize + 1) * m_tabSize };
if (targetIndex < rowStartIndex + m_mode.x)
printProperties.index = targetIndex;
else
printProperties.index = rowStartIndex + m_mode.x;
}
break;
case CursorCommand::TabReverse:
{
const unsigned int col{ printProperties.index % m_mode.x };
const unsigned int rowStartIndex{ printProperties.index - col };
const int targetIndex{ static_cast<int>(rowStartIndex + ((static_cast<long int>(col) - 1) / m_tabSize) * m_tabSize) };
if (targetIndex >= 0)
printProperties.index = static_cast<unsigned int>(targetIndex);
}
break;
case CursorCommand::Backspace:
// affects cell contents
if (printProperties.index > 0)
--printProperties.index;
priv_clearCell(printProperties.index, false, false);
if (printProperties.stretch == StretchType::Both)
{
const unsigned int belowIndex{ printProperties.index + m_mode.x };
if (priv_isCellIndexInRange(belowIndex))
priv_clearCell(belowIndex, false, false);
}
break;
case CursorCommand::Delete:
// affects cell contents
priv_clearCell(printProperties.index, false, false);
if (printProperties.stretch == StretchType::Both)
{
const unsigned int belowIndex{ printProperties.index + m_mode.x };
if (priv_isCellIndexInRange(belowIndex))
priv_clearCell(belowIndex, false, false);
}
break;
case CursorCommand::None:
default:
;
}
if (printProperties.index > maxIndex)
{
if (m_is.directPrinting)
printProperties.index = maxIndex;
else
priv_testCursorForScroll();
}
if (m_do.updateAutomatically)
{
priv_updateCell(currentIndex);
priv_updateCell(printProperties.index);
}
return *this;
}
ConsoleScreen& ConsoleScreen::operator>>(std::string& string)
{
if (priv_isCellIndexInRange(priv_getCurrentPrintProperties().index))
string = priv_read(priv_getCurrentPrintProperties().index);
else
string = "";
return *this;
}
ConsoleScreen& ConsoleScreen::operator>>(const unsigned int length)
{
m_readLength = length;
return *this;
}
ConsoleScreen& ConsoleScreen::operator>>(const Direct& direct)
{
return *this << direct;
}
ConsoleScreen& ConsoleScreen::operator>>(const Location& location)
{
return *this << location;
}
ConsoleScreen& ConsoleScreen::operator>>(const Offset& offset)
{
return *this << offset;
}
ConsoleScreen& ConsoleScreen::operator>>(const MovementControl& movementControl)
{
return *this << movementControl;
}
ConsoleScreen& ConsoleScreen::operator>>(const CursorCommand& cursorCommand)
{
return *this << cursorCommand;
}
ConsoleScreen::ConsoleScreen(const sf::Vector2u mode)
: m_cells()
, m_mode(mode)
, m_buffers()
, m_do()
, m_is()
, m_display()
, m_backgroundDisplay()
, m_overDisplay()
, m_underDisplay()
, m_size{ 100.f, 100.f }
, m_texture(nullptr)
, m_textureOffset{ 0u, 0u }
, m_tileSize{ 8u, 8u }
, m_numberOfTilesPerRow{ 8u }
, m_palette()
, m_cursor{ static_cast<int>('_'), defaultCursorColor, true, false, false }
, m_tabSize{ 4u }
, m_readLength{ 1u }
, m_characterMap()
, m_defaultPrintProperties{ 0u, ColorPair(defaultColor, defaultBackgroundColor), StretchType::None, CellAttributes(), Affect::Default, ColorType::Foreground }
{
m_cursorPrintProperties = m_defaultPrintProperties;
m_directPrintProperties = m_defaultPrintProperties;
randomSeed();
loadPalette(Palette::Default);
setMode(m_mode);
}
void ConsoleScreen::setMode(sf::Vector2u mode)
{
if (mode.x == 0 || mode.y == 0)
mode = { 0u, 0u };
m_mode = mode;
m_cells.resize(m_mode.x * m_mode.y, defaultCell);
m_display.resize(m_cells.size() * 4);
m_backgroundDisplay = m_display;
m_buffers.clear();
clear(Color(0));
}
void ConsoleScreen::setTexture(const sf::Texture& texture)
{
m_texture = &texture;
}
void ConsoleScreen::setTexture()
{
m_texture = nullptr;
}
void ConsoleScreen::setSize(const sf::Vector2f size)
{
m_size = size;
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::setTextureOffset(const sf::Vector2u textureOffset)
{
m_textureOffset = textureOffset;
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::setTextureTileSize(const sf::Vector2u tileSize)
{
m_tileSize = tileSize;
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::setNumberOfTextureTilesPerRow(const unsigned int numberOfTextureTilesPerRow)
{
if (numberOfTextureTilesPerRow < 1)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set number of texture tiles per row to zero.");
return;
}
m_numberOfTilesPerRow = numberOfTextureTilesPerRow;
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::setThrowExceptions(const bool throwExceptions)
{
m_do.throwExceptions = throwExceptions;
}
void ConsoleScreen::setUpdateAutomatically(const bool updateAutomatically)
{
m_do.updateAutomatically = updateAutomatically;
}
void ConsoleScreen::setShowCursor(const bool showCursor)
{
m_cursor.visible = showCursor;
if (m_do.updateAutomatically)
priv_updateCell(m_cursorPrintProperties.index);
}
void ConsoleScreen::setInvertCursor(const bool invertCursor)
{
m_cursor.inverse = invertCursor;
if (m_do.updateAutomatically)
priv_updateCell(m_cursorPrintProperties.index);
}
void ConsoleScreen::setUseCursorColor(const bool useCursorColor)
{
m_cursor.useOwnColour = useCursorColor;
if (m_do.updateAutomatically)
priv_updateCell(m_cursorPrintProperties.index);
}
void ConsoleScreen::setShowBackground(const bool showBackground)
{
m_do.showBackround = showBackground;
}
void ConsoleScreen::setScrollAutomatically(const bool scrollAutomatically)
{
m_do.scrollAutomatically = scrollAutomatically;
}
void ConsoleScreen::setWrapOnManualScroll(const bool wrapOnManualScroll)
{
m_do.wrapOnManualScroll = wrapOnManualScroll;
}
void ConsoleScreen::setAddNewColorToPalette(const bool addNewColorToPalette)
{
m_do.addNewColorToPalette = addNewColorToPalette;
}
void ConsoleScreen::update()
{
if (m_display.size() != (m_mode.x * m_mode.y * 4))
return;
if (m_backgroundDisplay.size() != m_display.size())
m_backgroundDisplay.resize(m_display.size());
if (m_display.size() < 4)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot update display.\nNo cells available.");
return;
}
for (unsigned int i{ 0u }; i < m_cells.size(); ++i)
priv_updateCell(i);
priv_updateUnderCells();
priv_updateOverCells();
}
sf::Vector2f ConsoleScreen::getSize() const
{
return m_size;
}
sf::Vector2f ConsoleScreen::getPerfectSize() const
{
return{ static_cast<float>(m_tileSize.x * m_mode.x), static_cast<float>(m_tileSize.y * m_mode.y) };
}
sf::FloatRect ConsoleScreen::getLocalBounds() const
{
return{ { 0.f, 0.f }, m_size };
}
sf::FloatRect ConsoleScreen::getGlobalBounds() const
{
return getTransform().transformRect(getLocalBounds());
}
sf::Vector2u ConsoleScreen::getMode() const
{
return m_mode;
}
unsigned int ConsoleScreen::getNumberOfCells() const
{
return m_cells.size();
}
sf::Vector2u ConsoleScreen::getNumberOfTilesInTexture2d() const
{
return{ m_numberOfTilesPerRow, m_texture->getSize().y / m_tileSize.y };
}
unsigned int ConsoleScreen::getNumberOfTilesInTexture() const
{
const sf::Vector2u numberOfTiles{ getNumberOfTilesInTexture2d() };
return numberOfTiles.x * numberOfTiles.y;
}
bool ConsoleScreen::getThrowExceptions() const
{
return m_do.throwExceptions;
}
bool ConsoleScreen::getUpdateAutomatically() const
{
return m_do.updateAutomatically;
}
bool ConsoleScreen::getShowCursor() const
{
return m_cursor.visible;
}
bool ConsoleScreen::getInvertCursor() const
{
return m_cursor.inverse;
}
bool ConsoleScreen::getUseCursorColor() const
{
return m_cursor.useOwnColour;
}
bool ConsoleScreen::getShowBackground() const
{
return m_do.showBackround;
}
bool ConsoleScreen::getScrollAutomatically() const
{
return m_do.scrollAutomatically;
}
bool ConsoleScreen::getWrapOnManualScroll() const
{
return m_do.wrapOnManualScroll;
}
bool ConsoleScreen::getAddNewColorToPalette() const
{
return m_do.addNewColorToPalette;
}
void ConsoleScreen::setCursor(const int cellValue)
{
m_cursor.value = cellValue;
if (m_do.updateAutomatically)
priv_updateCell(m_cursorPrintProperties.index);
}
void ConsoleScreen::setCursor(const char cellCharacter, bool mapCharacter)
{
m_cursor.value = mapCharacter ? priv_getCellValueFromCharacter(cellCharacter) : static_cast<int>(cellCharacter);
if (m_do.updateAutomatically)
priv_updateCell(m_cursorPrintProperties.index);
}
void ConsoleScreen::setCursorColor(const Color& color)
{
m_cursor.color = color;
}
int ConsoleScreen::getCursorValue() const
{
return m_cursor.value;
}
char ConsoleScreen::getCursorChar(const bool mapCharacter) const
{
return mapCharacter ? priv_getCharacterFromCellValue(m_cursor.value) : static_cast<char>(m_cursor.value);
}
ConsoleScreen::Color ConsoleScreen::getCursorColor() const
{
return m_cursor.color;
}
void ConsoleScreen::print(const char character)
{
if (getIsMappedCursorCommandCharacter(character))
{
*this << getMappedCursorCommandCharacter(character);
return;
}
PrintProperties& printProperties{ priv_getCurrentPrintProperties() };
if (!priv_isCellIndexInRange(printProperties.index))
return;
const unsigned int currentIndex{ printProperties.index };
const unsigned int cellValue{ priv_getCellValueFromCharacter(character) };
const Cell existingCell = peek(currentIndex);
Cell cell = existingCell;
if (printProperties.affectBitmask & Affect::Value)
cell.value = cellValue;
if (printProperties.affectBitmask & Affect::FgColor)
cell.colors.foreground = printProperties.colors.foreground;
if (printProperties.affectBitmask & Affect::BgColor)
cell.colors.background = printProperties.colors.background;
if (printProperties.affectBitmask & Affect::Inverse)
cell.attributes.inverse = printProperties.attributes.inverse;
if (printProperties.affectBitmask & Affect::Bright)
cell.attributes.bright = printProperties.attributes.bright;
if (printProperties.affectBitmask & Affect::FlipX)
cell.attributes.flipX = printProperties.attributes.flipX;
if (printProperties.affectBitmask & Affect::FlipY)
cell.attributes.flipY = printProperties.attributes.flipY;
if (printProperties.affectBitmask & Affect::Stretch)
{
if (printProperties.stretch == StretchType::Both)
cell.stretch = StretchType::Top;
else
cell.stretch = printProperties.stretch;
}
poke(currentIndex, cell);
if (printProperties.stretch == StretchType::Both)
{
const unsigned int belowIndex{ currentIndex + m_mode.x };
if (priv_isCellIndexInRange(belowIndex))
{
cell.stretch = StretchType::Bottom;
poke(belowIndex, cell);
}
}
++printProperties.index;
if (!m_is.directPrinting)
priv_testCursorForScroll();
else if (!priv_isCellIndexInRange(printProperties.index))
printProperties.index = m_cells.size() - 1;
if (m_do.updateAutomatically)
{
priv_updateCell(currentIndex);
if (currentIndex != printProperties.index)
priv_updateCell(printProperties.index);
}
}
void ConsoleScreen::print(const std::string& string)
{
for (auto& character : string)
print(character);
}
void ConsoleScreen::print(const Location& location, char character)
{
PrintProperties backupPrintProperties = priv_getCurrentPrintProperties();
priv_getCurrentPrintProperties().index = priv_getPrintIndex(location);
print(character);
priv_getCurrentPrintProperties() = backupPrintProperties;
}
void ConsoleScreen::print(const Location& location, const std::string& string)
{
PrintProperties backupPrintProperties = priv_getCurrentPrintProperties();
priv_getCurrentPrintProperties().index = priv_getPrintIndex(location);
print(string);
priv_getCurrentPrintProperties() = backupPrintProperties;
}
void ConsoleScreen::addOverAt(const Location& location, char character)
{
if (getIsMappedCursorCommandCharacter(character))
{
*this << getMappedCursorCommandCharacter(character);
return;
}
PrintProperties& printProperties{ priv_getCurrentPrintProperties() };
const unsigned int cellValue{ priv_getCellValueFromCharacter(character) };
Cell cell;
cell.value = cellValue;
cell.colors.foreground = printProperties.colors.foreground.id < 0 ? 0 : printProperties.colors.foreground;
cell.attributes.inverse = printProperties.attributes.inverse;
cell.attributes.bright = printProperties.attributes.bright;
cell.attributes.flipX = printProperties.attributes.flipX;
cell.attributes.flipY = printProperties.attributes.flipY;
if (printProperties.stretch == StretchType::Both)
cell.stretch = StretchType::Top;
else
cell.stretch = printProperties.stretch;
addOverAt(location, cell);
if (printProperties.stretch == StretchType::Both)
{
const Location belowLocation{ location.x, location.y + 1 };
if (priv_isCellLocationInRange(belowLocation))
{
cell.stretch = StretchType::Bottom;
addOverAt(belowLocation, cell);
}
}
}
void ConsoleScreen::addOverAt(const Location& location, const std::string& string)
{
Location currentLocation{ location };
for (auto& character : string)
{
addOverAt(currentLocation, character);
++currentLocation.x;
if (currentLocation.x >= m_mode.x)
{
currentLocation.x = 0;
++currentLocation.y;
if (currentLocation.y >= m_mode.y)
return;
}
}
}
void ConsoleScreen::addOverAt(const Location& location, const Cell& cell)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception("Cannot add stack-over cell.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
const unsigned int index{ priv_cellIndex(location) };
m_overCells.emplace_back(CellAt{ index, cell });
if (m_overCells.back().cell.colors.foreground.id < 0)
m_overCells.back().cell.colors.foreground = 0;
if (m_do.updateAutomatically)
priv_updateOverCells();
}
void ConsoleScreen::addUnderAt(const Location& location, char character)
{
if (getIsMappedCursorCommandCharacter(character))
{
*this << getMappedCursorCommandCharacter(character);
return;
}
PrintProperties& printProperties{ priv_getCurrentPrintProperties() };
const unsigned int cellValue{ priv_getCellValueFromCharacter(character) };
Cell cell;
cell.value = cellValue;
cell.colors.foreground = printProperties.colors.foreground.id < 0 ? 0 : printProperties.colors.foreground;
cell.attributes.inverse = printProperties.attributes.inverse;
cell.attributes.bright = printProperties.attributes.bright;
cell.attributes.flipX = printProperties.attributes.flipX;
cell.attributes.flipY = printProperties.attributes.flipY;
if (printProperties.stretch == StretchType::Both)
cell.stretch = StretchType::Top;
else
cell.stretch = printProperties.stretch;
addUnderAt(location, cell);
if (printProperties.stretch == StretchType::Both)
{
const Location belowLocation{ location.x, location.y + 1 };
if (priv_isCellLocationInRange(belowLocation))
{
cell.stretch = StretchType::Bottom;
addUnderAt(belowLocation, cell);
}
}
}
void ConsoleScreen::addUnderAt(const Location& location, const std::string& string)
{
Location currentLocation{ location };
for (auto& character : string)
{
addUnderAt(currentLocation, character);
++currentLocation.x;
if (currentLocation.x >= m_mode.x)
{
currentLocation.x = 0;
++currentLocation.y;
if (currentLocation.y >= m_mode.y)
return;
}
}
}
void ConsoleScreen::addUnderAt(const Location& location, const Cell& cell)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception("Cannot add stack-under cell.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
const unsigned int index{ priv_cellIndex(location) };
m_underCells.emplace_back(CellAt{ index, cell });
if (m_underCells.back().cell.colors.foreground.id < 0)
m_underCells.back().cell.colors.foreground = 0;
if (m_do.updateAutomatically)
priv_updateUnderCells();
}
void ConsoleScreen::clearOversAt(const Location& location)
{
const unsigned int index{ priv_cellIndex(location) };
m_overCells.erase(std::remove_if(m_overCells.begin(), m_overCells.end(), [&index](const CellAt& cellAt) { return cellAt.index == index; }), m_overCells.end());
if (m_do.updateAutomatically)
priv_updateOverCells();
}
void ConsoleScreen::clearUndersAt(const Location& location)
{
const unsigned int index{ priv_cellIndex(location) };
m_underCells.erase(std::remove_if(m_underCells.begin(), m_underCells.end(), [&index](const CellAt& cellAt) { return cellAt.index == index; }), m_underCells.end());
if (m_do.updateAutomatically)
priv_updateUnderCells();
}
void ConsoleScreen::clearStackAt(const Location& location)
{
clearOversAt(location);
clearUndersAt(location);
}
void ConsoleScreen::clearOvers()
{
m_overCells.clear();
if (m_do.updateAutomatically)
m_overDisplay.clear();
}
void ConsoleScreen::clearUnders()
{
m_underCells.clear();
if (m_do.updateAutomatically)
m_underDisplay.clear();
}
void ConsoleScreen::clearStack()
{
clearOvers();
clearUnders();
}
void ConsoleScreen::pasteOver(const sf::Vector2i offset)
{
if (m_buffers.size() == 0)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot stack-paste buffer.\nNo buffer exists.");
return;
}
pasteOver(m_buffers.size() - 1, offset);
}
void ConsoleScreen::pasteUnder(const sf::Vector2i offset)
{
if (m_buffers.size() == 0)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot stack-paste buffer.\nNo buffer exists.");
return;
}
pasteUnder(m_buffers.size() - 1, offset);
}
void ConsoleScreen::pasteOver(const unsigned int index, const sf::Vector2i offset)
{
if (!priv_isScreenBufferIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot stack-paste buffer.\nBuffer index (" + std::to_string(index) + ") out of range.");
return;
}
Buffer& buffer{ m_buffers[index] };
for (unsigned int i{ 0 }; i < buffer.cells.size(); ++i)
{
const sf::Vector2i location{ static_cast<int>(i % buffer.width) + offset.x, static_cast<int>(i / buffer.width) + offset.y };
if (location.x < 0 || location.y < 0)
continue;
const sf::Vector2u cellLocation{ static_cast<unsigned int>(location.x), static_cast<unsigned int>(location.y) };
if (priv_isCellLocationInRange(cellLocation))
addOverAt(cellLocation, buffer.cells[i]);
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::pasteUnder(const unsigned int index, const sf::Vector2i offset)
{
if (!priv_isScreenBufferIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot stack-paste buffer.\nBuffer index (" + std::to_string(index) + ") out of range.");
return;
}
Buffer& buffer{ m_buffers[index] };
for (unsigned int i{ 0 }; i < buffer.cells.size(); ++i)
{
const sf::Vector2i location{ static_cast<int>(i % buffer.width) + offset.x, static_cast<int>(i / buffer.width) + offset.y };
if (location.x < 0 || location.y < 0)
continue;
const sf::Vector2u cellLocation{ static_cast<unsigned int>(location.x), static_cast<unsigned int>(location.y) };
if (priv_isCellLocationInRange(cellLocation))
addUnderAt(cellLocation, buffer.cells[i]);
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::resetPrintProperties(const PrintType printType)
{
priv_getPrintProperties(printType) = m_defaultPrintProperties;
}
ConsoleScreen::Location ConsoleScreen::getLocation(const PrintType printType)
{
return priv_cellLocation(priv_getPrintProperties(printType).index);
}
unsigned int ConsoleScreen::getIndex(const PrintType printType)
{
return priv_getPrintProperties(printType).index;
}
ConsoleScreen::ColorPair ConsoleScreen::getColors(const PrintType printType)
{
return priv_getPrintProperties(printType).colors;
}
ConsoleScreen::StretchType ConsoleScreen::getStretchType(const PrintType printType)
{
return priv_getPrintProperties(printType).stretch;
}
ConsoleScreen::CellAttributes ConsoleScreen::getCellAttributes(const PrintType printType)
{
return priv_getPrintProperties(printType).attributes;
}
unsigned int ConsoleScreen::getAffectBitmask(const PrintType printType)
{
return priv_getPrintProperties(printType).affectBitmask;
}
ConsoleScreen::ColorType ConsoleScreen::getColorType(const PrintType printType)
{
return priv_getPrintProperties(printType).colorType;
}
void ConsoleScreen::clearCellAt(const sf::Vector2u location)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot clear cell.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
priv_clearCell(priv_cellIndex(location), m_cursorPrintProperties.colors.foreground, m_cursorPrintProperties.colors.background);
if (m_do.updateAutomatically)
priv_updateCell(priv_cellIndex(location));
}
void ConsoleScreen::setCellAt(const sf::Vector2u location, const Cell& cell)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set cell.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
m_cells[priv_cellIndex(location)] = cell;
if (m_do.updateAutomatically)
priv_updateCell(priv_cellIndex(location));
}
void ConsoleScreen::setValueAt(const sf::Vector2u location, const unsigned int value)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set cell value.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
m_cells[priv_cellIndex(location)].value = value;
if (m_do.updateAutomatically)
priv_updateCell(priv_cellIndex(location));
}
void ConsoleScreen::setColorsAt(const sf::Vector2u location, const Color color, const Color backgroundColor)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set cell colors.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
const unsigned int index{ priv_cellIndex(location) };
m_cells[index].colors.foreground = color;
m_cells[index].colors.background = backgroundColor;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::setForegroundColorAt(const sf::Vector2u location, const Color color)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set cell foreground color.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
const unsigned int index{ priv_cellIndex(location) };
m_cells[index].colors.foreground = color;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::setBackgroundColorAt(const sf::Vector2u location, const Color backgroundColor)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set cell background colors.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
const unsigned int index{ priv_cellIndex(location) };
m_cells[index].colors.background = backgroundColor;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::setStretchAt(const sf::Vector2u location, const StretchType& stretch)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set cell stretch.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
m_cells[priv_cellIndex(location)].stretch = stretch;
if (m_do.updateAutomatically)
priv_updateCell(priv_cellIndex(location));
}
void ConsoleScreen::setAttributesAt(const sf::Vector2u location, const CellAttributes& attributes)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set cell attributes.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
m_cells[priv_cellIndex(location)].attributes = attributes;
if (m_do.updateAutomatically)
priv_updateCell(priv_cellIndex(location));
}
void ConsoleScreen::setAttributesAt(const sf::Vector2u location, const Affect& attributeMask)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set cell attributes.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
CellAttributes& cellAttributes{ m_cells[priv_cellIndex(location)].attributes };
cellAttributes.inverse = (attributeMask & Affect::Inverse) == Affect::Inverse;
cellAttributes.bright = (attributeMask & Affect::Bright) == Affect::Bright;
cellAttributes.flipX = (attributeMask & Affect::FlipX) == Affect::FlipX;
cellAttributes.flipY = (attributeMask & Affect::FlipY) == Affect::FlipY;
if (m_do.updateAutomatically)
priv_updateCell(priv_cellIndex(location));
}
void ConsoleScreen::setAttributesToAt(const sf::Vector2u location, const bool attributeValue, const Affect& attributeMask)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set cell attributes.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return;
}
CellAttributes& cellAttributes{ m_cells[priv_cellIndex(location)].attributes };
if ((attributeMask & Affect::Inverse) == Affect::Inverse)
cellAttributes.inverse = attributeValue;
if ((attributeMask & Affect::Bright) == Affect::Bright)
cellAttributes.bright = attributeValue;
if ((attributeMask & Affect::FlipX) == Affect::FlipX)
cellAttributes.flipX = attributeValue;
if ((attributeMask & Affect::FlipY) == Affect::FlipY)
cellAttributes.flipY = attributeValue;
if (m_do.updateAutomatically)
priv_updateCell(priv_cellIndex(location));
}
ConsoleScreen::Cell ConsoleScreen::getCellAt(const sf::Vector2u location) const
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot get cell.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return Cell();
}
return m_cells[priv_cellIndex(location)];
}
unsigned int ConsoleScreen::getValueAt(const sf::Vector2u location) const
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot get cell value.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return 0u;
}
return m_cells[priv_cellIndex(location)].value;
}
ConsoleScreen::Color ConsoleScreen::getColorAt(const sf::Vector2u location) const
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot get cell color.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return Color(ColorCommand::Unused);
}
return m_cells[priv_cellIndex(location)].colors.foreground;
}
ConsoleScreen::Color ConsoleScreen::getBackgroundColorAt(const sf::Vector2u location) const
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot get cell background color.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return Color(ColorCommand::Unused);
}
return m_cells[priv_cellIndex(location)].colors.background;
}
ConsoleScreen::StretchType ConsoleScreen::getStretchAt(const sf::Vector2u location) const
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot get cell stretch.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return StretchType::None;
}
return m_cells[priv_cellIndex(location)].stretch;
}
ConsoleScreen::CellAttributes ConsoleScreen::getAttributesAt(const sf::Vector2u location) const
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot get cell attributes.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return CellAttributes();
}
return m_cells[priv_cellIndex(location)].attributes;
}
bool ConsoleScreen::getAttributeAt(const sf::Vector2u location, const Affect& attributeMask)
{
if (!priv_isCellLocationInRange(location))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot get cell attribute.\nLocation (" + std::to_string(location.x) + ", " + std::to_string(location.y) + ") out of range.");
return false;
}
CellAttributes& cellAttributes{ m_cells[priv_cellIndex(location)].attributes };
if ((attributeMask & Affect::Inverse) == Affect::Inverse)
return cellAttributes.inverse;
if ((attributeMask & Affect::Bright) == Affect::Bright)
return cellAttributes.bright;
if ((attributeMask & Affect::FlipX) == Affect::FlipX)
return cellAttributes.flipX;
if ((attributeMask & Affect::FlipY) == Affect::FlipY)
return cellAttributes.flipY;
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot get cell attribute.\nAttribute mask does not include attribute.");
return false;
}
void ConsoleScreen::scrollUp(const unsigned int amount)
{
if (m_mode.y == 0 || amount == 0)
return;
std::vector<Cell> topRow(m_mode.x);
for (unsigned int repeat{ 0 }; repeat < amount; ++repeat) // lazy way of scrolling multiple times - loop scrolling (entirely by 1 each time)
{
for (unsigned int y{ 0 }; y < m_mode.y; ++y)
{
for (unsigned int x{ 0 }; x < m_mode.x; ++x)
{
if (m_do.wrapOnManualScroll && y == 0)
topRow[x] = m_cells[x];
if (y < m_mode.y - 1)
m_cells[priv_cellIndex({ x, y })] = m_cells[priv_cellIndex({ x, y + 1 })];
else if (m_do.wrapOnManualScroll)
m_cells[priv_cellIndex({ x, y })] = topRow[x];
else
priv_clearCell(priv_cellIndex({ x, y }), true, true);
}
}
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::scrollDown(const unsigned int amount)
{
if (m_mode.y == 0 || amount == 0)
return;
std::vector<Cell> bottomRow(m_mode.x);
for (unsigned int repeat{ 0 }; repeat < amount; ++repeat) // lazy way of scrolling multiple times - loop scrolling (entirely by 1 each time)
{
for (unsigned int y{ 0 }; y < m_mode.y; ++y)
{
for (unsigned int x{ 0 }; x < m_mode.x; ++x)
{
const unsigned cellY{ m_mode.y - y - 1 };
if (m_do.wrapOnManualScroll && y == 0)
bottomRow[x] = m_cells[priv_cellIndex({ x, cellY })];
if (cellY > 0)
m_cells[priv_cellIndex({ x, cellY })] = m_cells[priv_cellIndex({ x, cellY - 1 })];
else if (m_do.wrapOnManualScroll)
m_cells[priv_cellIndex({ x, cellY })] = bottomRow[x];
else
priv_clearCell(priv_cellIndex({ x, cellY }), true, true);
}
}
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::scrollLeft(const unsigned int amount)
{
if (m_mode.x == 0 || amount == 0)
return;
Cell leftCell;
for (unsigned int repeat{ 0 }; repeat < amount; ++repeat) // lazy way of scrolling multiple times - loop scrolling (entirely by 1 each time)
{
for (unsigned int cell{ 0 }; cell < m_cells.size(); ++cell)
{
if (cell % m_mode.x == 0)
leftCell = m_cells[cell];
if (cell % m_mode.x == m_mode.x - 1)
{
if (m_do.wrapOnManualScroll)
m_cells[cell] = leftCell;
else
priv_clearCell(cell, true, true);
}
else
m_cells[cell] = m_cells[cell + 1];
}
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::scrollRight(const unsigned int amount)
{
if (m_mode.x == 0 || amount == 0)
return;
Cell rightCell;
for (unsigned int repeat{ 0 }; repeat < amount; ++repeat) // lazy way of scrolling multiple times - loop scrolling (entirely by 1 each time)
{
for (unsigned int i{ 0 }; i < m_cells.size(); ++i)
{
const unsigned int cell{ static_cast<unsigned int>(m_cells.size() - i - 1) };
if (i % m_mode.x == 0)
rightCell = m_cells[cell];
if (cell % m_mode.x == 0)
{
if (m_do.wrapOnManualScroll)
m_cells[cell] = rightCell;
else
priv_clearCell(cell, true, true);
}
else
m_cells[cell] = m_cells[cell - 1];
}
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::scrollUp(unsigned int amount, sf::IntRect selectionRectangle)
{
if (m_mode.y == 0 || amount == 0)
return;
if (!priv_isSelectionRectangleContainedInScreen(selectionRectangle))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot scroll selection up.\nThe selection rectangle is not valid.");
return;
}
std::vector<Cell> topRow(selectionRectangle.width);
for (unsigned int repeat{ 0 }; repeat < amount; ++repeat) // lazy way of scrolling multiple times - loop scrolling (entirely by 1 each time)
{
for (unsigned int y{ 0 }; y < static_cast<unsigned int>(selectionRectangle.height); ++y)
{
for (unsigned int x{ 0 }; x < static_cast<unsigned int>(selectionRectangle.width); ++x)
{
if (m_do.wrapOnManualScroll && y == 0)
topRow[x] = m_cells[priv_cellIndex({ selectionRectangle.left + x, selectionRectangle.top + y })];
if (y < static_cast<unsigned int>(selectionRectangle.height) - 1)
m_cells[priv_cellIndex({ selectionRectangle.left + x, selectionRectangle.top + y })] = m_cells[priv_cellIndex({ selectionRectangle.left + x, selectionRectangle.top + y + 1 })];
else if (m_do.wrapOnManualScroll)
m_cells[priv_cellIndex({ selectionRectangle.left + x, selectionRectangle.top + y })] = topRow[x];
else
priv_clearCell(priv_cellIndex({ selectionRectangle.left + x, selectionRectangle.top + y }), true, true);
}
}
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::scrollDown(unsigned int amount, sf::IntRect selectionRectangle)
{
if (m_mode.y == 0 || amount == 0)
return;
if (!priv_isSelectionRectangleContainedInScreen(selectionRectangle))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot scroll selection down.\nThe selection rectangle is not valid.");
return;
}
std::vector<Cell> bottomRow(selectionRectangle.width);
for (unsigned int repeat{ 0 }; repeat < amount; ++repeat) // lazy way of scrolling multiple times - loop scrolling (entirely by 1 each time)
{
for (unsigned int y{ 0 }; y < static_cast<unsigned int>(selectionRectangle.height); ++y)
{
for (unsigned int x{ 0 }; x < static_cast<unsigned int>(selectionRectangle.width); ++x)
{
const unsigned cellY{ selectionRectangle.top + selectionRectangle.height - y - 1 };
if (m_do.wrapOnManualScroll && y == 0)
bottomRow[x] = m_cells[priv_cellIndex({ selectionRectangle.left + x, cellY })];
if (cellY > static_cast<unsigned int>(selectionRectangle.top))
m_cells[priv_cellIndex({ selectionRectangle.left + x, cellY })] = m_cells[priv_cellIndex({ selectionRectangle.left + x, cellY - 1 })];
else if (m_do.wrapOnManualScroll)
m_cells[priv_cellIndex({ selectionRectangle.left + x, cellY })] = bottomRow[x];
else
priv_clearCell(priv_cellIndex({ selectionRectangle.left + x, cellY }), true, true);
}
}
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::scrollLeft(unsigned int amount, sf::IntRect selectionRectangle)
{
if (m_mode.x == 0 || amount == 0)
return;
if (!priv_isSelectionRectangleContainedInScreen(selectionRectangle))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot scroll selection left.\nThe selection rectangle is not valid.");
return;
}
std::vector<Cell> leftColumn(selectionRectangle.height);
for (unsigned int repeat{ 0 }; repeat < amount; ++repeat) // lazy way of scrolling multiple times - loop scrolling (entirely by 1 each time)
{
for (unsigned int x{ 0 }; x < static_cast<unsigned int>(selectionRectangle.width); ++x)
{
for (unsigned int y{ 0 }; y < static_cast<unsigned int>(selectionRectangle.height); ++y)
{
if (m_do.wrapOnManualScroll && x == 0)
leftColumn[y] = m_cells[priv_cellIndex({ selectionRectangle.left + x, selectionRectangle.top + y })];
if (x < static_cast<unsigned int>(selectionRectangle.width) - 1)
m_cells[priv_cellIndex({ selectionRectangle.left + x, selectionRectangle.top + y })] = m_cells[priv_cellIndex({ selectionRectangle.left + x + 1, selectionRectangle.top + y })];
else if (m_do.wrapOnManualScroll)
m_cells[priv_cellIndex({ selectionRectangle.left + x, selectionRectangle.top + y })] = leftColumn[y];
else
priv_clearCell(priv_cellIndex({ selectionRectangle.left + x, selectionRectangle.top + y }), true, true);
}
}
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::scrollRight(unsigned int amount, sf::IntRect selectionRectangle)
{
if (m_mode.x == 0 || amount == 0)
return;
if (!priv_isSelectionRectangleContainedInScreen(selectionRectangle))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot scroll selection right.\nThe selection rectangle is not valid.");
return;
}
std::vector<Cell> rightColumn(selectionRectangle.height);
for (unsigned int repeat{ 0 }; repeat < amount; ++repeat) // lazy way of scrolling multiple times - loop scrolling (entirely by 1 each time)
{
for (unsigned int y{ 0 }; y < static_cast<unsigned int>(selectionRectangle.height); ++y)
{
for (unsigned int x{ 0 }; x < static_cast<unsigned int>(selectionRectangle.width); ++x)
{
const unsigned cellX{ selectionRectangle.left + selectionRectangle.width - x - 1 };
if (m_do.wrapOnManualScroll && x == 0)
rightColumn[y] = m_cells[priv_cellIndex({ cellX, selectionRectangle.top + y, })];
if (cellX > static_cast<unsigned int>(selectionRectangle.left))
m_cells[priv_cellIndex({ cellX, selectionRectangle.top + y })] = m_cells[priv_cellIndex({ cellX - 1, selectionRectangle.top + y })];
else if (m_do.wrapOnManualScroll)
m_cells[priv_cellIndex({ cellX, selectionRectangle.top + y })] = rightColumn[y];
else
priv_clearCell(priv_cellIndex({ cellX, selectionRectangle.top + y }), true, true);
}
}
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::fill(Cell cell)
{
if (m_cells.size() == 0)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot fill cells.\nNo cells exist.");
return;
}
if (cell.colors.background.id < 0)
cell.colors.background = 0;
if (cell.colors.foreground.id < 0)
cell.colors.foreground = 0;
for (auto& singleCell : m_cells)
singleCell = cell;
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::clear(const ColorPair colors)
{
if (m_cells.size() == 0)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot clear cell.\nNo cells exist.");
return;
}
if (colors.background.id < 0)
{
clear(static_cast<ColorCommand>(colors.background.id));
return;
}
for (unsigned int i{ 0 }; i < m_cells.size(); ++i)
priv_clearCell(i, colors.foreground, colors.background);
m_cursorPrintProperties.index = 0u;
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::clear(const Color backgroundColor)
{
clear({ m_cursorPrintProperties.colors.foreground, backgroundColor });
}
void ConsoleScreen::clear(const ColorCommand backgroundColorCommand)
{
clear(priv_getModifiedColorFromColorPairUsingSpecifiedColorType({ m_cursorPrintProperties.colors.foreground, backgroundColorCommand }, ColorType::Background));
}
void ConsoleScreen::clear()
{
clear(m_cursorPrintProperties.colors.background);
}
void ConsoleScreen::crash()
{
for (auto& cell : m_cells)
{
cell = { randomByte(), ColorPair(priv_getRandomColor(), priv_getRandomColor()),
StretchType(), CellAttributes()};
}
m_cursorPrintProperties.index = m_cells.size() - 1;
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::setCursorTab(const unsigned int tabSize)
{
m_tabSize = tabSize;
}
unsigned int ConsoleScreen::getCursorTab() const
{
return m_tabSize;
}
std::string ConsoleScreen::read()
{
std::string string;
*this >> string;
return string;
}
std::string ConsoleScreen::read(const unsigned int length)
{
m_readLength = length;
return read();
}
std::string ConsoleScreen::read(const Location& location)
{
std::string string;
PrintProperties backupPrintProperties = priv_getCurrentPrintProperties();
*this >> location >> string;
priv_getCurrentPrintProperties() = backupPrintProperties;
return string;
}
std::string ConsoleScreen::read(const Location& location, const unsigned int length)
{
m_readLength = length;
return read(location);
}
void ConsoleScreen::loadPalette(const Palette palette)
{
m_is.rgbMode = false;
m_palette.clear();
switch (palette)
{
case Palette::Colors16Cga:
addPalette16ColorCga(m_palette);
break;
case Palette::Colors16CgaNonIbm:
addPalette16ColorCgaNonIbm(m_palette);
break;
case Palette::Colors16Greenscale:
addPalette16ColorGreenscale(m_palette);
break;
case Palette::Colors16Grayscale:
addPalette16ColorGrayscale(m_palette);
break;
case Palette::Colors16Sepia:
addPalette16ColorSepia(m_palette);
break;
case Palette::Colors16Windows:
addPalette16ColorWindows(m_palette);
break;
case Palette::Colors16Mac:
addPalette16ColorMac(m_palette);
break;
case Palette::Colors16ZxSpectrum:
addPalette16ColorZxSpectrum(m_palette);
break;
case Palette::Colors16Html:
addPalette16Color16Html(m_palette);
break;
case Palette::Colors216Web:
addPalette216ColorWebSafe(m_palette);
break;
case Palette::Colors256Greenscale:
addPalette256ColorGreenscale(m_palette);
break;
case Palette::Colors256Grayscale:
addPalette256ColorGrayscale(m_palette);
break;
case Palette::Colors256Sepia:
addPalette256ColorSepia(m_palette);
break;
case Palette::ColorsRgb:
m_is.rgbMode = true;
break;
case Palette::Default:
default:
addPaletteDefault(m_palette);
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::addColorToPalette(const sf::Color color)
{
m_palette.emplace_back(color);
}
void ConsoleScreen::setPaletteColor(const Color color, const sf::Color newColor)
{
if (m_is.rgbMode)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set palette color.\nRGB Mode is currently active.");
return;
}
if (!priv_isColorInPaletteRange(color))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set palette color.\nColor ID (" + std::to_string(color.id) + ") out of range.");
return;
}
m_palette[color.id] = newColor;
if (m_do.updateAutomatically)
update();
}
sf::Color ConsoleScreen::getPaletteColor(const Color color) const
{
if (!priv_isColorInPaletteRange(color))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot get palette color.\nColor ID (" + std::to_string(color.id) + ") out of range.");
return sf::Color::Transparent;
}
return m_is.rgbMode ? sf::Color(static_cast<sf::Uint8>(color.id / 65536), static_cast<sf::Uint8>((color.id % 65536) / 256), static_cast<sf::Uint8>(color.id % 256)) : m_palette[color.id];
}
void ConsoleScreen::setPaletteSize(const unsigned long int size)
{
if (m_is.rgbMode)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot resize palette.\nRGB Mode is currently active.");
return;
}
if (size < 1)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot set palette size to zero.");
return;
}
m_palette.resize(size);
}
unsigned long int ConsoleScreen::getPaletteSize() const
{
return m_is.rgbMode ? 16777216L : m_palette.size();
}
void ConsoleScreen::removePaletteColor(const Color color)
{
if (m_is.rgbMode)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot remove palette color.\nRGB Mode is currently active.");
return;
}
if (!priv_isColorInPaletteRange(color))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot remove palette color.\nColor ID (" + std::to_string(color.id) + ") out of range.");
return;
}
if (m_palette.size() < 2)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot remove final palette color.");
return;
}
m_palette.erase(m_palette.begin() + color.id);
}
void ConsoleScreen::cyclePaletteUp(const long amount)
{
if (m_palette.size() < 2)
return;
cyclePaletteUp(amount, 0, m_palette.size() - 1);
}
void ConsoleScreen::cyclePaletteDown(const long amount)
{
if (m_palette.size() < 2)
return;
cyclePaletteDown(amount, 0, m_palette.size() - 1);
}
void ConsoleScreen::cyclePaletteUp(long amount, Color firstColor, Color lastColor)
{
if (m_palette.size() < 2 || amount < 1)
return;
if (lastColor.id < firstColor.id)
std::swap(lastColor, firstColor);
if (firstColor.id < 0)
firstColor = 0;
if (lastColor.id > static_cast<long>(m_palette.size() - 1))
lastColor = m_palette.size() - 1;
const long rangeSize{ lastColor.id - firstColor.id + 1 };
amount %= rangeSize;
std::vector<sf::Color> buffer;
for (long i{ 0 }; i < amount; ++i)
buffer.emplace_back(m_palette[lastColor.id - i]);
for (long i{ lastColor.id }; i >= firstColor.id; --i)
{
if (i - amount >= firstColor.id)
m_palette[i] = m_palette[i - amount];
else
m_palette[i] = buffer[firstColor.id - (i - amount) - 1];
}
if (m_do.updateAutomatically)
update();
}
void ConsoleScreen::cyclePaletteDown(long amount, Color firstColor, Color lastColor)
{
if (m_palette.size() < 2 || amount < 1)
return;
if (lastColor.id < firstColor.id)
std::swap(lastColor, firstColor);
if (firstColor.id < 0)
firstColor = 0;
if (lastColor.id > static_cast<long>(m_palette.size() - 1))
lastColor = m_palette.size() - 1;
const long rangeSize{ lastColor.id - firstColor.id + 1 };
amount %= rangeSize;
std::vector<sf::Color> buffer;
for (long i{ 0 }; i < amount; ++i)
buffer.emplace_back(m_palette[firstColor.id + i]);
for (long i{ firstColor.id }; i <= lastColor.id; ++i)
{
if (i + amount <= lastColor.id)
m_palette[i] = m_palette[i + amount];
else
m_palette[i] = buffer[i + amount - lastColor.id - 1];
}
if (m_do.updateAutomatically)
update();
}
unsigned int ConsoleScreen::copy()
{
m_buffers.push_back({ m_mode.x, m_cells });
return m_buffers.size() - 1;
}
void ConsoleScreen::copy(const unsigned int index)
{
if (!priv_isScreenBufferIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot replace buffer with copy.\nBuffer index (" + std::to_string(index) + ") does not exist.");
return;
}
m_buffers[index] = { m_mode.x, m_cells };
if (m_do.updateAutomatically)
update();
}
unsigned int ConsoleScreen::copy(const sf::IntRect selectionRectangle)
{
m_buffers.emplace_back();
priv_copyToBufferFromSelectionRectangle(m_buffers.back(), selectionRectangle);
return m_buffers.size() - 1;
}
void ConsoleScreen::copy(const unsigned int index, const sf::IntRect selectionRectangle)
{
if (!priv_isScreenBufferIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot replace buffer with copy.\nBuffer index (" + std::to_string(index) + ") does not exist.");
return;
}
priv_copyToBufferFromSelectionRectangle(m_buffers[index], selectionRectangle);
}
void ConsoleScreen::paste(const sf::Vector2i offset)
{
if (m_buffers.size() == 0)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot paste buffer.\nNo buffer exists.");
return;
}
priv_pasteOffsettedBuffer(m_buffers.back(), offset);
}
void ConsoleScreen::paste(const unsigned int index, const sf::Vector2i offset)
{
if (!priv_isScreenBufferIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot paste buffer.\nBuffer index (" + std::to_string(index) + ") out of range.");
return;
}
priv_pasteOffsettedBuffer(m_buffers[index], offset);
}
void ConsoleScreen::removeBuffer()
{
if (m_buffers.size() == 0)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot remove buffer.\nNo buffer exists.");
return;
}
m_buffers.pop_back();
}
void ConsoleScreen::removeBuffer(const unsigned int index)
{
if (!priv_isScreenBufferIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot remove buffer.\nBuffer index (" + std::to_string(index) + ") out of range.");
return;
}
m_buffers.erase(m_buffers.begin() + index);
}
void ConsoleScreen::removeAllBuffers()
{
m_buffers.clear();
}
unsigned int ConsoleScreen::getNumberOfBuffers() const
{
return m_buffers.size();
}
void ConsoleScreen::setMappedCharacter(const char character, const unsigned int value)
{
m_characterMap[character] = value;
}
void ConsoleScreen::setMappedCharacters(const std::string& characters, unsigned int initialValue)
{
for (auto& character : characters)
setMappedCharacter(character, initialValue++);
}
void ConsoleScreen::removeMappedCharacter(const char character)
{
m_characterMap.erase(character);
}
void ConsoleScreen::removeMappedCharacters(const std::string& characters)
{
for (auto& character : characters)
removeMappedCharacter(character);
}
bool ConsoleScreen::getIsMappedCharacter(const char character) const
{
return m_characterMap.find(character) != m_characterMap.end();
}
unsigned int ConsoleScreen::getMappedCharacter(const char character) const
{
return m_characterMap.at(character);
}
void ConsoleScreen::setMappedCursorCommandCharacter(const char character, const CursorCommand cursorCommand)
{
m_characterMapCursorCommand[character] = cursorCommand;
}
void ConsoleScreen::setMappedCursorCommandCharacters(const std::string& characters, const std::vector<CursorCommand>& cursorCommands)
{
for (unsigned int i{ 0u }; i < characters.size() && i < cursorCommands.size(); ++i)
setMappedCursorCommandCharacter(characters[i], cursorCommands[i]);
}
void ConsoleScreen::removeMappedCursorCommandCharacter(const char character)
{
m_characterMapCursorCommand.erase(character);
}
void ConsoleScreen::removeMappedCursorCommandCharacters(const std::string& characters)
{
for (auto& character : characters)
removeMappedCursorCommandCharacter(character);
}
bool ConsoleScreen::getIsMappedCursorCommandCharacter(const char character) const
{
return m_characterMapCursorCommand.find(character) != m_characterMapCursorCommand.end();
}
ConsoleScreen::CursorCommand ConsoleScreen::getMappedCursorCommandCharacter(const char character) const
{
return m_characterMapCursorCommand.at(character);
}
void ConsoleScreen::poke(const unsigned int index, const Cell& cell)
{
if (!priv_isCellIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot poke cell.\nCell number (" + std::to_string(index) + ") out of range.");
return;
}
m_cells[index] = cell;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::poke(const unsigned int index, const unsigned int value)
{
if (!priv_isCellIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot poke value.\nCell number (" + std::to_string(index) + ") out of range.");
return;
}
m_cells[index].value = value;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::poke(const unsigned int index, const Color& color)
{
if (!priv_isCellIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot poke color.\nCell number (" + std::to_string(index) + ") out of range.");
return;
}
m_cells[index].colors.foreground = color;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::poke(const unsigned int index, const Color& color, const Color& backgroundColor)
{
if (!priv_isCellIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot poke colors.\nCell number (" + std::to_string(index) + ") out of range.");
return;
}
m_cells[index].colors.foreground = color;
m_cells[index].colors.background = backgroundColor;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::poke(const unsigned int index, const StretchType& stretch)
{
if (!priv_isCellIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot poke stretch attribute.\nCell number (" + std::to_string(index) + ") out of range.");
return;
}
m_cells[index].stretch = stretch;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::poke(const unsigned int index, const CellAttributes& cellAttributes)
{
if (!priv_isCellIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot poke attributes.\nCell number (" + std::to_string(index) + ") out of range.");
return;
}
m_cells[index].attributes = cellAttributes;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::poke(const unsigned int index, const bool attributeValue, const Affect& attributeMask)
{
if (!priv_isCellIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot poke attribute.\nCell number (" + std::to_string(index) + ") out of range.");
return;
}
CellAttributes& cellAttributes{ m_cells[index].attributes };
if ((attributeMask & Affect::Inverse) == Affect::Inverse)
cellAttributes.inverse = attributeValue;
if ((attributeMask & Affect::Bright) == Affect::Bright)
cellAttributes.bright = attributeValue;
if ((attributeMask & Affect::FlipX) == Affect::FlipX)
cellAttributes.flipX = attributeValue;
if ((attributeMask & Affect::FlipY) == Affect::FlipY)
cellAttributes.flipY = attributeValue;
if (m_do.updateAutomatically)
priv_updateCell(index);
}
ConsoleScreen::Cell ConsoleScreen::peek(const unsigned int index) const
{
if (!priv_isCellIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot peek cell.\nCell number (" + std::to_string(index) + ") out of range.");
return Cell();
}
return m_cells[index];
}
ConsoleScreen::Cell& ConsoleScreen::cell(const unsigned int index)
{
if (!priv_isCellIndexInRange(index))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot retrieve cell.\nCell number (" + std::to_string(index) + ") out of range.");
return m_cells.empty() ? fakeCell : m_cells.back();
}
return m_cells[index];
}
// PRIVATE
void ConsoleScreen::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform = getTransform();
if (m_do.showBackround && m_backgroundDisplay.size() > 0)
{
states.texture = nullptr;
target.draw(&m_backgroundDisplay.front(), m_backgroundDisplay.size(), primitiveType, states);
}
states.texture = m_texture;
if (m_underDisplay.size() > 0)
target.draw(&m_underDisplay.front(), m_underDisplay.size(), primitiveType, states);
if (m_display.size() > 0)
target.draw(&m_display.front(), m_display.size(), primitiveType, states);
if (m_overDisplay.size() > 0)
target.draw(&m_overDisplay.front(), m_overDisplay.size(), primitiveType, states);
}
void ConsoleScreen::priv_setVerticesFromCell(unsigned int index, int baseVertex, const bool overLayer)
{
bool mainLayer{ (baseVertex < 0) };
Cell* pCell;
if (mainLayer)
pCell = &m_cells[index];
else
{
if (overLayer)
{
pCell = &m_overCells[index].cell;
index = m_overCells[index].index;
}
else
{
pCell = &m_underCells[index].cell;
index = m_underCells[index].index;
}
}
Cell& cell{ *pCell };
unsigned int cellValue{ cell.value };
sf::Color cellColor;
sf::Color backgroundColor;
if (mainLayer)
{
cellColor = getPaletteColor(priv_getModifiedColorFromCellUsingSpecifiedColorType(index, ColorType::Foreground).id);
backgroundColor = getPaletteColor(priv_getModifiedColorFromCellUsingSpecifiedColorType(index, ColorType::Background).id);
}
else
{
cellColor = getPaletteColor(cell.colors.foreground.id);
backgroundColor = getPaletteColor(cell.colors.background.id);
}
const bool isCursor{ m_cursor.visible && m_cursorPrintProperties.index == index };
bool useCursorValue{ false };
if (mainLayer && isCursor)
{
if (m_cursor.value >= 0)
{
useCursorValue = true;
cellValue = m_cursor.value;
}
if (m_cursor.useOwnColour)
cellColor = getPaletteColor(m_cursor.color.id);
if (cell.attributes.inverse != m_cursor.inverse)
swapColors(cellColor, backgroundColor);
}
else if (cell.attributes.inverse)
swapColors(cellColor, backgroundColor);
if (!cell.attributes.bright)
{
makeColorUnBright(cellColor);
if (mainLayer)
makeColorUnBright(backgroundColor);
}
const unsigned int cellX{ index % m_mode.x };
const unsigned int cellY{ index / m_mode.x };
const float left{ linearInterpolation(0.f, m_size.x, static_cast<float>(cellX + (cell.attributes.flipX ? 1 : 0)) / m_mode.x) };
const float right{ linearInterpolation(0.f, m_size.x, static_cast<float>(cellX + (cell.attributes.flipX ? 0 : 1)) / m_mode.x) };
const float top{ linearInterpolation(0.f, m_size.y, static_cast<float>(cellY + (cell.attributes.flipY ? 1 : 0)) / m_mode.y) };
const float bottom{ linearInterpolation(0.f, m_size.y, static_cast<float>(cellY + (cell.attributes.flipY ? 0 : 1)) / m_mode.y) };
sf::Vector2u textureCell{ cellValue % m_numberOfTilesPerRow, cellValue / m_numberOfTilesPerRow };
const float textureLeft{ static_cast<float>(m_textureOffset.x + textureCell.x * m_tileSize.x) };
const float textureTop{ static_cast<float>(m_textureOffset.y + (textureCell.y + (!useCursorValue && cell.stretch == StretchType::Bottom ? 0.5f : 0.f)) * m_tileSize.y) };
const float textureRight{ static_cast<float>(m_textureOffset.x + (textureCell.x + 1) * m_tileSize.x) };
const float textureBottom{ static_cast<float>(m_textureOffset.y + (textureCell.y + (!useCursorValue && cell.stretch == StretchType::Top ? 0.5f : 1.f)) * m_tileSize.y) };
if (mainLayer)
baseVertex = index * 4;
// main display
sf::Vertex* const pVertex1{ (mainLayer ? &m_display[baseVertex] : overLayer ? &m_overDisplay[baseVertex] : &m_underDisplay[baseVertex]) };
sf::Vertex* const pVertex2{ pVertex1 + 1 };
sf::Vertex* const pVertex3{ pVertex1 + 2 };
sf::Vertex* const pVertex4{ pVertex1 + 3 };
pVertex1->position = { left, top };
pVertex2->position = { right, top };
pVertex3->position = { right, bottom };
pVertex4->position = { left, bottom };
pVertex1->texCoords = { textureLeft, textureTop };
pVertex2->texCoords = { textureRight, textureTop };
pVertex3->texCoords = { textureRight, textureBottom };
pVertex4->texCoords = { textureLeft, textureBottom };
pVertex1->color = cellColor;
pVertex2->color = cellColor;
pVertex3->color = cellColor;
pVertex4->color = cellColor;
// background display
if (mainLayer)
{
sf::Vertex* const pBackgroundVertex1{ &m_backgroundDisplay[baseVertex] };
sf::Vertex* const pBackgroundVertex2{ pBackgroundVertex1 + 1 };
sf::Vertex* const pBackgroundVertex3{ pBackgroundVertex1 + 2 };
sf::Vertex* const pBackgroundVertex4{ pBackgroundVertex1 + 3 };
pBackgroundVertex1->position = pVertex1->position;
pBackgroundVertex2->position = pVertex2->position;
pBackgroundVertex3->position = pVertex3->position;
pBackgroundVertex4->position = pVertex4->position;
pBackgroundVertex1->color = backgroundColor;
pBackgroundVertex2->color = backgroundColor;
pBackgroundVertex3->color = backgroundColor;
pBackgroundVertex4->color = backgroundColor;
}
}
void ConsoleScreen::priv_updateCell(const unsigned int index)
{
if (!priv_isCellIndexInRange(index))
return;
if (m_display.size() != (m_mode.x * m_mode.y * 4))
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Bug: display does not match cells.");
return;
}
if (m_display.size() < 4)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Bug: cannot update cell. No cells available.");
return;
}
priv_setVerticesFromCell(index);
}
void ConsoleScreen::priv_updateUnderCells()
{
m_underDisplay.resize(m_underCells.size() * 4);
unsigned int outOfRangeCells{ 0u };
unsigned int baseVertex{ 0u };
for (unsigned int i{ 0u }; i < m_underCells.size(); ++i)
{
if (!priv_isCellIndexInRange(m_underCells[i].index))
{
++outOfRangeCells;
continue;
}
priv_setVerticesFromCell(i, baseVertex, false);
baseVertex += 4;
}
if (outOfRangeCells > 0)
m_underDisplay.resize(baseVertex);
}
void ConsoleScreen::priv_updateOverCells()
{
m_overDisplay.resize(m_overCells.size() * 4);
unsigned int outOfRangeCells{ 0u };
unsigned int baseVertex{ 0u };
for (unsigned int i{ 0u }; i < m_overCells.size(); ++i)
{
if (!priv_isCellIndexInRange(m_overCells[i].index))
{
++outOfRangeCells;
continue;
}
priv_setVerticesFromCell(i, baseVertex, true);
baseVertex += 4;
}
if (outOfRangeCells > 0)
m_overDisplay.resize(baseVertex);
}
inline unsigned int ConsoleScreen::priv_cellIndex(const sf::Vector2u location) const
{
return location.y * m_mode.x + location.x;
}
inline sf::Vector2u ConsoleScreen::priv_cellLocation(const unsigned int index) const
{
return{ index % m_mode.x, index / m_mode.x };
}
inline bool ConsoleScreen::priv_isCellIndexInRange(const unsigned int index) const
{
return index < m_cells.size();
}
inline bool ConsoleScreen::priv_isCellLocationInRange(const sf::Vector2u location) const
{
return (location.x < m_mode.x && location.y < m_mode.y);
}
inline bool ConsoleScreen::priv_isScreenBufferIndexInRange(const unsigned int index) const
{
return index < m_buffers.size();
}
inline bool ConsoleScreen::priv_isCursorInRange() const
{
return priv_isCellIndexInRange(m_cursorPrintProperties.index);
}
inline bool ConsoleScreen::priv_isColorInPaletteRange(const Color color) const
{
return (color.id >= 0) && ((m_is.rgbMode && color.id < 16777216L) || (color.id < static_cast<long int>(m_palette.size())));
}
inline void ConsoleScreen::priv_clearCell(const unsigned int index, const bool overwriteColor, const bool overwriteBackgroundColor)
{
const Color color{ overwriteColor ? m_cursorPrintProperties.colors.foreground : m_cells[index].colors.foreground };
const Color backgroundColor{ overwriteBackgroundColor ? m_cursorPrintProperties.colors.background : m_cells[index].colors.background };
poke(index, { 0, ColorPair(color, backgroundColor), StretchType::None, CellAttributes() });
}
inline void ConsoleScreen::priv_clearCell(const unsigned int index, const Color& backgroundColor, const bool overwriteColor)
{
const Color color{ overwriteColor ? m_cursorPrintProperties.colors.foreground : m_cells[index].colors.foreground };
poke(index, { 0, ColorPair(color, backgroundColor), StretchType::None, CellAttributes() });
}
inline void ConsoleScreen::priv_clearCell(const unsigned int index, const Color& color, const Color& backgroundColor)
{
poke(index, { 0, ColorPair(color, backgroundColor), StretchType::None, CellAttributes() });
}
inline void ConsoleScreen::priv_paintCell(const unsigned int index, const Color& color, const Color& backgroundColor)
{
poke(index, color, backgroundColor);
if (m_do.updateAutomatically)
priv_updateCell(index);
}
void ConsoleScreen::priv_setCursorIndex(const unsigned int index)
{
const unsigned int previousIndex{ m_cursorPrintProperties.index };
m_cursorPrintProperties.index = index;
if (m_do.updateAutomatically)
{
priv_updateCell(previousIndex);
priv_updateCell(m_cursorPrintProperties.index);
}
}
void ConsoleScreen::priv_moveCursorToBeginningOfLine()
{
priv_setCursorIndex(m_cursorPrintProperties.index - m_cursorPrintProperties.index % m_mode.x);
}
void ConsoleScreen::priv_moveCursorUp()
{
if (m_cursorPrintProperties.index >= m_mode.x)
priv_setCursorIndex(m_cursorPrintProperties.index - m_mode.x);
}
void ConsoleScreen::priv_moveCursorDown()
{
priv_setCursorIndex(m_cursorPrintProperties.index + m_mode.x);
priv_testCursorForScroll();
}
void ConsoleScreen::priv_moveCursorLeft()
{
if (m_cursorPrintProperties.index > 0)
priv_setCursorIndex(m_cursorPrintProperties.index - 1);
}
void ConsoleScreen::priv_moveCursorRight()
{
priv_setCursorIndex(m_cursorPrintProperties.index + 1);
priv_testCursorForScroll();
}
void ConsoleScreen::priv_testCursorForScroll()
{
if (m_cursorPrintProperties.index >= m_cells.size())
{
if (m_do.scrollAutomatically)
{
priv_scroll();
if (m_do.updateAutomatically)
update();
}
else
{
m_cursorPrintProperties.index = m_cells.size() - 1;
if (m_do.updateAutomatically)
priv_updateCell(m_cursorPrintProperties.index);
}
}
}
void ConsoleScreen::priv_scroll()
{
for (unsigned int y{ 0 }; y < m_mode.y; ++y)
{
for (unsigned int x{ 0 }; x < m_mode.x; ++x)
{
if (y < m_mode.y - 1)
m_cells[priv_cellIndex({ x, y })] = m_cells[priv_cellIndex({ x, y + 1 })];
else
priv_clearCell(priv_cellIndex({ x, y }), true, true);
}
}
priv_moveCursorUp();
}
void ConsoleScreen::priv_copyToBufferFromSelectionRectangle(Buffer& buffer, const sf::IntRect& selectionRectangle)
{
if (selectionRectangle.left >= static_cast<int>(m_mode.x) ||
selectionRectangle.top >= static_cast<int>(m_mode.y) ||
selectionRectangle.width <= 0 ||
selectionRectangle.height <= 0 ||
(selectionRectangle.left + selectionRectangle.width) < 0 ||
(selectionRectangle.top + selectionRectangle.height) < 0)
{
if (m_do.throwExceptions)
throw Exception(exceptionPrefix + "Cannot copy selection.\nSelection does not contain any cells.");
return;
}
buffer.width = 0u;
buffer.cells.clear();
for (int y{ 0 }; y < selectionRectangle.height; ++y)
{
for (int x{ 0 }; x < selectionRectangle.width; ++x)
{
const sf::Vector2i location{ x + selectionRectangle.left, y + selectionRectangle.top };
if (location.x < 0 || location.y < 0)
continue;
const sf::Vector2u cellLocation{ static_cast<unsigned int>(location.x), static_cast<unsigned int>(location.y) };
if (priv_isCellLocationInRange(cellLocation))
{
buffer.cells.push_back(m_cells[priv_cellIndex(cellLocation)]);
if (y == 0)
++buffer.width;
}
}
}
}
void ConsoleScreen::priv_pasteOffsettedBuffer(Buffer& buffer, const sf::Vector2i& offset)
{
for (unsigned int i{ 0 }; i < buffer.cells.size(); ++i)
{
const sf::Vector2i location{ static_cast<int>(i % buffer.width) + offset.x, static_cast<int>(i / buffer.width) + offset.y };
if (location.x < 0 || location.y < 0)
continue;
const sf::Vector2u cellLocation{ static_cast<unsigned int>(location.x), static_cast<unsigned int>(location.y) };
if (priv_isCellLocationInRange(cellLocation))
m_cells[priv_cellIndex(cellLocation)] = buffer.cells[i];
}
if (m_do.updateAutomatically)
update();
}
inline bool ConsoleScreen::priv_isSelectionRectangleContainedInScreen(const sf::IntRect& selectionRectangle)
{
return (selectionRectangle.left >= 0 &&
selectionRectangle.top >= 0 &&
selectionRectangle.width >= 0 &&
selectionRectangle.height >= 0 &&
static_cast<unsigned int>(selectionRectangle.left + selectionRectangle.width) < m_mode.x &&
static_cast<unsigned int>(selectionRectangle.top + selectionRectangle.height) < m_mode.y);
}
unsigned int ConsoleScreen::priv_getPrintIndex(sf::Vector2u location) const
{
if (location.x >= m_mode.x)
{
location.y += location.x / m_mode.x;
location.x %= m_mode.x;
}
if (location.y >= m_mode.y)
{
location.y = m_mode.y - 1;
location.x = m_mode.x - 1; // push cursor to the end of the line if cursor was below the last line
}
return priv_cellIndex(location);
}
inline unsigned int ConsoleScreen::priv_getCellValueFromCharacter(const char character) const
{
if (getIsMappedCharacter(character))
return m_characterMap.at(character);
else
return static_cast<unsigned int>(character);
}
inline char ConsoleScreen::priv_getCharacterFromCellValue(const unsigned int cellValue) const
{
for (auto& pair : m_characterMap)
{
if (pair.second == cellValue)
return pair.first;
}
return static_cast<char>(cellValue);
}
ConsoleScreen::Color ConsoleScreen::priv_getRandomColor() const
{
return Color(std::uniform_int_distribution<unsigned long int>(0u, m_is.rgbMode ? 16777215L : m_palette.size() - 1u)(randomGenerator));
}
inline ConsoleScreen::PrintProperties& ConsoleScreen::priv_getCurrentPrintProperties()
{
if (m_is.directPrinting)
return m_directPrintProperties;
else
return m_cursorPrintProperties;
}
ConsoleScreen::PrintProperties& ConsoleScreen::priv_getPrintProperties(const PrintType& printType)
{
switch (printType)
{
case PrintType::Cursor:
return m_cursorPrintProperties;
case PrintType::Direct:
return m_directPrintProperties;
case PrintType::Current:
default:
return priv_getCurrentPrintProperties();
}
}
ConsoleScreen::Color ConsoleScreen::priv_getModifiedColorFromColorPairUsingSpecifiedColorType(const ColorPair& colors, const ColorType& colorType)
{
const Color& focusColor{ (colorType == ColorType::Foreground ? colors.foreground : colors.background) };
const Color& supportColor{ (colorType == ColorType::Foreground ? colors.background : colors.foreground) };
if (focusColor.id >= 0)
return focusColor;
Color color;
switch (focusColor.id)
{
case ColorCommand::Invert:
{
if (priv_isColorInPaletteRange(supportColor))
color = priv_getIndexOfClosestPaletteColor(invertedColor(getPaletteColor(supportColor.id)));
}
break;
case ColorCommand::Contrast:
{
if (priv_isColorInPaletteRange(supportColor))
color = priv_getIndexOfClosestPaletteColor(contrastedColor(getPaletteColor(supportColor.id)));
}
break;
case ColorCommand::Opposite:
color = supportColor;
break;
default:
color = focusColor;
}
if (color.id < 0)
color = 0;
return color;
}
inline ConsoleScreen::Color ConsoleScreen::priv_getModifiedColorFromCellUsingSpecifiedColorType(const unsigned int& cellIndex, const ColorType& colorType)
{
return priv_getModifiedColorFromColorPairUsingSpecifiedColorType(m_cells[cellIndex].colors, colorType);
}
inline ConsoleScreen::Color& ConsoleScreen::priv_getActiveColor()
{
PrintProperties& printProperties{ priv_getCurrentPrintProperties() };
return (printProperties.colorType == ColorType::Foreground) ? printProperties.colors.foreground : printProperties.colors.background;
}
inline ConsoleScreen::Color& ConsoleScreen::priv_getInactiveColor()
{
PrintProperties& printProperties{ priv_getCurrentPrintProperties() };
return (printProperties.colorType == ColorType::Foreground) ? printProperties.colors.background : printProperties.colors.foreground;
}
int ConsoleScreen::priv_getIndexOfClosestPaletteColor(const sf::Color& color) const
{
int index{ -1 }; // returns -1 if the palette is empty
int currentDistance{ 195076 }; // 195076 = 255 * 255 * 3 + 1 (one further than the maximum possible distance)
const unsigned int numberOfColorsInPalette{ static_cast<unsigned int>(m_palette.size()) };
for (unsigned int i{ 0u }; i < numberOfColorsInPalette; ++i)
{
const int r{ static_cast<int>(m_palette[i].r) - color.r };
const int g{ static_cast<int>(m_palette[i].g) - color.g };
const int b{ static_cast<int>(m_palette[i].b) - color.b };
const int distance{ r * r + g * g + b * b };
if (distance < currentDistance)
{
index = i;
currentDistance = distance;
}
}
return index;
}
std::string ConsoleScreen::priv_read(unsigned int index, const bool unmapCharacters)
{
std::string string;
for (unsigned int i{ 0u }; i < m_readLength; ++i)
{
string += (unmapCharacters ? priv_getCharacterFromCellValue(m_cells[index].value) : m_cells[index].value);
++index;
if (!priv_isCellIndexInRange(index))
break;
priv_getCurrentPrintProperties().index = index;
}
return string;
}
} // namespace selbaward
| 32.536951
| 196
| 0.669085
|
Stellaris-code
|
4b3f8cea15522bf113b7a6a32c185670c2566529
| 38,304
|
cpp
|
C++
|
cflw代码库/cflw图形_d3d12.cpp
|
cflw/cflw_cpp
|
4d623480ae51b78ed8292fe689197f03aba85b75
|
[
"MIT"
] | 9
|
2018-10-18T18:13:14.000Z
|
2021-07-21T19:55:56.000Z
|
cflw代码库/cflw图形_d3d12.cpp
|
cflw/cflw_cpp
|
4d623480ae51b78ed8292fe689197f03aba85b75
|
[
"MIT"
] | 1
|
2020-08-18T02:07:09.000Z
|
2020-08-19T12:50:55.000Z
|
cflw代码库/cflw图形_d3d12.cpp
|
cflw/cflw_cpp
|
4d623480ae51b78ed8292fe689197f03aba85b75
|
[
"MIT"
] | 1
|
2019-04-22T20:35:04.000Z
|
2019-04-22T20:35:04.000Z
|
#include <D3Dcompiler.h>
#include "cflw图形_d3d12.h"
#include "d3dx12.h"
#include "cflw视窗.h"
#include "cflw辅助.h"
namespace cflw::图形::d3d12 {
D3D12_SHADER_BYTECODE ft着色器字节码(const std::span<const std::byte> &a) {
D3D12_SHADER_BYTECODE v;
v.pShaderBytecode = a.data();
v.BytecodeLength = a.size();
return v;
}
//==============================================================================
// 三维
//==============================================================================
C三维::~C三维() {
f销毁();
}
void C三维::f销毁() {
if (m设备 == nullptr) {
return;
}
m渲染控制->f等待完成帧();
m缓冲工厂.reset();
m创建设备.reset();
m渲染状态.reset();
m渲染目标管理.reset();
m渲染控制.reset();
m默认根签名.Reset();
m命令分配器.Reset();
m交换链.Reset();
m命令队列.Reset();
m设备.Reset();
}
void C三维::f初始化窗口(HWND a) {
m窗口 = a;
fs窗口大小();
}
HRESULT C三维::f初始化设备(HRESULT(C创建设备::*af取显卡)(IDXGIAdapter3 **)) {
C创建设备 &v创建设备 = fg创建设备();
if constexpr (c调试) {
m标志[e调试] = v创建设备.f开启调试层();
}
HRESULT hr = S_OK;
ComPtr<IDXGIAdapter3> v显卡;
if (af取显卡 == nullptr) {
af取显卡 = &C创建设备::f取显卡_性能;
}
hr = (v创建设备.*af取显卡)(&v显卡);
if (FAILED(hr)) {
return hr;
}
hr = v创建设备.f创建设备(v显卡.Get(), &m设备);
if (FAILED(hr)) {
return hr;
}
m标志[e软件设备] = af取显卡 == &C创建设备::f取软件适配器;
return S_OK;
}
HRESULT C三维::f初始化软件设备() {
return f初始化设备(&C创建设备::f取软件适配器);
}
HRESULT C三维::f初始化命令队列() {
assert(m设备);
D3D12_COMMAND_QUEUE_DESC qd = {};
qd.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
qd.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
HRESULT hr = m设备->CreateCommandQueue(&qd, IID_PPV_ARGS(&m命令队列));
if (FAILED(hr)) {
return hr;
}
hr = m设备->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m命令分配器));
if (FAILED(hr)) {
return hr;
}
return S_OK;
}
HRESULT C三维::f初始化交换链() {
assert(m设备);
C创建设备 &v创建设备 = fg创建设备();
m标志[e撕裂] = v创建设备.f检查撕裂();
const UINT v撕裂 = m标志[e撕裂] ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0;
m交换链标志 = v撕裂;
//交换链描述
DXGI_SWAP_CHAIN_DESC1 sd = {};
sd.BufferCount = c帧数;
sd.Width = m窗口大小[0];
sd.Height = m窗口大小[1];
sd.Format = c交换链格式;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Stereo = false;
sd.Flags = m交换链标志;
sd.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
sd.Scaling = DXGI_SCALING_STRETCH;
//创建交换链
ComPtr<IDXGIFactory5> v工厂 = v创建设备.fg工厂();
ComPtr<IDXGISwapChain1> v交换链;
HRESULT hr = v工厂->CreateSwapChainForHwnd(m命令队列.Get(), m窗口, &sd, nullptr, nullptr, &v交换链);
if (FAILED(hr)) {
return hr;
}
//其它
hr = v工厂->MakeWindowAssociation(m窗口, DXGI_MWA_NO_ALT_ENTER);
if (FAILED(hr)) {
return hr;
}
//返回
v交换链.As(&m交换链);
return S_OK;
}
HRESULT C三维::f初始化渲染目标视图() {
assert(m设备);
m渲染目标管理 = std::make_unique<C渲染目标管理>();
//堆
D3D12_DESCRIPTOR_HEAP_DESC v描述 = {};
v描述.NumDescriptors = c帧数;
v描述.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
v描述.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
m设备->CreateDescriptorHeap(&v描述, IID_PPV_ARGS(&m渲染目标管理->m渲染目标堆));
m渲染目标管理->m渲染目标视图大小 = m设备->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
//循环
D3D12_CPU_DESCRIPTOR_HANDLE v渲染目标视图句柄 = m渲染目标管理->m渲染目标堆->GetCPUDescriptorHandleForHeapStart();
for (UINT i = 0; i < c帧数; ++i) {
auto &v渲染目标 = m渲染目标管理->m渲染目标[i];
//资源
m交换链->GetBuffer(i, IID_PPV_ARGS(&v渲染目标));
//视图
m设备->CreateRenderTargetView(v渲染目标.Get(), nullptr, v渲染目标视图句柄);
v渲染目标视图句柄.ptr += m渲染目标管理->m渲染目标视图大小;
//名称
if constexpr (c调试) {
const std::wstring v名称 = std::wstring(L"渲染目标") + std::to_wstring(i);
v渲染目标->SetName(v名称.c_str());
}
}
//结束
if (m渲染控制) {
m渲染目标管理->m帧索引 = &m渲染控制->m帧索引;
}
return S_OK;
}
HRESULT C三维::f初始化深度模板视图() {
m深度模板管理 = std::make_unique<C深度模板管理>();
//堆
D3D12_DESCRIPTOR_HEAP_DESC v堆描述 = {};
v堆描述.NumDescriptors = 1;
v堆描述.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
v堆描述.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
HRESULT hr = m设备->CreateDescriptorHeap(&v堆描述, IID_PPV_ARGS(&m深度模板管理->m深度模板堆));
if (FAILED(hr)) {
return hr;
}
//资源准备
const D3D12_RESOURCE_DESC v资源描述 = S资源描述::fc纹理2(m窗口大小[0], m窗口大小[1], c深度模板格式, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL);
const D3D12_HEAP_PROPERTIES v堆属性 = S堆属性::fc类型(D3D12_HEAP_TYPE_DEFAULT);
const D3D12_CLEAR_VALUE v清除值 = S清除值::fc深度模板(c深度模板格式, c清屏深度r, 0);
//视图准备
D3D12_DEPTH_STENCIL_VIEW_DESC v视图描述 = {};
v视图描述.Format = c深度模板格式;
v视图描述.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
v视图描述.Texture2D.MipSlice = 0;
//循环
D3D12_CPU_DESCRIPTOR_HANDLE v深度模板视图句柄 = m深度模板管理->m深度模板堆->GetCPUDescriptorHandleForHeapStart();
for (UINT i = 0; i != c帧数; ++i) {
auto &v深度模板 = m深度模板管理->m深度模板[i];
//资源
hr = m设备->CreateCommittedResource(&v堆属性, D3D12_HEAP_FLAG_NONE, &v资源描述, D3D12_RESOURCE_STATE_DEPTH_WRITE, &v清除值, IID_PPV_ARGS(&v深度模板));
if (FAILED(hr)) {
return hr;
}
//视图
m设备->CreateDepthStencilView(v深度模板.Get(), &v视图描述, v深度模板视图句柄);
v深度模板视图句柄.ptr += m深度模板管理->m深度模板视图大小;
//名称
if constexpr (c调试) {
const std::wstring v名称 = std::wstring(L"深度模板") + std::to_wstring(i);
v深度模板->SetName(v名称.c_str());
}
}
//结束
if (m渲染控制) {
m深度模板管理->m帧索引 = &m渲染控制->m帧索引;
}
return S_OK;
}
HRESULT C三维::f初始化根签名() {
D3D12_ROOT_SIGNATURE_DESC v描述 = {};
v描述.NumParameters = 0;
v描述.pParameters = nullptr;
v描述.NumStaticSamplers = 0;
v描述.pStaticSamplers = nullptr;
v描述.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT;
return f创建根签名(m默认根签名, v描述);
}
bool C三维::f初始化(const HWND &a) {
try {
f初始化窗口(a);
视窗::f失败则抛出(f初始化设备());
视窗::f失败则抛出(f初始化命令队列());
视窗::f失败则抛出(f初始化交换链());
视窗::f失败则抛出(f初始化渲染目标视图());
视窗::f失败则抛出(f初始化深度模板视图());
视窗::f失败则抛出(f初始化根签名());
return true;
} catch (HRESULT hr) {
return false;
}
}
HRESULT C三维::f重置屏幕资源() {
HRESULT hr;
const bool v重置深度模板 = m深度模板管理.operator bool();
if (m交换链) {
hr = f重置交换链();
if (FAILED(hr)) {
return hr;
}
hr = f初始化渲染目标视图();
if (FAILED(hr)) {
return hr;
}
}
if (v重置深度模板) {
hr = f初始化深度模板视图();
if (FAILED(hr)) {
return hr;
}
}
return S_OK;
}
HRESULT C三维::f重置交换链() {
assert(m交换链);
//m渲染控制->f重置命令();
m渲染控制->m命令列表->Close();
m渲染目标管理 = nullptr;
m深度模板管理 = nullptr;
HRESULT hr = m交换链->ResizeBuffers(c帧数, m窗口大小[0], m窗口大小[1], c交换链格式, m交换链标志);
if (FAILED(hr)) {
return hr;
}
m渲染控制->m帧索引 = m交换链->GetCurrentBackBufferIndex();
return S_OK;
}
HRESULT C三维::f调整目标大小() {
DXGI_MODE_DESC v模式描述 = {};
v模式描述.Width = m窗口大小[0];
v模式描述.Height = m窗口大小[1];
HRESULT hr = m交换链->ResizeTarget(&v模式描述);
return hr;
}
HRESULT C三维::f创建图形管线(tp图形管线 &a, const D3D12_GRAPHICS_PIPELINE_STATE_DESC &a描述) {
assert(m设备);
//检查参数
if (a描述.VS.pShaderBytecode) {
assert(a描述.InputLayout.pInputElementDescs && a描述.InputLayout.NumElements);
}
assert(a描述.PrimitiveTopologyType != D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED);
//创建
//注意:I卡可能会报错D3D12 ERROR: ID3D12Device::CreateVertexShader: Shader is corrupt or in an unrecognized format. [ STATE_CREATION ERROR #67: CREATEVERTEXSHADER_INVALIDSHADERBYTECODE]。换成其他显卡则正常。
HRESULT hr = m设备->CreateGraphicsPipelineState(&a描述, IID_PPV_ARGS(&a));
if (FAILED(hr)) {
return hr;
}
return S_OK;
}
HRESULT C三维::f创建命令列表(tp命令列表 &a, ID3D12PipelineState *a图形管线) {
assert(m设备);
HRESULT hr = m设备->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m命令分配器.Get(), a图形管线, IID_PPV_ARGS(&a));
if (FAILED(hr)) {
return hr;
}
hr = a->Close();
if (FAILED(hr)) {
return hr;
}
return S_OK;
}
HRESULT C三维::f创建根签名(tp根签名 &a, const C根签名参数 &a参数) {
D3D12_ROOT_SIGNATURE_DESC v描述;
v描述.NumStaticSamplers = a参数.ma采样器.size();
v描述.pStaticSamplers = a参数.ma采样器.data();
v描述.Flags = a参数.m标志;
std::vector<D3D12_ROOT_PARAMETER> va参数;
for (const auto &v0 : a参数.ma索引) {
switch (v0.m类型) {
case C根签名参数::E根参数类型::e描述符表:{
const auto &v1 = a参数.ma描述符表[v0.m位置];
D3D12_ROOT_PARAMETER v参数;
v参数.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
v参数.DescriptorTable.NumDescriptorRanges = v1.m数量;
v参数.DescriptorTable.pDescriptorRanges = &a参数.ma描述范围[v1.m开始位置];
v参数.ShaderVisibility = v1.m可见性;
va参数.push_back(v参数);
break;
}
case C根签名参数::E根参数类型::e常量:
case C根签名参数::E根参数类型::e描述符:
va参数.push_back(a参数.ma参数[v0.m位置]);
break;
default:
return E_INVALIDARG;
}
}
v描述.NumParameters = va参数.size();
v描述.pParameters = va参数.data();
return f创建根签名(a, v描述);
}
HRESULT C三维::f创建根签名(tp根签名 &a, const D3D12_ROOT_SIGNATURE_DESC &a描述) {
ComPtr<ID3DBlob> v签名, v错误;
HRESULT hr = D3D12SerializeRootSignature(&a描述, D3D_ROOT_SIGNATURE_VERSION_1, &v签名, &v错误);
if (FAILED(hr)) {
return hr;
}
hr = m设备->CreateRootSignature(0, v签名->GetBufferPointer(), v签名->GetBufferSize(), IID_PPV_ARGS(&a));
if (FAILED(hr)) {
return hr;
}
return S_OK;
}
D3D12_VIEWPORT C三维::fg窗口视口() {
D3D12_VIEWPORT v视口;
v视口.Width = (FLOAT)m窗口大小[0];
v视口.Height = (FLOAT)m窗口大小[1];
v视口.MinDepth = 0.0f;
v视口.MaxDepth = 1.0f;
v视口.TopLeftX = 0;
v视口.TopLeftY = 0;
return v视口;
}
D3D12_RECT C三维::fg窗口矩形() {
return {0, 0, m窗口大小[0], m窗口大小[1]};
}
数学::S向量2 C三维::fg窗口大小() const {
return {(float)m窗口大小[0], (float)m窗口大小[1]};
}
void C三维::fs窗口大小() {
视窗::S客户区尺寸 v尺寸 = 视窗::S客户区尺寸::fc窗口(m窗口);
fs窗口大小_(v尺寸.fg宽(), v尺寸.fg高());
}
HRESULT C三维::fs窗口大小(int a宽, int a高) {
fs窗口大小_(a宽, a高);
if (!fi全屏()) {
HRESULT hr = f调整目标大小();
if (FAILED(hr)) {
return hr;
}
}
return S_OK;
}
void C三维::fs窗口大小_(int a宽, int a高) {
m窗口大小[0] = a宽;
m窗口大小[1] = a高;
m默认视口 = fg窗口视口();
m默认裁剪矩形 = fg窗口矩形();
}
bool C三维::fi全屏() const {
BOOL v;
m交换链->GetFullscreenState(&v, nullptr);
return v;
}
bool C三维::fi窗口() const {
return !fi全屏();
}
void C三维::fs全屏(bool a) {
m交换链->SetFullscreenState(a, nullptr);
if (!a) {
f调整目标大小();
}
}
C渲染控制 &C三维::fg渲染控制() {
if (m渲染控制 == nullptr) {
m渲染控制 = std::make_unique<C渲染控制>();
m渲染控制->m三维 = this;
f创建命令列表(m渲染控制->m命令列表);
m渲染控制->m根签名 = m默认根签名;
m渲染目标管理->m帧索引 = &m渲染控制->m帧索引;
m深度模板管理->m帧索引 = &m渲染控制->m帧索引;
m渲染控制->f初始化围栏(m设备.Get());
}
return *m渲染控制;
}
C渲染状态 &C三维::fg渲染状态() {
if (m渲染状态 == nullptr) {
m渲染状态 = std::make_unique<C渲染状态>();
}
return *m渲染状态;
}
C创建设备 &C三维::fg创建设备() {
if (m创建设备 == nullptr) {
m创建设备 = std::make_unique<C创建设备>();
}
return *m创建设备;
}
C缓冲工厂 &C三维::fg缓冲工厂() {
if (m缓冲工厂 == nullptr) {
m缓冲工厂 = std::make_unique<C缓冲工厂>();
m缓冲工厂->f初始化(m设备.Get());
}
return *m缓冲工厂;
}
C纹理工厂 &C三维::fg纹理工厂() {
if (m纹理工厂 == nullptr) {
m纹理工厂 = std::make_unique<C纹理工厂>();
m纹理工厂->m缓冲工厂 = &fg缓冲工厂();
m纹理工厂->m设备 = m设备;
m纹理工厂->m渲染控制 = &fg渲染控制();
m纹理工厂->f初始化();
}
return *m纹理工厂;
}
C渲染目标管理 &C三维::fg渲染目标管理() {
return *m渲染目标管理;
}
C深度模板管理 &C三维::fg深度模板管理() {
return *m深度模板管理;
}
ID3D12RootSignature *C三维::fg默认根签名() {
return m默认根签名.Get();
}
ComPtr<ID3D12Device> C三维::fg设备() const {
return m设备;
}
//==============================================================================
// 创建设备
//==============================================================================
ComPtr<IDXGIFactory5> C创建设备::fg工厂() {
if (m工厂 == nullptr) {
HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(&m工厂));
if (FAILED(hr)) {
throw;
}
}
return m工厂;
}
bool C创建设备::f开启调试层() {
ComPtr<ID3D12Debug> v调试;
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&v调试)))) {
v调试->EnableDebugLayer();
return true;
}
return false;
}
bool C创建设备::f检查撕裂() {
fg工厂();
BOOL v撕裂 = FALSE;
HRESULT hr = m工厂->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &v撕裂, sizeof(v撕裂));
return SUCCEEDED(hr) && v撕裂;
}
HRESULT C创建设备::f取显卡_首选(IDXGIAdapter3 **a显卡) {
HRESULT hr = S_OK;
fg工厂();
ComPtr<IDXGIAdapter1> v显卡, v目标显卡;
*a显卡 = nullptr;
for (UINT i = 0; DXGI_ERROR_NOT_FOUND != m工厂->EnumAdapters1(i, &v显卡); ++i) {
DXGI_ADAPTER_DESC1 v描述;
v显卡->GetDesc1(&v描述);
if (v描述.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) {
continue;
}
hr = D3D12CreateDevice(v显卡.Get(), c最低功能级别, __uuidof(ID3D12Device), nullptr);
if (FAILED(hr)) {
continue;
} else {
v目标显卡 = v显卡;
break;
}
}
if (v目标显卡) {
ComPtr<IDXGIAdapter3> v输出;
v目标显卡.As(&v输出);
*a显卡 = v输出.Detach();
return S_OK;
} else {
return hr;
}
}
HRESULT C创建设备::f取显卡_性能(IDXGIAdapter3 **a显卡) {
HRESULT hr = S_OK;
fg工厂();
ComPtr<IDXGIAdapter1> v显卡, v目标显卡;
*a显卡 = nullptr;
SIZE_T v显存 = 0;
for (UINT i = 0; DXGI_ERROR_NOT_FOUND != m工厂->EnumAdapters1(i, &v显卡); ++i) {
DXGI_ADAPTER_DESC1 v描述;
v显卡->GetDesc1(&v描述);
if (v描述.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) {
continue;
}
hr = D3D12CreateDevice(v显卡.Get(), c最低功能级别, __uuidof(ID3D12Device), nullptr);
if (FAILED(hr)) {
continue;
}
if (v描述.DedicatedVideoMemory > v显存) {
v目标显卡 = v显卡;
v显存 = v描述.DedicatedVideoMemory;
}
}
if (v目标显卡) {
ComPtr<IDXGIAdapter3> v输出;
v目标显卡.As(&v输出);
*a显卡 = v输出.Detach();
return S_OK;
} else {
return hr;
}
}
HRESULT C创建设备::f取软件适配器(IDXGIAdapter3 **a显卡) {
return m工厂->EnumWarpAdapter(IID_PPV_ARGS(a显卡));
}
HRESULT C创建设备::f创建设备(IDXGIAdapter3 *a显卡, ID3D12Device **a设备) {
HRESULT hr;
//新着色器模型功能,旧系统(win10 v1803之前)旧显卡需要调用
hr = D3D12EnableExperimentalFeatures(1, &D3D12ExperimentalShaderModels, nullptr, nullptr);
if (FAILED(hr)) {
if (hr == 0x80004002) { //E_NOINTERFACE No such interface supported.
//跳过
} else {
return hr;
}
}
hr = D3D12CreateDevice(a显卡, c最低功能级别, IID_PPV_ARGS(a设备));
return hr;
}
//==============================================================================
// 渲染控制
//==============================================================================
C渲染控制::~C渲染控制() {
f销毁();
}
void C渲染控制::f销毁() {
CloseHandle(m围栏事件);
}
HRESULT C渲染控制::f初始化围栏(ID3D12Device *a设备) {
HRESULT hr = a设备->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m围栏));
m围栏值 = 1;
m围栏事件 = CreateEventW(nullptr, FALSE, FALSE, nullptr);
if (m围栏事件 == nullptr) {
hr = HRESULT_FROM_WIN32(GetLastError());
if (FAILED(hr)) {
return hr;
}
}
f等待完成帧();
return S_OK;
}
void C渲染控制::f开始() {
m命令列表->SetGraphicsRootSignature(m根签名.Get());
m命令列表->RSSetViewports(1, &m三维->m默认视口);
m命令列表->RSSetScissorRects(1, &m三维->m默认裁剪矩形);
const D3D12_RESOURCE_BARRIER v栅栏 = fc渲染视图栅栏变换(D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET);
m命令列表->ResourceBarrier(1, &v栅栏);
m三维->m渲染目标管理->f更新视图();
m三维->m深度模板管理->f更新视图();
m命令列表->OMSetRenderTargets(1, &m三维->m渲染目标管理->fg当前视图(), FALSE, &m三维->m深度模板管理->fg当前视图());
}
void C渲染控制::f结束() {
const D3D12_RESOURCE_BARRIER v栅栏 = fc渲染视图栅栏变换(D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT);
m命令列表->ResourceBarrier(1, &v栅栏);
}
void C渲染控制::f清屏() {
m命令列表->ClearRenderTargetView(m三维->m渲染目标管理->fg当前视图(), m清屏颜色.fg数据(), 0, nullptr);
constexpr D3D12_CLEAR_FLAGS c清除深度模板标志 = D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL;
m命令列表->ClearDepthStencilView(m三维->m深度模板管理->fg当前视图(), c清除深度模板标志, m清屏深度, m清屏模板, 0, nullptr);
}
void C渲染控制::f显示() {
const UINT v标志 = (m三维->m标志[C三维::e撕裂] && m三维->fi窗口()) ? DXGI_PRESENT_ALLOW_TEARING : 0;
m三维->m交换链->Present(0, v标志);
f等待完成帧();
f更新帧索引();
ma更新资源.clear();
}
void C渲染控制::f重置命令() {
m三维->m命令分配器->Reset();
m命令列表->Reset(m三维->m命令分配器.Get(), m图形管线.Get());
}
void C渲染控制::f执行命令() {
m命令列表->Close();
ID3D12CommandList* v命令列表[] = {m命令列表.Get()};
m三维->m命令队列->ExecuteCommandLists(_countof(v命令列表), v命令列表);
}
void C渲染控制::f执行命令并等待() {
f执行命令();
f等待完成帧();
ma更新资源.clear();
}
void C渲染控制::f执行命令并显示() {
f执行命令();
f显示();
}
void C渲染控制::f绘制(UINT a顶点数, UINT a开始) {
m命令列表->DrawInstanced(a顶点数, 1, a开始, 0);
}
void C渲染控制::f绘制索引(UINT a索引数, UINT a开始索引, INT a开始顶点) {
m命令列表->DrawIndexedInstanced(a索引数, 1, a开始索引, a开始顶点, 0);
}
void C渲染控制::f等待完成帧() {
const UINT64 v围栏值 = m围栏值;
m三维->m命令队列->Signal(m围栏.Get(), v围栏值);
m围栏值++;
// 等到前一帧完成。
if (m围栏->GetCompletedValue() < v围栏值) {
m围栏->SetEventOnCompletion(v围栏值, m围栏事件);
WaitForSingleObject(m围栏事件, INFINITE);
}
}
UINT C渲染控制::f更新帧索引() {
m帧索引 = m三维->m交换链->GetCurrentBackBufferIndex();
return m帧索引;
}
UINT C渲染控制::fg帧索引() const {
return m帧索引;
}
void C渲染控制::f更新资源(ID3D12Resource *a目标, ID3D12Resource *a源) {
m命令列表->CopyResource(a目标, a源);
ma更新资源.emplace_back(a源);
}
void C渲染控制::f更新纹理(ID3D12Resource *a目标, ID3D12Resource *a源, D3D12_SUBRESOURCE_DATA &a资源描述) {
UpdateSubresources(m命令列表.Get(), a目标, a源, 0, 0, 1, &a资源描述);
const S资源栅栏 v资源栅栏 = S资源栅栏::fc变换(a目标, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
m命令列表->ResourceBarrier(1, &v资源栅栏);
ma更新资源.emplace_back(a源);
}
void C渲染控制::fs清屏颜色(const 数学::S颜色 &a) {
m清屏颜色 = a;
}
void C渲染控制::fs清屏深度(float a) {
m清屏深度 = a;
}
void C渲染控制::fs清屏模板(UINT8 a) {
m清屏模板 = a;
}
void C渲染控制::fs模板参考值(UINT a) {
m命令列表->OMSetStencilRef(a);
}
void C渲染控制::fs图形管线(ID3D12PipelineState *a) {
m图形管线 = a;
m命令列表->SetPipelineState(a);
}
void C渲染控制::fs根签名(ID3D12RootSignature *a) {
m根签名 = a;
m命令列表->SetGraphicsRootSignature(a);
}
void C渲染控制::fs图元拓扑(E图元拓扑 a) {
m命令列表->IASetPrimitiveTopology((D3D_PRIMITIVE_TOPOLOGY)a);
}
void C渲染控制::fs顶点缓冲(const D3D12_VERTEX_BUFFER_VIEW &a) {
m命令列表->IASetVertexBuffers(0, 1, &a);
}
void C渲染控制::fs索引缓冲(const D3D12_INDEX_BUFFER_VIEW &a) {
m命令列表->IASetIndexBuffer(&a);
}
void C渲染控制::fs常量缓冲(UINT a槽, const D3D12_GPU_VIRTUAL_ADDRESS &a位置) {
m命令列表->SetGraphicsRootConstantBufferView(a槽, a位置);
}
void C渲染控制::fs纹理(UINT a槽, const D3D12_GPU_VIRTUAL_ADDRESS &a位置) {
m命令列表->SetGraphicsRootShaderResourceView(a槽, a位置);
}
void C渲染控制::fs描述符表(UINT a槽, ID3D12DescriptorHeap *a堆) {
m命令列表->SetDescriptorHeaps(1, &a堆);
m命令列表->SetGraphicsRootDescriptorTable(a槽, a堆->GetGPUDescriptorHandleForHeapStart());
}
D3D12_RESOURCE_BARRIER C渲染控制::fc渲染视图栅栏变换(D3D12_RESOURCE_STATES a前, D3D12_RESOURCE_STATES a后) {
return S资源栅栏::fc变换(m三维->m渲染目标管理->fg当前资源(), a前, a后);
}
//==============================================================================
// 渲染目标
//==============================================================================
const D3D12_CPU_DESCRIPTOR_HANDLE &C渲染目标管理::f更新视图() {
m当前渲染目标视图 = m渲染目标堆->GetCPUDescriptorHandleForHeapStart();
m当前渲染目标视图.ptr += *m帧索引 * m渲染目标视图大小;
return m当前渲染目标视图;
}
const D3D12_CPU_DESCRIPTOR_HANDLE &C渲染目标管理::fg当前视图() const {
return m当前渲染目标视图;
}
ID3D12Resource *C渲染目标管理::fg当前资源() const {
return m渲染目标[*m帧索引].Get();
}
const D3D12_CPU_DESCRIPTOR_HANDLE &C深度模板管理::f更新视图() {
m当前深度模板视图 = m深度模板堆->GetCPUDescriptorHandleForHeapStart();
m当前深度模板视图.ptr += *m帧索引 * m深度模板视图大小;
return m当前深度模板视图;
}
const D3D12_CPU_DESCRIPTOR_HANDLE &C深度模板管理::fg当前视图() const {
return m当前深度模板视图;
}
ID3D12Resource *C深度模板管理::fg当前资源() const {
return m深度模板[*m帧索引].Get();
}
//==============================================================================
// 渲染状态
//==============================================================================
C渲染状态::C渲染状态() {
//光栅化 ================================================================
//线框渲染
m光栅化.m线框渲染 = c默认光栅化;
m光栅化.m线框渲染.CullMode = D3D12_CULL_MODE_BACK;
m光栅化.m线框渲染.FillMode = D3D12_FILL_MODE_WIREFRAME;
m光栅化.m线框渲染.FrontCounterClockwise = false;
m光栅化.m线框渲染.DepthClipEnable = true;
m光栅化.m线框渲染.MultisampleEnable = true;
//显示隐藏面
m光栅化.m显示隐藏面 = c默认光栅化;
m光栅化.m显示隐藏面.CullMode = D3D12_CULL_MODE_NONE;
m光栅化.m显示隐藏面.FillMode = D3D12_FILL_MODE_SOLID;
//设置逆时针为正面
m光栅化.m反面渲染 = c默认光栅化;
m光栅化.m反面渲染.FrontCounterClockwise = true;
//混合 ====================================================================
//开启透明
m混合.m开启透明 = c默认混合;
m混合.m开启透明.RenderTarget[0].BlendEnable = true;
m混合.m开启透明.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA;
m混合.m开启透明.RenderTarget[0].DestBlend = D3D12_BLEND_INV_SRC_ALPHA;
m混合.m开启透明.RenderTarget[0].BlendOp = D3D12_BLEND_OP_ADD;
m混合.m开启透明.RenderTarget[0].SrcBlendAlpha = D3D12_BLEND_SRC_ALPHA;
m混合.m开启透明.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_DEST_ALPHA;
m混合.m开启透明.RenderTarget[0].BlendOpAlpha = D3D12_BLEND_OP_MAX;
m混合.m开启透明.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL;
//颜色叠加
m混合.m颜色叠加 = m混合.m开启透明;
m混合.m颜色叠加.RenderTarget[0].DestBlend = D3D12_BLEND_DEST_ALPHA;
m混合.m颜色叠加.RenderTarget[0].SrcBlendAlpha = D3D12_BLEND_SRC_ALPHA;
m混合.m颜色叠加.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_DEST_ALPHA;
//禁止写颜色
m混合.m禁止写颜色 = c默认混合;
m混合.m禁止写颜色.RenderTarget[0].BlendEnable = false;
m混合.m禁止写颜色.RenderTarget[0].RenderTargetWriteMask = 0;
//深度模板 ================================================================
//正常深度
m深度模板.m正常深度l = c默认深度模板;
m深度模板.m正常深度l.DepthEnable = true;
m深度模板.m正常深度l.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
m深度模板.m正常深度l.DepthFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL;
m深度模板.m正常深度l.StencilEnable = false;
m深度模板.m正常深度r = m深度模板.m正常深度l;
m深度模板.m正常深度r.DepthFunc = D3D12_COMPARISON_FUNC_GREATER_EQUAL;
m深度模板.m总是覆盖 = m深度模板.m正常深度l;
m深度模板.m总是覆盖.DepthFunc = D3D12_COMPARISON_FUNC_ALWAYS;
//模板标记
m深度模板.m模板标记 = c默认深度模板;
m深度模板.m模板标记.DepthEnable = false;
m深度模板.m模板标记.StencilEnable = true;
m深度模板.m模板标记.FrontFace.StencilFailOp = D3D12_STENCIL_OP_KEEP;
m深度模板.m模板标记.FrontFace.StencilDepthFailOp = D3D12_STENCIL_OP_KEEP;
m深度模板.m模板标记.FrontFace.StencilPassOp = D3D12_STENCIL_OP_REPLACE;
m深度模板.m模板标记.FrontFace.StencilFunc = D3D12_COMPARISON_FUNC_ALWAYS;
m深度模板.m模板标记.BackFace = m深度模板.m模板标记.FrontFace;
//模板比较
m深度模板.m模板比较 = c默认深度模板;
m深度模板.m模板比较.StencilEnable = true;
m深度模板.m模板比较.FrontFace.StencilFunc = D3D12_COMPARISON_FUNC_EQUAL;
m深度模板.m模板比较.BackFace.StencilFunc = D3D12_COMPARISON_FUNC_EQUAL;
//采样器 ================================================================
//纹理
m采样器.m纹理.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
m采样器.m纹理.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
m采样器.m纹理.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
m采样器.m纹理.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
m采样器.m纹理.ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER;
m采样器.m纹理.BorderColor[0] = 0;
m采样器.m纹理.BorderColor[1] = 0;
m采样器.m纹理.BorderColor[2] = 0;
m采样器.m纹理.BorderColor[3] = 0;
m采样器.m纹理.MinLOD = 0;
m采样器.m纹理.MaxLOD = D3D12_FLOAT32_MAX;
m采样器.m纹理.MipLODBias = 0;
m采样器.m纹理.MaxAnisotropy = 16;
//图案
m采样器.m图案 = m采样器.m纹理;
m采样器.m图案.AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
m采样器.m图案.AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
m采样器.m图案.AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
//各向异性过滤
m采样器.m各向异性过滤 = m采样器.m纹理;
m采样器.m各向异性过滤.Filter = D3D12_FILTER_ANISOTROPIC;
}
C渲染状态::~C渲染状态() {
}
D3D12_SAMPLER_DESC C渲染状态::ft采样器(const D3D12_STATIC_SAMPLER_DESC &a) {
return {a.Filter, a.AddressU, a.AddressV, a.AddressW, a.MipLODBias, a.MaxAnisotropy, a.ComparisonFunc, {0, 0, 0, 0}, a.MinLOD, a.MaxLOD};
}
D3D12_STATIC_SAMPLER_DESC C渲染状态::ft静态采样器(const D3D12_SAMPLER_DESC &a, UINT a寄存器, UINT a空间, D3D12_SHADER_VISIBILITY a可视性) {
return {a.Filter, a.AddressU, a.AddressV, a.AddressW, a.MipLODBias, a.MaxAnisotropy, a.ComparisonFunc, D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK, a.MinLOD, a.MaxLOD, a寄存器, a空间, a可视性};
}
//==============================================================================
// 顶点格式
//==============================================================================
static const char*const ca顶点语义[] = {
"POSITION",
"NORMAL",
"BINORMAL",
"COLOR",
"TEXCOORD",
"PSIZE",
"TANGENT",
"ALPHA"
};
void C顶点格式::f清空() {
m数组.clear();
m类型累计.clear();
m字节累计 = 0;
}
void C顶点格式::f添加(E类型 a类型, int a大小) {
f添加(ca顶点语义[a类型], a大小);
}
void C顶点格式::f添加(E类型 a类型, int a大小, int a数量) {
for (int i = 0; i != a数量; ++i) {
f添加(ca顶点语义[a类型], a大小);
}
}
void C顶点格式::f添加(const char *a语义, int a大小) {
static const DXGI_FORMAT ca格式[] = {
DXGI_FORMAT_R32_FLOAT,
DXGI_FORMAT_R32G32_FLOAT,
DXGI_FORMAT_R32G32B32_FLOAT,
DXGI_FORMAT_R32G32B32A32_FLOAT
};
assert(a大小 <= _countof(ca格式));
D3D12_INPUT_ELEMENT_DESC v;
v.AlignedByteOffset = m字节累计;
v.Format = ca格式[a大小 - 1];
m字节累计 += a大小 * 4;
v.SemanticName = a语义;
auto &v语义索引 = m类型累计[a语义];
v.SemanticIndex = v语义索引;
v语义索引 += 1;
v.InputSlot = 0;
v.InputSlotClass = D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA;
v.InstanceDataStepRate = 0;
m数组.push_back(v);
}
D3D12_INPUT_LAYOUT_DESC C顶点格式::fg输入层描述() const {
return {m数组.data(), (UINT)m数组.size()};
}
//==============================================================================
// 根签名
//==============================================================================
void C根签名参数::f清空() {
ma索引.clear();
ma参数.clear();
ma采样器.clear();
ma描述范围.clear();
ma描述符表.clear();
mi连续添加 = false;
}
C根签名参数 &C根签名参数::f添加描述符(E类型 a类型, UINT a寄存器, UINT a空间, E着色器 a可见性) {
f实现_添加索引(E根参数类型::e描述符);
D3D12_ROOT_PARAMETER v参数 = {};
v参数.ParameterType = f计算根参数类型(a类型);
v参数.Descriptor.ShaderRegister = a寄存器;
v参数.Descriptor.RegisterSpace = a空间;
v参数.ShaderVisibility = f计算可见性(a可见性);
ma参数.push_back(v参数);
return *this;
}
C根签名参数 &C根签名参数::f添加采样器(const D3D12_SAMPLER_DESC &a采样器, UINT a寄存器, UINT a空间, E着色器 a可见性) {
ma采样器.push_back(C渲染状态::ft静态采样器(a采样器, a寄存器, a空间, f计算可见性(a可见性)));
return *this;
}
C根签名参数 &C根签名参数::f添加范围(E类型 a类型, UINT a数量, UINT a开始寄存器, UINT a寄存器空间, UINT a偏移, E着色器 a可见性) {
assert(mi连续添加 == false); //连续添加范围时不能添加单个范围
assert(a数量 > 0);
f实现_添加索引(E根参数类型::e描述符表);
S描述符表 v描述表;
v描述表.m开始位置 = ma描述范围.size();
v描述表.m数量 = 1;
v描述表.m可见性 = f计算可见性(a可见性);
ma描述符表.push_back(v描述表);
f实现_添加范围(a类型, a数量, a开始寄存器, a寄存器空间, a偏移);
return *this;
}
C根签名参数 &C根签名参数::f连续添加范围(E类型 a类型, UINT a数量, UINT a开始寄存器, UINT a寄存器空间, UINT a偏移) {
assert(mi连续添加 == true);
f实现_添加范围(a类型, a数量, a开始寄存器, a寄存器空间, a偏移);
++m连续添加.m数量;
return *this;
}
C根签名参数 &C根签名参数::f连续添加范围开始(E着色器 a可见性) {
assert(mi连续添加 == false);
f实现_添加索引(E根参数类型::e描述符表);
m连续添加.m开始位置 = ma描述范围.size();
m连续添加.m数量 = 0;
m连续添加.m可见性 = f计算可见性(a可见性);
mi连续添加 = true;
return *this;
}
C根签名参数 &C根签名参数::f连续添加范围结束() {
assert(mi连续添加 == true);
ma描述符表.push_back(m连续添加);
mi连续添加 = false;
return *this;
}
void C根签名参数::fs标志(E根签名标志 a) {
fs标志((D3D12_ROOT_SIGNATURE_FLAGS)a);
}
void C根签名参数::fs标志(D3D12_ROOT_SIGNATURE_FLAGS a) {
}
void C根签名参数::f实现_添加范围(E类型 a类型, UINT a数量, UINT a开始寄存器, UINT a寄存器空间, UINT a偏移) {
D3D12_DESCRIPTOR_RANGE v范围;
v范围.RangeType = f计算描述范围类型(a类型);
v范围.NumDescriptors = a数量;
v范围.BaseShaderRegister = a开始寄存器;
v范围.RegisterSpace = a寄存器空间;
v范围.OffsetInDescriptorsFromTableStart = a偏移;
ma描述范围.push_back(v范围);
}
void C根签名参数::f实现_添加索引(E根参数类型 a类型) {
S根参数索引 v索引 = {};
v索引.m类型 = a类型;
switch (a类型) {
case E根参数类型::e描述符表:
v索引.m位置 = ma描述符表.size();
break;
case E根参数类型::e常量:
case E根参数类型::e描述符:
v索引.m位置 = ma参数.size();
break;
default:
throw;
}
ma索引.push_back(v索引);
}
D3D12_SHADER_VISIBILITY C根签名参数::f计算可见性(E着色器 a) {
switch (a) {
case E着色器::e顶点着色器:
return D3D12_SHADER_VISIBILITY_VERTEX;
case E着色器::e外壳着色器:
return D3D12_SHADER_VISIBILITY_HULL;
case E着色器::e域着色器:
return D3D12_SHADER_VISIBILITY_DOMAIN;
case E着色器::e几何着色器:
return D3D12_SHADER_VISIBILITY_GEOMETRY;
case E着色器::e像素着色器:
return D3D12_SHADER_VISIBILITY_PIXEL;
default:
return D3D12_SHADER_VISIBILITY_ALL;
}
}
D3D12_ROOT_PARAMETER_TYPE C根签名参数::f计算根参数类型(E类型 a) {
switch (a) {
case E类型::e着色器资源视图:
return D3D12_ROOT_PARAMETER_TYPE_SRV;
case E类型::e常量缓冲视图:
return D3D12_ROOT_PARAMETER_TYPE_CBV;
case E类型::e无序访问视图:
return D3D12_ROOT_PARAMETER_TYPE_UAV;
case E类型::e根常量:
return D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
default:
throw;
}
}
D3D12_DESCRIPTOR_RANGE_TYPE C根签名参数::f计算描述范围类型(E类型 a) {
switch (a) {
case E类型::e着色器资源视图:
return D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
case E类型::e常量缓冲视图:
return D3D12_DESCRIPTOR_RANGE_TYPE_CBV;
case E类型::e无序访问视图:
return D3D12_DESCRIPTOR_RANGE_TYPE_UAV;
case E类型::e采样器:
return D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER;
default:
throw;
}
}
//==============================================================================
// 修改
//==============================================================================
C自动映射::C自动映射(ID3D12Resource *a):
m资源(a) {
HRESULT hr = m资源->Map(0, nullptr, (void**)&m数据);
if (FAILED(hr)) {
throw;
}
}
C自动映射::~C自动映射() {
m资源->Unmap(0, nullptr);
}
void C自动映射::f映射并复制(ID3D12Resource *a资源, const void *a数据, size_t a大小) {
void *v数据;
HRESULT hr = a资源->Map(0, nullptr, &v数据);
if (FAILED(hr)) {
throw;
}
memcpy(v数据, a数据, a大小);
a资源->Unmap(0, nullptr);
}
void C自动映射::f复制(const void *a数据, size_t a大小) {
memcpy(m数据, a数据, a大小);
}
//==============================================================================
// 资源工厂
//==============================================================================
DXGI_FORMAT C缓冲工厂::f计算索引格式(UINT a类型大小) {
switch (a类型大小) {
case 2:
return DXGI_FORMAT_R16_UINT;
case 4:
return DXGI_FORMAT_R32_UINT;
default:
return DXGI_FORMAT_UNKNOWN;
}
}
void C缓冲工厂::f初始化(ID3D12Device *a设备) {
m设备 = a设备;
}
HRESULT C缓冲工厂::f创建上传资源(ComPtr<ID3D12Resource> &a, const void *a数据, UINT a数据大小) {
const D3D12_HEAP_PROPERTIES v堆属性 = {D3D12_HEAP_TYPE_UPLOAD, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, 1, 1};
const D3D12_RESOURCE_DESC v资源描述 = S资源描述::fc缓存(a数据大小);
HRESULT hr = m设备->CreateCommittedResource(&v堆属性, D3D12_HEAP_FLAG_NONE, &v资源描述, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&a));
if (FAILED(hr)) {
return hr;
}
a->SetName(L"上传");
if (a数据) {
C自动映射::f映射并复制(a.Get(), a数据, a数据大小);
}
return S_OK;
}
HRESULT C缓冲工厂::f创建顶点(tp顶点 &a, const void *a数据, UINT a类型大小, UINT a数据大小) {
tp顶点 v = std::make_shared<C顶点缓冲>();
HRESULT hr = f创建上传资源(v->m资源, a数据, a数据大小);
if (FAILED(hr)) {
return hr;
}
v->m资源->SetName(L"顶点");
//顶点缓存视图
v->m视图.BufferLocation = v->m资源->GetGPUVirtualAddress();
v->m视图.StrideInBytes = a类型大小;
v->m视图.SizeInBytes = a数据大小;
//结束
a = std::move(v);
return S_OK;
}
HRESULT C缓冲工厂::f创建索引(tp索引 &a, const void *a数据, UINT a类型大小, UINT a数据大小) {
//检查参数
const DXGI_FORMAT v索引格式 = f计算索引格式(a类型大小);
if (v索引格式 == DXGI_FORMAT_UNKNOWN) {
return E_INVALIDARG;
}
//资源
tp索引 v = std::make_shared<C索引缓冲>();
HRESULT hr = f创建上传资源(v->m资源, a数据, a数据大小);
if (FAILED(hr)) {
return hr;
}
v->m资源->SetName(L"索引");
//顶点缓存视图
v->m视图.BufferLocation = v->m资源->GetGPUVirtualAddress();
v->m视图.SizeInBytes = a数据大小;
v->m视图.Format = v索引格式;
//结束
a = std::move(v);
return S_OK;
}
HRESULT C缓冲工厂::f创建常量(tp常量 &a, const void *a数据, UINT a类型大小, UINT a数据大小) {
//堆描述符
D3D12_DESCRIPTOR_HEAP_DESC v描述符堆参数 = {};
v描述符堆参数.NumDescriptors = 1;
v描述符堆参数.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
v描述符堆参数.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
tp常量 v = std::make_shared<C常量缓冲>();
HRESULT hr = m设备->CreateDescriptorHeap(&v描述符堆参数, IID_PPV_ARGS(&v->m描述符堆));
if (FAILED(hr)) {
return hr;
}
//资源
const S堆属性 v堆属性 = S堆属性::fc类型(D3D12_HEAP_TYPE_UPLOAD);
const UINT v数据大小 = (a数据大小 + 255) & ~255; // 256字节对齐
const D3D12_RESOURCE_DESC v资源描述 = S资源描述::fc缓存(v数据大小);
hr = m设备->CreateCommittedResource(&v堆属性, D3D12_HEAP_FLAG_NONE, &v资源描述, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&v->m资源));
if (FAILED(hr)) {
return hr;
}
v->m资源->SetName(L"常量");
//视图
D3D12_CONSTANT_BUFFER_VIEW_DESC v常量缓冲视图参数 = {};
v常量缓冲视图参数.BufferLocation = v->m资源->GetGPUVirtualAddress();
v常量缓冲视图参数.SizeInBytes = v数据大小;
m设备->CreateConstantBufferView(&v常量缓冲视图参数, v->m描述符堆->GetCPUDescriptorHandleForHeapStart());
if (FAILED(hr)) {
return hr;
}
C自动映射::f映射并复制(v->m资源.Get(), a数据, a数据大小);
//结束
a = std::move(v);
return S_OK;
}
//==============================================================================
// 纹理工厂
//==============================================================================
C纹理工厂::~C纹理工厂() {}
HRESULT C纹理工厂::f初始化() {
m工厂 = std::make_unique<纹理::C图像工厂>();
return m工厂->f初始化();
}
HRESULT C纹理工厂::f从文件创建纹理资源视图(tp纹理资源视图 &a输出, const wchar_t *a文件) {
std::unique_ptr<纹理::C只读纹理> v纹理 = m工厂->f一键读取(a文件);
if (v纹理 == nullptr) {
return E_FAIL;
}
return f从纹理对象创建纹理资源视图(a输出, *v纹理);
}
HRESULT C纹理工厂::f从纹理对象创建纹理资源视图(tp纹理资源视图 &a输出, const 纹理::I纹理 &a纹理) {
tp纹理资源视图 v = std::make_shared<C纹理资源>();
HRESULT hr = f从纹理对象创建纹理资源(v->m资源, a纹理);
if (FAILED(hr)) {
return hr;
}
hr = f从纹理资源创建纹理视图(v->m描述符堆, v->m资源, a纹理.fg格式());
if (FAILED(hr)) {
return hr;
}
//结束
a输出 = std::move(v);
return S_OK;
}
HRESULT C纹理工厂::f从内存创建纹理资源(tp资源 &a输出, const void *a数据, DXGI_FORMAT a格式, UINT a宽, UINT a高, UINT a行距, UINT a大小) {
//创建资源
D3D12_RESOURCE_DESC v纹理描述 = {};
v纹理描述.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
v纹理描述.Width = a宽;
v纹理描述.Height = a高;
v纹理描述.DepthOrArraySize = 1;
v纹理描述.MipLevels = 1;
v纹理描述.Format = a格式;
v纹理描述.SampleDesc.Count = 1;
v纹理描述.SampleDesc.Quality = 0;
v纹理描述.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
v纹理描述.Flags = D3D12_RESOURCE_FLAG_NONE;
const S堆属性 v堆属性 = S堆属性::fc类型(D3D12_HEAP_TYPE_DEFAULT);
HRESULT hr = m设备->CreateCommittedResource(&v堆属性, D3D12_HEAP_FLAG_NONE, &v纹理描述, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&a输出));
if (FAILED(hr)) {
return hr;
}
a输出->SetName(L"纹理");
//复制数据
const UINT64 v上传大小 = GetRequiredIntermediateSize(a输出.Get(), 0, 1);
ComPtr<ID3D12Resource> v上传资源;
hr = m缓冲工厂->f创建上传资源(v上传资源, nullptr, v上传大小);
if (FAILED(hr)) {
return hr;
}
D3D12_SUBRESOURCE_DATA v资源描述 = {};
v资源描述.pData = a数据;
v资源描述.RowPitch = a行距;
v资源描述.SlicePitch = a大小;
m渲染控制->f更新纹理(a输出.Get(), v上传资源.Get(), v资源描述);
return S_OK;
}
HRESULT C纹理工厂::f从纹理对象创建纹理资源(tp资源 &a输出, const 纹理::I纹理 &a纹理) {
return f从内存创建纹理资源(a输出, a纹理.fg数据(), a纹理.fg格式(), a纹理.fg宽(), a纹理.fg高(), a纹理.fg行距(), a纹理.fg图像大小());
}
HRESULT C纹理工厂::f从纹理资源创建纹理视图(tp描述符堆 &a输出, const tp资源 &a资源, DXGI_FORMAT a格式) {
D3D12_DESCRIPTOR_HEAP_DESC v堆描述 = {};
v堆描述.NumDescriptors = 1;
v堆描述.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
v堆描述.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
HRESULT hr = m设备->CreateDescriptorHeap(&v堆描述, IID_PPV_ARGS(&a输出));
if (FAILED(hr)) {
return hr;
}
D3D12_SHADER_RESOURCE_VIEW_DESC v视图描述 = {};
v视图描述.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
v视图描述.Format = a格式;
v视图描述.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
v视图描述.Texture2D.MipLevels = 1;
m设备->CreateShaderResourceView(a资源.Get(), &v视图描述, a输出->GetCPUDescriptorHandleForHeapStart());
return S_OK;
}
//==============================================================================
// 资源描述
//==============================================================================
S资源描述 S资源描述::fc缓存(UINT64 a宽) {
S资源描述 v = {};
v.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
v.Alignment = 0;
v.Width = a宽;
v.Height = 1;
v.DepthOrArraySize = 1;
v.MipLevels = 1;
v.Format = DXGI_FORMAT_UNKNOWN;
v.SampleDesc.Count = 1;
v.SampleDesc.Quality = 0;
v.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
v.Flags = D3D12_RESOURCE_FLAG_NONE;
return v;
}
S资源描述 S资源描述::fc纹理2(UINT64 a宽, UINT a高, DXGI_FORMAT a格式, D3D12_RESOURCE_FLAGS a标志) {
S资源描述 v = {};
v.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
v.Alignment = 0;
v.Width = a宽;
v.Height = a高;
v.DepthOrArraySize = 1;
v.MipLevels = 1;
v.Format = a格式;
v.SampleDesc.Count = 1;
v.SampleDesc.Quality = 0;
v.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
v.Flags = a标志;
return v;
}
//==============================================================================
// 图形管线参数
//==============================================================================
S图形管线参数::S图形管线参数():
D3D12_GRAPHICS_PIPELINE_STATE_DESC() {
NumRenderTargets = 1;
RTVFormats[0] = c交换链格式;
SampleDesc.Count = 1;
SampleMask = UINT_MAX;
}
void S图形管线参数::fs输入布局(const C顶点格式 &a) {
InputLayout = a.fg输入层描述();
}
void S图形管线参数::fs根签名(ID3D12RootSignature *a) {
pRootSignature = a;
}
void S图形管线参数::fs顶点着色器(const std::span<const std::byte> &a) {
assert(!a.empty());
VS = ft着色器字节码(a);
}
void S图形管线参数::fs像素着色器(const std::span<const std::byte> &a) {
assert(!a.empty());
PS = ft着色器字节码(a);
}
void S图形管线参数::fs几何着色器(const std::span<const std::byte> &a) {
assert(!a.empty());
GS = ft着色器字节码(a);
}
void S图形管线参数::fs外壳着色器(const std::span<const std::byte> &a) {
assert(!a.empty());
HS = ft着色器字节码(a);
}
void S图形管线参数::fs域着色器(const std::span<const std::byte> &a) {
assert(!a.empty());
DS = ft着色器字节码(a);
}
void S图形管线参数::fs光栅化(const D3D12_RASTERIZER_DESC &a) {
RasterizerState = a;
}
void S图形管线参数::fs混合(const D3D12_BLEND_DESC &a) {
BlendState = a;
}
void S图形管线参数::fs深度模板(const D3D12_DEPTH_STENCIL_DESC &a) {
DSVFormat = c深度模板格式;
DepthStencilState = a;
}
void S图形管线参数::f关闭深度模板() {
DepthStencilState.DepthEnable = FALSE;
DepthStencilState.StencilEnable = FALSE;
}
void S图形管线参数::fs图元拓扑类型(E图元拓扑类型 a) {
PrimitiveTopologyType = (D3D12_PRIMITIVE_TOPOLOGY_TYPE)a;
}
S资源栅栏 S资源栅栏::fc变换(ID3D12Resource* a资源, D3D12_RESOURCE_STATES a前, D3D12_RESOURCE_STATES a后, UINT a子资源, D3D12_RESOURCE_BARRIER_FLAGS a标志) {
S资源栅栏 v栅栏{};
v栅栏.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
v栅栏.Flags = a标志;
v栅栏.Transition.StateBefore = a前;
v栅栏.Transition.StateAfter = a后;
v栅栏.Transition.pResource = a资源;
v栅栏.Transition.Subresource = a子资源;
return v栅栏;
}
//==============================================================================
// 计算管线参数
//==============================================================================
S计算管线参数::S计算管线参数():
D3D12_COMPUTE_PIPELINE_STATE_DESC() {
}
void S计算管线参数::fs根签名(ID3D12RootSignature *a) {
pRootSignature = a;
}
void S计算管线参数::fs计算着色器(const std::span<const std::byte> &a) {
CS = ft着色器字节码(a);
}
//==============================================================================
// 堆属性
//==============================================================================
S堆属性 S堆属性::fc类型(D3D12_HEAP_TYPE a类型, UINT a创建节点掩码, UINT a可见节点掩码) {
S堆属性 v堆属性 = {};
v堆属性.Type = a类型;
v堆属性.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
v堆属性.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
v堆属性.CreationNodeMask = a创建节点掩码;
v堆属性.VisibleNodeMask = a可见节点掩码;
return v堆属性;
}
//==============================================================================
// 纹理复制区
//==============================================================================
S纹理复制区 S纹理复制区::fc脚印(ID3D12Resource *a资源, const D3D12_PLACED_SUBRESOURCE_FOOTPRINT &a脚印) {
S纹理复制区 v = {};
v.pResource = a资源;
v.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
v.PlacedFootprint = a脚印;
return v;
}
S纹理复制区 S纹理复制区::fc索引(ID3D12Resource *a资源, UINT a索引) {
S纹理复制区 v = {};
v.pResource = a资源;
v.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
v.SubresourceIndex = a索引;
return v;
}
//==============================================================================
// 清除值
//==============================================================================
S清除值 S清除值::fc颜色(DXGI_FORMAT a格式, const 数学::S颜色 &a颜色) {
S清除值 v = {};
v.Format = a格式;
v.Color[0] = a颜色.r;
v.Color[1] = a颜色.g;
v.Color[2] = a颜色.b;
v.Color[3] = a颜色.a;
return v;
}
S清除值 S清除值::fc深度模板(DXGI_FORMAT a格式, float a深度, UINT8 a模板) {
S清除值 v = {};
v.Format = a格式;
v.DepthStencil.Depth = a深度;
v.DepthStencil.Stencil = a模板;
return v;
}
//==============================================================================
// 深度模板参数
//==============================================================================
S深度模板参数::S深度模板参数() :
D3D12_DEPTH_STENCIL_DESC(c默认深度模板) {
}
void S深度模板参数::fs深度部分(const D3D12_DEPTH_STENCIL_DESC &a) {
DepthEnable = a.DepthEnable;
DepthWriteMask = a.DepthWriteMask;
DepthFunc = a.DepthFunc;
}
void S深度模板参数::fs模板部分(const D3D12_DEPTH_STENCIL_DESC &a) {
StencilEnable = a.StencilEnable;
StencilReadMask = a.StencilReadMask;
StencilWriteMask = a.StencilWriteMask;
FrontFace = a.FrontFace;
BackFace = a.BackFace;
}
} //namespace cflw::图形::d3d12
| 28.206186
| 188
| 0.655206
|
cflw
|
4b4116f052b7dd02fee93ca6fcc1a9a2a53c6382
| 2,016
|
cpp
|
C++
|
Xlet.Wallet/lib/Xlet.Targets.M5Stack/src/Network/M5StackBluetoothAdapter.cpp
|
MattPearce/xlet
|
e0f64f231e627d0cc52f3c032e66f59a63b2942f
|
[
"MIT"
] | 3
|
2020-11-29T03:14:36.000Z
|
2021-04-14T16:45:46.000Z
|
Xlet.Wallet/lib/Xlet.Targets.M5Stack/src/Network/M5StackBluetoothAdapter.cpp
|
MattPearce/xlet
|
e0f64f231e627d0cc52f3c032e66f59a63b2942f
|
[
"MIT"
] | 2
|
2020-06-18T18:45:00.000Z
|
2020-06-26T08:04:43.000Z
|
Xlet.Wallet/lib/Xlet.Targets.M5Stack/src/Network/M5StackBluetoothAdapter.cpp
|
MattPearce/xlet
|
e0f64f231e627d0cc52f3c032e66f59a63b2942f
|
[
"MIT"
] | 3
|
2020-11-30T21:04:50.000Z
|
2021-05-04T18:14:39.000Z
|
#include "Network/M5StackBluetoothAdapter.h"
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <BLE2902.h>
#include <sstream>
void M5StackBluetoothAdapter::Initialise()
{
BLEDevice::init("Matt's Xlet Wallet");
m_pServer = BLEDevice::createServer();
}
void M5StackBluetoothAdapter::CreateService(const std::string& serviceUUID)
{
auto service = m_pServer->createService(serviceUUID.c_str());
m_services[serviceUUID] = service;
}
void M5StackBluetoothAdapter::StartService(const std::string& serviceUUID)
{
m_services[serviceUUID]->start();
}
void M5StackBluetoothAdapter::CreateCharacteristic(const std::string& serviceUUID, const std::string& characteristicUUID)
{
auto characteristic = m_services[serviceUUID]->createCharacteristic(characteristicUUID.c_str(),
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE |
BLECharacteristic::PROPERTY_NOTIFY |
BLECharacteristic::PROPERTY_INDICATE);
m_characteristics[characteristicUUID] = std::make_shared<BLECharacteristicData>(characteristic);
characteristic->setCallbacks(m_characteristics[characteristicUUID].get());
characteristic->addDescriptor(new BLE2902());
}
void M5StackBluetoothAdapter::SetCharacteristic(const std::string& characteristicUUID, std::string value)
{
m_characteristics[characteristicUUID]->GetCharacteristic()->setValue(value);
m_characteristics[characteristicUUID]->GetCharacteristic()->notify();
}
void M5StackBluetoothAdapter::SetCharacteristicReadHandler(const std::string &characteristicUUID, std::function<std::string()> onRead)
{
m_characteristics[characteristicUUID]->SetReadHandler(onRead);
}
void M5StackBluetoothAdapter::SetCharacteristicWriteHandler(const std::string &characteristicUUID, std::function<void(const std::string &)> onWrite)
{
m_characteristics[characteristicUUID]->SetWriteHandler(onWrite);
}
void M5StackBluetoothAdapter::StartAdvertising()
{
m_pServer->startAdvertising();
}
| 33.04918
| 148
| 0.779762
|
MattPearce
|
4b4253276023e50aee7ffba42fd3e68a124ff64d
| 12,388
|
cpp
|
C++
|
AFML/src/FocusManager.cpp
|
rysmith0315/avs-device-sdk
|
f0fa55856af9e33d0889ac14820efbb807341f17
|
[
"Apache-2.0"
] | 1
|
2019-10-22T06:08:20.000Z
|
2019-10-22T06:08:20.000Z
|
AFML/src/FocusManager.cpp
|
yodaos-project/voice-interface-avs
|
d01136637f92df952be894bb1869d420889689ac
|
[
"Apache-2.0"
] | null | null | null |
AFML/src/FocusManager.cpp
|
yodaos-project/voice-interface-avs
|
d01136637f92df952be894bb1869d420889689ac
|
[
"Apache-2.0"
] | 1
|
2020-09-30T12:34:56.000Z
|
2020-09-30T12:34:56.000Z
|
/*
* Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include "AFML/FocusManager.h"
#include <AVSCommon/Utils/Logger/Logger.h>
namespace alexaClientSDK {
namespace afml {
using namespace avsCommon::sdkInterfaces;
using namespace avsCommon::utils;
using namespace avsCommon::avs;
/// String to identify log entries originating from this file.
static const std::string TAG("FocusManager");
/**
* Create a LogEntry using this file's TAG and the specified event string.
*
* @param The event string for this @c LogEntry.
*/
#define LX(event) alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)
FocusManager::FocusManager(
const std::vector<ChannelConfiguration> channelConfigurations,
std::shared_ptr<ActivityTrackerInterface> activityTrackerInterface) :
m_activityTracker{activityTrackerInterface} {
for (auto config : channelConfigurations) {
if (doesChannelNameExist(config.name)) {
ACSDK_ERROR(LX("createChannelFailed").d("reason", "channelNameExists").d("config", config.toString()));
continue;
}
if (doesChannelPriorityExist(config.priority)) {
ACSDK_ERROR(LX("createChannelFailed").d("reason", "channelPriorityExists").d("config", config.toString()));
continue;
}
auto channel = std::make_shared<Channel>(config.name, config.priority);
m_allChannels.insert({config.name, channel});
}
}
bool FocusManager::acquireChannel(
const std::string& channelName,
std::shared_ptr<ChannelObserverInterface> channelObserver,
const std::string& interface) {
ACSDK_DEBUG1(LX("acquireChannel").d("channelName", channelName).d("interface", interface));
std::shared_ptr<Channel> channelToAcquire = getChannel(channelName);
if (!channelToAcquire) {
ACSDK_ERROR(LX("acquireChannelFailed").d("reason", "channelNotFound").d("channelName", channelName));
return false;
}
m_executor.submit([this, channelToAcquire, channelObserver, interface]() {
acquireChannelHelper(channelToAcquire, channelObserver, interface);
});
return true;
}
std::future<bool> FocusManager::releaseChannel(
const std::string& channelName,
std::shared_ptr<ChannelObserverInterface> channelObserver) {
ACSDK_DEBUG1(LX("releaseChannel").d("channelName", channelName));
// Using a shared_ptr here so that the promise stays in scope by the time the Executor picks up the task.
auto releaseChannelSuccess = std::make_shared<std::promise<bool>>();
std::future<bool> returnValue = releaseChannelSuccess->get_future();
std::shared_ptr<Channel> channelToRelease = getChannel(channelName);
if (!channelToRelease) {
ACSDK_ERROR(LX("releaseChannelFailed").d("reason", "channelNotFound").d("channelName", channelName));
releaseChannelSuccess->set_value(false);
return returnValue;
}
m_executor.submit([this, channelToRelease, channelObserver, releaseChannelSuccess, channelName]() {
releaseChannelHelper(channelToRelease, channelObserver, releaseChannelSuccess, channelName);
});
return returnValue;
}
void FocusManager::stopForegroundActivity() {
// We lock these variables so that we can correctly capture the currently foregrounded channel and activity.
std::unique_lock<std::mutex> lock(m_mutex);
std::shared_ptr<Channel> foregroundChannel = getHighestPriorityActiveChannelLocked();
if (!foregroundChannel) {
ACSDK_DEBUG(LX("stopForegroundActivityFailed").d("reason", "noForegroundActivity"));
return;
}
std::string foregroundChannelInterface = foregroundChannel->getInterface();
lock.unlock();
m_executor.submitToFront([this, foregroundChannel, foregroundChannelInterface]() {
stopForegroundActivityHelper(foregroundChannel, foregroundChannelInterface);
});
}
void FocusManager::stopAllActivities() {
ACSDK_DEBUG5(LX(__func__));
if (m_activeChannels.empty()) {
ACSDK_DEBUG5(LX(__func__).m("no active channels"));
return;
}
ChannelsToInterfaceNamesMap channelOwnersCapture;
std::unique_lock<std::mutex> lock(m_mutex);
for (const auto& channel : m_activeChannels) {
channelOwnersCapture.insert(std::pair<std::shared_ptr<Channel>, std::string>(channel, channel->getInterface()));
}
lock.unlock();
m_executor.submitToFront([this, channelOwnersCapture]() { stopAllActivitiesHelper(channelOwnersCapture); });
}
void FocusManager::addObserver(const std::shared_ptr<FocusManagerObserverInterface>& observer) {
std::lock_guard<std::mutex> lock(m_mutex);
m_observers.insert(observer);
}
void FocusManager::removeObserver(const std::shared_ptr<FocusManagerObserverInterface>& observer) {
std::lock_guard<std::mutex> lock(m_mutex);
m_observers.erase(observer);
}
void FocusManager::setChannelFocus(const std::shared_ptr<Channel>& channel, FocusState focus) {
if (!channel->setFocus(focus)) {
return;
}
std::unique_lock<std::mutex> lock(m_mutex);
auto observers = m_observers;
lock.unlock();
for (auto& observer : observers) {
observer->onFocusChanged(channel->getName(), focus);
}
m_activityUpdates.push_back(channel->getState());
}
void FocusManager::acquireChannelHelper(
std::shared_ptr<Channel> channelToAcquire,
std::shared_ptr<ChannelObserverInterface> channelObserver,
const std::string& interface) {
// Notify the old observer, if there is one, that it lost focus.
setChannelFocus(channelToAcquire, FocusState::NONE);
// Lock here to update internal state which stopForegroundActivity may concurrently access.
std::unique_lock<std::mutex> lock(m_mutex);
std::shared_ptr<Channel> foregroundChannel = getHighestPriorityActiveChannelLocked();
channelToAcquire->setInterface(interface);
m_activeChannels.insert(channelToAcquire);
lock.unlock();
// Set the new observer.
channelToAcquire->setObserver(channelObserver);
if (!foregroundChannel) {
setChannelFocus(channelToAcquire, FocusState::FOREGROUND);
} else if (foregroundChannel == channelToAcquire) {
setChannelFocus(channelToAcquire, FocusState::FOREGROUND);
} else if (*channelToAcquire > *foregroundChannel) {
setChannelFocus(foregroundChannel, FocusState::BACKGROUND);
setChannelFocus(channelToAcquire, FocusState::FOREGROUND);
} else {
setChannelFocus(channelToAcquire, FocusState::BACKGROUND);
}
notifyActivityTracker();
}
void FocusManager::releaseChannelHelper(
std::shared_ptr<Channel> channelToRelease,
std::shared_ptr<ChannelObserverInterface> channelObserver,
std::shared_ptr<std::promise<bool>> releaseChannelSuccess,
const std::string& name) {
if (!channelToRelease->doesObserverOwnChannel(channelObserver)) {
ACSDK_ERROR(LX("releaseChannelHelperFailed").d("reason", "observerDoesNotOwnChannel").d("channel", name));
releaseChannelSuccess->set_value(false);
return;
}
releaseChannelSuccess->set_value(true);
// Lock here to update internal state which stopForegroundActivity may concurrently access.
std::unique_lock<std::mutex> lock(m_mutex);
bool wasForegrounded = isChannelForegroundedLocked(channelToRelease);
m_activeChannels.erase(channelToRelease);
lock.unlock();
setChannelFocus(channelToRelease, FocusState::NONE);
if (wasForegrounded) {
foregroundHighestPriorityActiveChannel();
}
notifyActivityTracker();
}
void FocusManager::stopForegroundActivityHelper(
std::shared_ptr<Channel> foregroundChannel,
std::string foregroundChannelInterface) {
if (foregroundChannelInterface != foregroundChannel->getInterface()) {
return;
}
if (!foregroundChannel->hasObserver()) {
return;
}
setChannelFocus(foregroundChannel, FocusState::NONE);
// Lock here to update internal state which stopForegroundActivity may concurrently access.
std::unique_lock<std::mutex> lock(m_mutex);
m_activeChannels.erase(foregroundChannel);
lock.unlock();
foregroundHighestPriorityActiveChannel();
notifyActivityTracker();
}
void FocusManager::stopAllActivitiesHelper(const ChannelsToInterfaceNamesMap& channelsOwnersMap) {
ACSDK_DEBUG3(LX(__func__));
std::set<std::shared_ptr<Channel>> channelsToClear;
std::unique_lock<std::mutex> lock(m_mutex);
for (const auto& channelAndInterface : channelsOwnersMap) {
if (channelAndInterface.first->getInterface() == channelAndInterface.second) {
m_activeChannels.erase(channelAndInterface.first);
channelsToClear.insert(channelAndInterface.first);
} else {
ACSDK_INFO(LX(__func__)
.d("reason", "channel has other ownership")
.d("channel", channelAndInterface.first->getName())
.d("currentInterface", channelAndInterface.first->getInterface())
.d("originalInterface", channelAndInterface.second));
}
}
lock.unlock();
for (const auto& channel : channelsToClear) {
setChannelFocus(channel, FocusState::NONE);
}
foregroundHighestPriorityActiveChannel();
notifyActivityTracker();
}
std::shared_ptr<Channel> FocusManager::getChannel(const std::string& channelName) const {
auto search = m_allChannels.find(channelName);
if (search != m_allChannels.end()) {
return search->second;
}
return nullptr;
}
std::shared_ptr<Channel> FocusManager::getHighestPriorityActiveChannelLocked() const {
if (m_activeChannels.empty()) {
return nullptr;
}
return *m_activeChannels.begin();
}
bool FocusManager::isChannelForegroundedLocked(const std::shared_ptr<Channel>& channel) const {
return getHighestPriorityActiveChannelLocked() == channel;
}
bool FocusManager::doesChannelNameExist(const std::string& name) const {
return m_allChannels.find(name) != m_allChannels.end();
}
bool FocusManager::doesChannelPriorityExist(const unsigned int priority) const {
for (auto it = m_allChannels.begin(); it != m_allChannels.end(); ++it) {
if (it->second->getPriority() == priority) {
return true;
}
}
return false;
}
void FocusManager::foregroundHighestPriorityActiveChannel() {
std::unique_lock<std::mutex> lock(m_mutex);
std::shared_ptr<Channel> channelToForeground = getHighestPriorityActiveChannelLocked();
lock.unlock();
if (channelToForeground) {
setChannelFocus(channelToForeground, FocusState::FOREGROUND);
}
}
void FocusManager::notifyActivityTracker() {
if (m_activityTracker) {
m_activityTracker->notifyOfActivityUpdates(m_activityUpdates);
}
m_activityUpdates.clear();
}
const std::vector<FocusManager::ChannelConfiguration> FocusManager::getDefaultAudioChannels() {
static const std::vector<FocusManager::ChannelConfiguration> defaultAudioChannels = {
{FocusManagerInterface::DIALOG_CHANNEL_NAME, FocusManagerInterface::DIALOG_CHANNEL_PRIORITY},
{FocusManagerInterface::ALERT_CHANNEL_NAME, FocusManagerInterface::ALERT_CHANNEL_PRIORITY},
{FocusManagerInterface::COMMUNICATIONS_CHANNEL_NAME, FocusManagerInterface::COMMUNICATIONS_CHANNEL_PRIORITY},
{FocusManagerInterface::CONTENT_CHANNEL_NAME, FocusManagerInterface::CONTENT_CHANNEL_PRIORITY}};
return defaultAudioChannels;
}
const std::vector<FocusManager::ChannelConfiguration> FocusManager::getDefaultVisualChannels() {
static const std::vector<FocusManager::ChannelConfiguration> defaultVisualChannels = {
{FocusManagerInterface::VISUAL_CHANNEL_NAME, FocusManagerInterface::VISUAL_CHANNEL_PRIORITY}};
return defaultVisualChannels;
}
} // namespace afml
} // namespace alexaClientSDK
| 38.116923
| 120
| 0.723926
|
rysmith0315
|
4b47330ccbf6553f39f96dcd11c9305ffb2e8983
| 670
|
cc
|
C++
|
test/util/memory_output_stream.cc
|
falk-werner/nv
|
7bb2b71de4333466b91b960f1eda822a73c3382e
|
[
"MIT"
] | null | null | null |
test/util/memory_output_stream.cc
|
falk-werner/nv
|
7bb2b71de4333466b91b960f1eda822a73c3382e
|
[
"MIT"
] | null | null | null |
test/util/memory_output_stream.cc
|
falk-werner/nv
|
7bb2b71de4333466b91b960f1eda822a73c3382e
|
[
"MIT"
] | null | null | null |
#include "util/memory_output_stream.hpp"
#include <cstdlib>
#include <stdexcept>
namespace nv_test
{
MemoryOutputStream::MemoryOutputStream()
{
file_ = open_memstream(&buffer_, &size_);
if(nullptr == file_)
{
throw std::runtime_error("open_memstream: failed to create");
}
}
MemoryOutputStream::~MemoryOutputStream()
{
fclose(file_);
free(buffer_);
}
MemoryOutputStream::operator FILE *()
{
return file_;
}
FILE * MemoryOutputStream::file()
{
return file_;
}
size_t MemoryOutputStream::size()
{
fflush(file_);
return size_;
}
char const * MemoryOutputStream::c_str()
{
fflush(file_);
return buffer_;
}
}
| 14.255319
| 69
| 0.674627
|
falk-werner
|
4b4a495559239cde51dcc7cdc25efced80314f68
| 629
|
hpp
|
C++
|
simulator/include/marlin/simulator/core/Simulator.hpp
|
WhiteWalker608/ActionsTest
|
41e3c3cf6d5a2094d90fd4c004ad0cd3856d42cd
|
[
"MIT"
] | null | null | null |
simulator/include/marlin/simulator/core/Simulator.hpp
|
WhiteWalker608/ActionsTest
|
41e3c3cf6d5a2094d90fd4c004ad0cd3856d42cd
|
[
"MIT"
] | null | null | null |
simulator/include/marlin/simulator/core/Simulator.hpp
|
WhiteWalker608/ActionsTest
|
41e3c3cf6d5a2094d90fd4c004ad0cd3856d42cd
|
[
"MIT"
] | 1
|
2020-10-28T07:38:49.000Z
|
2020-10-28T07:38:49.000Z
|
#ifndef MARLIN_SIMULATOR_CORE_SIMULATOR_HPP
#define MARLIN_SIMULATOR_CORE_SIMULATOR_HPP
#include "marlin/simulator/core/EventQueue.hpp"
namespace marlin {
namespace simulator {
class Simulator {
public:
// Add a singleton simulator
// Intended to be used similar to uv_default_loop()
static Simulator default_instance;
EventQueue<Simulator> queue;
Simulator();
void add_event(std::shared_ptr<Event<Simulator>> event);
void remove_event(std::shared_ptr<Event<Simulator>> event);
void run();
uint64_t current_tick();
};
} // namespace simulator
} // namespace marlin
#endif // MARLIN_SIMULATOR_CORE_SIMULATOR_HPP
| 20.966667
| 60
| 0.783784
|
WhiteWalker608
|
4b4bc240656b4d1f4dd6632b3968b0c481a44128
| 1,507
|
cpp
|
C++
|
src/Message.cpp
|
pawREP/ZHM5A_TraceSink
|
ce4c16f1b24198c1c8276573c3d2cb3e1cca565c
|
[
"MIT"
] | 1
|
2020-04-27T00:03:22.000Z
|
2020-04-27T00:03:22.000Z
|
src/Message.cpp
|
pawREP/ZHM5A_TraceSink
|
ce4c16f1b24198c1c8276573c3d2cb3e1cca565c
|
[
"MIT"
] | null | null | null |
src/Message.cpp
|
pawREP/ZHM5A_TraceSink
|
ce4c16f1b24198c1c8276573c3d2cb3e1cca565c
|
[
"MIT"
] | null | null | null |
#include "Message.h"
#include <algorithm>
void MessageView::tokenizeMessage(const std::string_view& msg, std::vector<std::string_view>& tokens) {
auto beg = 0;
while (true) {
auto end = msg.find_first_of("\n", beg);
if (end == msg.npos)
break;
if (end != beg)
tokens.emplace_back(msg.data() + beg, end - beg);
beg = end + 1;
}
}
MessageView::MessageView(const char* buffer, int bufferSize) : message_() {
std::string_view full_view(buffer, bufferSize);
constexpr char* messageStartMagic = "[MESSAGE]";
constexpr char* messageEndMagic = "[END]";
const auto begin = full_view.find(messageStartMagic);
const auto end = full_view.find(messageEndMagic) + strlen(messageEndMagic);
if ((begin == full_view.npos) || (end == full_view.npos))
return;//buffer doesn't contain complete message
message_ = std::string_view(buffer + begin, end - begin);
tokenizeMessage(message_, messageTokens);
}
const std::string_view& MessageView::message() const {
return message_;
}
const std::vector<std::string_view>& MessageView::tokens() const{
return messageTokens;
}
void MessageView::print() const {
const auto& tokens_ = tokens();
if (tokens_.size() != 10)
return;
printf("%-*.*s | %-*.*s | %-.*s\n",
15, tokens_.at(7).size(), tokens_.at(7).data(),
25, tokens_.at(8).size(), tokens_.at(8).data(),
tokens_.at(9).size(), tokens_.at(9).data());
}
| 28.433962
| 103
| 0.621102
|
pawREP
|
4b5369692bc70a399c082154709d4c73ea2d9ecc
| 1,779
|
hpp
|
C++
|
src/yawpitchdist.hpp
|
degarashi/frea
|
bb598245c2ab710cc816e98d7361e5863af5fd7e
|
[
"MIT"
] | null | null | null |
src/yawpitchdist.hpp
|
degarashi/frea
|
bb598245c2ab710cc816e98d7361e5863af5fd7e
|
[
"MIT"
] | null | null | null |
src/yawpitchdist.hpp
|
degarashi/frea
|
bb598245c2ab710cc816e98d7361e5863af5fd7e
|
[
"MIT"
] | null | null | null |
#pragma once
#include "quaternion.hpp"
namespace frea {
template <class T>
struct YawPitchDist : lubee::op::Ne<YawPitchDist<T>> {
using Rad = Radian<T>;
using Vec3 = Vec_t<T,3,true>;
using Quat = QuatT<T,true>;
Rad yaw, pitch;
T distance;
template <class Ar, class T2>
friend void serialize(Ar&, YawPitchDist<T2>&);
bool operator == (const YawPitchDist& ypd) const noexcept {
return yaw==ypd.yaw &&
pitch==ypd.pitch &&
distance==ypd.distance;
}
//! 方向ベクトルをYaw,Pitch,Distanceに分解
template <class V, ENABLE_IF((is_vector<V>{} || is_wrap<V>{}))>
static auto FromPos(const V& pos) noexcept {
YawPitchDist<T> ypd;
// Distance
Vec3 v(pos);
ypd.distance = v.length();
v /= ypd.distance;
// Yaw
Vec3 xzvec(v.x, 0, v.z);
if(xzvec.len_sq() < lubee::ThresholdF<T>(0.4))
ypd.yaw.set(0);
else {
xzvec.normalize();
T ac = std::acos(lubee::Saturate<T>(xzvec.z, 1));
if(xzvec.x < 0)
ac = 2*Pi<T> - ac;
ypd.yaw.set(ac);
}
// Pitch
constexpr T h = AngleInfo<Radian_t>::one_rotation<T> / 2;
ypd.pitch.set(lubee::Saturate(std::asin(lubee::Saturate<T>(v.y, 1)), -h, h));
return ypd;
}
//! YawPitchDistの位置から座標原点を見る姿勢
auto toOffsetRot() const {
std::pair<Vec3, Quat> ret;
// Z軸をYaw/Pitch/Roll傾けた方向に対してDist距離進んだ場所がカメラの位置
// カメラの方向は変換済みZ軸と逆
const Quat q = Quat::RotationYPR(yaw, pitch, RadF(0));
const Vec3 z = q.getDir();
ret.first = z*distance;
const Vec3 vd = -(z*distance).normalization();
ret.second = Quat::LookAt(vd, Vec3(0,1,0));
return ret;
}
};
template <class T>
inline std::ostream& operator << (std::ostream& os, const YawPitchDist<T>& ypd) {
return os << "YPD: yaw=" << ypd.yaw << " pitch=" << ypd.pitch << " dist=" << ypd.distance;
}
}
| 27.369231
| 92
| 0.621698
|
degarashi
|
4b56b294901ff9ebdab099daba4af993584c3f0c
| 1,872
|
hpp
|
C++
|
Sources/Engine/Framebuffer/Framebuffer.hpp
|
ValentinCamus/GIR-Engine
|
1aa8f6d44f65a00bc19e932ecd5ce98136015ee0
|
[
"MIT"
] | 4
|
2020-01-21T14:51:29.000Z
|
2020-02-26T17:02:40.000Z
|
Sources/Engine/Framebuffer/Framebuffer.hpp
|
ValentinCamus/GIR-Engine
|
1aa8f6d44f65a00bc19e932ecd5ce98136015ee0
|
[
"MIT"
] | null | null | null |
Sources/Engine/Framebuffer/Framebuffer.hpp
|
ValentinCamus/GIR-Engine
|
1aa8f6d44f65a00bc19e932ecd5ce98136015ee0
|
[
"MIT"
] | 3
|
2020-02-18T10:55:46.000Z
|
2021-11-14T12:02:44.000Z
|
#pragma once
#include <Core/Core.hpp>
#include <Engine/Component/OpenGLComponent.hpp>
#include <Engine/Texture/Texture.hpp>
namespace gir
{
class Framebuffer : public OpenGLComponent
{
public:
/// Constructor.
explicit Framebuffer(const std::string& name);
/// Destructor.
~Framebuffer() override;
/// Resize the framebuffer with the given dimension.
void Resize(unsigned width, unsigned height);
/// Attach a render buffer to the framebuffer.
/// @format: specifies the internal format to use for the renderbuffer object's image.
/// @attachment: specifies the attachment point to which renderbuffer should be attached.
void AttachRenderbuffer(int format, int attachment);
/// Attach a texture to the framebuffer.
/// @texture: the texture to attach.
/// @attachment: specifies the attachment point to which an image from texture should be attached.
void AttachTexture(std::unique_ptr<Texture>&& texture, int attachment);
void Bind() override;
void Unbind() override;
void BlitDepthBuffer(const Framebuffer* target) const;
/// @return: true if the framebuffer is complete.
bool IsComplete() const;
inline bool IsRenderbufferAttached() const { return m_rbo > 0; }
inline bool HasTexturesAttached() const { return !m_textures.empty(); }
inline Texture* GetTexture(unsigned i) { return m_textures[i].get(); }
inline unsigned GetTextureCount() const { return static_cast<unsigned>(m_textures.size()); }
float GetAspectRatio() const;
private:
/// Renderbuffer's id.
unsigned m_rbo = 0;
unsigned m_width = 0;
unsigned m_height = 0;
std::vector<std::unique_ptr<Texture>> m_textures {};
};
} // namespace gir
| 31.728814
| 106
| 0.653846
|
ValentinCamus
|
4b56d8739793007049b42767de9e9ca0074e23aa
| 1,048
|
cpp
|
C++
|
AmoebotSim/main/main.cpp
|
pritiahya/Coarse-Models
|
7bb60cbb5ae90eda951c91036cd4773284f5fa35
|
[
"MIT"
] | null | null | null |
AmoebotSim/main/main.cpp
|
pritiahya/Coarse-Models
|
7bb60cbb5ae90eda951c91036cd4773284f5fa35
|
[
"MIT"
] | null | null | null |
AmoebotSim/main/main.cpp
|
pritiahya/Coarse-Models
|
7bb60cbb5ae90eda951c91036cd4773284f5fa35
|
[
"MIT"
] | null | null | null |
/* AmoebotSim: a visual simulator for the amoebot model of programmable matter.
* Copyright (C) 2020 Joshua J. Daymude, Robert Gmyr, and Kristian Hinnenthal.
* Please direct all questions and communications to sopslab@asu.edu.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*
* AmoebotSim is developed using Open Source Qt. */
#include "application.h"
int main(int argc, char *argv[]) {
Application app(argc, argv);
return app.exec();
}
| 40.307692
| 80
| 0.744275
|
pritiahya
|
4b58d66da4bc37fed11ff8077df12d75ec10e47c
| 2,347
|
cc
|
C++
|
HTTP/src/HttpResponseGenerator.cc
|
frankencode/CoreComponents
|
4c66d7ff9fc5be19222906ba89ba0e98951179de
|
[
"Zlib"
] | 1
|
2019-07-29T04:07:29.000Z
|
2019-07-29T04:07:29.000Z
|
HTTP/src/HttpResponseGenerator.cc
|
frankencode/CoreComponents
|
4c66d7ff9fc5be19222906ba89ba0e98951179de
|
[
"Zlib"
] | null | null | null |
HTTP/src/HttpResponseGenerator.cc
|
frankencode/CoreComponents
|
4c66d7ff9fc5be19222906ba89ba0e98951179de
|
[
"Zlib"
] | 1
|
2020-03-04T17:13:04.000Z
|
2020-03-04T17:13:04.000Z
|
/*
* Copyright (C) 2021 Frank Mertens.
*
* Distribution and use is allowed under the terms of the zlib license
* (see cc/LICENSE-zlib).
*
*/
#include <cc/HttpResponseGenerator>
#include <cc/httpDate>
#include <cc/System>
namespace cc {
struct HttpResponseGenerator::State: public HttpMessageGenerator::State
{
State(const Stream &stream):
HttpMessageGenerator::State{stream}
{}
void polishHeader() override
{
if (nodeVersion_ != "") header_.insert("Server", nodeVersion_);
String now = httpDateToString(Date{System::now()});
header_.insert("Date", now);
if (status_ != HttpStatus::NotModified) {
if (contentLength_ >= 0) {
header_.remove("Transfer-Encoding");
header_.establish("Content-Length", str(contentLength_));
}
else {
header_.establish("Transfer-Encoding", "chunked");
}
header_.insert("Last-Modified", now);
}
}
void writeFirstLine(Format &sink) override
{
sink << "HTTP/1.1 " << +status_ << " " << reasonPhrase_ << "\r\n";
}
long long bytesWritten() const
{
return (payload_) ? payload_.totalWritten() : bytesWritten_;
}
bool headerWritten() const
{
return headerWritten_;
}
HttpStatus status_ { 200 };
String reasonPhrase_;
String nodeVersion_;
};
HttpResponseGenerator::HttpResponseGenerator(const Stream &stream):
HttpMessageGenerator{new State{stream}}
{}
void HttpResponseGenerator::setStatus(HttpStatus status, const String &reasonPhrase)
{
me().status_ = status;
me().reasonPhrase_ = (reasonPhrase == "") ? String{httpReasonPhrase(status)} : reasonPhrase;
}
void HttpResponseGenerator::setNodeVersion(const String &nodeVersion)
{
me().nodeVersion_ = nodeVersion;
}
long long HttpResponseGenerator::bytesWritten() const
{
return me().bytesWritten();
}
bool HttpResponseGenerator::delivered() const
{
return me().headerWritten();
}
HttpStatus HttpResponseGenerator::status() const
{
return me().status_;
}
HttpResponseGenerator::State &HttpResponseGenerator::me()
{
return Object::me.as<State>();
}
const HttpResponseGenerator::State &HttpResponseGenerator::me() const
{
return Object::me.as<State>();
}
} // namespace cc
| 23.237624
| 96
| 0.64934
|
frankencode
|
4b5d4a01cfceef009ea0cafefc213231ef423e7d
| 816
|
cpp
|
C++
|
test/barrier.cpp
|
leezhenghui/Mushroom
|
8aed2bdd80453d856145925d067bef5ed9d10ee0
|
[
"BSD-3-Clause"
] | 351
|
2016-10-12T14:06:09.000Z
|
2022-03-24T14:53:54.000Z
|
test/barrier.cpp
|
leezhenghui/Mushroom
|
8aed2bdd80453d856145925d067bef5ed9d10ee0
|
[
"BSD-3-Clause"
] | 7
|
2017-03-07T01:49:16.000Z
|
2018-07-27T08:51:54.000Z
|
test/barrier.cpp
|
UncP/Mushroom
|
8aed2bdd80453d856145925d067bef5ed9d10ee0
|
[
"BSD-3-Clause"
] | 62
|
2016-10-31T12:46:45.000Z
|
2021-12-28T11:25:26.000Z
|
/**
* > Author: UncP
* > Github: www.github.com/UncP/Mushroom
* > License: BSD-3
* > Time: 2018-7-27 17:43:00
**/
#include <pthread.h>
#include "../src/palm/barrier.hpp"
static const int threads = 5;
static Mushroom::Barrier barrier(threads);
void* f1(void *)
{
printf("hello\n");
barrier.Wait();
return (void *)0;
}
void* f2(void *)
{
printf("world\n");
barrier.Wait();
return (void *)0;
}
int main()
{
pthread_t ids[threads];
for (int i = 0; i < threads; ++i) {
assert(pthread_create(&ids[i], 0, f1, 0) == 0);
}
for (int i = 0; i != threads; ++i)
assert(pthread_join(ids[i], 0) == 0);
for (int i = 0; i < threads; ++i) {
assert(pthread_create(&ids[i], 0, f2, 0) == 0);
}
for (int i = 0; i != threads; ++i)
assert(pthread_join(ids[i], 0) == 0);
return 0;
}
| 18.545455
| 49
| 0.5625
|
leezhenghui
|
4b600a421e5ad8c7b14410467515a59e7cbfd89d
| 15,964
|
hpp
|
C++
|
include/SFML/Audio/SoundStream.hpp
|
Cobaltergeist/SFML
|
c2c5c3371898ae848db5c612fe6c208c990dbfd0
|
[
"Zlib"
] | null | null | null |
include/SFML/Audio/SoundStream.hpp
|
Cobaltergeist/SFML
|
c2c5c3371898ae848db5c612fe6c208c990dbfd0
|
[
"Zlib"
] | null | null | null |
include/SFML/Audio/SoundStream.hpp
|
Cobaltergeist/SFML
|
c2c5c3371898ae848db5c612fe6c208c990dbfd0
|
[
"Zlib"
] | null | null | null |
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDSTREAM_HPP
#define SFML_SOUNDSTREAM_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/Audio/SoundSource.hpp>
#include <SFML/System/Thread.hpp>
#include <SFML/System/Time.hpp>
#include <cstdlib>
namespace sf
{
////////////////////////////////////////////////////////////
/// \brief Abstract base class for streamed audio sources
///
////////////////////////////////////////////////////////////
class SFML_AUDIO_API SoundStream : public SoundSource
{
public :
////////////////////////////////////////////////////////////
/// \brief Structure defining a chunk of audio data to stream
///
////////////////////////////////////////////////////////////
struct Chunk
{
const Int16* samples; ///< Pointer to the audio samples
std::size_t sampleCount; ///< Number of samples pointed by Samples
};
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
virtual ~SoundStream();
////////////////////////////////////////////////////////////
/// \brief Start or resume playing the audio stream
///
/// This function starts the stream if it was stopped, resumes
/// it if it was paused, and restarts it from beginning if it
/// was it already playing.
/// This function uses its own thread so that it doesn't block
/// the rest of the program while the stream is played.
///
/// \see pause, stop
///
////////////////////////////////////////////////////////////
void play();
////////////////////////////////////////////////////////////
/// \brief Pause the audio stream
///
/// This function pauses the stream if it was playing,
/// otherwise (stream already paused or stopped) it has no effect.
///
/// \see play, stop
///
////////////////////////////////////////////////////////////
void pause();
////////////////////////////////////////////////////////////
/// \brief Stop playing the audio stream
///
/// This function stops the stream if it was playing or paused,
/// and does nothing if it was already stopped.
/// It also resets the playing position (unlike pause()).
///
/// \see play, pause
///
////////////////////////////////////////////////////////////
void stop();
////////////////////////////////////////////////////////////
/// \brief Return the number of channels of the stream
///
/// 1 channel means a mono sound, 2 means stereo, etc.
///
/// \return Number of channels
///
////////////////////////////////////////////////////////////
unsigned int getChannelCount() const;
////////////////////////////////////////////////////////////
/// \brief Get the stream sample rate of the stream
///
/// The sample rate is the number of audio samples played per
/// second. The higher, the better the quality.
///
/// \return Sample rate, in number of samples per second
///
////////////////////////////////////////////////////////////
unsigned int getSampleRate() const;
////////////////////////////////////////////////////////////
/// \brief Get the current status of the stream (stopped, paused, playing)
///
/// \return Current status
///
////////////////////////////////////////////////////////////
Status getStatus() const;
////////////////////////////////////////////////////////////
/// \brief Change the current playing position of the stream
///
/// The playing position can be changed when the stream is
/// either paused or playing.
///
/// \param timeOffset New playing position, from the beginning of the stream
///
/// \see getPlayingOffset
///
////////////////////////////////////////////////////////////
void setPlayingOffset(Time timeOffset);
////////////////////////////////////////////////////////////
/// \brief Get the current playing position of the stream
///
/// \return Current playing position, from the beginning of the stream
///
/// \see setPlayingOffset
///
////////////////////////////////////////////////////////////
Time getPlayingOffset() const;
////////////////////////////////////////////////////////////
/// \brief Set whether or not the stream should loop after reaching the end
///
/// If set, the stream will restart from beginning after
/// reaching the end and so on, until it is stopped or
/// setLoop(false) is called.
/// The default looping state for streams is false.
///
/// \param loop True to play in loop, false to play once
///
/// \see getLoop
///
////////////////////////////////////////////////////////////
void setLoop(bool loop);
////////////////////////////////////////////////////////////
/// \brief Tell whether or not the stream is in loop mode
///
/// \return True if the stream is looping, false otherwise
///
/// \see setLoop
///
////////////////////////////////////////////////////////////
bool getLoop() const;
protected :
enum BufferEnd
{
NoEnd, ///< Not an ending buffer
FileEnd, ///< End of file
LoopEnd ///< End of loop
};
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// This constructor is only meant to be called by derived classes.
///
////////////////////////////////////////////////////////////
SoundStream();
////////////////////////////////////////////////////////////
/// \brief Define the audio stream parameters
///
/// This function must be called by derived classes as soon
/// as they know the audio settings of the stream to play.
/// Any attempt to manipulate the stream (play(), ...) before
/// calling this function will fail.
/// It can be called multiple times if the settings of the
/// audio stream change, but only when the stream is stopped.
///
/// \param channelCount Number of channels of the stream
/// \param sampleRate Sample rate, in samples per second
///
////////////////////////////////////////////////////////////
void initialize(unsigned int channelCount, unsigned int sampleRate);
////////////////////////////////////////////////////////////
/// \brief Request a new chunk of audio samples from the stream source
///
/// This function must be overriden by derived classes to provide
/// the audio samples to play. It is called continuously by the
/// streaming loop, in a separate thread.
/// The source can choose to stop the streaming loop at any time, by
/// returning false to the caller.
///
/// \param data Chunk of data to fill
///
/// \return True to continue playback, false to stop
///
////////////////////////////////////////////////////////////
virtual bool onGetData(Chunk& data) = 0;
////////////////////////////////////////////////////////////
/// \brief Change the current playing position in the stream source
///
/// This function must be overriden by derived classes to
/// allow random seeking into the stream source.
///
/// \param timeOffset New playing position, relative to the beginning of the stream
///
////////////////////////////////////////////////////////////
virtual void onSeek(Time timeOffset) = 0;
////////////////////////////////////////////////////////////
/// \brief Change the current playing position in the stream source to the beginning of the loop
///
/// This function can be overriden by derived classes to
/// allow implementation of custom loop points.
/// Otherwise, it just calls onSeek(Time::Zero)
///
/// \return The end condition of this loop operation (file or loop)
///
////////////////////////////////////////////////////////////
virtual BufferEnd onLoop();
////////////////////////////////////////////////////////////
/// \brief Called to determine the "samples processed" count of the beginning of the loop
///
/// This function can be overriden by derived classes to provide
/// reliable implementation of custom loop points.
/// Derived classes must pass the sample position of the loop start
/// in order for getPlayingOffset() to track the correct in-file
/// position between loop iterations. By default this returns 0.
///
/// \return The sample position of the loop start
///
////////////////////////////////////////////////////////////
virtual Uint64 getLoopSampleOffset();
private :
////////////////////////////////////////////////////////////
/// \brief Function called as the entry point of the thread
///
/// This function starts the streaming loop, and returns
/// only when the sound is stopped.
///
////////////////////////////////////////////////////////////
void streamData();
////////////////////////////////////////////////////////////
/// \brief Fill a new buffer with audio samples, and append
/// it to the playing queue
///
/// This function is called as soon as a buffer has been fully
/// consumed; it fills it again and inserts it back into the
/// playing queue.
///
/// \param bufferNum Number of the buffer to fill (in [0, BufferCount])
///
/// \return True if the stream source has requested to stop, false otherwise
///
////////////////////////////////////////////////////////////
bool fillAndPushBuffer(unsigned int bufferNum);
////////////////////////////////////////////////////////////
/// \brief Fill the audio buffers and put them all into the playing queue
///
/// This function is called when playing starts and the
/// playing queue is empty.
///
/// \return True if the derived class has requested to stop, false otherwise
///
////////////////////////////////////////////////////////////
bool fillQueue();
////////////////////////////////////////////////////////////
/// \brief Clear all the audio buffers and empty the playing queue
///
/// This function is called when the stream is stopped.
///
////////////////////////////////////////////////////////////
void clearQueue();
enum
{
BufferCount = 3 ///< Number of audio buffers used by the streaming loop
};
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Thread m_thread; ///< Thread running the background tasks
bool m_isStreaming; ///< Streaming state (true = playing, false = stopped)
unsigned int m_buffers[BufferCount]; ///< Sound buffers used to store temporary audio data
unsigned int m_channelCount; ///< Number of channels (1 = mono, 2 = stereo, ...)
unsigned int m_sampleRate; ///< Frequency (samples / second)
Uint32 m_format; ///< Format of the internal sound buffers
bool m_loop; ///< Loop flag (true to loop, false to play once)
Uint64 m_samplesProcessed; ///< Number of buffers processed since beginning of the stream
BufferEnd m_endBuffers[BufferCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation
};
} // namespace sf
#endif // SFML_SOUNDSTREAM_HPP
////////////////////////////////////////////////////////////
/// \class sf::SoundStream
/// \ingroup audio
///
/// Unlike audio buffers (see sf::SoundBuffer), audio streams
/// are never completely loaded in memory. Instead, the audio
/// data is acquired continuously while the stream is playing.
/// This behaviour allows to play a sound with no loading delay,
/// and keeps the memory consumption very low.
///
/// Sound sources that need to be streamed are usually big files
/// (compressed audio musics that would eat hundreds of MB in memory)
/// or files that would take a lot of time to be received
/// (sounds played over the network).
///
/// sf::SoundStream is a base class that doesn't care about the
/// stream source, which is left to the derived class. SFML provides
/// a built-in specialization for big files (see sf::Music).
/// No network stream source is provided, but you can write your own
/// by combining this class with the network module.
///
/// A derived class has to override two virtual functions:
/// \li onGetData fills a new chunk of audio data to be played
/// \li onSeek changes the current playing position in the source
///
/// It is important to note that each SoundStream is played in its
/// own separate thread, so that the streaming loop doesn't block the
/// rest of the program. In particular, the OnGetData and OnSeek
/// virtual functions may sometimes be called from this separate thread.
/// It is important to keep this in mind, because you may have to take
/// care of synchronization issues if you share data between threads.
///
/// Usage example:
/// \code
/// class CustomStream : public sf::SoundStream
/// {
/// public :
///
/// bool open(const std::string& location)
/// {
/// // Open the source and get audio settings
/// ...
/// unsigned int channelCount = ...;
/// unsigned int sampleRate = ...;
///
/// // Initialize the stream -- important!
/// initialize(channelCount, sampleRate);
/// }
///
/// private :
///
/// virtual bool onGetData(Chunk& data)
/// {
/// // Fill the chunk with audio data from the stream source
/// data.samples = ...;
/// data.sampleCount = ...;
///
/// // Return true to continue playing
/// return true;
/// }
///
/// virtual void onSeek(Uint32 timeOffset)
/// {
/// // Change the current position in the stream source
/// ...
/// }
/// }
///
/// // Usage
/// CustomStream stream;
/// stream.open("path/to/stream");
/// stream.play();
/// \endcode
///
/// \see sf::Music
///
////////////////////////////////////////////////////////////
| 38.841849
| 128
| 0.486783
|
Cobaltergeist
|
4b60a3a14310981eca088079e6922ffabf0056a0
| 4,574
|
hh
|
C++
|
vm/vm/main/float-decl.hh
|
Ahzed11/mozart2
|
4806504b103e11be723e7813be8f69e4d85875cf
|
[
"BSD-2-Clause"
] | 379
|
2015-01-02T20:27:33.000Z
|
2022-03-26T23:18:17.000Z
|
vm/vm/main/float-decl.hh
|
Ahzed11/mozart2
|
4806504b103e11be723e7813be8f69e4d85875cf
|
[
"BSD-2-Clause"
] | 81
|
2015-01-08T13:18:52.000Z
|
2021-12-21T14:02:21.000Z
|
vm/vm/main/float-decl.hh
|
Ahzed11/mozart2
|
4806504b103e11be723e7813be8f69e4d85875cf
|
[
"BSD-2-Clause"
] | 75
|
2015-01-06T09:08:20.000Z
|
2021-12-17T09:40:18.000Z
|
// Copyright © 2011, Université catholique de Louvain
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#ifndef MOZART_FLOAT_DECL_H
#define MOZART_FLOAT_DECL_H
#include "mozartcore-decl.hh"
namespace mozart {
#ifndef MOZART_GENERATOR
#include "Float-implem-decl.hh"
#endif
class Float: public DataType<Float>,
StoredAs<double>, WithValueBehavior {
public:
static atom_t getTypeAtom(VM vm) {
return vm->coreatoms.float_;
}
explicit Float(double value) : _value(value) {}
static void create(double& self, VM, double value) {
self = value;
}
inline
static void create(double& self, VM vm, GR gr, Float from);
double value() const { return _value; }
inline
bool equals(VM vm, RichNode right);
public:
// Comparable interface
inline
int compare(VM vm, RichNode right);
public:
// Numeric inteface
bool isNumber(VM vm) {
return true;
}
bool isInt(VM vm) {
return false;
}
bool isFloat(VM vm) {
return true;
}
inline
UnstableNode opposite(VM vm);
inline
UnstableNode add(VM vm, RichNode right);
inline
UnstableNode add(RichNode self, VM vm, nativeint right);
inline
UnstableNode addValue(VM vm, double b);
inline
UnstableNode subtract(VM vm, RichNode right);
inline
UnstableNode subtractValue(VM vm, double b);
inline
UnstableNode multiply(VM vm, RichNode right);
inline
UnstableNode multiplyValue(VM vm, double b);
inline
UnstableNode divide(VM vm, RichNode right);
inline
UnstableNode divideValue(VM vm, double b);
inline
UnstableNode fmod(VM vm, RichNode right);
inline
UnstableNode fmodValue(VM vm, double b);
inline
UnstableNode div(RichNode self, VM vm, RichNode right);
inline
UnstableNode mod(RichNode self, VM vm, RichNode right);
inline
UnstableNode pow(VM vm, RichNode right);
inline
UnstableNode powValue(VM vm, double b);
inline
UnstableNode abs(VM vm);
inline
UnstableNode acos(VM vm);
inline
UnstableNode acosh(VM vm);
inline
UnstableNode asin(VM vm);
inline
UnstableNode asinh(VM vm);
inline
UnstableNode atan(VM vm);
inline
UnstableNode atanh(VM vm);
inline
UnstableNode atan2(VM vm, RichNode right);
inline
UnstableNode atan2Value(VM vm, double b);
inline
UnstableNode ceil(VM vm);
inline
UnstableNode cos(VM vm);
inline
UnstableNode cosh(VM vm);
inline
UnstableNode exp(VM vm);
inline
UnstableNode floor(VM vm);
inline
UnstableNode log(VM vm);
inline
UnstableNode round(VM vm);
inline
UnstableNode sin(VM vm);
inline
UnstableNode sinh(VM vm);
inline
UnstableNode sqrt(VM vm);
inline
UnstableNode tan(VM vm);
inline
UnstableNode tanh(VM vm);
public:
// Miscellaneous
void printReprToStream(VM vm, std::ostream& out, int depth, int width) {
if (value() >= 0.0) {
out << value();
} else {
std::ostringstream ss;
ss << value();
std::string s(ss.str());
s[0] = '~';
// We also want to replace the ~ before the exponent
size_t pos = s.find('-');
if (pos != std::string::npos)
s[pos] = '~';
out << s;
}
}
private:
const double _value;
};
#ifndef MOZART_GENERATOR
#include "Float-implem-decl-after.hh"
#endif
}
#endif // MOZART_FLOAT_DECL_H
| 20.981651
| 79
| 0.704198
|
Ahzed11
|
4b61afe17731254fb0d03f992282a94d35305c08
| 241
|
cpp
|
C++
|
atcoder/abc096/A/main.cpp
|
xirc/cp-algorithm
|
89c67cff2f00459c5bb020ab44bff5ae419a1728
|
[
"Apache-2.0"
] | 8
|
2020-12-23T07:54:53.000Z
|
2021-11-23T02:46:35.000Z
|
atcoder/abc096/A/main.cpp
|
xirc/cp-algorithm
|
89c67cff2f00459c5bb020ab44bff5ae419a1728
|
[
"Apache-2.0"
] | 1
|
2020-11-07T13:22:29.000Z
|
2020-12-20T12:54:00.000Z
|
atcoder/abc096/A/main.cpp
|
xirc/cp-algorithm
|
89c67cff2f00459c5bb020ab44bff5ae419a1728
|
[
"Apache-2.0"
] | 1
|
2021-01-16T03:40:10.000Z
|
2021-01-16T03:40:10.000Z
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int a, b;
cin >> a >> b;
int m = (a - 1) + (a <= b ? 1 : 0);
cout << m << endl;
return 0;
}
| 16.066667
| 39
| 0.493776
|
xirc
|
4b67494c98e82516116c0eed5efb06e90acd794b
| 338
|
cpp
|
C++
|
CodeChef/CookOff/OctCookOff2017/oct_cookoff_2017_median.cpp
|
ysumit99/Compi-Coding
|
d0e96c4f024328b0bfb799fab927919dae367f7a
|
[
"MIT"
] | 1
|
2019-04-19T13:06:33.000Z
|
2019-04-19T13:06:33.000Z
|
CodeChef/CookOff/OctCookOff2017/oct_cookoff_2017_median.cpp
|
ysumit99/Compi-Coding
|
d0e96c4f024328b0bfb799fab927919dae367f7a
|
[
"MIT"
] | null | null | null |
CodeChef/CookOff/OctCookOff2017/oct_cookoff_2017_median.cpp
|
ysumit99/Compi-Coding
|
d0e96c4f024328b0bfb799fab927919dae367f7a
|
[
"MIT"
] | null | null | null |
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
int t;
cin>>t;
while(t--)
{
std::vector<int> v;
int ele,n,k;
scanf("%d %d",&n,&k);
for (int i = 0; i < n; ++i)
{
scanf("%d",&ele);
v.push_back(ele);
}
sort(v.begin(),v.end());
printf("%d\n",v[(n+k)/2]);
}
return 0;
}
| 11.655172
| 38
| 0.502959
|
ysumit99
|
b49be897124f97a421d033ebb6df12cee020a971
| 545
|
cpp
|
C++
|
2021/09. Arrays/20321029/3.sum x^k/3.sum x^k.cpp
|
GeorgiIT/CS104
|
7efcc069256dfdb5bc18bd76fbb683edf2cde230
|
[
"MIT"
] | 7
|
2021-03-24T16:30:45.000Z
|
2022-03-27T09:02:15.000Z
|
2021/09. Arrays/20321029/3.sum x^k/3.sum x^k.cpp
|
GeorgiIT/CS104
|
7efcc069256dfdb5bc18bd76fbb683edf2cde230
|
[
"MIT"
] | null | null | null |
2021/09. Arrays/20321029/3.sum x^k/3.sum x^k.cpp
|
GeorgiIT/CS104
|
7efcc069256dfdb5bc18bd76fbb683edf2cde230
|
[
"MIT"
] | 17
|
2021-03-22T09:42:22.000Z
|
2022-03-28T03:24:07.000Z
|
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
// Необходими променливи
int x, n, sum = 0;
// Въвеждане на стойности на необходимите променливи
cout << "x=";
cin >> x;
cout << "n=";
cin >> n;
// Мaсив за степените на x
int f[1000];
// Изчисляване на степените и записването им в масива
for (int k = 0; k < n; k++)
{
f[k] = pow(x, k + 1);
sum = sum + f[k];
}
// Извеждане на крайният резултат
cout << "sum = " << sum << endl;
return 0;
}
| 18.166667
| 57
| 0.526606
|
GeorgiIT
|
b49cdd16bac6b20644f3033c018f0f5198694f64
| 829
|
cpp
|
C++
|
chap04/Page157_sizeof.cpp
|
sjbarigye/CPP_Primer
|
d9d31a73a45ca46909bae104804fc9503ab242f2
|
[
"Apache-2.0"
] | 50
|
2016-01-08T14:28:53.000Z
|
2022-01-21T12:55:00.000Z
|
chap04/Page157_sizeof.cpp
|
sjbarigye/CPP_Primer
|
d9d31a73a45ca46909bae104804fc9503ab242f2
|
[
"Apache-2.0"
] | 2
|
2017-06-05T16:45:20.000Z
|
2021-04-17T13:39:24.000Z
|
chap04/Page157_sizeof.cpp
|
sjbarigye/CPP_Primer
|
d9d31a73a45ca46909bae104804fc9503ab242f2
|
[
"Apache-2.0"
] | 18
|
2016-08-17T15:23:51.000Z
|
2022-03-26T18:08:43.000Z
|
#include <iostream>
#include <string>
#include <vector>
using std::cout;
using std::endl;
using std::string;
using std::vector;
int main()
{
string s = "This is the string. Ask for my size.";
string s2;
vector<int> v = {2, 3, 5, 7, 9};
vector<int> v2;
vector<double> v3;
cout << "size of a string returned by sizeof: " << sizeof(s) << " "
<< sizeof(s2) << endl;
cout << "size of a string returned by string.size: " << s.size() << endl;
cout << "size of a vector: " << sizeof(v) << " "
<< sizeof(vector<string>) << endl;
cout << "size of a vector returned by vector.size: " << v.size() << endl;
return 0;
}
// Note: result returned by sizeof of a string or vector is a fixed value.
// It doesn't matter what type vector is and how many elements in a vector or
// string.
| 30.703704
| 77
| 0.603136
|
sjbarigye
|
b49d8e9e68ad768dc0054fb351e3b3d02afa33ee
| 10,027
|
cpp
|
C++
|
Source/Foundation/bsfUtility/String/BsUnicode.cpp
|
bsf2dev/bsf
|
b318cd4eb1b0299773d625e6c870b8d503cf539e
|
[
"MIT"
] | 1,745
|
2018-03-16T02:10:28.000Z
|
2022-03-26T17:34:21.000Z
|
Source/Foundation/bsfUtility/String/BsUnicode.cpp
|
bsf2dev/bsf
|
b318cd4eb1b0299773d625e6c870b8d503cf539e
|
[
"MIT"
] | 395
|
2018-03-16T10:18:20.000Z
|
2021-08-04T16:52:08.000Z
|
Source/Foundation/bsfUtility/String/BsUnicode.cpp
|
bsf2dev/bsf
|
b318cd4eb1b0299773d625e6c870b8d503cf539e
|
[
"MIT"
] | 267
|
2018-03-17T19:32:54.000Z
|
2022-02-17T16:55:50.000Z
|
//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
#include "BsUnicode.h"
namespace bs
{
/** Converts an UTF-8 encoded character (possibly multibyte) into an UTF-32 character. */
template<typename T>
T UTF8To32(T begin, T end, char32_t& output, char32_t invalidChar = 0)
{
// Nothing to parse
if (begin >= end)
return begin;
// Determine the number of bytes used by the character
UINT32 numBytes;
UINT8 firstByte = (UINT8)*begin;
if (firstByte < 192)
numBytes = 1;
else if (firstByte < 224)
numBytes = 2;
else if (firstByte < 240)
numBytes = 3;
else if (firstByte < 248)
numBytes = 4;
else if (firstByte < 252)
numBytes = 5;
else // < 256
numBytes = 6;
// Not enough bytes were provided, invalid character
if((begin + numBytes) > end)
{
output = invalidChar;
return end;
}
// Decode the character
output = 0;
switch(numBytes)
{
case 6: output += (UINT8)(*begin); ++begin; output <<= 6; BS_FALLTHROUGH;
case 5: output += (UINT8)(*begin); ++begin; output <<= 6; BS_FALLTHROUGH;
case 4: output += (UINT8)(*begin); ++begin; output <<= 6; BS_FALLTHROUGH;
case 3: output += (UINT8)(*begin); ++begin; output <<= 6; BS_FALLTHROUGH;
case 2: output += (UINT8)(*begin); ++begin; output <<= 6; BS_FALLTHROUGH;
case 1: output += (UINT8)(*begin); ++begin; BS_FALLTHROUGH;
default: break;
}
constexpr UINT32 offsets[6] = { 0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080 };
output -= offsets[numBytes - 1];
return begin;
}
/** Converts an UTF-32 encoded character into an (possibly multibyte) UTF-8 character. */
template<typename T>
T UTF32To8(char32_t input, T output, UINT32 maxElems, char invalidChar = 0)
{
// No place to write the character
if (maxElems == 0)
return output;
// Check if character is valid
if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF)))
{
*output = invalidChar;
++output;
return output;
}
// Determine the number of bytes used by the character
UINT32 numBytes;
if (input < 0x80)
numBytes = 1;
else if (input < 0x800)
numBytes = 2;
else if (input < 0x10000)
numBytes = 3;
else // <= 0x0010FFFF
numBytes = 4;
// Check if we have enough space
if(numBytes > maxElems)
{
*output = invalidChar;
++output;
return output;
}
// Encode the character
constexpr UINT8 headers[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
char bytes[4];
switch (numBytes)
{
case 4: bytes[3] = (char)((input | 0x80) & 0xBF); input >>= 6; BS_FALLTHROUGH;
case 3: bytes[2] = (char)((input | 0x80) & 0xBF); input >>= 6; BS_FALLTHROUGH;
case 2: bytes[1] = (char)((input | 0x80) & 0xBF); input >>= 6; BS_FALLTHROUGH;
case 1: bytes[0] = (char)(input | headers[numBytes]); BS_FALLTHROUGH;
default: break;
}
output = std::copy(bytes, bytes + numBytes, output);
return output;
}
/** Converts an UTF-16 encoded character into an UTF-32 character. */
template<typename T>
T UTF16To32(T begin, T end, char32_t& output, char32_t invalidChar = 0)
{
// Nothing to parse
if (begin >= end)
return begin;
char16_t firstElem = (char16_t)*begin;
++begin;
// Check if it's a surrogate pair
if ((firstElem >= 0xD800) && (firstElem <= 0xDBFF))
{
// Invalid character
if (begin >= end)
{
output = invalidChar;
return end;
}
char32_t secondElem = (char32_t)*begin;
++begin;
if ((secondElem >= 0xDC00) && (secondElem <= 0xDFFF))
output = (char32_t)(((firstElem - 0xD800) << 10) + (secondElem - 0xDC00) + 0x0010000);
else // Invalid character
output = invalidChar;
}
else
{
output = (char32_t)firstElem;
return begin;
}
return begin;
}
/** Converts an UTF-32 encoded character into an UTF-16 character. */
template<typename T>
T UTF32To16(char32_t input, T output, UINT32 maxElems, char16_t invalidChar = 0)
{
// No place to write the character
if (maxElems == 0)
return output;
// Invalid character
if (input > 0x0010FFFF)
{
*output = invalidChar;
++output;
return output;
}
// Can be encoded as a single element
if (input <= 0xFFFF)
{
// Check if in valid range
if ((input >= 0xD800) && (input <= 0xDFFF))
{
*output = invalidChar;
++output;
return output;
}
*output = (char16_t)input;
++output;
}
else // Must be encoded as two elements
{
// Two elements won't fit
if (maxElems < 2)
{
*output = invalidChar;
++output;
return output;
}
input -= 0x0010000;
*output = (char16_t)((input >> 10) + 0xD800);
++output;
*output = (char16_t)((input & 0x3FFUL) + 0xDC00);
++output;
}
return output;
}
template<typename T>
T wideToUTF32(T begin, T end, char32_t& output, char32_t invalidChar = 0)
{
if (sizeof(wchar_t) == 4) // Assuming UTF-32 (i.e. Unix)
{
output = (char32_t)*begin;
++begin;
return begin;
}
else // Assuming UTF-16 (i.e. Windows)
return UTF16To32(begin, end, output, invalidChar);
}
char32_t ANSIToUTF32(char input, const std::locale& locale = std::locale(""))
{
const std::ctype<wchar_t>& facet = std::use_facet<std::ctype<wchar_t>>(locale);
// Note: Not exactly valid on Windows, since the input character could require a surrogate pair.
// Consider improving this if it ever becomes an issue.
wchar_t wideChar = facet.widen(input);
char32_t output;
wideToUTF32(&wideChar, &wideChar + 1, output);
return output;
}
template<typename T>
T UTF32ToWide(char32_t input, T output, UINT32 maxElems, wchar_t invalidChar = 0)
{
if(sizeof(wchar_t) == 4) // Assuming UTF-32 (i.e. Unix)
{
*output = (wchar_t)input;
++output;
return output;
}
else // Assuming UTF-16 (i.e. Windows)
return UTF32To16(input, output, maxElems, invalidChar);
}
char UTF32ToANSI(char32_t input, char invalidChar = 0, const std::locale& locale = std::locale(""))
{
const std::ctype<wchar_t>& facet = std::use_facet<std::ctype<wchar_t>>(locale);
// Note: Same as above, not exactly correct as narrow() doesn't accept a surrogate pair
return facet.narrow((wchar_t)input, invalidChar);
}
String UTF8::fromANSI(const String& input, const std::locale& locale)
{
String output;
output.reserve(input.size());
auto backInserter = std::back_inserter(output);
auto iter = input.begin();
while(iter != input.end())
{
char32_t u32char = ANSIToUTF32(*iter, locale);
UTF32To8(u32char, backInserter, 4);
++iter;
}
return output;
}
String UTF8::toANSI(const String& input, const std::locale& locale, char invalidChar)
{
String output;
auto iter = input.begin();
while(iter != input.end())
{
char32_t u32char;
iter = UTF8To32(iter, input.end(), u32char, invalidChar);
output.push_back(UTF32ToANSI(u32char, invalidChar, locale));
}
return output;
}
String UTF8::fromWide(const WString& input)
{
String output;
output.reserve(input.size());
auto backInserter = std::back_inserter(output);
auto iter = input.begin();
while(iter != input.end())
{
char32_t u32char;
iter = wideToUTF32(iter, input.end(), u32char);
UTF32To8(u32char, backInserter, 4);
}
return output;
}
WString UTF8::toWide(const String& input)
{
WString output;
auto backInserter = std::back_inserter(output);
auto iter = input.begin();
while(iter != input.end())
{
char32_t u32char;
iter = UTF8To32(iter, input.end(), u32char);
UTF32ToWide(u32char, backInserter, 2);
}
return output;
}
String UTF8::fromUTF16(const U16String& input)
{
String output;
output.reserve(input.size());
auto backInserter = std::back_inserter(output);
auto iter = input.begin();
while(iter != input.end())
{
char32_t u32char = 0;
iter = UTF16To32(iter, input.end(), u32char);
UTF32To8(u32char, backInserter, 4);
}
return output;
}
U16String UTF8::toUTF16(const String& input)
{
U16String output;
auto backInserter = std::back_inserter(output);
auto iter = input.begin();
while(iter != input.end())
{
char32_t u32char;
iter = UTF8To32(iter, input.end(), u32char);
UTF32To16(u32char, backInserter, 2);
}
return output;
}
String UTF8::fromUTF32(const U32String& input)
{
String output;
output.reserve(input.size());
auto backInserter = std::back_inserter(output);
auto iter = input.begin();
while(iter != input.end())
{
UTF32To8(*iter, backInserter, 4);
++iter;
}
return output;
}
U32String UTF8::toUTF32(const String& input)
{
U32String output;
auto iter = input.begin();
while(iter != input.end())
{
char32_t u32char;
iter = UTF8To32(iter, input.end(), u32char);
output.push_back(u32char);
}
return output;
}
UINT32 UTF8::count(const String& input)
{
UINT32 length = 0;
for (char i : input)
{
// Include only characters that don't start with bits 10
length += (i & 0xc0) != 0x80;
}
return length;
}
UINT32 UTF8::charToByteIndex(const String& input, UINT32 charIdx)
{
UINT32 curChar = 0;
UINT32 curByte = 0;
for (char i : input)
{
// Include only characters that don't start with bits 10
if((i & 0xc0) != 0x80)
{
if(curChar == charIdx)
return curByte;
curChar++;
}
curByte++;
}
return (UINT32)input.size();
}
UINT32 UTF8::charByteCount(const String& input, UINT32 charIdx)
{
const UINT32 byteIdx = charToByteIndex(input, charIdx);
UINT32 count = 1;
for(auto i = (size_t)byteIdx + 1; i < input.size(); i++)
{
if((i & 0xc0) != 0x80)
break;
count++;
}
return count;
}
String UTF8::toLower(const String& input)
{
return PlatformUtility::convertCaseUTF8(input, false);
}
String UTF8::toUpper(const String& input)
{
return PlatformUtility::convertCaseUTF8(input, true);
}
}
| 22.085903
| 124
| 0.638676
|
bsf2dev
|
b49d9230d796e1547b4e03370a40e00dac15765d
| 1,412
|
cpp
|
C++
|
src/vulkan/base/simple_vertex_format.cpp
|
WeiPhil/qulkan
|
1d926515ac73c9ea9604206ba5ee98917ce6d215
|
[
"Apache-2.0"
] | null | null | null |
src/vulkan/base/simple_vertex_format.cpp
|
WeiPhil/qulkan
|
1d926515ac73c9ea9604206ba5ee98917ce6d215
|
[
"Apache-2.0"
] | null | null | null |
src/vulkan/base/simple_vertex_format.cpp
|
WeiPhil/qulkan
|
1d926515ac73c9ea9604206ba5ee98917ce6d215
|
[
"Apache-2.0"
] | null | null | null |
#include "vulkan/base/simple_vertex_format.hpp"
namespace Qulkan::Vulkan {
ColoredVertex::ColoredVertex() {}
ColoredVertex::ColoredVertex(const glm::vec3 &aPos, const glm::vec3 &aColor) : pos(aPos), color(aColor) {}
std::vector<VkVertexInputAttributeDescription> ColoredVertex::createAttributeDescriptions() const {
// Position
VkVertexInputAttributeDescription posAttachment;
posAttachment.binding = 0;
posAttachment.location = 0;
posAttachment.format = VK_FORMAT_R32G32B32_SFLOAT;
posAttachment.offset = offsetof(ColoredVertex, pos);
// Color
VkVertexInputAttributeDescription colorAttachment;
colorAttachment.binding = 0;
colorAttachment.location = 1;
colorAttachment.format = VK_FORMAT_R32G32B32_SFLOAT;
colorAttachment.offset = offsetof(ColoredVertex, color);
return std::vector<VkVertexInputAttributeDescription>{posAttachment, colorAttachment};
}
VkVertexInputBindingDescription ColoredVertex::createBindingDescription() const {
VkVertexInputBindingDescription bindingDescription = {};
bindingDescription.binding = 0;
bindingDescription.stride = sizeof(ColoredVertex);
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
return bindingDescription;
}
ColoredVertex::~ColoredVertex(){};
} // namespace Qulkan::Vulkan
| 36.205128
| 110
| 0.724504
|
WeiPhil
|
b49e0a3fb74cb6b922c0e4904f7195dc21661918
| 14,112
|
cpp
|
C++
|
src/example/LALRGenParserTable.cpp
|
PhillipVoyle/WhiteBlackCat
|
652e9d544adfbe234b79e1088c5052cee24f1cc9
|
[
"MIT"
] | null | null | null |
src/example/LALRGenParserTable.cpp
|
PhillipVoyle/WhiteBlackCat
|
652e9d544adfbe234b79e1088c5052cee24f1cc9
|
[
"MIT"
] | null | null | null |
src/example/LALRGenParserTable.cpp
|
PhillipVoyle/WhiteBlackCat
|
652e9d544adfbe234b79e1088c5052cee24f1cc9
|
[
"MIT"
] | null | null | null |
/*
LALRGenParserTable.cpp, generated by wbcparse (c) Phillip Voyle 2005 - 2021.
*/
#include <assert.h>
#include "LALRGenParserTable.h"
const CLALRGenParserTable::Action CLALRGenParserTable::s_actionTable[CLALRGenParserTable::kStates][CLALRGenParserTable::kTerminals] = {
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 8), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 10)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 9), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 10), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 11), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 11), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 1)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 13), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 8), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 10)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 13), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 13), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 13), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 13), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 13), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 13), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 13), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 13)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 7), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 2), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 12)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 9)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 9), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 10), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 11), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 20), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 3), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 3), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 11), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 3), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 3), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 4), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 4), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 11), CLALRGenParserTable::Action(CLALRGenParserTable::aShift, 12), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 4), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 4), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 5), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 5), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 5), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 5), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 5), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 5), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 6), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)},
{CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 8), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 8), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 8), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 8), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 8), CLALRGenParserTable::Action(CLALRGenParserTable::aReduce, 8), CLALRGenParserTable::Action(CLALRGenParserTable::aError, 0)}
};
const int CLALRGenParserTable::s_gotoTable[CLALRGenParserTable::kStates][CLALRGenParserTable::kNonterminals] = {
{1, 2, 3, 4, 5},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, 2, 14, 4, 5},
{-1, -1, -1, -1, -1},
{-1, 15, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, 16, -1, -1, -1},
{-1, 17, -1, -1, -1},
{-1, 18, -1, -1, -1},
{-1, 19, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1}
};
const int CLALRGenParserTable::s_earlyReduce[CLALRGenParserTable::kStates] = {
-1,
0,
-1,
1,
-1,
-1,
7,
-1,
13,
-1,
-1,
-1,
-1,
12,
9,
-1,
-1,
-1,
5,
6,
8
};
const std::string CLALRGenParserTable::s_tokenNames[CLALRGenParserTable::kTerminals + CLALRGenParserTable::kNonterminals] = {
"tAdd",
"tSub",
"tMul",
"tDiv",
"tNumber",
"tLeftBracket",
"tRightBracket",
"tEndLine",
"$",
"ntProgram",
"ntExpression",
"ntLines",
"ntEvaluatedExpression",
"ntLine"
};
const CLALRGenParserTable::Action& CLALRGenParserTable::GetAction(int stateID, int tokenID)
{
assert(stateID >= 0 && stateID < kStates);
assert(tokenID >= 0 && tokenID < kTerminals);
return s_actionTable[stateID][tokenID];
}
int CLALRGenParserTable::GetGoto(int stateID, int tokenID)
{
assert(stateID >= 0 && stateID < kStates);
assert(tokenID >= kTerminals && tokenID < kTerminals + kNonterminals);
return s_gotoTable[stateID][tokenID - kTerminals];
}
int CLALRGenParserTable::GetEarlyReduce(int stateID)
{
assert(stateID >= 0 && stateID < kStates);
return s_earlyReduce[stateID];
}
std::string CLALRGenParserTable::GetTokenName(CLALRGenParserTable::TokenID id)
{
assert(id >= 0 && id < kTerminals + kNonterminals);
return s_tokenNames[id];
}
| 112
| 570
| 0.783376
|
PhillipVoyle
|
b4a06702fa794af0d62a5f79f42c0781fe4d447e
| 7,212
|
cpp
|
C++
|
test/unit/alignment/pairwise/edit_distance/global_edit_distance_max_errors_unbanded_test.cpp
|
anbratu/seqan3
|
8cbfe77a996572065b57c3fe67094cc56a2c43da
|
[
"CC0-1.0",
"CC-BY-4.0"
] | null | null | null |
test/unit/alignment/pairwise/edit_distance/global_edit_distance_max_errors_unbanded_test.cpp
|
anbratu/seqan3
|
8cbfe77a996572065b57c3fe67094cc56a2c43da
|
[
"CC0-1.0",
"CC-BY-4.0"
] | null | null | null |
test/unit/alignment/pairwise/edit_distance/global_edit_distance_max_errors_unbanded_test.cpp
|
anbratu/seqan3
|
8cbfe77a996572065b57c3fe67094cc56a2c43da
|
[
"CC0-1.0",
"CC-BY-4.0"
] | null | null | null |
// -----------------------------------------------------------------------------------------------------
// Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
// Copyright (c) 2016-2019, Knut Reinert & MPI für molekulare Genetik
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
// -----------------------------------------------------------------------------------------------------
#include "../edit_distance_unbanded_test_template.hpp"
#include "../fixture/global_edit_distance_max_errors_unbanded.hpp"
using global_edit_distance_max_errors_unbanded_types1
= ::testing::Types<
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e255, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e255, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e255, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e255, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e8, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e8, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e8, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e8, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e7, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e7, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e7, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e7, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e5, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e5, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e5, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01_e5, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01T_e255, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01T_e255, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01T_e255, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_01T_e255, uint64_t>
>;
using global_edit_distance_max_errors_unbanded_types2
= ::testing::Types<
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e255, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e255, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e255, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e255, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e8, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e8, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e8, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e8, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e4, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e4, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e4, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_e4, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s10u_15u_e7, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s10u_15u_e7, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s10u_15u_e7, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s10u_15u_e7, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s1u_15u_e255, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s1u_15u_e255, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s1u_15u_e255, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s1u_15u_e255, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s1u_15u_e5, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s1u_15u_e5, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s1u_15u_e5, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02_s1u_15u_e5, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02T_s15u_1u_e255, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02T_s15u_1u_e255, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02T_s15u_1u_e255, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02T_s15u_1u_e255, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02T_s15u_1u_e5, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02T_s15u_1u_e5, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02T_s15u_1u_e5, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_02T_s15u_1u_e5, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_03_e255, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_03_e255, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_03_e255, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::dna4_03_e255, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::aa27_01_e255, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::aa27_01_e255, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::aa27_01_e255, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::aa27_01_e255, uint64_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::aa27_01T_e255, uint8_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::aa27_01T_e255, uint16_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::aa27_01T_e255, uint32_t>,
global_fixture<&global::edit_distance::max_errors::unbanded::aa27_01T_e255, uint64_t>
>;
INSTANTIATE_TYPED_TEST_CASE_P(global1, edit_distance_unbanded_test, global_edit_distance_max_errors_unbanded_types1);
INSTANTIATE_TYPED_TEST_CASE_P(global2, edit_distance_unbanded_test, global_edit_distance_max_errors_unbanded_types2);
| 72.848485
| 117
| 0.74279
|
anbratu
|
b4a3bfebd22a6c42ed817258f0460c4d8172ed90
| 1,440
|
cpp
|
C++
|
CppSTL/Chapter1/io/check_cpu.cpp
|
SebastianTirado/Cpp-Learning-Archive
|
fb83379d0cc3f9b2390cef00119464ec946753f4
|
[
"MIT"
] | 19
|
2019-09-15T12:23:51.000Z
|
2020-06-18T08:31:26.000Z
|
CppSTL/Chapter1/io/check_cpu.cpp
|
SebastianTirado/Cpp-Learning-Archive
|
fb83379d0cc3f9b2390cef00119464ec946753f4
|
[
"MIT"
] | 15
|
2021-12-07T06:46:03.000Z
|
2022-01-31T07:55:32.000Z
|
CppSTL/Chapter1/io/check_cpu.cpp
|
SebastianTirado/Cpp-Learning-Archive
|
fb83379d0cc3f9b2390cef00119464ec946753f4
|
[
"MIT"
] | 13
|
2019-06-29T02:58:27.000Z
|
2020-05-07T08:52:22.000Z
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string fetch_from_cpuinfo(string search_string)
{
ifstream file;
const char* filename = "/proc/cpuinfo";
file.open(filename);
// Check if file is opened correctly ::
// WAY I: if(!file.is_open())
// WAY II: if(file.fail())
// WAY III: proposed one
if(!file)
{
cout << "Could not open " << filename << ". ERROR!\n";
exit(1);
}
string line;
string fetched_str;
// Loop through the end of file ::
while(!file.eof())
{
// Get current line
getline(file, line);
// Find string 'search_string'
size_t pos = line.find(search_string);
if(pos == std::string::npos)
continue;
pos = pos + search_string.length();
fetched_str = line.substr(pos, std::string::npos);
break;
}
// Close the file | free system resources
file.close();
if(!file.good()) {
cout << "Error occured during the close() of file " << filename << endl;
exit(1);
}
return fetched_str;
}
int main()
{
cout << "CPU Model Name : " << fetch_from_cpuinfo("model name\t:")
<< "\nCPU Frequency : " << fetch_from_cpuinfo("cpu MHz\t\t:") << " KHz"
<< "\nCPU Cache : " << fetch_from_cpuinfo("cache size\t:")
<< "\nCPU Cores : " << fetch_from_cpuinfo("cpu cores\t:")
<< "\nKnown Bugs : " << fetch_from_cpuinfo("bugs\t\t:")
<< endl;
return 0;
}
| 21.818182
| 81
| 0.586111
|
SebastianTirado
|
b4a4c91e4902e6eedd9f1b4ef5314410fa3d2f06
| 19,544
|
hpp
|
C++
|
src/coordinate_map_manager.hpp
|
BestSonny/MinkowskiEngineM
|
383e9f608fd8cb047fee3cf7c9e20137abad4859
|
[
"MIT"
] | null | null | null |
src/coordinate_map_manager.hpp
|
BestSonny/MinkowskiEngineM
|
383e9f608fd8cb047fee3cf7c9e20137abad4859
|
[
"MIT"
] | null | null | null |
src/coordinate_map_manager.hpp
|
BestSonny/MinkowskiEngineM
|
383e9f608fd8cb047fee3cf7c9e20137abad4859
|
[
"MIT"
] | 1
|
2020-07-09T15:24:26.000Z
|
2020-07-09T15:24:26.000Z
|
/*
* Copyright (c) 2020 NVIDIA CORPORATION.
* Copyright (c) 2018-2020 Chris Choy (chrischoy@ai.stanford.edu)
*
* 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.
*
* Please cite "4D Spatio-Temporal ConvNets: Minkowski Convolutional Neural
* Networks", CVPR'19 (https://arxiv.org/abs/1904.08755) if you use any part
* of the code.
*/
#ifndef COORDINATE_MAP_MANAGER
#define COORDINATE_MAP_MANAGER
#include "coordinate_map.hpp"
#include "coordinate_map_cpu.hpp"
#include "coordinate_map_key.hpp"
#include "errors.hpp"
#include "types.hpp"
#include "utils.hpp"
#ifndef CPU_ONLY
#include "coordinate_map_gpu.cuh"
#include "kernel_map.cuh"
#endif
#include <algorithm>
#include <array>
#include <functional>
#include <iostream>
#include <iterator>
#include <omp.h>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include <robin_hood.h>
#include <torch/extension.h>
namespace minkowski {
namespace detail {
template <template <typename T, template <typename Q> class A>
class CoordinateMapType>
struct is_cpu_coordinate_map : std::false_type {};
template <> struct is_cpu_coordinate_map<CoordinateMapCPU> : std::true_type {};
template <typename T1, typename T2> void copy_types(const T1 &src, T2 &dst) {
size_t curr_it = 0;
for (const auto s : src)
dst[curr_it++] = s;
}
template <default_types::index_type V>
default_types::stride_type _fill_vec(size_t const len) {
default_types::stride_type vec(len);
std::for_each(vec.begin(), vec.end(), [](auto &i) { i = V; });
return vec;
}
} // namespace detail
template <typename coordinate_type, typename coordinate_field_type,
template <typename C> class TemplatedAllocator,
template <typename T, template <typename Q> class A>
class CoordinateMapType>
class CoordinateMapManager {
public:
using size_type = default_types::size_type;
using index_type = default_types::index_type;
using stride_type = default_types::stride_type;
using map_type = CoordinateMapType<coordinate_type, TemplatedAllocator>;
#ifndef CPU_ONLY
using field_map_type = typename std::conditional<
detail::is_cpu_coordinate_map<CoordinateMapType>::value,
CoordinateFieldMapCPU<coordinate_field_type, TemplatedAllocator>,
CoordinateFieldMapGPU<coordinate_field_type, TemplatedAllocator>>::type;
#else
using field_map_type =
CoordinateFieldMapCPU<coordinate_field_type, TemplatedAllocator>;
#endif
using self_type = CoordinateMapManager<coordinate_type, coordinate_field_type,
TemplatedAllocator, CoordinateMapType>;
using map_collection_type = std::map<coordinate_map_key_type, map_type,
coordinate_map_key_comparator>;
using kernel_map_type =
#ifndef CPU_ONLY
typename std::conditional<
detail::is_cpu_coordinate_map<CoordinateMapType>::value,
cpu_kernel_map,
gpu_kernel_map<index_type, TemplatedAllocator<char>>>::type;
#else
cpu_kernel_map;
#endif
using kernel_map_reference_type =
#ifndef CPU_ONLY
typename std::conditional<
detail::is_cpu_coordinate_map<CoordinateMapType>::value,
cpu_kernel_map,
gpu_kernel_map<index_type, TemplatedAllocator<char>>>::type;
#else
cpu_kernel_map_reference;
#endif
public:
// allocator backend will be ignored when coordinate map backend is CPU
CoordinateMapManager(
MinkowskiAlgorithm::Mode algo = MinkowskiAlgorithm::DEFAULT,
size_type num_threads = 0)
: m_algorithm(algo) {
if (num_threads > 0) {
// Doesn't seem to work. use `export OMP_NUM_THREADS=N;` in bash.
omp_set_dynamic(0);
omp_set_num_threads(num_threads);
}
switch (m_algorithm) {
case MinkowskiAlgorithm::DEFAULT: {
m_kernel_map_mode = CUDAKernelMapMode::SPEED_OPTIMIZED;
m_gpu_default_occupancy = 25;
break;
}
case MinkowskiAlgorithm::MEMORY_EFFICIENT: {
m_kernel_map_mode = CUDAKernelMapMode::MEMORY_EFFICIENT;
m_gpu_default_occupancy = 50;
break;
}
case MinkowskiAlgorithm::SPEED_OPTIMIZED: {
m_kernel_map_mode = CUDAKernelMapMode::SPEED_OPTIMIZED;
m_gpu_default_occupancy = 25;
break;
}
}
}
~CoordinateMapManager() {}
/****************************************************************************
* Coordinate generation, modification, and initialization entry functions
****************************************************************************/
py::object insert_field(at::Tensor const &th_coordinate,
stride_type const tensor_stride,
std::string const string_id = "");
/*
* New coordinate map initialzation function.
*
* returns key and map, inverse map
*/
std::pair<py::object, std::pair<at::Tensor, at::Tensor>>
insert_and_map(at::Tensor const &th_coordinate,
stride_type const tensor_stride,
std::string const string_id = "");
/*
* Generate a new coordinate_map if it doesn't exists
*/
// returns out_map_key and flag which is true if a new map is created
std::pair<coordinate_map_key_type, bool>
stride(coordinate_map_key_type const &in_map_key,
stride_type const &kernel_stride);
// python-side stride function
py::object py_stride(CoordinateMapKey const *in_map_key,
stride_type const &kernel_stride) {
auto key = std::get<0>(stride(in_map_key->get_key(), kernel_stride));
return py::cast(new CoordinateMapKey(key.first.size() + 1, key));
}
// stride region: new coordinate generation
std::pair<coordinate_map_key_type, bool>
stride_region(coordinate_map_key_type const &in_map_key,
cpu_kernel_region<coordinate_type> &kernel,
stride_type const &out_tensor_stride,
bool const expand_coordinates);
// origin coordinate map creation
std::pair<coordinate_map_key_type, bool> origin();
// pruning
coordinate_map_key_type prune(coordinate_map_key_type const &in_key,
bool const *keep_begin, bool const *keep_end);
// python-side stride function
py::object py_origin() {
auto map_key_bool = origin();
LOG_DEBUG("Return origin map key");
return py::cast(new CoordinateMapKey(map_key_bool.first.first.size() + 1,
map_key_bool.first));
}
/****************************************************************************
* Tensor field related operations
****************************************************************************/
py::object insert(at::Tensor const &coordinates);
/****************************************************************************
* Coordinate management helper functions
****************************************************************************/
bool insert(coordinate_map_key_type map_key, map_type &map) {
LOG_DEBUG("insert map with tensor_stride", map_key.first);
auto result = m_coordinate_maps.insert(
std::make_pair<coordinate_map_key_type, map_type>(std::move(map_key),
std::move(map)));
LOG_DEBUG("map insertion", result.second);
return result.second;
}
bool insert_field_map(coordinate_map_key_type map_key, field_map_type &map) {
LOG_DEBUG("insert map with tensor_stride", map_key.first);
auto result = m_field_coordinates.insert(
std::make_pair<coordinate_map_key_type, field_map_type>(
std::move(map_key), std::move(map)));
LOG_DEBUG("map insertion", result.second);
return result.second;
}
typename map_collection_type::iterator
find(coordinate_map_key_type const &map_key) {
return m_coordinate_maps.find(map_key);
}
typename map_collection_type::const_iterator map_end() const {
return m_coordinate_maps.cend();
}
inline bool exists(coordinate_map_key_type const &key) const noexcept {
return m_coordinate_maps.find(key) != m_coordinate_maps.end();
}
// when the key is the python coordinate map key
inline bool exists(CoordinateMapKey const *p_key) const {
// key set exception
return exists(p_key->get_key());
}
inline size_type size(coordinate_map_key_type const &key) const {
auto it = m_coordinate_maps.find(key);
ASSERT(it != m_coordinate_maps.end(), ERROR_MAP_NOT_FOUND);
return it->second.size();
}
inline size_type size(CoordinateMapKey const *p_key) const {
return size(p_key->get_key());
}
inline size_type capacity(coordinate_map_key_type const &key) const {
auto it = m_coordinate_maps.find(key);
ASSERT(it != m_coordinate_maps.end(), ERROR_MAP_NOT_FOUND);
return it->second.capacity();
}
at::Tensor get_coordinates(CoordinateMapKey const *p_key) const;
at::Tensor get_coordinate_field(CoordinateMapKey const *p_key) const;
std::vector<py::object>
get_coordinate_map_keys(stride_type const tensor_stride) const {
std::vector<py::object> keys;
for (auto it = m_coordinate_maps.begin(); it != m_coordinate_maps.end();
++it) {
coordinate_map_key_type const &key = it->first;
if (key.first == tensor_stride) {
keys.push_back(py::cast(new CoordinateMapKey(key.first.size(), key)));
}
}
return keys;
}
std::string print_key(coordinate_map_key_type const &key) const {
Formatter out;
out << ArrToString(key.first);
if (key.second.length() > 0)
out << "-" << key.second;
return out.str();
}
std::string to_string(CoordinateMapKey const *p_key) const {
auto it = m_coordinate_maps.find(p_key->get_key());
ASSERT(it != m_coordinate_maps.end(), ERROR_MAP_NOT_FOUND);
return print_key(it->first) + " : " + it->second.to_string();
}
std::string to_string() const {
Formatter o;
for (auto const &kv : m_coordinate_maps) {
o << "\t" << print_key(kv.first) << ":\t" << kv.second.to_string()
<< "\n";
}
for (auto const &kv : m_kernel_maps) {
o << "\t" << print_key(std::get<0>(kv.first)) << "->"
<< print_key(std::get<1>(kv.first)) << ":\t" << kv.second << "\n";
}
return o.str();
}
MinkowskiAlgorithm::Mode algorithm() const { return m_algorithm; }
/****************************************************************************
* Kernel map related functions
****************************************************************************/
// return kernel map. for cpu it is {in maps, out maps}.
// For gpu it could be {in maps, out maps}, or {kernel index, in map, out map}
kernel_map_type const &
kernel_map(CoordinateMapKey const *py_in_coords_key, //
CoordinateMapKey const *py_out_coords_key, //
stride_type const &kernel_size, //
stride_type const &kernel_stride, //
stride_type const &kernel_dilation, //
RegionType::Type const region_type, //
at::Tensor const &offsets, bool is_transpose, bool is_pool);
// for kernel size 0
kernel_map_type const &kernel_map(CoordinateMapKey const *py_in_coords_key,
CoordinateMapKey const *py_out_coords_key);
kernel_map_type const &origin_map(CoordinateMapKey const *py_out_coords_key);
std::pair<at::Tensor, std::vector<at::Tensor>>
origin_map_th(CoordinateMapKey const *py_out_coords_key);
size_t origin_map_size() {
auto const key = origin().first;
return m_coordinate_maps.find(key)->second.size();
}
private:
void coordinate_map_key_check(CoordinateMapKey const *p_map_key) const {
ASSERT(p_map_key != nullptr, "Input coordinate map key not defined.");
ASSERT(p_map_key->is_key_set(), "Key not defined.");
ASSERT(exists(p_map_key->get_key()), "Key does not exist.");
}
// random string generator
std::string random_string(size_t length) {
auto randchar = []() -> char {
const char charset[] = "0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
const size_t max_index = (sizeof(charset) - 1);
return charset[rand() % max_index];
};
std::string str(length, 0);
std::generate_n(str.begin(), length, randchar);
return str;
}
coordinate_map_key_type get_random_string_id(stride_type const &tensor_stride,
std::string string_id) {
coordinate_map_key_type key = std::make_pair(
tensor_stride, string_id.size() > 0 ? string_id + '-' + random_string(5)
: random_string(5));
while (m_coordinate_maps.find(key) != m_coordinate_maps.end()) {
key =
std::make_pair(tensor_stride, string_id.size() > 0
? string_id + '-' + random_string(5)
: random_string(5));
}
return key;
}
kernel_map_key_type
origin_map_key(coordinate_map_key_type const &in_key) const {
map_type const &random_map = m_coordinate_maps.begin()->second;
stride_type zero_vec(random_map.coordinate_size() - 1);
std::for_each(zero_vec.begin(), zero_vec.end(), [](auto &i) { i = 0; });
coordinate_map_key_type origin_key = std::make_pair(zero_vec, "");
return std::make_tuple(in_key, origin_key, // maps
zero_vec, zero_vec, zero_vec, // kernels
RegionType::HYPER_CUBE, false, false);
}
public:
size_t m_gpu_default_occupancy;
#ifndef CPU_ONLY
void *allocate(size_type n) { return m_allocator.allocate(n); }
void deallocate(void *p, size_type n) {
m_allocator.deallocate((char *)p, n);
}
#endif
private:
// NOTE: operator[] required mapped_type(), which is not defined.
//
// CoordinateMapManager owns the coordinate maps
std::map<coordinate_map_key_type, map_type, coordinate_map_key_comparator>
m_coordinate_maps;
// CoordinateMapManager managed coordinates
std::map<coordinate_map_key_type, field_map_type,
coordinate_map_key_comparator>
m_field_coordinates;
// CoordinateMapManager owns the kernel maps
std::unordered_map<kernel_map_key_type, kernel_map_type,
kernel_map_key_hasher<coordinate_map_key_hasher>>
m_kernel_maps;
#ifndef CPU_ONLY
TemplatedAllocator<char> m_allocator;
#endif
// kernel map mode
CUDAKernelMapMode::Mode m_kernel_map_mode;
// Algorithm index
MinkowskiAlgorithm::Mode m_algorithm;
}; // coordsmanager
namespace detail {
template <typename coordinate_type, typename coordinate_field_type,
template <typename C> class TemplatedAllocator,
template <typename T, template <typename Q> class A>
class CoordinateMapType,
typename field_map_type>
struct insert_field_functor {
void operator()(
coordinate_map_key_type &map_key, at::Tensor const &th_coordinate,
CoordinateMapManager<coordinate_type, coordinate_field_type,
TemplatedAllocator, CoordinateMapType> &manager);
};
// a partial specialization functor for insertion
template <typename coordinate_type, typename coordinate_field_type,
template <typename C> class TemplatedAllocator,
template <typename T, template <typename Q> class A>
class CoordinateMapType>
struct insert_and_map_functor {
std::pair<at::Tensor, at::Tensor> operator()(
coordinate_map_key_type &map_key, at::Tensor const &th_coordinate,
CoordinateMapManager<coordinate_type, coordinate_field_type,
TemplatedAllocator, CoordinateMapType> &manager);
};
// a partial specialization functor for kernel map generation
template <typename coordinate_type,
template <typename C> class TemplatedAllocator,
template <typename T, template <typename Q> class A>
class CoordinateMapType,
typename kernel_map_type>
struct kernel_map_functor {
kernel_map_type operator()(
CoordinateMapType<coordinate_type, TemplatedAllocator> const &in_map,
CoordinateMapType<coordinate_type, TemplatedAllocator> const &out_map,
CUDAKernelMapMode::Mode kernel_map_mode,
cpu_kernel_region<coordinate_type> &kernel);
};
// a partial specialization functor for stride map generation
template <typename coordinate_type,
template <typename C> class TemplatedAllocator,
template <typename T, template <typename Q> class A>
class CoordinateMapType,
typename kernel_map_type>
struct stride_map_functor {
using stride_type = default_types::stride_type;
kernel_map_type operator()(
CoordinateMapType<coordinate_type, TemplatedAllocator> const &in_map,
CoordinateMapType<coordinate_type, TemplatedAllocator> const &out_map,
stride_type const &kernel);
};
// a partial specialization functor for kernel map in/out swap
template <typename kernel_map_type> struct swap_in_out_map_functor {
kernel_map_type operator()(kernel_map_type const &kernel_map);
};
// a partial specialization functor for origin_map
template <typename coordinate_type,
template <typename C> class TemplatedAllocator,
template <typename T, template <typename Q> class A>
class CoordinateMapType,
typename kernel_map_type>
struct origin_map_functor {
std::pair<at::Tensor, std::vector<at::Tensor>>
operator()(CoordinateMapType<coordinate_type, TemplatedAllocator> const
&origin_coordinate_map,
kernel_map_type const &origin_map);
};
} // namespace detail
// type defs
template <typename coordinate_type>
using cpu_manager_type =
CoordinateMapManager<coordinate_type, default_types::ccoordinate_type,
std::allocator, CoordinateMapCPU>;
#ifndef CPU_ONLY
template <typename coordinate_type,
template <typename C> class TemplatedAllocator>
using gpu_manager_type =
CoordinateMapManager<coordinate_type, default_types::ccoordinate_type,
TemplatedAllocator, CoordinateMapGPU>;
template <typename coordinate_type>
using gpu_default_manager_type =
gpu_manager_type<coordinate_type, detail::default_allocator>;
template <typename coordinate_type>
using gpu_c10_manager_type =
gpu_manager_type<coordinate_type, detail::c10_allocator>;
#endif
} // namespace minkowski
#endif // COORDINATE_MAP_MANAGER
| 36.667917
| 80
| 0.671255
|
BestSonny
|
b4a8d4de601499e5f97bd9c57ce54720f0344810
| 1,696
|
hpp
|
C++
|
libs/mavlink/include/mavlink/v2.0/common/mavlink_msg_encapsulated_data.hpp
|
thanhhaibk96/VIAM_AUV2000_QGC
|
ebe45f35bb8b136c57cea4296968a742d59a9658
|
[
"Apache-2.0"
] | 10
|
2021-03-15T03:58:06.000Z
|
2021-12-30T15:33:38.000Z
|
libs/mavlink/include/mavlink/v2.0/common/mavlink_msg_encapsulated_data.hpp
|
thanhhaibk96/VIAM_AUV2000_QGC
|
ebe45f35bb8b136c57cea4296968a742d59a9658
|
[
"Apache-2.0"
] | 2
|
2019-11-25T17:56:41.000Z
|
2022-03-22T23:28:09.000Z
|
libs/mavlink/include/mavlink/v2.0/common/mavlink_msg_encapsulated_data.hpp
|
thanhhaibk96/VIAM_AUV2000_QGC
|
ebe45f35bb8b136c57cea4296968a742d59a9658
|
[
"Apache-2.0"
] | 8
|
2021-10-09T08:47:53.000Z
|
2022-01-17T07:45:33.000Z
|
// MESSAGE ENCAPSULATED_DATA support class
#pragma once
namespace mavlink {
namespace common {
namespace msg {
/**
* @brief ENCAPSULATED_DATA message
*
* Data packet for images sent using the Image Transmission Protocol: https://mavlink.io/en/services/image_transmission.html.
*/
struct ENCAPSULATED_DATA : mavlink::Message {
static constexpr msgid_t MSG_ID = 131;
static constexpr size_t LENGTH = 255;
static constexpr size_t MIN_LENGTH = 255;
static constexpr uint8_t CRC_EXTRA = 223;
static constexpr auto NAME = "ENCAPSULATED_DATA";
uint16_t seqnr; /*< sequence number (starting with 0 on every transmission) */
std::array<uint8_t, 253> data; /*< image data bytes */
inline std::string get_name(void) const override
{
return NAME;
}
inline Info get_message_info(void) const override
{
return { MSG_ID, LENGTH, MIN_LENGTH, CRC_EXTRA };
}
inline std::string to_yaml(void) const override
{
std::stringstream ss;
ss << NAME << ":" << std::endl;
ss << " seqnr: " << seqnr << std::endl;
ss << " data: [" << to_string(data) << "]" << std::endl;
return ss.str();
}
inline void serialize(mavlink::MsgMap &map) const override
{
map.reset(MSG_ID, LENGTH);
map << seqnr; // offset: 0
map << data; // offset: 2
}
inline void deserialize(mavlink::MsgMap &map) override
{
map >> seqnr; // offset: 0
map >> data; // offset: 2
}
};
} // namespace msg
} // namespace common
} // namespace mavlink
| 26.092308
| 125
| 0.583726
|
thanhhaibk96
|
b4ab41c3a66cc7342e112b29b6e982bb1c33563f
| 9,559
|
cpp
|
C++
|
examples/tutorial/old/plc_test.cpp
|
viennagrid/viennagrid-dev
|
6e47c8d098a0b691d6b9988f2444cd11d440f4c2
|
[
"MIT"
] | 7
|
2015-09-13T03:50:58.000Z
|
2019-06-27T14:24:49.000Z
|
examples/tutorial/old/plc_test.cpp
|
viennagrid/viennagrid-dev
|
6e47c8d098a0b691d6b9988f2444cd11d440f4c2
|
[
"MIT"
] | null | null | null |
examples/tutorial/old/plc_test.cpp
|
viennagrid/viennagrid-dev
|
6e47c8d098a0b691d6b9988f2444cd11d440f4c2
|
[
"MIT"
] | 5
|
2015-07-03T07:14:15.000Z
|
2021-05-20T00:51:58.000Z
|
#include <iostream>
#include <typeinfo>
#include <map>
using std::cout;
using std::endl;
#include "viennagrid/forwards.hpp"
#include "viennagrid/storage/view.hpp"
#include "viennagrid/storage/container_collection.hpp"
#include "viennagrid/storage/inserter.hpp"
#include "viennagrid/storage/id_generator.hpp"
#include "viennagrid/storage/hidden_key_map.hpp"
#include "viennagrid/storage/range.hpp"
#include "viennagrid/topology/vertex.hpp"
#include "viennagrid/topology/line.hpp"
#include "viennagrid/topology/simplex.hpp"
#include "viennagrid/topology/plc.hpp"
#include "viennagrid/config/element_config.hpp"
#include "viennagrid/config/mesh_config.hpp"
#include "viennagrid/config/default_configs.hpp"
#include "viennagrid/element/element_key.hpp"
#include "viennagrid/element/element_orientation.hpp"
#include "viennagrid/element/element_view.hpp"
#include "viennagrid/point.hpp"
#include "viennagrid/mesh/mesh.hpp"
#include "viennagrid/mesh/element_creation.hpp"
struct WrappedConfigType
{
typedef viennagrid::storage::pointer_handle_tag handle_tag;
typedef viennagrid::config::result_of::full_mesh_config<viennagrid::plc_tag, viennagrid::config::point_type_2d, viennagrid::storage::pointer_handle_tag>::type type;
};
int main()
{
//
// First define the type of handle to use:
//
// typedef viennagrid::storage::pointer_handle_tag handle_tag;
//typedef viennagrid::storage::iterator_handle_tag handle_tag;
// typedef viennagrid::storage::id_handle_tag handle_tag;
//
// typedefing and setting up the topological mesh
//
// typedef viennagrid::config::result_of::full_mesh_config<viennagrid::plc_tag, viennagrid::config::point_type_2d, viennagrid::storage::pointer_handle_tag>::type mesh_config;
//typedef viennagrid::config::polygonal_2d_mesh MeshType;
typedef viennagrid::mesh< WrappedConfigType > MeshType;
MeshType mesh;
//
// typedefs for the element types
//
typedef viennagrid::result_of::point<MeshType>::type point_type;
typedef viennagrid::result_of::element<MeshType, viennagrid::vertex_tag>::type vertex_type;
typedef viennagrid::result_of::handle<MeshType, viennagrid::vertex_tag>::type vertex_handle_type;
typedef viennagrid::result_of::element<MeshType, viennagrid::line_tag>::type line_type;
typedef viennagrid::result_of::handle<MeshType, viennagrid::line_tag>::type line_handle_type;
// typedef viennagrid::result_of::element<MeshType, viennagrid::polygon_tag>::type polygon_type;
// typedef viennagrid::result_of::handle<MeshType, viennagrid::polygon_tag>::type polygon_handle_type;
std::vector<vertex_handle_type> v;
v.push_back( viennagrid::make_vertex( mesh, point_type(0, 0) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(10, 0) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(20, 10) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(20, 20) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(10, 20) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(0, 10) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(5, 5) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(10, 10) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(12, 10) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(10, 12) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(8, 10) ) );
v.push_back( viennagrid::make_vertex( mesh, point_type(15, 15) ) );
std::vector<line_handle_type> lines;
{
std::vector<vertex_handle_type>::iterator start = v.begin();
std::vector<vertex_handle_type>::iterator end = v.begin() + 7;
std::vector<vertex_handle_type>::iterator it1 = start;
std::vector<vertex_handle_type>::iterator it2 = it1; ++it2;
for (; it2 != end; ++it1, ++it2)
lines.push_back( viennagrid::make_line(mesh, *it1, *it2) );
lines.push_back( viennagrid::make_line(mesh, *it1, *start) );
}
{
std::vector<vertex_handle_type>::iterator start = v.begin() + 7;
std::vector<vertex_handle_type>::iterator end = v.begin() + 10;
std::vector<vertex_handle_type>::iterator it1 = start;
std::vector<vertex_handle_type>::iterator it2 = it1; ++it2;
for (; it2 != end; ++it1, ++it2)
lines.push_back( viennagrid::make_line(mesh, *it1, *it2) );
lines.push_back( viennagrid::make_line(mesh, *it1, *start) );
}
// polygon_handle_type bounding_poly = viennagrid::make_element<polygon_type>( mesh, v.begin(), v.begin() + 7 );
// polygon_handle_type hole_poly = viennagrid::make_element<polygon_type>( mesh, v.begin() + 7, v.begin() + 10 );
// std::vector<line_handle_type> lines( viennagrid::elements<line_type>( viennagrid::dereference_handle(mesh, hole_poly) ).size() );
// std::copy( viennagrid::elements<line_type>( viennagrid::dereference_handle(mesh, hole_poly) ).handle_begin(), viennagrid::elements<line_type>( viennagrid::dereference_handle(mesh, hole_poly) ).handle_end(), lines.begin() );
lines.push_back( viennagrid::make_element<line_type>( mesh, v.begin() + 9, v.begin() + 11 ) );
vertex_handle_type point = v[11];
// std::cout << bounding_poly << std::endl;
// std::cout << viennagrid::dereference_handle(mesh, bounding_poly) << std::endl;
// std::cout << hole_poly << std::endl;
// std::cout << viennagrid::dereference_handle(mesh, hole_poly) << std::endl;
typedef viennagrid::result_of::element<MeshType, viennagrid::plc_tag>::type plc_type;
typedef viennagrid::result_of::handle<MeshType, viennagrid::plc_tag>::type plc_handle_type;
std::vector<point_type> hole_points;
hole_points.push_back( point_type(10.5, 10.5) );
plc_handle_type plc_handle = viennagrid::make_plc( mesh,
// &bounding_poly, &bounding_poly + 1,
// bounding_poly,
// &hole_poly, &hole_poly+1,
lines.begin(), lines.end(),
&point, &point + 1,
hole_points.begin(), hole_points.end()
);
plc_type & plc = viennagrid::dereference_handle(mesh, plc_handle);
//std::cout << plc.get_bounding_polygon() << std::endl;
typedef viennagrid::result_of::element_range<plc_type, vertex_type>::type vertex_on_plc_range;
typedef viennagrid::result_of::iterator<vertex_on_plc_range>::type vertex_on_plc_iterator;
// viennagrid::tagging::result_of::element_tag<plc_type, viennagrid::loose_tag>::type loose_tag = viennagrid::tagging::make_element_tag<viennagrid::loose_tag>(plc);
std::cout << "All vertices of the PLC" << std::endl;
vertex_on_plc_range vertex_range = viennagrid::elements<vertex_type>( plc );
for (vertex_on_plc_iterator it = vertex_range.begin(); it != vertex_range.end(); ++it)
std::cout << *it << " " << viennagrid::point(mesh, *it) << std::endl;
std::cout << std::endl;
typedef viennagrid::result_of::element_range<plc_type, line_type>::type line_on_plc_range;
typedef viennagrid::result_of::iterator<line_on_plc_range>::type line_on_plc_iterator;
std::cout << "All lines of the PLC" << std::endl;
line_on_plc_range line_range = viennagrid::elements<line_type>( plc );
for (line_on_plc_iterator it = line_range.begin(); it != line_range.end(); ++it)
std::cout << *it << std::endl;
std::cout << std::endl;
std::cout << "All PLCs of the mesh" << std::endl;
typedef viennagrid::result_of::element_range< MeshType, plc_type >::type plc_range_type;
plc_range_type plc_range = viennagrid::elements< plc_type >(mesh);
for ( plc_range_type::iterator it = plc_range.begin(); it != plc_range.end(); ++it)
std::cout << *it << std::endl;
std::cout << std::endl;
// typedef viennagrid::result_of::const_element_view<plc_type, vertex_type>::type vertex_view_type;
// typedef viennagrid::result_of::iterator<vertex_view_type>::type vertex_view_iterator;
//
// std::cout << "All loose points of the plc" << std::endl;
// vertex_view_type vertex_view = viennagrid::loose_elements<vertex_type>(plc);
// for (vertex_view_iterator it = vertex_view.begin(); it != vertex_view.end(); ++it)
// std::cout << *it << std::endl;
// std::cout << std::endl;
// typedef viennagrid::result_of::element_view<plc_type, line_type>::type line_view_type;
//
// std::cout << "All inner lines of the plc" << std::endl;
// viennagrid::tagging::result_of::element_tag<plc_type, viennagrid::bounding_tag>::type bounding_tag = viennagrid::tagging::make_element_tag<viennagrid::bounding_tag>(plc);
// line_view_type inner_lines = viennagrid::untagged_elements<line_type>(plc, bounding_tag);
// std::copy( inner_lines.begin(), inner_lines.end(), std::ostream_iterator<line_type>(std::cout, "\n") );
// std::cout << std::endl;
std::cout << "All hole points of the plc" << std::endl;
std::vector<point_type> & pts = plc.appendix();// viennagrid::hole_points<MeshType>(plc);
std::copy( pts.begin(), pts.end(), std::ostream_iterator<point_type>(std::cout, "\n") );
return 0;
}
| 42.484444
| 232
| 0.667852
|
viennagrid
|
b4b00274898df9da6b274731dad200524b14501d
| 615
|
cpp
|
C++
|
PETCS/Basic/mwc15c7p2.cpp
|
dl4us/Competitive-Programming-1
|
d42fab3bd68168adbe4b5f594f19ee5dfcd1389b
|
[
"MIT"
] | null | null | null |
PETCS/Basic/mwc15c7p2.cpp
|
dl4us/Competitive-Programming-1
|
d42fab3bd68168adbe4b5f594f19ee5dfcd1389b
|
[
"MIT"
] | null | null | null |
PETCS/Basic/mwc15c7p2.cpp
|
dl4us/Competitive-Programming-1
|
d42fab3bd68168adbe4b5f594f19ee5dfcd1389b
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
int F, R, Q, C, psa[6][10005];
int main() {
cin.sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("../../input.txt", "r", stdin);
freopen("../../output.txt", "w", stdout);
#endif
cin >> F >> R;
for(int i = 1; i <= F; i++) {
for(int j = 1; j <= R; j++) {
cin >> C;
psa[i][j] = psa[i][j-1] + C;
}
}
cin >> Q;
int a, b, c;
while(Q--) {
cin >> a >> b >> c;
cout << psa[c][b]-psa[c][a-1] << "\n";
}
return 0;
}
| 22.777778
| 47
| 0.398374
|
dl4us
|
b4b4cd3000a1ebde7ad433830b2573a0e74b507c
| 9,213
|
cpp
|
C++
|
modules/cudaimgproc/src/canny.cpp
|
m000/opencv
|
ef16e4203ecb8ca789964163792f46a300933364
|
[
"BSD-3-Clause"
] | 5
|
2019-11-29T04:11:18.000Z
|
2022-02-05T06:38:18.000Z
|
modules/cudaimgproc/src/canny.cpp
|
m000/opencv
|
ef16e4203ecb8ca789964163792f46a300933364
|
[
"BSD-3-Clause"
] | 3
|
2019-08-21T07:13:41.000Z
|
2020-06-23T12:35:17.000Z
|
modules/cudaimgproc/src/canny.cpp
|
m000/opencv
|
ef16e4203ecb8ca789964163792f46a300933364
|
[
"BSD-3-Clause"
] | 5
|
2019-02-03T05:36:43.000Z
|
2021-12-15T01:15:32.000Z
|
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
using namespace cv;
using namespace cv::cuda;
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
Ptr<CannyEdgeDetector> cv::cuda::createCannyEdgeDetector(double, double, int, bool) { throw_no_cuda(); return Ptr<CannyEdgeDetector>(); }
#else /* !defined (HAVE_CUDA) */
namespace canny
{
void calcMagnitude(PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzi dx, PtrStepSzi dy, PtrStepSzf mag, bool L2Grad, cudaStream_t stream);
void calcMagnitude(PtrStepSzi dx, PtrStepSzi dy, PtrStepSzf mag, bool L2Grad, cudaStream_t stream);
void calcMap(PtrStepSzi dx, PtrStepSzi dy, PtrStepSzf mag, PtrStepSzi map, float low_thresh, float high_thresh, cudaStream_t stream);
void edgesHysteresisLocal(PtrStepSzi map, short2* st1, int* d_counter, cudaStream_t stream);
void edgesHysteresisGlobal(PtrStepSzi map, short2* st1, short2* st2, int* d_counter, cudaStream_t stream);
void getEdges(PtrStepSzi map, PtrStepSzb dst, cudaStream_t stream);
}
namespace
{
class CannyImpl : public CannyEdgeDetector
{
public:
CannyImpl(double low_thresh, double high_thresh, int apperture_size, bool L2gradient) :
low_thresh_(low_thresh), high_thresh_(high_thresh), apperture_size_(apperture_size), L2gradient_(L2gradient)
{
old_apperture_size_ = -1;
d_counter = NULL;
}
void detect(InputArray image, OutputArray edges, Stream& stream);
void detect(InputArray dx, InputArray dy, OutputArray edges, Stream& stream);
void setLowThreshold(double low_thresh) { low_thresh_ = low_thresh; }
double getLowThreshold() const { return low_thresh_; }
void setHighThreshold(double high_thresh) { high_thresh_ = high_thresh; }
double getHighThreshold() const { return high_thresh_; }
void setAppertureSize(int apperture_size) { apperture_size_ = apperture_size; }
int getAppertureSize() const { return apperture_size_; }
void setL2Gradient(bool L2gradient) { L2gradient_ = L2gradient; }
bool getL2Gradient() const { return L2gradient_; }
void write(FileStorage& fs) const
{
writeFormat(fs);
fs << "name" << "Canny_CUDA"
<< "low_thresh" << low_thresh_
<< "high_thresh" << high_thresh_
<< "apperture_size" << apperture_size_
<< "L2gradient" << L2gradient_;
}
void read(const FileNode& fn)
{
CV_Assert( String(fn["name"]) == "Canny_CUDA" );
low_thresh_ = (double)fn["low_thresh"];
high_thresh_ = (double)fn["high_thresh"];
apperture_size_ = (int)fn["apperture_size"];
L2gradient_ = (int)fn["L2gradient"] != 0;
}
private:
void createBuf(Size image_size);
void CannyCaller(GpuMat& edges, Stream& stream);
double low_thresh_;
double high_thresh_;
int apperture_size_;
bool L2gradient_;
GpuMat dx_, dy_;
GpuMat mag_;
GpuMat map_;
GpuMat st1_, st2_;
#ifdef HAVE_OPENCV_CUDAFILTERS
Ptr<Filter> filterDX_, filterDY_;
#endif
int old_apperture_size_;
int *d_counter;
};
void CannyImpl::detect(InputArray _image, OutputArray _edges, Stream& stream)
{
GpuMat image = _image.getGpuMat();
CV_Assert( image.type() == CV_8UC1 );
CV_Assert( deviceSupports(SHARED_ATOMICS) );
if (low_thresh_ > high_thresh_)
std::swap(low_thresh_, high_thresh_);
createBuf(image.size());
_edges.create(image.size(), CV_8UC1);
GpuMat edges = _edges.getGpuMat();
if (apperture_size_ == 3)
{
Size wholeSize;
Point ofs;
image.locateROI(wholeSize, ofs);
GpuMat srcWhole(wholeSize, image.type(), image.datastart, image.step);
canny::calcMagnitude(srcWhole, ofs.x, ofs.y, dx_, dy_, mag_, L2gradient_, StreamAccessor::getStream(stream));
}
else
{
#ifndef HAVE_OPENCV_CUDAFILTERS
throw_no_cuda();
#else
filterDX_->apply(image, dx_, stream);
filterDY_->apply(image, dy_, stream);
canny::calcMagnitude(dx_, dy_, mag_, L2gradient_, StreamAccessor::getStream(stream));
#endif
}
CannyCaller(edges, stream);
}
void CannyImpl::detect(InputArray _dx, InputArray _dy, OutputArray _edges, Stream& stream)
{
GpuMat dx = _dx.getGpuMat();
GpuMat dy = _dy.getGpuMat();
CV_Assert( dx.type() == CV_32SC1 );
CV_Assert( dy.type() == dx.type() && dy.size() == dx.size() );
CV_Assert( deviceSupports(SHARED_ATOMICS) );
dx.copyTo(dx_, stream);
dy.copyTo(dy_, stream);
if (low_thresh_ > high_thresh_)
std::swap(low_thresh_, high_thresh_);
createBuf(dx.size());
_edges.create(dx.size(), CV_8UC1);
GpuMat edges = _edges.getGpuMat();
canny::calcMagnitude(dx_, dy_, mag_, L2gradient_, StreamAccessor::getStream(stream));
CannyCaller(edges, stream);
}
void CannyImpl::createBuf(Size image_size)
{
CV_Assert(image_size.width < std::numeric_limits<short>::max() && image_size.height < std::numeric_limits<short>::max());
ensureSizeIsEnough(image_size, CV_32SC1, dx_);
ensureSizeIsEnough(image_size, CV_32SC1, dy_);
#ifdef HAVE_OPENCV_CUDAFILTERS
if (apperture_size_ != 3 && apperture_size_ != old_apperture_size_)
{
filterDX_ = cuda::createDerivFilter(CV_8UC1, CV_32S, 1, 0, apperture_size_, false, 1, BORDER_REPLICATE);
filterDY_ = cuda::createDerivFilter(CV_8UC1, CV_32S, 0, 1, apperture_size_, false, 1, BORDER_REPLICATE);
old_apperture_size_ = apperture_size_;
}
#endif
ensureSizeIsEnough(image_size, CV_32FC1, mag_);
ensureSizeIsEnough(image_size, CV_32SC1, map_);
ensureSizeIsEnough(1, image_size.area(), CV_16SC2, st1_);
ensureSizeIsEnough(1, image_size.area(), CV_16SC2, st2_);
}
void CannyImpl::CannyCaller(GpuMat& edges, Stream& stream)
{
map_.setTo(Scalar::all(0), stream);
canny::calcMap(dx_, dy_, mag_, map_, static_cast<float>(low_thresh_), static_cast<float>(high_thresh_), StreamAccessor::getStream(stream));
cudaSafeCall( cudaMalloc(&d_counter, sizeof(int)) );
canny::edgesHysteresisLocal(map_, st1_.ptr<short2>(), d_counter, StreamAccessor::getStream(stream));
canny::edgesHysteresisGlobal(map_, st1_.ptr<short2>(), st2_.ptr<short2>(), d_counter, StreamAccessor::getStream(stream));
cudaSafeCall( cudaFree(d_counter) );
canny::getEdges(map_, edges, StreamAccessor::getStream(stream));
}
}
Ptr<CannyEdgeDetector> cv::cuda::createCannyEdgeDetector(double low_thresh, double high_thresh, int apperture_size, bool L2gradient)
{
return makePtr<CannyImpl>(low_thresh, high_thresh, apperture_size, L2gradient);
}
#endif /* !defined (HAVE_CUDA) */
| 37.45122
| 147
| 0.665907
|
m000
|
b4b5677689023262edb879835939bf894921c25c
| 181
|
cpp
|
C++
|
Geometry/Translate.cpp
|
carlaMorral/raytracing-f01-1
|
e11e23e66623cdf11fb7058b2e732e6107cd0639
|
[
"Apache-2.0"
] | 1
|
2022-03-23T14:16:00.000Z
|
2022-03-23T14:16:00.000Z
|
Geometry/Translate.cpp
|
GiVD2020/raytracing-f01
|
e11e23e66623cdf11fb7058b2e732e6107cd0639
|
[
"Apache-2.0"
] | null | null | null |
Geometry/Translate.cpp
|
GiVD2020/raytracing-f01
|
e11e23e66623cdf11fb7058b2e732e6107cd0639
|
[
"Apache-2.0"
] | 2
|
2021-05-28T09:56:27.000Z
|
2022-03-30T20:27:15.000Z
|
#include "Translate.h"
TranslateTG::TranslateTG(glm::vec3 trasl): traslation(trasl)
{
matTG = glm::translate(glm::mat4(1.0f), traslation);
}
TranslateTG::~TranslateTG()
{
}
| 13.923077
| 60
| 0.690608
|
carlaMorral
|
b4b5c19bf5c41a8c128ce3c3e897f6347a85a032
| 16,116
|
cpp
|
C++
|
src/xray/render/base/sources/transform_controls_renderer.cpp
|
ixray-team/ixray-2.0
|
85c3a544175842323fc82f42efd96c66f0fc5abb
|
[
"Linux-OpenIB"
] | 3
|
2021-10-30T09:36:14.000Z
|
2022-03-26T17:00:06.000Z
|
src/xray/render/base/sources/transform_controls_renderer.cpp
|
acidicMercury8/ixray-2.0
|
85c3a544175842323fc82f42efd96c66f0fc5abb
|
[
"Linux-OpenIB"
] | null | null | null |
src/xray/render/base/sources/transform_controls_renderer.cpp
|
acidicMercury8/ixray-2.0
|
85c3a544175842323fc82f42efd96c66f0fc5abb
|
[
"Linux-OpenIB"
] | 1
|
2022-03-26T17:00:08.000Z
|
2022-03-26T17:00:08.000Z
|
////////////////////////////////////////////////////////////////////////////
// Created : 27.01.2009
// Author : Armen Abroyan
////////////////////////////////////////////////////////////////////////////
#include "pch.h"
#include "transform_controls_renderer.h"
#include <xray/render/base/editor_renderer.h>
#include <xray/render/base/platform.h>
#include <xray/render/base/detail_world.h>
#include "debug_renderer.h"
using xray::float3;
using xray::float4x4;
using xray::render::base::editor::detail::transform_control_base;
using xray::render::base::editor::detail::translation_control;
using xray::render::base::editor::detail::scaling_control;
using xray::render::base::editor::detail::rotation_control;
transform_control_base::transform_control_base ( xray::render::base::debug::renderer& helper_renderer ):
m_helper_renderer ( helper_renderer ),
m_x_axis_color ( math::color_xrgb( 255, 0, 0) ),
m_y_axis_color ( math::color_xrgb( 0, 255, 0) ),
m_z_axis_color ( math::color_xrgb( 255, 255, 0) ),
m_center_color ( math::color_xrgb( 255, 255, 255) )
{
(void) m_transform.identity();
}
transform_control_base::~transform_control_base ( )
{
}
void transform_control_base::set_transform ( const float4x4& transform)
{
m_transform = transform;
}
const float4x4& transform_control_base::get_transform ( )
{
return m_transform;
}
void transform_control_base::set_view_matrix ( const float4x4& transform )
{
m_view = transform;
}
float4x4 transform_control_base::calculate_fixed_size_transform ( )
{
float4x4 result;
float3 start_point ( 0, 0, 0 );
start_point = m_transform.transform_position( start_point );
float3 distance = (float3( m_view.c.x, m_view.c.y, m_view.c.z)-start_point);
result = m_transform*create_translation( (distance.magnitude()-20)*distance.normalize());
return result;
}
translation_control::translation_control ( xray::render::base::debug::renderer& helper_renderer ):
transform_control_base( helper_renderer),
m_arrow_size ( 5.f ),
m_arrow_head_length ( 0.4f ),
m_arrow_head_radius ( 0.15f ),
m_plane_move_mode ( enum_move_plane_camrea )
{
}
translation_control::~translation_control ( )
{
}
void translation_control::draw ( )
{
float4x4 transform = calculate_fixed_size_transform ( );
// Drawing translation control
float3 start_point ( 0, 0, 0 );
start_point = transform.transform_position( start_point );
// Drawing axes' arrow lines
float3 end_point = transform.transform_position( float3( m_arrow_size, 0, 0 ));
m_helper_renderer.draw_line ( start_point, end_point, m_x_axis_color);
end_point = transform.transform_position( float3( 0, m_arrow_size, 0 ));
m_helper_renderer.draw_line ( start_point, end_point, m_y_axis_color);
end_point = transform.transform_position( float3( 0, 0, -m_arrow_size ));
m_helper_renderer.draw_line ( start_point, end_point, m_z_axis_color);
// Drawing arrows heads as cones
//
// Drawing y axis cone.
float4x4 cone_transform = create_translation( float3 ( 0, m_arrow_size-m_arrow_head_length, 0 ));
m_helper_renderer.draw_cone_solid ( cone_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_length, m_arrow_head_radius ),
m_y_axis_color);
// Drawing x axis cone.
cone_transform = cone_transform*create_rotation( float3( 0, 0, math::deg2rad(-90)));
m_helper_renderer.draw_cone_solid ( cone_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_length, m_arrow_head_radius ),
m_x_axis_color);
// Drawing z axis cone.
cone_transform = cone_transform*create_rotation( float3( 0, math::deg2rad(90), 0 ));
m_helper_renderer.draw_cone_solid ( cone_transform*transform,
float3( m_arrow_head_radius,
m_arrow_head_length, m_arrow_head_radius ),
m_z_axis_color);
float4x4 rotate_to_view;
if( m_plane_move_mode == enum_move_plane_camrea )
{
float3 vector_to_object = ( float3( m_view.c.x, m_view.c.y, m_view.c.z )-start_point ).normalize( );
rotate_to_view = create_rotation( m_view.i.xyz(), vector_to_object );
}
else if ( m_plane_move_mode == enum_move_plane_xy )
{
rotate_to_view = math::create_rotation_x( math::deg2rad(90) );
}
else if ( m_plane_move_mode == enum_move_plane_yz )
{
rotate_to_view = math::create_rotation_z( math::deg2rad(90) );
}
else if ( m_plane_move_mode == enum_move_plane_zx )
{
rotate_to_view = rotate_to_view.identity();
}
rotate_to_view = create_translation( float3( 0, 1, 0 ))*rotate_to_view;
m_helper_renderer.draw_rectangle ( rotate_to_view*transform,
float3( 2*m_arrow_head_radius, 2*m_arrow_head_radius, 2*m_arrow_head_radius ),
m_center_color );
}
void translation_control::draw_collision_object ( )
{
float4x4 transform = calculate_fixed_size_transform ( );
// Drawing axes' cylinders.
float4x4 cylinder_transform = create_translation( float3( 0, (m_arrow_size-m_arrow_head_length)/2, 0) );
// Drawing y axis.
m_helper_renderer.draw_cylinder_solid( cylinder_transform*transform,
float3( m_arrow_head_radius/2, (m_arrow_size-m_arrow_head_length)/2, m_arrow_head_radius/2),
m_y_axis_color );
// Drawing x axis.
cylinder_transform = cylinder_transform*create_rotation( float3( 0, 0, math::deg2rad(-90)));
m_helper_renderer.draw_cylinder_solid( cylinder_transform*transform,
float3( m_arrow_head_radius/2, (m_arrow_size-m_arrow_head_length)/2, m_arrow_head_radius/2),
m_x_axis_color );
// Drawing z axis.
cylinder_transform = cylinder_transform*create_rotation( float3( 0, math::deg2rad(90), 0));
m_helper_renderer.draw_cylinder_solid( cylinder_transform*transform,
float3( m_arrow_head_radius/2, (m_arrow_size-m_arrow_head_length)/2, m_arrow_head_radius/2),
m_z_axis_color );
// Drawing arrows heads as cones
//
// Drawing y axis cone.
float4x4 cone_transform = create_translation( float3 ( 0, m_arrow_size-m_arrow_head_length, 0 ));
m_helper_renderer.draw_cone_solid ( cone_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_length, m_arrow_head_radius ),
m_y_axis_color);
// Drawing x axis cone.
cone_transform = cone_transform*create_rotation( float3( 0, 0, math::deg2rad(-90)));
m_helper_renderer.draw_cone_solid ( cone_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_length, m_arrow_head_radius ),
m_x_axis_color);
// Drawing z axis cone.
cone_transform = cone_transform*create_rotation( float3( 0, math::deg2rad(90), 0 ));
m_helper_renderer.draw_cone_solid ( cone_transform*transform,
float3( m_arrow_head_radius,
m_arrow_head_length, m_arrow_head_radius ),
m_z_axis_color);
const float3 start_point = transform.transform_position( float3( 0, 0, 0 ) );
float4x4 rotate_to_view;
if( m_plane_move_mode == enum_move_plane_camrea )
{
float3 vector_to_object = ( float3( m_view.c.x, m_view.c.y, m_view.c.z )-start_point ).normalize( );
rotate_to_view = create_rotation( m_view.i.xyz(), vector_to_object );
}
else if ( m_plane_move_mode == enum_move_plane_xy )
{
rotate_to_view = math::create_rotation_x( math::deg2rad(90) );
}
else if ( m_plane_move_mode == enum_move_plane_yz )
{
rotate_to_view = math::create_rotation_z( math::deg2rad(90) );
}
else if ( m_plane_move_mode == enum_move_plane_zx )
{
rotate_to_view = rotate_to_view.identity();
}
rotate_to_view = create_translation( float3( 0, 1, 0 ))*rotate_to_view;
m_helper_renderer.draw_rectangle_solid( rotate_to_view*transform,
float3( 2*m_arrow_head_radius, 2*m_arrow_head_radius, 2*m_arrow_head_radius ),
m_center_color );
}
scaling_control::scaling_control ( xray::render::base::debug::renderer& helper_renderer ):
transform_control_base( helper_renderer),
m_arrow_size ( 5.f ),
m_arrow_head_radius ( 0.15f )
{
}
scaling_control::~scaling_control ( )
{
}
void scaling_control::draw ( )
{
float4x4 transform = calculate_fixed_size_transform ( );
// Drawing scale control
float3 start_point ( 0, 0, 0 );
start_point = transform.transform_position( start_point );
// Drawing axes'lines
float3 end_point = transform.transform_position( float3( m_arrow_size, 0, 0 ));
m_helper_renderer.draw_line ( start_point, end_point, m_x_axis_color);
end_point = transform.transform_position( float3( 0, m_arrow_size, 0 ));
m_helper_renderer.draw_line ( start_point, end_point, m_y_axis_color);
end_point = transform.transform_position( float3( 0, 0, -m_arrow_size ));
m_helper_renderer.draw_line ( start_point, end_point, m_z_axis_color);
// Drawing arrows heads as cubes
//
// Drawing z axis cone.
float4x4 cube_transform = create_translation( float3 ( m_arrow_size-m_arrow_head_radius, 0, 0 ));
m_helper_renderer.draw_cube_solid ( cube_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_radius, m_arrow_head_radius),
m_x_axis_color );
// Drawing y axis cone.
cube_transform = create_translation ( float3 ( 0, m_arrow_size-m_arrow_head_radius, 0 ));
m_helper_renderer.draw_cube_solid ( cube_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_radius, m_arrow_head_radius),
m_y_axis_color );
// Drawing y axis cone.
cube_transform = create_translation ( float3 ( 0, 0, -(m_arrow_size-m_arrow_head_radius) ));
m_helper_renderer.draw_cube_solid ( cube_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_radius, m_arrow_head_radius),
m_z_axis_color );
m_helper_renderer.draw_cube_solid ( transform,
float3( m_arrow_head_radius, m_arrow_head_radius, m_arrow_head_radius),
m_center_color );
}
void scaling_control::draw_collision_object ( )
{
float4x4 transform = calculate_fixed_size_transform ( );
// Drawing axes' cylinders.
float4x4 cylinder_transform = create_translation( float3( 0, (m_arrow_size-m_arrow_head_radius)/2, 0) );
// Drawing y axis.
m_helper_renderer.draw_cylinder_solid( cylinder_transform*transform,
float3( m_arrow_head_radius/2, (m_arrow_size)/2-m_arrow_head_radius, m_arrow_head_radius/2),
m_y_axis_color );
// Drawing x axis.
cylinder_transform = cylinder_transform*create_rotation( float3( 0, 0, math::deg2rad(-90)));
m_helper_renderer.draw_cylinder_solid( cylinder_transform*transform,
float3( m_arrow_head_radius/2, (m_arrow_size)/2-m_arrow_head_radius, m_arrow_head_radius/2),
m_x_axis_color );
// Drawing z axis.
cylinder_transform = cylinder_transform*create_rotation( float3( 0, math::deg2rad(90), 0));
m_helper_renderer.draw_cylinder_solid( cylinder_transform*transform,
float3( m_arrow_head_radius/2, (m_arrow_size)/2-m_arrow_head_radius, m_arrow_head_radius/2),
m_z_axis_color );
// Drawing arrows heads as cubes
//
// Drawing z axis cone.
float4x4 cube_transform = create_translation( float3 ( m_arrow_size-m_arrow_head_radius, 0, 0 ));
m_helper_renderer.draw_cube_solid ( cube_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_radius, m_arrow_head_radius),
m_x_axis_color );
// Drawing y axis cone.
cube_transform = create_translation ( float3 ( 0, m_arrow_size-m_arrow_head_radius, 0 ));
m_helper_renderer.draw_cube_solid ( cube_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_radius, m_arrow_head_radius),
m_y_axis_color );
// Drawing y axis cone.
cube_transform = create_translation ( float3 ( 0, 0, -(m_arrow_size-m_arrow_head_radius) ));
m_helper_renderer.draw_cube_solid ( cube_transform*transform,
float3( m_arrow_head_radius, m_arrow_head_radius, m_arrow_head_radius),
m_z_axis_color );
m_helper_renderer.draw_cube_solid ( transform,
float3( m_arrow_head_radius, m_arrow_head_radius, m_arrow_head_radius),
m_center_color );
}
rotation_control::rotation_control ( xray::render::base::debug::renderer& helper_renderer ):
super ( helper_renderer),
m_radius( 4.5 ),
m_outer_radius(5),
m_inner_radius(4.0)
{
m_helper_renderer.create_torus ( m_torus_vertexes, m_torus_indexes, m_radius, 0.25, 32, 32, m_y_axis_color);
m_helper_renderer.create_torus ( m_torus_outer_vertexes, m_torus_outer_indexes, m_outer_radius, 0.25, 32, 32, m_y_axis_color);
}
rotation_control::~rotation_control ( )
{
}
void rotation_control::draw ( )
{
float4x4 transform = calculate_fixed_size_transform ( );
// Drawing scale control
float3 start_point( 0, 0, 0 );
start_point = transform.transform_position( start_point );
// Drawing axes'lines
float3 end_point = transform.transform_position( float3( 10, 0, 0 ));
float4x4 ellipse_transform = create_scale( float3( m_radius, m_radius, m_radius));
m_helper_renderer.draw_ellipse ( ellipse_transform*transform, m_y_axis_color );
ellipse_transform = ellipse_transform*create_rotation( float3 ( 0, 0, math::deg2rad(-90)));
m_helper_renderer.draw_ellipse ( ellipse_transform*transform, m_x_axis_color );
ellipse_transform = ellipse_transform*create_rotation( float3 ( 0, math::deg2rad(90), 0));
m_helper_renderer.draw_ellipse ( ellipse_transform*transform, m_z_axis_color );
start_point = float3( m_view.c.x, m_view.c.y, m_view.c.z)-start_point;
float4x4 rotate_to_view = create_rotation( m_view.i.xyz(), (start_point).normalize( ));
ellipse_transform = create_scale( float3( m_outer_radius, 1, m_outer_radius));
ellipse_transform = ellipse_transform*rotate_to_view;
m_helper_renderer.draw_ellipse ( ellipse_transform*transform, math::color_xrgb( 255, 255, 255) );
ellipse_transform = create_scale( float3( m_inner_radius, 1, m_inner_radius));
ellipse_transform = ellipse_transform*rotate_to_view;
m_helper_renderer.draw_ellipse ( ellipse_transform*transform, math::color_xrgb( 0, 0, 0) );
}
void rotation_control::draw_collision_object ( )
{
float4x4 transform = calculate_fixed_size_transform ( );
// m_helper_renderer.draw_triangles( m_torus_vertexes, m_torus_indexes);
// return;
m_working_vertexes.resize( m_torus_vertexes.size() );
// Draw y torus
for( u32 i = 0; i< m_torus_vertexes.size(); ++i)
{
m_working_vertexes[i].position = transform.transform_position( m_torus_vertexes[i].position);
m_working_vertexes[i].color = m_y_axis_color;
}
m_helper_renderer.draw_triangles( m_working_vertexes, m_torus_indexes);
// Draw x torus
float4x4 temp_transform = create_rotation( float3( 0, 0, math::deg2rad(-90) ) )*transform;
for( u32 i = 0; i< m_torus_vertexes.size(); ++i)
{
m_working_vertexes[i].position = temp_transform.transform_position( m_torus_vertexes[i].position);
m_working_vertexes[i].color = m_x_axis_color;
}
m_helper_renderer.draw_triangles( m_working_vertexes, m_torus_indexes);
// Draw z torus
temp_transform = create_rotation( float3( math::deg2rad(90), 0, 0 ) )*transform;
for( u32 i = 0; i< m_torus_vertexes.size(); ++i)
{
m_working_vertexes[i].position = temp_transform.transform_position( m_torus_vertexes[i].position);
m_working_vertexes[i].color = m_z_axis_color;
}
m_helper_renderer.draw_triangles( m_working_vertexes, m_torus_indexes);
// Drawing scale control
float3 start_point( 0, 0, 0 );
start_point = transform.transform_position( start_point );
start_point = float3( m_view.c.x, m_view.c.y, m_view.c.z)-start_point;
float4x4 rotate_to_view = create_rotation( m_view.i.xyz(), (start_point).normalize( ));
rotate_to_view = rotate_to_view*transform;
for( u32 i = 0; i< m_torus_outer_vertexes.size(); ++i)
{
m_working_vertexes[i].position = rotate_to_view.transform_position( m_torus_outer_vertexes[i].position);
m_working_vertexes[i].color = math::color_xrgb( 255, 255, 255);
}
m_helper_renderer.draw_triangles( m_working_vertexes, m_torus_outer_indexes);
m_helper_renderer.draw_ellipsoid_solid( transform, float3( m_inner_radius, m_inner_radius, m_inner_radius), math::color_xrgb( 0, 0, 0) );
}
| 36.963303
| 139
| 0.734053
|
ixray-team
|
b4b8d4dc0192a34371d7c04549db03a3b22a04d1
| 32,516
|
cpp
|
C++
|
MoravaEngine/src/H2M/Platform/Vulkan/VulkanShaderH2M.cpp
|
imgui-works/MoravaEngine_opengl_vulkan_2d_3d_game_engine
|
b8e6ee3c3c890e9b8cf5de7bcb564b32f6767b6b
|
[
"Apache-2.0"
] | null | null | null |
MoravaEngine/src/H2M/Platform/Vulkan/VulkanShaderH2M.cpp
|
imgui-works/MoravaEngine_opengl_vulkan_2d_3d_game_engine
|
b8e6ee3c3c890e9b8cf5de7bcb564b32f6767b6b
|
[
"Apache-2.0"
] | null | null | null |
MoravaEngine/src/H2M/Platform/Vulkan/VulkanShaderH2M.cpp
|
imgui-works/MoravaEngine_opengl_vulkan_2d_3d_game_engine
|
b8e6ee3c3c890e9b8cf5de7bcb564b32f6767b6b
|
[
"Apache-2.0"
] | 1
|
2022-01-05T03:51:02.000Z
|
2022-01-05T03:51:02.000Z
|
/**
* @package H2M
* @author Yan Chernikov (TheCherno)
* @licence Apache License 2.0
*/
#include "VulkanShaderH2M.h"
#include "H2M/Core/AssertH2M.h"
#include "H2M/Platform/Vulkan/VulkanContextH2M.h"
#include "H2M/Platform/Vulkan/VulkanTextureH2M.h"
#include "H2M/Renderer/RendererH2M.h"
#include "Core/Log.h"
#include <shaderc/shaderc.hpp>
#include <spirv_glsl.hpp>
#include <filesystem>
namespace H2M
{
static ShaderUniformTypeH2M SPIRTypeToShaderUniformType(spirv_cross::SPIRType type)
{
switch (type.basetype)
{
case spirv_cross::SPIRType::Boolean: return ShaderUniformTypeH2M::Bool;
case spirv_cross::SPIRType::Int: return ShaderUniformTypeH2M::Int;
case spirv_cross::SPIRType::Float:
if (type.vecsize == 1) return ShaderUniformTypeH2M::Float;
if (type.vecsize == 2) return ShaderUniformTypeH2M::Vec2;
if (type.vecsize == 3) return ShaderUniformTypeH2M::Vec3;
if (type.vecsize == 4) return ShaderUniformTypeH2M::Vec4;
if (type.columns == 3) return ShaderUniformTypeH2M::Mat3;
if (type.columns == 4) return ShaderUniformTypeH2M::Mat4;
break;
}
H2M_CORE_ASSERT(false, "Unknown type!");
return ShaderUniformTypeH2M::None;
}
static std::unordered_map<uint32_t, std::unordered_map<uint32_t, VulkanShaderH2M::UniformBufferH2M*>> s_UniformBuffers; // set -> binding point -> buffer
// Very temporary attribute in Vulkan Week Day 5 Part 1
// Hazel::Ref<Hazel::HazelTexture2D> VulkanShaderH2M::s_AlbedoTexture;
// Hazel::Ref<Hazel::HazelTexture2D> VulkanShaderH2M::s_NormalTexture;
VulkanShaderH2M::VulkanShaderH2M(const std::string& path, bool forceCompile)
: m_AssetPath(path)
{
// TODO: This should be more "general"
size_t found = path.find_last_of("/\\");
m_Name = found != std::string::npos ? path.substr(found + 1) : path;
found = m_Name.find_last_of(".");
m_Name = found != std::string::npos ? m_Name.substr(0, found) : m_Name;
Reload();
}
VulkanShaderH2M::~VulkanShaderH2M() {}
static std::string ReadShaderFromFile(const std::string& filepath)
{
std::string result;
std::ifstream in(filepath, std::ios::in | std::ios::binary);
if (in)
{
in.seekg(0, std::ios::end);
result.resize(in.tellg());
in.seekg(0, std::ios::beg);
in.read(&result[0], result.size());
}
else
{
H2M_CORE_ASSERT(false, "Could not load shader!");
}
in.close();
return result;
}
void VulkanShaderH2M::Reload(bool forceCompile)
{
// Ref<VulkanShader> instance = this;
// HazelRenderer::Submit([instance]() mutable
// {
// });
{
// Vertex and Fragment for now
std::string source = ReadShaderFromFile(m_AssetPath);
m_ShaderSource = PreProcess(source);
std::unordered_map<VkShaderStageFlagBits, std::vector<uint32_t>> shaderData;
CompileOrGetVulkanBinary(shaderData, forceCompile);
LoadAndCreateShaders(shaderData);
ReflectAllShaderStages(shaderData);
CreateDescriptors();
}
}
void VulkanShaderH2M::LoadAndCreateShaders(const std::unordered_map<VkShaderStageFlagBits, std::vector<uint32_t>>& shaderData)
{
VkDevice device = VulkanContextH2M::GetCurrentDevice()->GetVulkanDevice();
m_PipelineShaderStageCreateInfos.clear();
for (auto [stage, data] : shaderData)
{
H2M_CORE_ASSERT(data.size());
// Create a new shader module that will be used for pipeline creation
VkShaderModuleCreateInfo moduleCreateInfo{};
moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
moduleCreateInfo.codeSize = data.size() * sizeof(uint32_t);
moduleCreateInfo.pCode = data.data();
VkShaderModule shaderModule;
VK_CHECK_RESULT_H2M(vkCreateShaderModule(device, &moduleCreateInfo, NULL, &shaderModule));
VkPipelineShaderStageCreateInfo& shaderStage = m_PipelineShaderStageCreateInfos.emplace_back();
shaderStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStage.stage = stage;
shaderStage.module = shaderModule;
shaderStage.pName = "main";
}
}
void VulkanShaderH2M::ReflectAllShaderStages(const std::unordered_map<VkShaderStageFlagBits, std::vector<uint32_t>>& shaderData)
{
for (auto [stage, data] : shaderData)
{
Reflect(stage, data);
}
}
void VulkanShaderH2M::Reflect(VkShaderStageFlagBits shaderStage, const std::vector<uint32_t>& shaderData)
{
VkDevice device = VulkanContextH2M::GetCurrentDevice()->GetVulkanDevice();
std::string shaderStageName = "UNKNOWN";
switch (shaderStage)
{
case VK_SHADER_STAGE_VERTEX_BIT: shaderStageName = "VERTEX"; break;
case VK_SHADER_STAGE_FRAGMENT_BIT: shaderStageName = "FRAGMENT"; break;
case VK_SHADER_STAGE_COMPUTE_BIT: shaderStageName = "COMPUTE"; break;
}
MORAVA_CORE_TRACE("==========================");
MORAVA_CORE_TRACE(" Vulkan Shader Reflection (Stage: " + shaderStageName + ")");
MORAVA_CORE_TRACE(" {0}", m_AssetPath);
MORAVA_CORE_TRACE("==========================");
// Vertex Shader
spirv_cross::Compiler compiler(shaderData);
spirv_cross::ShaderResources resources = compiler.get_shader_resources();
MORAVA_CORE_TRACE("Uniform Buffers:");
for (const spirv_cross::Resource& resource : resources.uniform_buffers)
{
const auto& name = resource.name;
auto& bufferType = compiler.get_type(resource.base_type_id);
int memberCount = static_cast<uint32_t>(bufferType.member_types.size());
uint32_t binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
uint32_t descriptorSet = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
uint32_t size = static_cast<uint32_t>(compiler.get_declared_struct_size(bufferType));
ShaderDescriptorSetH2M& shaderDescriptorSet = m_ShaderDescriptorSets[descriptorSet];
H2M_CORE_ASSERT(shaderDescriptorSet.UniformBuffers.find(binding) == shaderDescriptorSet.UniformBuffers.end());
// UniformBuffer& buffer = shaderDescriptorSet.UniformBuffers[bindingPoint];
UniformBufferH2M& buffer = shaderDescriptorSet.UniformBuffers[binding];
// UniformBuffer buffer;
buffer.BindingPoint = binding;
buffer.DescriptorSet = descriptorSet;
buffer.Size = size;
// AllocateUniformBuffer(buffer);
buffer.Name = name;
buffer.ShaderStage = shaderStage;
// m_UniformBuffers.insert(std::pair(bindingPoint, buffer));
MORAVA_CORE_TRACE(" {0} ({1}, {2})", name, descriptorSet, binding);
MORAVA_CORE_TRACE(" Name: {0}", name);
MORAVA_CORE_TRACE(" Member Count: {0}", memberCount);
MORAVA_CORE_TRACE(" Descriptor Set: {0}", descriptorSet);
MORAVA_CORE_TRACE(" Binding Point: {0}", binding);
MORAVA_CORE_TRACE(" Size: {0}", size);
MORAVA_CORE_TRACE("--------------------------");
}
MORAVA_CORE_TRACE("Push Constant Buffers:");
for (const auto& resource : resources.push_constant_buffers)
{
const auto& bufferName = resource.name;
auto& bufferType = compiler.get_type(resource.base_type_id);
auto bufferSize = compiler.get_declared_struct_size(bufferType);
int memberCount = static_cast<int>(bufferType.member_types.size());
uint32_t bufferOffset = 0;
if (m_PushConstantRanges.size())
{
bufferOffset = m_PushConstantRanges.back().Offset + m_PushConstantRanges.back().Size;
}
auto& pushConstantRange = m_PushConstantRanges.emplace_back();
pushConstantRange.ShaderStage = shaderStage;
pushConstantRange.Size = static_cast<uint32_t>(bufferSize);
pushConstantRange.Offset = bufferOffset;
// Skip empty push constant buffers - these are for the renderer only
if (bufferName.empty())
{
continue;
}
ShaderBufferH2M& buffer = m_Buffers[bufferName];
buffer.Name = bufferName;
buffer.Size = static_cast<uint32_t>(bufferSize - bufferOffset);
// MORAVA_CORE_TRACE(" {0} ({1}, {2})", name, descriptorSet, binding);
MORAVA_CORE_TRACE(" Name: {0}", bufferName);
MORAVA_CORE_TRACE(" Member Count: {0}", memberCount);
// MORAVA_CORE_TRACE(" Binding Point: {0}", bindingPoint);
MORAVA_CORE_TRACE(" Buffer size: {0}", bufferSize);
MORAVA_CORE_TRACE("--------------------------");
for (int i = 0; i < memberCount; i++)
{
auto type = compiler.get_type(bufferType.member_types[i]);
const auto& memberName = compiler.get_member_name(bufferType.self, i);
auto size = compiler.get_declared_struct_member_size(bufferType, i);
auto offset = compiler.type_struct_member_offset(bufferType, i) - bufferOffset;
std::string uniformName = bufferName + "." + memberName;
buffer.Uniforms[uniformName] = ShaderUniformH2M(uniformName, SPIRTypeToShaderUniformType(type), static_cast<uint32_t>(size), offset);
}
}
MORAVA_CORE_TRACE("Sampled Images:");
for (const auto& resource : resources.sampled_images)
{
const auto& name = resource.name;
auto& type = compiler.get_type(resource.base_type_id);
uint32_t binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
uint32_t descriptorSet = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
uint32_t dimension = type.image.dim;
ShaderDescriptorSetH2M& shaderDescriptorSet = m_ShaderDescriptorSets[descriptorSet];
H2M_CORE_ASSERT(shaderDescriptorSet.ImageSamplers.find(binding) == shaderDescriptorSet.ImageSamplers.end());
auto& imageSampler = shaderDescriptorSet.ImageSamplers[binding];
// ImageSampler imageSampler;
imageSampler.BindingPoint = binding;
imageSampler.DescriptorSet = descriptorSet;
imageSampler.Name = name;
imageSampler.ShaderStage = shaderStage;
// m_ImageSamplers.insert(std::pair(bindingPoint, imageSampler));
MORAVA_CORE_TRACE(" {0} ({1}, {2})", name, descriptorSet, binding);
MORAVA_CORE_TRACE(" Name: {0}", name);
// MORAVA_CORE_TRACE(" Member Count: {0}", memberCount);
MORAVA_CORE_TRACE(" Descriptor Set: {0}", descriptorSet);
MORAVA_CORE_TRACE(" Binding Point: {0}", binding);
// MORAVA_CORE_TRACE(" Size: {0}", size);
MORAVA_CORE_TRACE("--------------------------");
}
MORAVA_CORE_TRACE("Storage Images:");
for (const auto& resource : resources.storage_images)
{
const auto& name = resource.name;
auto& type = compiler.get_type(resource.base_type_id);
uint32_t binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
uint32_t descriptorSet = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
uint32_t dimension = type.image.dim;
ShaderDescriptorSetH2M& shaderDescriptorSet = m_ShaderDescriptorSets[descriptorSet];
H2M_CORE_ASSERT(shaderDescriptorSet.StorageImages.find(binding) == shaderDescriptorSet.StorageImages.end());
auto& imageSampler = shaderDescriptorSet.StorageImages[binding];
// ImageSampler imageSampler;
imageSampler.BindingPoint = binding;
imageSampler.DescriptorSet = descriptorSet;
imageSampler.Name = name;
imageSampler.ShaderStage = shaderStage;
// m_ImageSamplers.insert(std::pair(bindingPoint, imageSampler));
MORAVA_CORE_TRACE(" {0} ({1}, {2})", name, descriptorSet, binding);
MORAVA_CORE_TRACE(" Name: {0}", name);
// MORAVA_CORE_TRACE(" Member Count: {0}", memberCount);
MORAVA_CORE_TRACE(" Descriptor Set: {0}", descriptorSet);
MORAVA_CORE_TRACE(" Binding Point: {0}", binding);
// MORAVA_CORE_TRACE(" Size: {0}", size);
MORAVA_CORE_TRACE("--------------------------");
}
MORAVA_CORE_TRACE("==========================");
}
void VulkanShaderH2M::CreateDescriptors()
{
VkDevice device = VulkanContextH2M::GetCurrentDevice()->GetVulkanDevice();
//////////////////////////////////////////////////////////////////////
// Descriptor Pool
//////////////////////////////////////////////////////////////////////
// We need to tell the API the number of max. requested descriptors per type
m_TypeCounts.clear();
for (auto&& [set, shaderDescriptorSet] : m_ShaderDescriptorSets)
{
// m_TypeCounts.insert(std::make_pair(0, std::vector<VkDescriptorPoolSize>()));
if (shaderDescriptorSet.UniformBuffers.size())
{
VkDescriptorPoolSize& typeCount = m_TypeCounts[set].emplace_back();
typeCount.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
typeCount.descriptorCount = static_cast<uint32_t>(shaderDescriptorSet.UniformBuffers.size());
}
if (shaderDescriptorSet.ImageSamplers.size())
{
VkDescriptorPoolSize& typeCount = m_TypeCounts[set].emplace_back();
typeCount.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
typeCount.descriptorCount = static_cast<uint32_t>(shaderDescriptorSet.ImageSamplers.size());
}
if (shaderDescriptorSet.StorageImages.size())
{
VkDescriptorPoolSize& typeCount = m_TypeCounts[set].emplace_back();
typeCount.type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
typeCount.descriptorCount = static_cast<uint32_t>(shaderDescriptorSet.StorageImages.size());
}
#if 0
// TODO: Move this to the centralized renderer
// Create the global descriptor pool
// All descriptors used in this example are allocated from this pool
VkDescriptorPoolCreateInfo descriptorPoolInfo = {};
descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
// Once you bind a descriptor set and use it in a vkCmdDraw() function, you can no longer modify it unless you specify the
// descriptorPoolInfo.flags = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT;
descriptorPoolInfo.pNext = nullptr;
descriptorPoolInfo.poolSizeCount = (uint32_t)m_TypeCounts.at(set).size();
descriptorPoolInfo.pPoolSizes = m_TypeCounts.at(set).data();
descriptorPoolInfo.maxSets = 1;
VK_CHECK_RESULT_H2M(vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &m_DescriptorPool));
#endif
//////////////////////////////////////////////////////////////////////
// Descriptor Set Layout
//////////////////////////////////////////////////////////////////////
std::vector<VkDescriptorSetLayoutBinding> layoutBindings;
for (auto& [binding, uniformBuffer] : shaderDescriptorSet.UniformBuffers)
{
VkDescriptorSetLayoutBinding& layoutBinding = layoutBindings.emplace_back();
layoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
layoutBinding.descriptorCount = 1;
layoutBinding.stageFlags = uniformBuffer.ShaderStage;
layoutBinding.pImmutableSamplers = nullptr;
layoutBinding.binding = binding;
VkWriteDescriptorSet& set = shaderDescriptorSet.WriteDescriptorSets[uniformBuffer.Name];
set = {};
set.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
set.descriptorType = layoutBinding.descriptorType; // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
set.descriptorCount = 1;
set.dstBinding = layoutBinding.binding;
AllocateUniformBuffer(uniformBuffer);
}
for (auto& [binding, imageSampler] : shaderDescriptorSet.ImageSamplers)
{
VkDescriptorSetLayoutBinding& layoutBinding = layoutBindings.emplace_back();
layoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
layoutBinding.descriptorCount = 1;
layoutBinding.stageFlags = imageSampler.ShaderStage;
layoutBinding.pImmutableSamplers = nullptr;
layoutBinding.binding = binding;
H2M_CORE_ASSERT(shaderDescriptorSet.UniformBuffers.find(binding) == shaderDescriptorSet.UniformBuffers.end(), "Binding is already present in m_UniformBuffers!");
VkWriteDescriptorSet& set = shaderDescriptorSet.WriteDescriptorSets[imageSampler.Name];
set = {};
set.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
set.descriptorType = layoutBinding.descriptorType; // VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
set.descriptorCount = 1;
set.dstBinding = layoutBinding.binding;
}
for (auto& [binding, storageImage] : shaderDescriptorSet.StorageImages)
{
VkDescriptorSetLayoutBinding& layoutBinding = layoutBindings.emplace_back();
layoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
layoutBinding.descriptorCount = 1;
layoutBinding.stageFlags = storageImage.ShaderStage;
layoutBinding.pImmutableSamplers = nullptr;
// uint32_t binding = bindingAndSet & 0xffffffff;
// uint32_t descriptorSet = (bindingAndSet >> 32);
layoutBinding.binding = binding;
H2M_CORE_ASSERT(shaderDescriptorSet.UniformBuffers.find(binding) == shaderDescriptorSet.UniformBuffers.end(), "Binding is already present in m_UniformBuffers!");
H2M_CORE_ASSERT(shaderDescriptorSet.ImageSamplers.find(binding) == shaderDescriptorSet.ImageSamplers.end(), "Binding is already present in m_ImageSamplers!");
VkWriteDescriptorSet& set = shaderDescriptorSet.WriteDescriptorSets[storageImage.Name];
set = {};
set.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
set.descriptorType = layoutBinding.descriptorType; // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
set.descriptorCount = 1;
set.dstBinding = layoutBinding.binding;
// set.dstSet = descriptorSet;
}
VkDescriptorSetLayoutCreateInfo descriptorLayout = {};
descriptorLayout.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
descriptorLayout.pNext = nullptr;
descriptorLayout.bindingCount = static_cast<uint32_t>(layoutBindings.size());
descriptorLayout.pBindings = layoutBindings.data();
MORAVA_CORE_INFO("Creating descriptor set {0} with {1} ubos, {2} samplers and {3} storage images", set,
shaderDescriptorSet.UniformBuffers.size(),
shaderDescriptorSet.ImageSamplers.size(),
shaderDescriptorSet.StorageImages.size());
VK_CHECK_RESULT_H2M(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &m_DescriptorSetLayouts[set]));
}
}
void VulkanShaderH2M::AllocateUniformBuffer(UniformBufferH2M& dst)
{
VkDevice device = VulkanContextH2M::GetCurrentDevice()->GetVulkanDevice();
UniformBufferH2M& uniformBuffer = dst;
// Prepare and initialize an uniform buffer block containing shader uniforms
// Single uniforms like in OpenGL are no longer present in Vulkan. All Shader uniforms are passed via uniform buffer blocks
// Vertex shader uniform buffer block
VkBufferCreateInfo bufferInfo = {};
VkMemoryAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.pNext = nullptr;
allocInfo.allocationSize = 0;
allocInfo.memoryTypeIndex = 0;
bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bufferInfo.size = uniformBuffer.Size;
// This buffer will be used as an uniform buffer
bufferInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
VulkanAllocatorH2M allocator(std::string("UniformBuffer"));
// Create a new buffer
VK_CHECK_RESULT_H2M(vkCreateBuffer(device, &bufferInfo, nullptr, &uniformBuffer.Buffer));
VkMemoryRequirements memoryRequirements;
vkGetBufferMemoryRequirements(device, uniformBuffer.Buffer, &memoryRequirements);
allocInfo.allocationSize = memoryRequirements.size;
allocator.Allocate(memoryRequirements, &uniformBuffer.Memory, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
VK_CHECK_RESULT_H2M(vkBindBufferMemory(device, uniformBuffer.Buffer, uniformBuffer.Memory, 0));
// Store information in the uniform's descriptor that is used by the descriptor set
uniformBuffer.Descriptor.buffer = uniformBuffer.Buffer;
uniformBuffer.Descriptor.offset = 0;
uniformBuffer.Descriptor.range = uniformBuffer.Size;
}
// ShaderMaterialDescriptorSet VulkanShaderH2M::AllocateDescriptorSet(uint32_t set)
// {
// return ShaderMaterialDescriptorSet();
// }
VulkanShaderH2M::ShaderMaterialDescriptorSet VulkanShaderH2M::CreateDescriptorSets(uint32_t set)
{
ShaderMaterialDescriptorSet result;
VkDevice device = VulkanContextH2M::GetCurrentDevice()->GetVulkanDevice();
H2M_CORE_ASSERT(m_TypeCounts.find(set) != m_TypeCounts.end());
// TODO: Move this to the centralized renderer
VkDescriptorPoolCreateInfo descriptorPoolInfo = {};
descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
descriptorPoolInfo.pNext = nullptr;
descriptorPoolInfo.poolSizeCount = (uint32_t)m_TypeCounts.at(set).size();
descriptorPoolInfo.pPoolSizes = m_TypeCounts.at(set).data();
descriptorPoolInfo.maxSets = 1;
VK_CHECK_RESULT_H2M(vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &result.Pool));
// Allocate a new descriptor set from the global descriptor pool
VkDescriptorSetAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
allocInfo.descriptorPool = result.Pool;
allocInfo.descriptorSetCount = 1;
allocInfo.pSetLayouts = &m_DescriptorSetLayouts[set];
result.DescriptorSets.emplace_back();
VK_CHECK_RESULT_H2M(vkAllocateDescriptorSets(device, &allocInfo, result.DescriptorSets.data()));
return result;
}
VulkanShaderH2M::ShaderMaterialDescriptorSet VulkanShaderH2M::CreateDescriptorSets(uint32_t set, uint32_t numberOfSets)
{
ShaderMaterialDescriptorSet result{};
VkDevice device = VulkanContextH2M::GetCurrentDevice()->GetVulkanDevice();
std::unordered_map<uint32_t, std::vector<VkDescriptorPoolSize>> poolSizes;
for (auto&& [set, shaderDescriptorSet] : m_ShaderDescriptorSets)
{
if (shaderDescriptorSet.UniformBuffers.size())
{
VkDescriptorPoolSize& typeCount = poolSizes[set].emplace_back();
typeCount.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
typeCount.descriptorCount = static_cast<uint32_t>(shaderDescriptorSet.UniformBuffers.size()) * numberOfSets;
}
if (shaderDescriptorSet.ImageSamplers.size())
{
VkDescriptorPoolSize& typeCount = poolSizes[set].emplace_back();
typeCount.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
typeCount.descriptorCount = static_cast<uint32_t>(shaderDescriptorSet.ImageSamplers.size()) * numberOfSets;
}
if (shaderDescriptorSet.StorageImages.size())
{
VkDescriptorPoolSize& typeCount = poolSizes[set].emplace_back();
typeCount.type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
typeCount.descriptorCount = static_cast<uint32_t>(shaderDescriptorSet.StorageImages.size()) * numberOfSets;
}
}
if (poolSizes.find(set) == poolSizes.end())
{
// H2M_CORE_ASSERT(poolSizes.find(set) != poolSizes.end());
Log::GetLogger()->error("VulkanShaderH2M::CreateDescriptorSets('{0}, {1}') - descriptor set not found in 'poolSizes'!", set, numberOfSets);
}
// TODO: Move this to the centralized renderer
VkDescriptorPoolCreateInfo descriptorPoolInfo = {};
descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
descriptorPoolInfo.pNext = nullptr;
descriptorPoolInfo.poolSizeCount = static_cast<uint32_t>(poolSizes.at(set).size());
descriptorPoolInfo.pPoolSizes = poolSizes.at(set).data();
descriptorPoolInfo.maxSets = numberOfSets;
VK_CHECK_RESULT_H2M(vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &result.Pool));
result.DescriptorSets.resize(numberOfSets);
for (uint32_t i = 0; i < numberOfSets; i++)
{
VkDescriptorSetAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
allocInfo.descriptorPool = result.Pool;
allocInfo.descriptorSetCount = 1;
allocInfo.pSetLayouts = &m_DescriptorSetLayouts[set];
VK_CHECK_RESULT_H2M(vkAllocateDescriptorSets(device, &allocInfo, &result.DescriptorSets[i]));
}
return result;
}
const VkWriteDescriptorSet* VulkanShaderH2M::GetDescriptorSet(const std::string& name, uint32_t set) const
{
H2M_CORE_ASSERT(m_ShaderDescriptorSets.find(set) != m_ShaderDescriptorSets.end());
if (m_ShaderDescriptorSets.at(set).WriteDescriptorSets.find(name) == m_ShaderDescriptorSets.at(set).WriteDescriptorSets.end())
{
// HZ_CORE_WARN("Shader {0} does not contain requested descriptor set {1}", m_Name, name);
Log::GetLogger()->warn("Shader {0} does not contain requested descriptor set {1}", m_Name, name);
return nullptr;
}
return &m_ShaderDescriptorSets.at(set).WriteDescriptorSets.at(name);
}
// does not exist in Vulkan Week version, added later
std::vector<VkDescriptorSetLayout> VulkanShaderH2M::GetAllDescriptorSetLayouts()
{
std::vector<VkDescriptorSetLayout> result;
result.reserve(m_DescriptorSetLayouts.size());
for (auto [set, layout] : m_DescriptorSetLayouts)
{
result.emplace_back(layout);
}
return result;
}
VulkanShaderH2M::UniformBufferH2M& VulkanShaderH2M::GetUniformBuffer(uint32_t binding, uint32_t set)
{
H2M_CORE_ASSERT(m_ShaderDescriptorSets.at(set).UniformBuffers.size() > binding);
return m_ShaderDescriptorSets.at(set).UniformBuffers[binding];
}
static const char* VkShaderStageCachedFileExtension(VkShaderStageFlagBits stage)
{
switch (stage)
{
case VK_SHADER_STAGE_VERTEX_BIT: return ".cached_vulkan.vert";
case VK_SHADER_STAGE_FRAGMENT_BIT: return ".cached_vulkan.frag";
case VK_SHADER_STAGE_COMPUTE_BIT: return ".cached_vulkan.comp";
}
Log::GetLogger()->error("Invalid VkShaderStageFlagBits value '{0}'!", stage);
H2M_CORE_ASSERT(false, "Invalid VkShaderStageFlagBits value!");
return "";
}
static shaderc_shader_kind VkShaderStageToShaderC(VkShaderStageFlagBits stage)
{
switch (stage)
{
case VK_SHADER_STAGE_VERTEX_BIT: return shaderc_vertex_shader;
case VK_SHADER_STAGE_FRAGMENT_BIT: return shaderc_fragment_shader;
case VK_SHADER_STAGE_COMPUTE_BIT: return shaderc_compute_shader;
}
Log::GetLogger()->error("Invalid VkShaderStageFlagBits value '{0}'!", stage);
H2M_CORE_ASSERT(false, "Invalid VkShaderStageFlagBits value!");
return (shaderc_shader_kind)-1;
}
void VulkanShaderH2M::CompileOrGetVulkanBinary(std::unordered_map<VkShaderStageFlagBits, std::vector<uint32_t>>& outputBinary, bool forceCompile)
{
for (auto [stage, source] : m_ShaderSource)
{
auto extension = VkShaderStageCachedFileExtension(stage);
if (!forceCompile)
{
// Retrieve shader code from cache, if available
std::filesystem::path p = m_AssetPath;
auto path = p.parent_path() / "cached" / (p.filename().string() + extension);
std::string cachedFilePath = path.string();
FILE* f = fopen(cachedFilePath.c_str(), "rb");
if (f)
{
fseek(f, 0, SEEK_END);
uint64_t size = ftell(f);
fseek(f, 0, SEEK_SET);
outputBinary[stage] = std::vector<uint32_t>(size / sizeof(uint32_t));
fread(outputBinary[stage].data(), sizeof(uint32_t), outputBinary[stage].size(), f);
fclose(f);
}
}
if (outputBinary[stage].size() == 0)
{
// TODO: Do we need to init a compiler for each stage?
shaderc::Compiler compiler;
shaderc::CompileOptions options;
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_2);
const bool optimize = false;
if (optimize)
{
options.SetOptimizationLevel(shaderc_optimization_level_performance);
}
if (m_ShaderSource.find(stage) == m_ShaderSource.end()) return;
// Compile shader
{
auto& shaderSource = m_ShaderSource.at(stage); // e.g. VK_SHADER_STAGE_VERTEX_BIT
shaderc::SpvCompilationResult module = compiler.CompileGlslToSpv(shaderSource, VkShaderStageToShaderC(stage), m_AssetPath.c_str(), options);
if (module.GetCompilationStatus() != shaderc_compilation_status_success)
{
H2M_CORE_ERROR(module.GetErrorMessage());
H2M_CORE_ASSERT(false);
}
const uint8_t* begin = (const uint8_t*)module.cbegin();
const uint8_t* end = (const uint8_t*)module.cend();
const ptrdiff_t size = end - begin;
outputBinary[stage] = std::vector<uint32_t>(module.cbegin(), module.cend());
}
// Cache compiled shader
{
std::filesystem::path p = m_AssetPath;
auto path = p.parent_path() / "cached" / (p.filename().string() + extension);
std::string cachedFilePath = path.string();
FILE* f = fopen(cachedFilePath.c_str(), "wb");
fwrite(outputBinary[stage].data(), sizeof(uint32_t), outputBinary[stage].size(), f);
fclose(f);
}
}
}
}
static VkShaderStageFlagBits ShaderTypeFromString(const std::string& type)
{
if (type == "vertex") return VK_SHADER_STAGE_VERTEX_BIT;
if (type == "fragment" || type == "pixel") return VK_SHADER_STAGE_FRAGMENT_BIT;
if (type == "compute") return VK_SHADER_STAGE_COMPUTE_BIT;
return VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM;
}
std::unordered_map<VkShaderStageFlagBits, std::string> VulkanShaderH2M::PreProcess(const std::string& source)
{
std::unordered_map<VkShaderStageFlagBits, std::string> shaderSources;
const char* typeToken = "#type";
size_t typeTokenLength = strlen(typeToken);
size_t pos = source.find(typeToken, 0);
while (pos != std::string::npos)
{
size_t eol = source.find_first_of("\r\n", pos);
H2M_CORE_ASSERT(eol != std::string::npos, "Syntax error");
size_t begin = pos + typeTokenLength + 1;
std::string type = source.substr(begin, eol - begin);
H2M_CORE_ASSERT(type == "vertex" || type == "fragment" || type == "pixel" || type == "compute", "Invalid shader type specified");
size_t nextLinePos = source.find_first_not_of("\r\n", eol);
pos = source.find(typeToken, nextLinePos);
auto shaderType = ShaderTypeFromString(type);
shaderSources[shaderType] = source.substr(nextLinePos, pos - (nextLinePos == std::string::npos ? source.size() - 1 : nextLinePos));
}
return shaderSources;
}
void VulkanShaderH2M::Bind() {}
uint32_t VulkanShaderH2M::GetRendererID() const { return 0; }
void VulkanShaderH2M::ClearUniformBuffers()
{
s_UniformBuffers.clear();
}
size_t VulkanShaderH2M::GetHash() const
{
return std::hash<std::string>{}(m_AssetPath);
}
void VulkanShaderH2M::SetUniformBuffer(const std::string& name, const void* data, uint32_t size) {}
/****
const std::vector<VkPipelineShaderStageCreateInfo>& VulkanShaderH2M::GetShaderStages() const
{
std::vector<VkPipelineShaderStageCreateInfo> shaderStages;
for (auto [stage, pipelineShaderStageCreateInfo] : m_ShaderStages)
{
shaderStages.push_back(pipelineShaderStageCreateInfo);
}
return shaderStages;
}
****/
void VulkanShaderH2M::SetUniform(const std::string& fullname, float value) {}
void VulkanShaderH2M::SetUniform(const std::string& fullname, int value) {}
void VulkanShaderH2M::SetUniform(const std::string& fullname, const glm::vec2& value) {}
void VulkanShaderH2M::SetUniform(const std::string& fullname, const glm::vec3& value) {}
void VulkanShaderH2M::SetUniform(const std::string& fullname, const glm::vec4& value) {}
void VulkanShaderH2M::SetUniform(const std::string& fullname, const glm::mat3& value) {}
void VulkanShaderH2M::SetUniform(const std::string& fullname, const glm::mat4& value) {}
void VulkanShaderH2M::SetUniform(const std::string& fullname, uint32_t value) {}
void VulkanShaderH2M::SetInt(const std::string& name, int value) {}
void VulkanShaderH2M::SetUInt(const std::string& name, uint32_t value) {}
void VulkanShaderH2M::SetFloat(const std::string& name, float value) {}
void VulkanShaderH2M::SetFloat2(const std::string& name, const glm::vec2& value) {}
void VulkanShaderH2M::SetFloat3(const std::string& name, const glm::vec3& value) {}
void VulkanShaderH2M::SetFloat4(const std::string& name, const glm::vec4& value) {}
void VulkanShaderH2M::SetMat4(const std::string& name, const glm::mat4& value) {}
void VulkanShaderH2M::SetMat4FromRenderThread(const std::string& name, const glm::mat4& value, bool bind /*= true*/) {}
void VulkanShaderH2M::SetIntArray(const std::string& name, int* values, uint32_t size) {}
// const std::unordered_map<std::string, Hazel::ShaderBuffer>& VulkanShaderH2M::GetShaderBuffers() const { return {}; }
const std::unordered_map<std::string, ShaderResourceDeclarationH2M>& VulkanShaderH2M::GetResources() const
{
return {};
}
void VulkanShaderH2M::AddShaderReloadedCallback(const ShaderReloadedCallback& callback) {}
void* VulkanShaderH2M::MapUniformBuffer(uint32_t bindingPoint, uint32_t set)
{
H2M_CORE_ASSERT(m_ShaderDescriptorSets.find(set) != m_ShaderDescriptorSets.end());
VkDevice device = VulkanContextH2M::GetCurrentDevice()->GetVulkanDevice();
uint8_t* pData;
VK_CHECK_RESULT_H2M(vkMapMemory(device, m_ShaderDescriptorSets.at(set).UniformBuffers.at(bindingPoint).Memory, 0, m_ShaderDescriptorSets.at(set).UniformBuffers.at(bindingPoint).Size, 0, (void**)&pData));
return pData;
}
void VulkanShaderH2M::UnmapUniformBuffer(uint32_t bindingPoint, uint32_t set)
{
H2M_CORE_ASSERT(m_ShaderDescriptorSets.find(set) != m_ShaderDescriptorSets.end());
VkDevice device = VulkanContextH2M::GetCurrentDevice()->GetVulkanDevice();
vkUnmapMemory(device, m_ShaderDescriptorSets.at(set).UniformBuffers.at(bindingPoint).Memory);
}
}
| 39.461165
| 205
| 0.737514
|
imgui-works
|
b4b9f02f4dcd19b2e1eca5155b95e5ca4f0e36a6
| 431
|
cpp
|
C++
|
node_modules/gl/angle/src/tests/angle_end2end_tests_main.cpp
|
aaverty/editly
|
71bccaf91f8d68609c80ba59425b79e3f94579ad
|
[
"MIT"
] | 2,151
|
2020-04-18T07:31:17.000Z
|
2022-03-31T08:39:18.000Z
|
node_modules/gl/angle/src/tests/angle_end2end_tests_main.cpp
|
aaverty/editly
|
71bccaf91f8d68609c80ba59425b79e3f94579ad
|
[
"MIT"
] | 395
|
2020-04-18T08:22:18.000Z
|
2021-12-08T13:04:49.000Z
|
node_modules/gl/angle/src/tests/angle_end2end_tests_main.cpp
|
aaverty/editly
|
71bccaf91f8d68609c80ba59425b79e3f94579ad
|
[
"MIT"
] | 338
|
2020-04-18T08:03:10.000Z
|
2022-03-29T12:33:22.000Z
|
//
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "gtest/gtest.h"
#include "test_utils/ANGLETest.h"
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
testing::AddGlobalTestEnvironment(new ANGLETestEnvironment());
int rt = RUN_ALL_TESTS();
return rt;
}
| 25.352941
| 73
| 0.709977
|
aaverty
|
b4bb44d151d0d05fcef3e7179c2d3a7f0c15d3ff
| 2,690
|
cpp
|
C++
|
Backtracking/17longestPossibleRouteInMatrixWithHurdles.cpp
|
Coderangshu/450DSA
|
fff6cee65f75e5a0bb61d5fd8d000317a7736ca3
|
[
"MIT"
] | 1
|
2021-01-18T14:51:20.000Z
|
2021-01-18T14:51:20.000Z
|
Backtracking/17longestPossibleRouteInMatrixWithHurdles.cpp
|
Coderangshu/450DSA
|
fff6cee65f75e5a0bb61d5fd8d000317a7736ca3
|
[
"MIT"
] | null | null | null |
Backtracking/17longestPossibleRouteInMatrixWithHurdles.cpp
|
Coderangshu/450DSA
|
fff6cee65f75e5a0bb61d5fd8d000317a7736ca3
|
[
"MIT"
] | null | null | null |
#include<bits/stdc++.h>
using namespace std;
// Method: The idea is to use Backtracking. We start from the source cell of the matrix,
// move forward in all four allowed directions and recursively checks if they leads to
// the solution or not. If destination is found, we update the value of longest path
// else if none of the above solutions work we return false from our function.
bool isSafe(int R, int C, int x, int y, vector<vector<bool>> &visited, vector<vector<int>> &matrix){
return (x>=0 and x<R and y>=0 and y<C and !visited[x][y] and matrix[x][y]!=0);
}
// moves available(x,y) coordinates
vector<int> mx = {-1,0,1, 0};
vector<int> my = { 0,1,0,-1};
// variable to store the max steps
int maxSteps = INT_MIN;
// to store the longest path using 1s(used) and
// 0s (not used)
vector<vector<bool>> ans;
bool findLongestPathUtil(vector<vector<int>> &matrix, pair<int,int> s, pair<int,int> d,
vector<vector<bool>> &visited, int steps){
if(s==d){
if(maxSteps<steps){
maxSteps = steps;
auto [sx,sy] = s;
visited[sx][sy] = true;
ans = visited;
visited[sx][sy] = false;
}
return true;
}
int R = matrix.size();
int C = matrix[0].size();
auto [sx,sy] = s;
auto [dx,dy] = d;
visited[sx][sy] = true;
bool a = false;
for(int i=0;i<4;i++){
int nx = sx+mx[i];
int ny = sy+my[i];
if(isSafe(R,C,nx,ny,visited,matrix))
a = findLongestPathUtil(matrix,{nx,ny},d,visited,steps+1) or a;
}
visited[sx][sy] = false;
return a;
}
void findLongestPath(vector<vector<int>> &matrix, pair<int,int> s, pair<int,int> d){
// resetting maxSteps for next problem
maxSteps = INT_MIN;
int R = matrix.size();
int C = matrix[0].size();
auto [sx,sy] = s;
auto [dx,dy] = d;
vector<vector<bool>> visited(R,vector<bool>(C,false));
if(findLongestPathUtil(matrix,s,d,visited,0)){
cout<<"Longest path length is: "<<maxSteps<<endl;
cout<<"The path is shown using 1s"<<endl;
for(auto e:ans){
for(auto v:e) cout<<v<<" ";
cout<<endl;
}
}
else cout<<"No Possible Path"<<endl;
}
int main(){
vector<vector<int>> matrix = {
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 0, 1, 1, 0, 1, 1, 0, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
};
pair<int,int> src = {0,0};
pair<int,int> dest = {1,7};
findLongestPath(matrix,src,dest);
matrix = {
{ 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 },
{ 1, 1, 1, 1, 1, 0, 0, 1, 0, 1 },
{ 1, 1, 0, 0, 0, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
};
src = {0,0};
dest = {1,7};
findLongestPath(matrix,src,dest);
return 0;
}
| 25.377358
| 100
| 0.568773
|
Coderangshu
|
b4bbf609e3d23fe30480252a2b49d40286b47226
| 246
|
hpp
|
C++
|
src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryConditions/RegisterDerivedWithCharm.hpp
|
macedo22/spectre
|
97b2b7ae356cf86830258cb5f689f1191fdb6ddd
|
[
"MIT"
] | 2
|
2021-04-11T04:07:42.000Z
|
2021-04-11T05:07:54.000Z
|
src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryConditions/RegisterDerivedWithCharm.hpp
|
macedo22/spectre
|
97b2b7ae356cf86830258cb5f689f1191fdb6ddd
|
[
"MIT"
] | 4
|
2018-06-04T20:26:40.000Z
|
2018-07-27T14:54:55.000Z
|
src/Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryConditions/RegisterDerivedWithCharm.hpp
|
macedo22/spectre
|
97b2b7ae356cf86830258cb5f689f1191fdb6ddd
|
[
"MIT"
] | null | null | null |
// Distributed under the MIT License.
// See LICENSE.txt for details.
#pragma once
namespace grmhd::ValenciaDivClean::BoundaryConditions {
void register_derived_with_charm() noexcept;
} // namespace grmhd::ValenciaDivClean::BoundaryConditions
| 27.333333
| 59
| 0.800813
|
macedo22
|
b4bd26de3851dab977bc7616fcb8967b35b30db5
| 6,055
|
cpp
|
C++
|
openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp
|
hellok-coder/OS-Testing
|
e9e18ad9e99f709a3f992601ed8d2e0662175af4
|
[
"blessing"
] | 1
|
2019-11-12T02:07:03.000Z
|
2019-11-12T02:07:03.000Z
|
openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp
|
hellok-coder/OS-Testing
|
e9e18ad9e99f709a3f992601ed8d2e0662175af4
|
[
"blessing"
] | 1
|
2019-02-04T23:30:45.000Z
|
2019-02-04T23:30:45.000Z
|
openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp
|
hellok-coder/OS-Testing
|
e9e18ad9e99f709a3f992601ed8d2e0662175af4
|
[
"blessing"
] | null | null | null |
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2019, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
* written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************************************************************/
#include "../ForwardTranslator.hpp"
#include "../../model/Model.hpp"
#include "../../model/OutputVariable.hpp"
#include "../../model/OutputVariable_Impl.hpp"
#include "../../model/OutputMeter.hpp"
#include "../../model/OutputMeter_Impl.hpp"
#include "../../model/Schedule.hpp"
#include "../../model/Schedule_Impl.hpp"
#include "../../model/EnergyManagementSystemMeteredOutputVariable.hpp"
#include "../../model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp"
#include <utilities/idd/EnergyManagementSystem_MeteredOutputVariable_FieldEnums.hxx>
#include "../../utilities/idd/IddEnums.hpp"
#include <utilities/idd/IddEnums.hxx>
using namespace openstudio::model;
using namespace std;
namespace openstudio {
namespace energyplus {
boost::optional<IdfObject> ForwardTranslator::translateEnergyManagementSystemMeteredOutputVariable(EnergyManagementSystemMeteredOutputVariable & modelObject)
{
boost::optional<std::string> s;
IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_MeteredOutputVariable);
m_idfObjects.push_back(idfObject);
//Name
s = modelObject.name();
if (s) {
idfObject.setName(*s);
}
// look for UID and if found replace with object name; otherwise just use string value
s = modelObject.emsVariableName();
if (s) {
//find uids
const int subs[] = { 1 };
std::string newline = s.get();
std::string possible_uid;
size_t pos;
bool is_uuid = false;
const Model m = modelObject.model();
boost::optional<ModelObject> mObject;
boost::sregex_token_iterator j(s.get().begin(), s.get().end(), uuidInString(), subs);
while (j != boost::sregex_token_iterator()) {
possible_uid = *j++;
//look to see if uid is in the model and return the object
UUID uid = toUUID(possible_uid);
mObject = m.getModelObject<model::ModelObject>(uid);
if (mObject) {
is_uuid = true;
//replace uid with namestring
pos = newline.find(possible_uid);
if (pos + 38 <= newline.length()) {
newline.replace(pos, 38, mObject.get().nameString());
idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, newline);
}
}
else {
//did not find an object with the UID so do not FT
LOG(Error, "Key Name for EMS:MeteredOutputVariable '" << modelObject.nameString() << "' is UID but does not exist, it will not be translated.");
return boost::none;
}
}
//string is not a uuid so just translate its value for the EMSVariableName
if (!is_uuid) {
idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, s.get());
}
}
idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency, modelObject.updateFrequency());
s = modelObject.emsProgramOrSubroutineName();
if (s.is_initialized()) {
idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, s.get());
}
idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::ResourceType, modelObject.resourceType());
idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::GroupType, modelObject.groupType());
idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory, modelObject.endUseCategory());
s = modelObject.endUseSubcategory();
if (s.is_initialized()) {
idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, s.get());
}
s = modelObject.units();
if (s.is_initialized()) {
idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::Units, s.get());
}
return idfObject;
}
} // energyplus
} // openstudio
| 45.526316
| 157
| 0.716763
|
hellok-coder
|
b4be4cbfd5ebd34d4ffe81315a69bc77f54b48e7
| 2,413
|
cxx
|
C++
|
src/runtime_src/core/pcie/emulation/hw_em/generic_pcie_hal2/device_hwemu.cxx
|
Himanshu-xilinx/XRT
|
72ed6f33780396550b3b1e8d3c6011faa0bb0827
|
[
"Apache-2.0"
] | null | null | null |
src/runtime_src/core/pcie/emulation/hw_em/generic_pcie_hal2/device_hwemu.cxx
|
Himanshu-xilinx/XRT
|
72ed6f33780396550b3b1e8d3c6011faa0bb0827
|
[
"Apache-2.0"
] | null | null | null |
src/runtime_src/core/pcie/emulation/hw_em/generic_pcie_hal2/device_hwemu.cxx
|
Himanshu-xilinx/XRT
|
72ed6f33780396550b3b1e8d3c6011faa0bb0827
|
[
"Apache-2.0"
] | 3
|
2020-08-12T03:03:13.000Z
|
2020-08-12T03:39:45.000Z
|
/**
* Copyright (C) 2020 Xilinx, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#include "device_hwemu.h"
#include "core/common/query_requests.h"
#include "shim.h"
#include <string>
#include <map>
#include <boost/format.hpp>
namespace {
namespace query = xrt_core::query;
using key_type = query::key_type;
using qtype = std::underlying_type<query::key_type>::type;
static std::map<query::key_type, std::unique_ptr<query::request>> query_tbl;
struct deviceQuery
{
static uint32_t
get(const xrt_core::device* device, key_type query_key)
{
xclhwemhal2::HwEmShim *drv = xclhwemhal2::HwEmShim::handleCheck(device->get_device_handle());
if (!drv)
return 0;
return drv->deviceQuery(query_key);
}
};
template <typename QueryRequestType, typename Getter>
struct function0_get : virtual QueryRequestType
{
boost::any
get(const xrt_core::device* device) const
{
auto k = QueryRequestType::key;
return Getter::get(device, k);
}
};
template <typename QueryRequestType, typename Getter>
static void
emplace_func0_request()
{
auto k = QueryRequestType::key;
query_tbl.emplace(k, std::make_unique<function0_get<QueryRequestType, Getter>>());
}
static void
initialize_query_table()
{
emplace_func0_request<query::m2m, deviceQuery>();
emplace_func0_request<query::nodma, deviceQuery>();
}
struct X { X() { initialize_query_table(); } };
static X x;
}
namespace xrt_core { namespace hwemu {
const query::request&
device::
lookup_query(query::key_type query_key) const
{
auto it = query_tbl.find(query_key);
if (it == query_tbl.end())
throw query::no_such_key(query_key);
return *(it->second);
}
device::
device(handle_type device_handle, id_type device_id, bool user)
: shim<device_pcie>(device_handle, device_id, user)
{
}
}} // hwemu,xrt_core
| 24.622449
| 99
| 0.700787
|
Himanshu-xilinx
|
b4be743dec97e94a9bf1a1b7c6b5462b721b53f2
| 3,516
|
hpp
|
C++
|
include/GlobalNamespace/VRControllersRecorderData_Keyframe.hpp
|
Fernthedev/BeatSaber-Quest-Codegen
|
716e4ff3f8608f7ed5b83e2af3be805f69e26d9e
|
[
"Unlicense"
] | null | null | null |
include/GlobalNamespace/VRControllersRecorderData_Keyframe.hpp
|
Fernthedev/BeatSaber-Quest-Codegen
|
716e4ff3f8608f7ed5b83e2af3be805f69e26d9e
|
[
"Unlicense"
] | null | null | null |
include/GlobalNamespace/VRControllersRecorderData_Keyframe.hpp
|
Fernthedev/BeatSaber-Quest-Codegen
|
716e4ff3f8608f7ed5b83e2af3be805f69e26d9e
|
[
"Unlicense"
] | null | null | null |
// Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "extern/beatsaber-hook/shared/utils/typedefs.h"
#include "extern/beatsaber-hook/shared/utils/byref.hpp"
// Including type: VRControllersRecorderData
#include "GlobalNamespace/VRControllersRecorderData.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp"
#include "extern/beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Type namespace:
namespace GlobalNamespace {
// Size: 0x1C
#pragma pack(push, 1)
// Autogenerated type: VRControllersRecorderData/Keyframe
// [TokenAttribute] Offset: FFFFFFFF
class VRControllersRecorderData::Keyframe : public ::Il2CppObject {
public:
// public readonly VRControllersRecorderData/PositionAndRotation[] positionsAndRotations
// Size: 0x8
// Offset: 0x10
::Array<GlobalNamespace::VRControllersRecorderData::PositionAndRotation>* positionsAndRotations;
// Field size check
static_assert(sizeof(::Array<GlobalNamespace::VRControllersRecorderData::PositionAndRotation>*) == 0x8);
// public readonly System.Single time
// Size: 0x4
// Offset: 0x18
float time;
// Field size check
static_assert(sizeof(float) == 0x4);
// Creating value type constructor for type: Keyframe
Keyframe(::Array<GlobalNamespace::VRControllersRecorderData::PositionAndRotation>* positionsAndRotations_ = {}, float time_ = {}) noexcept : positionsAndRotations{positionsAndRotations_}, time{time_} {}
// Get instance field reference: public readonly VRControllersRecorderData/PositionAndRotation[] positionsAndRotations
::Array<GlobalNamespace::VRControllersRecorderData::PositionAndRotation>*& dyn_positionsAndRotations();
// Get instance field reference: public readonly System.Single time
float& dyn_time();
// public System.Void .ctor(VRControllersRecorderData/PositionAndRotation[] positionAndRotations, System.Single time)
// Offset: 0x129F79C
template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary>
static VRControllersRecorderData::Keyframe* New_ctor(::Array<GlobalNamespace::VRControllersRecorderData::PositionAndRotation>* positionAndRotations, float time) {
static auto ___internal__logger = ::Logger::get().WithContext("GlobalNamespace::VRControllersRecorderData::Keyframe::.ctor");
return THROW_UNLESS((::il2cpp_utils::New<VRControllersRecorderData::Keyframe*, creationType>(positionAndRotations, time)));
}
}; // VRControllersRecorderData/Keyframe
#pragma pack(pop)
static check_size<sizeof(VRControllersRecorderData::Keyframe), 24 + sizeof(float)> __GlobalNamespace_VRControllersRecorderData_KeyframeSizeCheck;
static_assert(sizeof(VRControllersRecorderData::Keyframe) == 0x1C);
}
DEFINE_IL2CPP_ARG_TYPE(GlobalNamespace::VRControllersRecorderData::Keyframe*, "", "VRControllersRecorderData/Keyframe");
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
// Writing MetadataGetter for method: GlobalNamespace::VRControllersRecorderData::Keyframe::New_ctor
// Il2CppName: .ctor
// Cannot get method pointer of value based method overload from template for constructor!
// Try using FindMethod instead!
| 59.59322
| 207
| 0.755688
|
Fernthedev
|
b4c0b1e1948ee5e6184fec4cb944af558cc35149
| 3,714
|
cpp
|
C++
|
tools_intern/efficiency/efficiency_linux64/C_intersect_presorted.cpp
|
umariqb/3D_Pose_Estimation_CVPR2016
|
83f6bf36aa68366ea8fa078eea6d91427e28503b
|
[
"BSD-3-Clause"
] | 47
|
2016-07-25T00:48:59.000Z
|
2021-02-17T09:19:03.000Z
|
tools_intern/efficiency/efficiency_linux64/C_intersect_presorted.cpp
|
umariqb/3D_Pose_Estimation_CVPR2016
|
83f6bf36aa68366ea8fa078eea6d91427e28503b
|
[
"BSD-3-Clause"
] | 5
|
2016-09-17T19:40:46.000Z
|
2018-11-07T06:49:02.000Z
|
tools_intern/efficiency/efficiency_linux64/C_intersect_presorted.cpp
|
iqbalu/3D_Pose_Estimation_CVPR2016
|
83f6bf36aa68366ea8fa078eea6d91427e28503b
|
[
"BSD-3-Clause"
] | 35
|
2016-07-21T09:13:15.000Z
|
2019-05-13T14:11:37.000Z
|
#include "mex.h"
#include <memory.h>
#include <stdio.h>
/* printf("List %d: %d entries... ",i+1,cell_lengths[i]);
for (j=0; j<cell_lengths[i]; j++)
printf("%f ",((double*)vals)[j]);
printf("\n");*/
int C_intersect_presorted(double* list_out, double* pA, double* pB, int mA, int mB, double* pIA, double* pIB, int* nIA, int* nIB)
{
int nOut = 0,
iA = 0,
iB = 0;
double v;
while (iA<mA && iB<mB)
{
if (pA[iA] < pB[iB])
{
iA++;
}
else
{
if (pA[iA] > pB[iB])
{
iB++;
}
else // (pA[iA] == pB[iB])
{
v = pA[iA];
*(list_out++) = v;
nOut++;
while (pA[iA] == v && iA<mA) // fast forward through occurences of v
iA++;
while (pB[iB] == v && iB<mB) // (duplicate elimination!!)
iB++;
if (pIA != NULL) // record indices AFTER previous incrementations because of Matlab indexing!!
{
*(pIA++) = iA;
(*nIA)++;
}
if (pIB != NULL)
{
*(pIB++) = iB;
(*nIB)++;
}
}
}
}
return nOut;
}
// [list_out, IA, IB] = C_intersect_presorted(A,B)
/* The gateway routine */
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
double *pA,
*pB,
*pIA=NULL,
*pIB=NULL,
*list_out;
const mxArray *A,*B;
int mA,
nA,
mB,
nB,
nIA=0,
nIB=0,
max_list_out_length,
list_out_length;
bool return_IA = false,
return_IB = false;
/* Check for proper number of arguments. */
/* NOTE: You do not need an else statement when using
mexErrMsgTxt within an if statement. It will never
get to the else statement if mexErrMsgTxt is executed.
(mexErrMsgTxt breaks you out of the MEX-file.)
*/
if (nrhs != 2)
mexErrMsgTxt("Two inputs required.");
if (nlhs>1)
return_IA = true;
if (nlhs>2)
return_IB = true;
A = prhs[0];
B = prhs[1];
if (mxIsEmpty(A) || mxIsEmpty(B))
{
plhs[0] = mxCreateDoubleMatrix(0,1,mxREAL);
if (return_IA)
plhs[1] = mxCreateDoubleMatrix(0,1,mxREAL);
if (return_IB)
plhs[2] = mxCreateDoubleMatrix(0,1,mxREAL);
return;
}
pA = (double*)mxGetPr(A);
pB = (double*)mxGetPr(B);
/* Get the dimensions of the input arrays. */
mA = mxGetM(A); nA = mxGetN(A);
mB = mxGetM(B); nB = mxGetN(B);
/* Check to make sure the two input argument are real double vectors. */
if ((mxIsComplex(A) || !mxIsDouble(A) || (mA != 1 && nA != 1)) ||
(mxIsComplex(B) || !mxIsDouble(B) || (mB != 1 && nB != 1)))
{
mexErrMsgTxt("Inputs must be real double vectors.");
}
mA = (mA>nA?mA:nA);
mB = (mB>nB?mB:nB);
max_list_out_length = (mA<mB?mA:mB);
/* Create a C pointer to the output matrix. */
plhs[0] = mxCreateDoubleMatrix(1,max_list_out_length, mxREAL);
list_out = (double*)mxGetPr(plhs[0]);
if (return_IA)
{
plhs[1] = mxCreateDoubleMatrix(1,mA, mxREAL);
pIA = (double*)mxGetPr(plhs[1]);
}
if (return_IB)
{
plhs[2] = mxCreateDoubleMatrix(1,mB, mxREAL);
pIB = (double*)mxGetPr(plhs[2]);
}
/* Call the C subroutine. */
list_out_length = C_intersect_presorted(list_out,pA,pB,mA,mB,pIA,pIB,&nIA,&nIB);
/* Resize output arrays to required sizes. */
list_out = (double*)mxRealloc(list_out,list_out_length*sizeof(double));
mxSetPr(plhs[0], list_out);
mxSetN(plhs[0], list_out_length);
if (return_IA)
{
pIA = (double*)mxRealloc(pIA,nIA*sizeof(double));
mxSetPr(plhs[1], pIA);
mxSetN(plhs[1], nIA);
}
if (return_IB)
{
pIB = (double*)mxRealloc(pIB,nIB*sizeof(double));
mxSetPr(plhs[2], pIB);
mxSetN(plhs[2], nIB);
}
}
| 23.2125
| 130
| 0.559505
|
umariqb
|
b4c127fc760f73fb05f2869fe8bff5d2438dc029
| 5,085
|
hpp
|
C++
|
hypercall/include/mv_exit_reason_t.hpp
|
Pavan-Infovision/MicroV
|
b83870f20d6b3bfde80e3a0012f14e0e8d77a6e9
|
[
"MIT"
] | 159
|
2020-04-10T22:31:16.000Z
|
2022-03-26T07:52:23.000Z
|
hypercall/include/mv_exit_reason_t.hpp
|
Pavan-Infovision/MicroV
|
b83870f20d6b3bfde80e3a0012f14e0e8d77a6e9
|
[
"MIT"
] | 67
|
2020-04-21T19:40:54.000Z
|
2022-03-04T13:38:40.000Z
|
hypercall/include/mv_exit_reason_t.hpp
|
Pavan-Infovision/MicroV
|
b83870f20d6b3bfde80e3a0012f14e0e8d77a6e9
|
[
"MIT"
] | 29
|
2020-04-11T02:43:33.000Z
|
2022-02-07T15:53:18.000Z
|
/// @copyright
/// Copyright (C) 2020 Assured Information Security, Inc.
///
/// @copyright
/// 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:
///
/// @copyright
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// @copyright
/// 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.
#ifndef MV_EXIT_REASON_T_HPP
#define MV_EXIT_REASON_T_HPP
#include <bsl/convert.hpp>
#include <bsl/safe_integral.hpp>
namespace hypercall
{
/// <!-- description -->
/// @brief Defines different bit sizes for address, operands, etc.
///
enum class mv_exit_reason_t : bsl::int32
{
/// @brief Returnsed on error
mv_exit_reason_t_failure = 0,
/// @brief an unknown/unsupported VMExit has occurred
mv_exit_reason_t_unknown = 1,
/// @brief a halt event has occurred
mv_exit_reason_t_hlt = 2,
/// @brief a IO event has occurred
mv_exit_reason_t_io = 3,
/// @brief a MMIO event has occurred
mv_exit_reason_t_mmio = 4,
/// @brief a MSR event has occurred
mv_exit_reason_t_msr = 5,
/// @brief an interrupt event has occurred
mv_exit_reason_t_interrupt = 6,
/// @brief an nmi event has occurred
mv_exit_reason_t_nmi = 7,
};
/// <!-- description -->
/// @brief Returns bsl::to_i32(static_cast<bsl::int32>(val))
///
/// <!-- inputs/outputs -->
/// @param val the mv_exit_reason_t to convert
/// @return Returns bsl::to_i32(static_cast<bsl::int32>(val))
///
[[nodiscard]] constexpr auto
to_i32(mv_exit_reason_t const val) noexcept -> bsl::safe_i32
{
return bsl::to_i32(static_cast<bsl::int32>(val));
}
/// <!-- description -->
/// @brief Returns bsl::to_i64(static_cast<bsl::uint64>(val))
///
/// <!-- inputs/outputs -->
/// @param val the mv_exit_reason_t to convert
/// @return Returns bsl::to_i64(static_cast<bsl::uint64>(val))
///
[[nodiscard]] constexpr auto
to_u64(mv_exit_reason_t const val) noexcept -> bsl::safe_u64
{
return bsl::to_u64(static_cast<bsl::uint64>(val));
}
/// <!-- description -->
/// @brief Returns static_cast<mv_exit_reason_t>(val.get())
///
/// <!-- inputs/outputs -->
/// @param val the value to convert
/// @return Returns static_cast<mv_exit_reason_t>(val.get())
///
[[nodiscard]] constexpr auto
to_mv_exit_reason_t(bsl::safe_i32 const &val) noexcept -> mv_exit_reason_t
{
return static_cast<mv_exit_reason_t>(val.get());
}
/// <!-- description -->
/// @brief Returns static_cast<mv_exit_reason_t>(val.get())
///
/// <!-- inputs/outputs -->
/// @param val the value to convert
/// @return Returns static_cast<mv_exit_reason_t>(val.get())
///
[[nodiscard]] constexpr auto
to_mv_exit_reason_t(bsl::safe_u64 const &val) noexcept -> mv_exit_reason_t
{
return static_cast<mv_exit_reason_t>(val.get());
}
/// @brief integer version of mv_exit_reason_t_failure
constexpr auto EXIT_REASON_FAILURE{to_i32(mv_exit_reason_t::mv_exit_reason_t_failure)};
/// @brief integer version of mv_exit_reason_t_unknown
constexpr auto EXIT_REASON_UNKNOWN{to_i32(mv_exit_reason_t::mv_exit_reason_t_unknown)};
/// @brief integer version of mv_exit_reason_t_hlt
constexpr auto EXIT_REASON_HLT{to_i32(mv_exit_reason_t::mv_exit_reason_t_hlt)};
/// @brief integer version of mv_exit_reason_t_io
constexpr auto EXIT_REASON_IO{to_i32(mv_exit_reason_t::mv_exit_reason_t_io)};
/// @brief integer version of mv_exit_reason_t_mmio
constexpr auto EXIT_REASON_MMIO{to_i32(mv_exit_reason_t::mv_exit_reason_t_mmio)};
/// @brief integer version of mv_exit_reason_t_msr
constexpr auto EXIT_REASON_MSR{to_i32(mv_exit_reason_t::mv_exit_reason_t_msr)};
/// @brief integer version of mv_exit_reason_t_interrupt
constexpr auto EXIT_REASON_INTERRUPT{to_i32(mv_exit_reason_t::mv_exit_reason_t_interrupt)};
/// @brief integer version of mv_exit_reason_t_nmi
constexpr auto EXIT_REASON_NMI{to_i32(mv_exit_reason_t::mv_exit_reason_t_nmi)};
}
#endif
| 40.03937
| 95
| 0.686922
|
Pavan-Infovision
|
b4c25a87bde3d178543b455ab2aa35cc7e2264c3
| 2,099
|
cpp
|
C++
|
gemcutter/Rendering/Text.cpp
|
EmilianC/Gemcutter
|
cbd31f20a9336b6d879849c7a3cdfd8c28a3ac12
|
[
"MIT"
] | 8
|
2021-02-07T21:40:42.000Z
|
2022-03-29T15:55:30.000Z
|
gemcutter/Rendering/Text.cpp
|
EmilianC/Gemcutter
|
cbd31f20a9336b6d879849c7a3cdfd8c28a3ac12
|
[
"MIT"
] | null | null | null |
gemcutter/Rendering/Text.cpp
|
EmilianC/Gemcutter
|
cbd31f20a9336b6d879849c7a3cdfd8c28a3ac12
|
[
"MIT"
] | 3
|
2021-02-08T14:40:23.000Z
|
2021-03-30T07:05:35.000Z
|
// Copyright (c) 2017 Emilian Cioca
#include "Text.h"
#include "gemcutter/Application/Logging.h"
#include "gemcutter/Resource/Font.h"
namespace gem
{
Text::Text(Entity& _owner)
: Renderable(_owner)
{
}
Text::Text(Entity& _owner, Font::Ptr _font)
: Renderable(_owner)
, font(std::move(_font))
{
}
Text::Text(Entity& _owner, std::string _string)
: Renderable(_owner)
, string(std::move(_string))
{
}
Text::Text(Entity& _owner, Material::Ptr material)
: Renderable(_owner, std::move(material))
{
}
Text::Text(Entity& _owner, Font::Ptr _font, std::string _string, Material::Ptr material)
: Renderable(_owner, std::move(material))
, font(std::move(_font))
, string(std::move(_string))
{
}
unsigned Text::GetNumLines() const
{
if (string.empty())
{
return 0;
}
unsigned count = 1;
const char* ptr = string.data();
while (true)
{
switch (*ptr)
{
case '\n':
++count;
break;
case '\0':
return count;
}
++ptr;
}
}
float Text::GetLineWidth(unsigned line) const
{
ASSERT(line != 0, "'line' must be greater than 0.");
ASSERT(font != nullptr, "Must have a Font attached to query width.");
if (line > GetNumLines())
{
return 0.0f;
}
else if (line == 1)
{
size_t loc = string.find('\n');
if (loc == std::string::npos)
{
return static_cast<float>(font->GetStringWidth(string));
}
else
{
return static_cast<float>(font->GetStringWidth({ string.begin(), string.begin() + loc }));
}
}
else
{
size_t start = std::string::npos;
unsigned count = 1;
for (unsigned i = 0; i < string.size(); ++i)
{
if (string[i] == '\n')
{
count++;
if (count == line)
{
start = i;
break;
}
}
}
size_t end = string.size();
for (unsigned i = start + 1; i < string.size(); ++i)
{
if (string[i] == '\n')
{
end = i;
break;
}
}
if (start == std::string::npos)
{
return 0.0f;
}
return static_cast<float>(font->GetStringWidth({ string.begin() + start, string.begin() + end }));
}
}
}
| 17.638655
| 101
| 0.575512
|
EmilianC
|
b4c58381b028bbb748feac724c77ad8b84869f1f
| 3,527
|
cpp
|
C++
|
Wexport/release/windows/obj/src/lime/graphics/_CairoRenderContext/CairoRenderContext_Impl_.cpp
|
BushsHaxs/FNF-coding-tutorial
|
596c6a938eb687440cbcddda9a4005db67bc68bb
|
[
"Apache-2.0"
] | 1
|
2021-07-19T05:10:43.000Z
|
2021-07-19T05:10:43.000Z
|
Wexport/release/windows/obj/src/lime/graphics/_CairoRenderContext/CairoRenderContext_Impl_.cpp
|
BushsHaxs/FNF-coding-tutorial
|
596c6a938eb687440cbcddda9a4005db67bc68bb
|
[
"Apache-2.0"
] | null | null | null |
Wexport/release/windows/obj/src/lime/graphics/_CairoRenderContext/CairoRenderContext_Impl_.cpp
|
BushsHaxs/FNF-coding-tutorial
|
596c6a938eb687440cbcddda9a4005db67bc68bb
|
[
"Apache-2.0"
] | 1
|
2021-12-11T09:19:29.000Z
|
2021-12-11T09:19:29.000Z
|
#include <hxcpp.h>
#ifndef INCLUDED_lime_graphics_RenderContext
#include <lime/graphics/RenderContext.h>
#endif
#ifndef INCLUDED_lime_graphics__CairoRenderContext_CairoRenderContext_Impl_
#include <lime/graphics/_CairoRenderContext/CairoRenderContext_Impl_.h>
#endif
#ifndef INCLUDED_lime_graphics_cairo_Cairo
#include <lime/graphics/cairo/Cairo.h>
#endif
HX_LOCAL_STACK_FRAME(_hx_pos_8556288c3ba73522_24_fromRenderContext,"lime.graphics._CairoRenderContext.CairoRenderContext_Impl_","fromRenderContext",0x4c67089a,"lime.graphics._CairoRenderContext.CairoRenderContext_Impl_.fromRenderContext","lime/graphics/CairoRenderContext.hx",24,0x00243123)
namespace lime{
namespace graphics{
namespace _CairoRenderContext{
void CairoRenderContext_Impl__obj::__construct() { }
Dynamic CairoRenderContext_Impl__obj::__CreateEmpty() { return new CairoRenderContext_Impl__obj; }
void *CairoRenderContext_Impl__obj::_hx_vtable = 0;
Dynamic CairoRenderContext_Impl__obj::__Create(::hx::DynamicArray inArgs)
{
::hx::ObjectPtr< CairoRenderContext_Impl__obj > _hx_result = new CairoRenderContext_Impl__obj();
_hx_result->__construct();
return _hx_result;
}
bool CairoRenderContext_Impl__obj::_hx_isInstanceOf(int inClassId) {
return inClassId==(int)0x00000001 || inClassId==(int)0x7ffd6205;
}
::lime::graphics::cairo::Cairo CairoRenderContext_Impl__obj::fromRenderContext( ::lime::graphics::RenderContext context){
HX_STACKFRAME(&_hx_pos_8556288c3ba73522_24_fromRenderContext)
HXDLIN( 24) return context->cairo;
}
STATIC_HX_DEFINE_DYNAMIC_FUNC1(CairoRenderContext_Impl__obj,fromRenderContext,return )
CairoRenderContext_Impl__obj::CairoRenderContext_Impl__obj()
{
}
bool CairoRenderContext_Impl__obj::__GetStatic(const ::String &inName, Dynamic &outValue, ::hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 17:
if (HX_FIELD_EQ(inName,"fromRenderContext") ) { outValue = fromRenderContext_dyn(); return true; }
}
return false;
}
#ifdef HXCPP_SCRIPTABLE
static ::hx::StorageInfo *CairoRenderContext_Impl__obj_sMemberStorageInfo = 0;
static ::hx::StaticInfo *CairoRenderContext_Impl__obj_sStaticStorageInfo = 0;
#endif
::hx::Class CairoRenderContext_Impl__obj::__mClass;
static ::String CairoRenderContext_Impl__obj_sStaticFields[] = {
HX_("fromRenderContext",6f,19,d4,ba),
::String(null())
};
void CairoRenderContext_Impl__obj::__register()
{
CairoRenderContext_Impl__obj _hx_dummy;
CairoRenderContext_Impl__obj::_hx_vtable = *(void **)&_hx_dummy;
::hx::Static(__mClass) = new ::hx::Class_obj();
__mClass->mName = HX_("lime.graphics._CairoRenderContext.CairoRenderContext_Impl_",d9,d8,31,92);
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &CairoRenderContext_Impl__obj::__GetStatic;
__mClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField;
__mClass->mStatics = ::hx::Class_obj::dupFunctions(CairoRenderContext_Impl__obj_sStaticFields);
__mClass->mMembers = ::hx::Class_obj::dupFunctions(0 /* sMemberFields */);
__mClass->mCanCast = ::hx::TCanCast< CairoRenderContext_Impl__obj >;
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = CairoRenderContext_Impl__obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = CairoRenderContext_Impl__obj_sStaticStorageInfo;
#endif
::hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
} // end namespace lime
} // end namespace graphics
} // end namespace _CairoRenderContext
| 37.126316
| 290
| 0.809753
|
BushsHaxs
|
b4c5eea38ccd0f3c84e53c86cb8a40a5bdf5eec7
| 1,454
|
hpp
|
C++
|
src/preprocess/mt-metis-0.7.2/wildriver/src/Util.hpp
|
curiosityyy/SubgraphMatchGPU
|
7089496084d94a72693dca230ed5165cb94ae4a4
|
[
"MIT"
] | 2
|
2017-07-25T19:46:52.000Z
|
2018-02-13T15:24:02.000Z
|
external/mt-metis-0.7.2/wildriver/src/Util.hpp
|
yfg/GDSP
|
56fe2242b32d3a1efd24733d0ab30242ee3df2ba
|
[
"MIT"
] | 25
|
2017-07-20T02:35:49.000Z
|
2018-12-21T01:43:42.000Z
|
external/mt-metis-0.7.2/wildriver/src/Util.hpp
|
yfg/GDSP
|
56fe2242b32d3a1efd24733d0ab30242ee3df2ba
|
[
"MIT"
] | null | null | null |
/**
* @file Util.hpp
* @brief Utility functions.
* @author Dominique LaSalle <dominique@solidlake.com>
* Copyright 2017
* @version 1
* @date 2017-08-03
*/
#ifndef WILDIRVER_UTIL_HPP
#define WILDIRVER_UTIL_HPP
#include <cstring>
#include <string>
#include <vector>
namespace WildRiver
{
class Util
{
public:
/**
* @brief Split a string into chunks separated by 'delims'.
*
* @param input The string to split.
* @param delims The characters to split the string on.
*
* @return A vector non-empty strings.
*/
static std::vector<std::string> split(
std::string const & input,
char const * const delims = " \t") noexcept
{
// create a character map of all 0's
bool map[256] = {false};
// mark my delimiters
const size_t n = strlen(delims);
for (size_t i = 0; i < n; ++i) {
map[(int)delims[i]] = true;
}
// fill in chunks
std::vector<std::string> chunks;
size_t last = 0;
for (size_t i = 0; i < input.length(); ++i) {
if (map[static_cast<uint8_t>(input[i])]) {
if (i > last) {
chunks.emplace_back(input.substr(last, i-last));
}
last = i+1;
}
}
// check for last chunk
if (last < input.length()) {
chunks.emplace_back(input.substr(last, input.length()-last));
}
return chunks;
}
};
}
#endif
| 16.522727
| 69
| 0.555708
|
curiosityyy
|
b4d26ef2994cec0c9e640c8b7a1781aaa7363139
| 1,055
|
cpp
|
C++
|
Data_Structures/Linked_list/create_circular_LL.cpp
|
SouvikSSG/C-Programming
|
e5ae8b4b0ab0ca39532ed4d25e1d997b793f669c
|
[
"Apache-2.0"
] | null | null | null |
Data_Structures/Linked_list/create_circular_LL.cpp
|
SouvikSSG/C-Programming
|
e5ae8b4b0ab0ca39532ed4d25e1d997b793f669c
|
[
"Apache-2.0"
] | null | null | null |
Data_Structures/Linked_list/create_circular_LL.cpp
|
SouvikSSG/C-Programming
|
e5ae8b4b0ab0ca39532ed4d25e1d997b793f669c
|
[
"Apache-2.0"
] | null | null | null |
#include <iostream>
class node {
public:
int data;
node *next;
node(int x) { data = x; }
};
class linkedList {
public:
node *first = NULL;
node *CreateCLL(int A[], int n);
void DisplayCLL(node *p);
};
node *linkedList ::CreateCLL(int A[], int n) {
node *t = NULL, *last = NULL;
first = new node(A[0]);
first->next = first;
last = first;
for (int i = 1; i < n; i++) {
t = new node(A[i]);
t->next = last->next;
last->next = t;
last = t;
}
return first;
}
void linkedList::DisplayCLL(node *p) {
do {
std::cout << p->data << "\t";
p = p->next;
} while (p != first);
}
int main() {
linkedList C_LL1, C_LL2;
int A[] = {2, 5, 9, 4, 10, 7};
int B[] = {7, 0, 3, 2};
int num1 = sizeof(A) / sizeof(A[0]);
int num2 = sizeof(B) / sizeof(B[0]);
node *LL1 = C_LL1.CreateCLL(A, num1);
node *LL2 = C_LL2.CreateCLL(B, num2);
C_LL1.DisplayCLL(LL1);
std::cout << std::endl;
C_LL2.DisplayCLL(LL2);
std::cout << std::endl;
return 0;
}
| 18.839286
| 47
| 0.521327
|
SouvikSSG
|
b4d44db0f485556f526a0dcb70ff1ae1dc371675
| 741
|
cpp
|
C++
|
Leetcode Solution/Top 100 Liked Questions/Medium/49. Group Anagrams.cpp
|
bilwa496/Placement-Preparation
|
bd32ee717f671d95c17f524ed28b0179e0feb044
|
[
"MIT"
] | 169
|
2021-05-30T10:02:19.000Z
|
2022-03-27T18:09:32.000Z
|
Leetcode Solution/Top 100 Liked Questions/Medium/49. Group Anagrams.cpp
|
bilwa496/Placement-Preparation
|
bd32ee717f671d95c17f524ed28b0179e0feb044
|
[
"MIT"
] | 1
|
2021-10-02T14:46:26.000Z
|
2021-10-02T14:46:26.000Z
|
Leetcode Solution/Top 100 Liked Questions/Medium/49. Group Anagrams.cpp
|
bilwa496/Placement-Preparation
|
bd32ee717f671d95c17f524ed28b0179e0feb044
|
[
"MIT"
] | 44
|
2021-05-30T19:56:29.000Z
|
2022-03-17T14:49:00.000Z
|
class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& s) {
unordered_map<string,vector<string>> mp;
for(int i=0;i<s.size();i++)
{
string t = s[i];
sort(t.begin(),t.end());
mp[t].push_back(s[i]);
}
int i=0;
vector<vector<string>> ans;
ans.resize(mp.size(),{});
for(auto m :mp)
{
for(auto j:m.second)
{
ans[i].push_back(j);
}
i++;
}
return ans;
}
};
| 23.903226
| 61
| 0.321188
|
bilwa496
|
b4d59aa41e43ff99e16f094e8636a95af18f75af
| 1,300
|
cpp
|
C++
|
src/ui/view/offline/offlineview.cpp
|
jtymburski/halodoom-launcher
|
3d0c20599c79eb1a953b9be88dd68b53378cb571
|
[
"MIT"
] | 1
|
2021-09-19T22:43:28.000Z
|
2021-09-19T22:43:28.000Z
|
src/ui/view/offline/offlineview.cpp
|
jtymburski/halodoom-launcher
|
3d0c20599c79eb1a953b9be88dd68b53378cb571
|
[
"MIT"
] | null | null | null |
src/ui/view/offline/offlineview.cpp
|
jtymburski/halodoom-launcher
|
3d0c20599c79eb1a953b9be88dd68b53378cb571
|
[
"MIT"
] | null | null | null |
/**
* @class OfflineView
*
* Top level widget that handles the offline skirmish flow screens and cycling through
* them based on the current selection.
*/
#include "ui/view/offline/offlineview.h"
/**
* Constructor, with just the parent.
* @param controller game business logic encapsulation
* @param parent top level owning widget, for garbage collection
*/
OfflineView::OfflineView(GameController *controller, QWidget *parent) : QWidget(parent)
{
QGridLayout *layout = new QGridLayout(this);
layout->setMargin(0);
layout->setRowStretch(1, 1);
// Animated background
AnimatedBackground *background = new AnimatedBackground(this);
background->addBackground(":/image/background/offline1.jpg");
layout->addWidget(background, 0, 0, -1, -1);
// Page header
PageHeader *header = new PageHeader("Offline Skirmish", "Main Menu", this);
connect(header, SIGNAL(backClicked()), this, SLOT(backToPreviousView()));
layout->addWidget(header, 0, 0);
// Game create main view
view_create = new GameCreateView(controller, this);
layout->addWidget(view_create, 1, 0);
}
/**
* Back selected slot in the page. Cycle back through the views before exiting this view.
*/
void OfflineView::backToPreviousView()
{
if(!view_create->backToPreviousView())
emit backClicked();
}
| 30.232558
| 89
| 0.729231
|
jtymburski
|
b4d5c20c0148f22519a55b4a0a1ea7527ab18975
| 7,587
|
cpp
|
C++
|
P001/Source/P001/P001Character.cpp
|
Gadnuuk/P001
|
53fd164ef4a5aa436ec0eb6c72477e87ba60cbee
|
[
"MIT"
] | null | null | null |
P001/Source/P001/P001Character.cpp
|
Gadnuuk/P001
|
53fd164ef4a5aa436ec0eb6c72477e87ba60cbee
|
[
"MIT"
] | null | null | null |
P001/Source/P001/P001Character.cpp
|
Gadnuuk/P001
|
53fd164ef4a5aa436ec0eb6c72477e87ba60cbee
|
[
"MIT"
] | null | null | null |
// Copyright Epic Games, Inc. All Rights Reserved.
#include "P001Character.h"
#include "Gameplay/CharacterMovement/TraversalMovementComponent.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
#include "Components/InputComponent.h"
#include "Components/ArrowComponent.h"
#include "Components/SphereComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/Controller.h"
#include "GameFramework/SpringArmComponent.h"
//////////////////////////////////////////////////////////////////////////
// AP001Character
AP001Character::AP001Character()
{
}
AP001Character::AP001Character(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UTraversalMovementComponent>(ACharacter::CharacterMovementComponentName))
{
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
// set our turn rates for input
BaseTurnRate = 45.f;
BaseLookUpRate = 45.f;
// Don't rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
// Configure character movement
GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...
GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f, 0.0f); // ...at this rotation rate
GetCharacterMovement()->JumpZVelocity = 600.f;
GetCharacterMovement()->AirControl = 0.2f;
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(GetCapsuleComponent());
CameraBoom->TargetArmLength = 300.0f; // The camera follows at this distance behind the character
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
// Create a follow camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
ActionPointCollision = CreateDefaultSubobject<USphereComponent>(TEXT("Action Point Collision"));
ActionPointCollision->SetupAttachment(GetRootComponent());
ActionPointCollision->SetSphereRadius(500.f);
// traversal options set
GetTraversalMovementComponent()->ActionPointDetectionCollision = ActionPointCollision;
GetTraversalMovementComponent()->bCanEverRaiseLegs = true;
GetTraversalMovementComponent()->ClimbStartSettings.PlayerOffsetFromWall = FVector(28.169436f, 0.f, -86.333076f);
GetTraversalMovementComponent()->ClimbStartSettings.MaxDistanceThreshold = 200.f;
GetTraversalMovementComponent()->ClimbStartSettings.MaxDotThreshold = 0.5f;
GetTraversalMovementComponent()->ClimbStartSettings.MaxHeightThreshold = 75.0f;
GetTraversalMovementComponent()->ClimbStartSettings.MinHeightThreshold = -50.0f;
GetTraversalMovementComponent()->ClimbStartSettings.FallingHeightScalar = 1.5f;
GetTraversalMovementComponent()->ClimbStartSettings.LateralThreshold = 100.f;
GetTraversalMovementComponent()->ClimbStartSettings.MaxDistanceScalar = 1.5f;
GetTraversalMovementComponent()->ClimbTransitionSettings.PlayerOffsetFromWall = FVector(50.f, 0, -50.f);
GetTraversalMovementComponent()->ClimbTransitionSettings.MaxDistanceThreshold = 200.f;
GetTraversalMovementComponent()->ClimbTransitionSettings.MinDistanceThreshold = GetCapsuleComponent()->GetScaledCapsuleRadius();
GetTraversalMovementComponent()->ClimbTransitionSettings.MaxDotThreshold = 0.5f;
GetTraversalMovementComponent()->ClimbTransitionSettings.MaxHeightThreshold = 75.0f;
GetTraversalMovementComponent()->ClimbTransitionSettings.MinHeightThreshold = -50.0f;
GetTraversalMovementComponent()->ClimbTransitionSettings.FallingHeightScalar = 1.5f;
GetTraversalMovementComponent()->ClimbTransitionSettings.LateralThreshold = 100.f;
GetTraversalMovementComponent()->ClimbTransitionSettings.WallStepDepth = 30.f;
GetTraversalMovementComponent()->ClimbTransitionSettings.MaxDistanceScalar = 1.5f;
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
// are set in the derived blueprint asset named MyCharacter (to avoid direct content references in C++)
}
//////////////////////////////////////////////////////////////////////////
// Input
void AP001Character::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
// Set up gameplay key bindings
check(PlayerInputComponent);
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &AP001Character::StartJump); // ACharacter::Jump handled by animation event.
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
PlayerInputComponent->BindAxis("MoveForward", this, &AP001Character::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &AP001Character::MoveRight);
// We have 2 versions of the rotation bindings to handle different kinds of devices differently
// "turn" handles devices that provide an absolute delta, such as a mouse.
// "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("TurnRate", this, &AP001Character::TurnAtRate);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
PlayerInputComponent->BindAxis("LookUpRate", this, &AP001Character::LookUpAtRate);
}
class UTraversalMovementComponent* AP001Character::GetTraversalMovementComponent()
{
return Cast<UTraversalMovementComponent>(GetCharacterMovement());
}
void AP001Character::TurnAtRate(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}
void AP001Character::LookUpAtRate(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}
void AP001Character::StartJump()
{
GetTraversalMovementComponent()->Jump();
}
void AP001Character::MoveForward(float Value)
{
if ((Controller != nullptr) && (Value != 0.0f) && (!GetTraversalMovementComponent()->GetIsClimbing()))
{
// find out which way is forward
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get forward vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
else if ((Controller != nullptr))
{
// apply move vector to traversal move component
GetTraversalMovementComponent()->AddClimbVerticalInput(Value);
}
}
void AP001Character::MoveRight(float Value)
{
if ( (Controller != nullptr) && (Value != 0.0f) && (!GetTraversalMovementComponent()->GetIsClimbing()))
{
// find out which way is right
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get right vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
// add movement in that direction
AddMovementInput(Direction, Value);
}
else if((Controller != nullptr))
{
// apply move vector to traversal move component
GetTraversalMovementComponent()->AddClimbHorizontalInput(Value);
}
}
| 44.629412
| 180
| 0.78015
|
Gadnuuk
|
b4da6a45418f08ac738c7e0cbb9a98acc19af9ee
| 297
|
cpp
|
C++
|
src/ZClient.cpp
|
markreds81/TeleportGuru
|
69f3ada7e74269d5f5ac70b3bc9cc0d7c0a5b1c5
|
[
"Apache-2.0"
] | null | null | null |
src/ZClient.cpp
|
markreds81/TeleportGuru
|
69f3ada7e74269d5f5ac70b3bc9cc0d7c0a5b1c5
|
[
"Apache-2.0"
] | null | null | null |
src/ZClient.cpp
|
markreds81/TeleportGuru
|
69f3ada7e74269d5f5ac70b3bc9cc0d7c0a5b1c5
|
[
"Apache-2.0"
] | null | null | null |
#include "ZClient.h"
int ZClient::nextClientId = 1;
ZClient::ZClient() : WiFiClient()
{
m_id = nextClientId++;
m_answered = false;
flags = 0;
}
int ZClient::connect(const char *host, uint16_t port)
{
strncpy(m_host, host, sizeof(m_host));
return Base::connect(host, port);
}
| 18.5625
| 53
| 0.656566
|
markreds81
|
b4e34f555496080dfa2a17c4307202c3d179e15b
| 6,687
|
cpp
|
C++
|
src/integer_polyomino/gpmap/bindings.cpp
|
vatj/integer_polyomino
|
ffa7f53bb17e43c53ea387bfc3cf8a6c917037c4
|
[
"MIT"
] | null | null | null |
src/integer_polyomino/gpmap/bindings.cpp
|
vatj/integer_polyomino
|
ffa7f53bb17e43c53ea387bfc3cf8a6c917037c4
|
[
"MIT"
] | 11
|
2019-11-28T16:56:06.000Z
|
2021-12-13T20:09:22.000Z
|
src/integer_polyomino/gpmap/bindings.cpp
|
vatj/gpmap_integer_polyomino
|
ffa7f53bb17e43c53ea387bfc3cf8a6c917037c4
|
[
"MIT"
] | null | null | null |
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "gpmap_api.hpp"
namespace py = pybind11;
PYBIND11_MODULE(gpmap, m) {
m.doc() = R"pbdoc(
Integer Polyomino GPMap Analysis Module
--------------------------------------------
.. currentmodule:: gpmap
.. autosummary::
:toctree: _generate
)pbdoc"; // optional module docstring
// Genome Space generator functions
m.def("MinimalGenomes", &MinimalGenomesAPI,
"Create a new phenotype table and return generate minimal genomes for (n_genes, colours)",
py::arg("n_genes") = 2, py::arg("low_colour") = 0, py::arg("high_colour") = 6,
py::arg("genome_file") = std::string("None"), py::arg("phenotype_builds") = 40,
py::arg("threshold") = 0.25, py::arg("fixed_table") = true, py::arg("determinism") = 1);
m.def("MinimalGenomesVoid", &MinimalGenomesVoidAPI,
"Create a new phenotype table, generate minimal genomes for (n_genes, colours) and save them in genome_file",
py::arg("n_genes") = 2, py::arg("low_colour") = 0, py::arg("high_colour") = 6,
py::arg("genome_file") = std::string("None"), py::arg("phenotype_builds") = 40,
py::arg("threshold") = 0.25, py::arg("fixed_table") = true, py::arg("determinism") = 1);
// GPmap functions
m.def("MinimalMap", &MinimalMapAPI,
"Return the GP map built from a list of genomes or a genome file.",
py::arg("genomes") = std::vector <Genotype> (), py::arg("table_file") = std::string("None"),
py::arg("gpmap_file") = std::string("None"), py::arg("genome_file") = std::string("None"),
py::arg("threshold") = 0.25, py::arg("phenotype_builds") = 250,
py::arg("fixed_table") = true, py::arg("determinism") = 1);
m.def("MinimalMapVoid", &MinimalMapVoidAPI,
"Save the GP map built from a list of genomes or a genome file.",
py::arg("genomes") = std::vector <Genotype> (), py::arg("table_file") = std::string("None"),
py::arg("gpmap_file") = std::string("None"), py::arg("genome_file") = std::string("None"),
py::arg("threshold") = 0.25, py::arg("phenotype_builds") = 250,
py::arg("fixed_table") = true, py::arg("determinism") = 1);
// Neighbourhood
m.def("GenotypeNeighbourhood", &GenotypeNeighbourhoodAPI,
"Return the list of the single mutation neighbour of a genome",
py::arg("genomes") = std::vector <Genotype> (), py::arg("low_colour") = 0,
py::arg("high_colour") = 6);
m.def("PhenotypeNeighbourhood", &PhenotypeNeighbourhoodAPI,
"Return the list of the Phenotype_IDs of single mutation neighbours of a genome",
py::arg("genome"), py::arg("low_colour") = 0, py::arg("high_colour") = 6,
py::arg("threshold") = 0.25, py::arg("phenotype_builds") = 40,
py::arg("fixed_table") = true, py::arg("determinism") = 1,
py::arg("table_file") = std::string("None"));
m.def("MetricNeighbourhood", &MetricNeighbourhoodAPI,
"Return metric analysis of the genome neighbourhood as a dictionary",
py::arg("genome"), py::arg("low_colour") = 0, py::arg("high_colour") = 6,
py::arg("threshold") = 0.25, py::arg("phenotype_builds") = 40,
py::arg("fixed_table") = true, py::arg("determinism") = 1,
py::arg("table_file") = std::string("None"));
// Metric Sampling
m.def("MetricSampling", &MetricSamplingAPI,
"Analysis of the local neighbourhood of mutant genomes isomorphic to the original genome list",
py::arg("genomes") = std::vector <Genotype> (),
py::arg("genome_file") = std::string("None"), py::arg("table_file") = std::string("None"),
py::arg("set_metric_file") = std::string("None"), py::arg("genome_metric_file") = std::string("None"),
py::arg("threshold") = 0.25, py::arg("phenotype_builds") = 40,
py::arg("fixed_table") = true, py::arg("determinism") = 1,
py::arg("n_genes") = 2, py::arg("low_colour") = 0, py::arg("high_colour") = 6,
py::arg("n_jiggle") = 3, py::arg("dup_aware") = false);
// Duplicate
m.def("GenomesDuplication", &GenomesDuplicationAPI,
"Return a list containing all genomes with a duplicated genes",
py::arg("genomes") = std::vector <Genotype> ());
// Phenotype Table
m.def("PrintTableFromMap", &PrintTableFromMapAPI,
"Return the GP map built from a list of genomes or a genome file.",
py::arg("genomes") = std::vector <Genotype> (), py::arg("table_file") = std::string("None"),
py::arg("gpmap_file") = std::string("None"), py::arg("genome_file") = std::string("None"),
py::arg("threshold") = 0.25, py::arg("phenotype_builds") = 250,
py::arg("fixed_table") = true, py::arg("determinism") = 1);
m.def("LoadTable", &LoadTableAPI,
"Return a python dictionary of the unordered_map variable of the target PhenotypeTable",
py::arg("table_file") = std::string("None"));
// Metric Class
// py::class_<Genotype_Metrics> (m, "Genotype_Metrics", py::dynamic_attr())
// .def(py::init <uint8_t, int8_t, int8_t> ())
// .def_readwrite("n_genes", &Genotype_Metrics::n_genes)
// .def_readwrite("low_colour", &Genotype_Metrics::low_colour)
// .def_readwrite("high_colour", &Genotype_Metrics::high_colour)
// .def_readwrite("ref_genotype", &Genotype_Metrics::ref_genotype)
// .def_readwrite("original", &Genotype_Metrics::original)
// .def_readwrite("ref_pIDs", &Genotype_Metrics::ref_pIDs)
// .def_readwrite("pID_counter", &Genotype_Metrics::pID_counter)
// .def_readwrite("number_of_neighbours", &Genotype_Metrics::number_of_neighbours)
// .def_readwrite("strict_robustness", &Genotype_Metrics::strict_robustness)
// .def_readwrite("intersection_robustness", &Genotype_Metrics::intersection_robustness)
// .def_readwrite("union_evolvability", &Genotype_Metrics::union_evolvability)
// .def_readwrite("complex_diversity", &Genotype_Metrics::complex_diversity)
// .def_readwrite("robust_evolvability", &Genotype_Metrics::robust_evolvability)
// .def_readwrite("complex_evolvability", &Genotype_Metrics::complex_evolvability)
// .def_readwrite("rare", &Genotype_Metrics::rare)
// .def_readwrite("unbound", &Genotype_Metrics::unbound)
// .def_readwrite("neutral_weight", &Genotype_Metrics::neutral_weight)
// .def("to_dict", &Genotype_Metrics::to_dict);
// m.def("GenerateTable", &GenerateTableAPI, "Test function to print the phenotype Table", py::arg("genotype"), py::arg("filepath") = "None", py::arg("filename") = "None");
#ifdef VERSION_INFO
m.attr("__version__") = VERSION_INFO;
#else
m.attr("__version__") = "dev";
#endif
}
| 51.837209
| 176
| 0.642291
|
vatj
|
b4e5595c0a4ca76f1865bf49af1b3be669b3b48a
| 4,100
|
cpp
|
C++
|
Src/Qt/kwt/src/kwaitcondition.cpp
|
iclosure/smartsoft
|
62eaed49efd8306642b928ef4f2d96e36aca6527
|
[
"MIT"
] | null | null | null |
Src/Qt/kwt/src/kwaitcondition.cpp
|
iclosure/smartsoft
|
62eaed49efd8306642b928ef4f2d96e36aca6527
|
[
"MIT"
] | null | null | null |
Src/Qt/kwt/src/kwaitcondition.cpp
|
iclosure/smartsoft
|
62eaed49efd8306642b928ef4f2d96e36aca6527
|
[
"MIT"
] | 1
|
2020-05-11T05:36:49.000Z
|
2020-05-11T05:36:49.000Z
|
#include "precomp.h"
#include "kwaitcondition.h"
#if (QT_VERSION < 0x050000)
#include <Windows.h>
#endif
/////////////////////////////////////////////////////////////
/// WaitEventPrivate
class WaitEventPrivate : QObject
{
public:
explicit WaitEventPrivate(QString name, QObject *parent = 0);
virtual ~WaitEventPrivate(void);
bool setEvent();
bool resetEvent();
private:
Q_DISABLE_COPY(WaitEventPrivate)
int q_priority;
HANDLE q_event;
QMutex q_mutex;
friend class KWaitEvent;
friend class KWaitEventQueue;
};
WaitEventPrivate::WaitEventPrivate(QString name, QObject *parent) :
QObject(parent), q_priority(0)
{
Q_ASSERT(parent->inherits("KWaitEvent"));
setObjectName(name + QUuid().createUuid().toString());
#ifndef Q_OS_WINRT
q_priority = GetThreadPriority(GetCurrentThread());
#endif
#ifndef Q_OS_WINRT
q_event = ::CreateEvent(NULL, TRUE, FALSE, objectName().toStdWString().c_str());
#else
q_event = ::CreateEventEx(NULL, objectName().toStdWString().c_str(), CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
#endif
}
WaitEventPrivate::~WaitEventPrivate()
{
::CloseHandle(q_event);
}
bool WaitEventPrivate::setEvent()
{
qDebug() << QString("set event [%1]").arg(objectName());
QMutexLocker locker(&q_mutex);
return ::SetEvent(q_event) ? true : false;
}
bool WaitEventPrivate::resetEvent()
{
qDebug() << QString("reset event [%1]").arg(objectName());
QMutexLocker locker(&q_mutex);
return ::ResetEvent(q_event) ? true : false;
}
/////////////////////////////////////////////////////////////
/// KWaitEvent
KWaitEvent::KWaitEvent(QObject *parent) :
QObject(parent)
{
setObjectName("KWaitEvent");
d = new WaitEventPrivate(objectName(), this);
}
KWaitEvent::KWaitEvent(QString name, QObject *parent) :
QObject(parent)
{
setObjectName("KWaitEvent");
d = new WaitEventPrivate(name.isEmpty() ? objectName() : name, this);
}
KWaitEvent::~KWaitEvent()
{
delete d;
}
bool KWaitEvent::setEvent()
{
return d->setEvent();
}
bool KWaitEvent::resetEvent()
{
return d->resetEvent();
}
KWaitEvent::WaitResult KWaitEvent::wait(unsigned long msecs)
{
#ifndef Q_OS_WINRT
switch (::WaitForSingleObject(d->q_event, msecs)) {
#else
switch (::WaitForSingleObjectEx(d->q_event, msecs, FALSE)) {
#endif
case WAIT_OBJECT_0: return KWaitEvent::WaitObject0;
case WAIT_TIMEOUT: return KWaitEvent::WaitTimeout;
case WAIT_FAILED: return KWaitEvent::WaitFailed;
default: return KWaitEvent::WaitInvalid;
}
}
/////////////////////////////////////////////////////////////
/// KWaitEventQueue
KWaitEventQueue::KWaitEventQueue()
{
}
KWaitEventQueue::~KWaitEventQueue()
{
}
bool KWaitEventQueue::add(KWaitEvent * event)
{
// insert 'event' into the queue (sorted by priority)
int index = 0;
for (; index < size(); index++) {
if (at(index)->d->q_priority < event->d->q_priority) {
break;
}
}
insert(index, event);
return true;
}
KWaitEvent::WaitResult KWaitEventQueue::waitQueue(WaitMode mode, unsigned long msecs)
{
QVector<HANDLE> handleQueue;
QListIterator<KWaitEvent*> iter(*this);
while (iter.hasNext()) {
handleQueue << iter.next()->d->q_event;
}
quint32 waitResult;
#ifndef Q_OS_WINRT
waitResult = ::WaitForMultipleObjects(handleQueue.count(), handleQueue.constData(),
(mode == KWaitEventQueue::WaitAll) ? TRUE : FALSE, msecs);
#else
waitResult = ::WaitForMultipleObjectsEx(handleQueue.count(), handleQueue.constData(),
(mode == KWaitEventQueue::WaitAll) ? TRUE : FALSE, msecs, FALSE);
#endif
if (WAIT_OBJECT_0 > waitResult || waitResult >= (quint32)(WAIT_OBJECT_0 + handleQueue.count())) {
switch (waitResult) {
case WAIT_TIMEOUT: waitResult = KWaitEvent::WaitTimeout;
case WAIT_FAILED: waitResult = KWaitEvent::WaitFailed;
default: waitResult = KWaitEvent::WaitInvalid;
}
}
return (KWaitEvent::WaitResult)waitResult;
}
| 24.404762
| 118
| 0.642927
|
iclosure
|
b4e6f4239f12c5a491f63f5571bf9c9f813306d5
| 61,093
|
cpp
|
C++
|
samples/03_advances/09_software_occlusion_culling/src/model_mesh.cpp
|
SiminBadri/Wolf.Engine
|
3da04471ec26e162e1cbb7cc88c7ce37ee32c954
|
[
"BSL-1.0",
"Apache-2.0",
"libpng-2.0"
] | 1
|
2020-07-15T13:14:26.000Z
|
2020-07-15T13:14:26.000Z
|
samples/03_advances/09_software_occlusion_culling/src/model_mesh.cpp
|
foroughmajidi/Wolf.Engine
|
f08a8cbd519ca2c70b1c8325250dc9af7ac4c498
|
[
"BSL-1.0",
"Apache-2.0",
"libpng-2.0"
] | null | null | null |
samples/03_advances/09_software_occlusion_culling/src/model_mesh.cpp
|
foroughmajidi/Wolf.Engine
|
f08a8cbd519ca2c70b1c8325250dc9af7ac4c498
|
[
"BSL-1.0",
"Apache-2.0",
"libpng-2.0"
] | null | null | null |
#include "pch.h"
#include "model_mesh.h"
using namespace wolf;
using namespace wolf::system;
using namespace wolf::render::vulkan;
using namespace wolf::content_pipeline;
model_mesh::model_mesh(
_In_ w_cpipeline_model* pContentPipelineModel,
_In_ w_vertex_binding_attributes pVertexBindingAttributes) :
vertex_binding_attributes(pVertexBindingAttributes),
_name("model"),
_mesh(nullptr),
_show_only_lod(false),
global_visiblity(true),
c_model(pContentPipelineModel),
_selected_lod_index(0),
_show_wireframe(false),
_show_bounding_box(false),
_is_sky(false)
{
}
model_mesh::~model_mesh()
{
release();
}
W_RESULT model_mesh::load(
_In_ const std::shared_ptr<w_graphics_device>& pGDevice,
_In_z_ const std::string& pPipelineCacheName,
_In_z_ const std::string& pComputePipelineCacheName,
_In_z_ const std::wstring& pVertexShaderPath,
_In_z_ const std::wstring& pFragmentShaderPath,
_In_ const w_render_pass& pRenderPass,
_In_ const w_viewport& pViewport,
_In_ const w_viewport_scissor& pViewportScissor)
{
if (!pGDevice || !this->c_model) return W_FAILED;
this->gDevice = pGDevice;
const std::string _trace_info = this->_name + "::load";
//create mesh
this->_mesh = new (std::nothrow) w_mesh();
if (!this->_mesh)
{
release();
V(W_FAILED,
w_log_type::W_WARNING,
"allocating memory for w_mesh for model: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
_mesh->set_vertex_binding_attributes(this->vertex_binding_attributes);
//load all textures
if (_load_textures() == W_PASSED)
{
//TODO: currently we use one texture per mesh
_mesh->set_texture(this->_textures[0]);
}
else
{
//set the default texture
this->_textures.push_back(w_texture::default_texture);
logger.warning("default texture will be used for model: {}", this->model_name);
_mesh->set_texture(this->_textures[0]);
}
//load mesh
auto _v_size = static_cast<uint32_t>(this->tmp_batch_vertices.size());
auto _i_size = static_cast<uint32_t>(this->tmp_batch_indices.size());
auto _hr = _mesh->load(
this->gDevice,
this->tmp_batch_vertices.data(),
static_cast<uint32_t>(this->tmp_batch_vertices.size() * sizeof(float)),
_v_size,
this->tmp_batch_indices.data(),
_i_size);
//clear vectors
this->tmp_batch_vertices.clear();
this->tmp_batch_indices.clear();
if (_hr == W_FAILED)
{
release();
V(W_FAILED,
w_log_type::W_WARNING,
"loading mesh for model: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++
//The following codes have been added for this project
//++++++++++++++++++++++++++++++++++++++++++++++++++++
if (_create_buffers() == W_FAILED)
{
release();
return W_FAILED;
}
//create shader modules
if (_create_shader_modules(pVertexShaderPath, pFragmentShaderPath) == W_FAILED)
{
release();
return W_FAILED;
}
//create pipeline
if (_create_pipelines(pPipelineCacheName, pComputePipelineCacheName, pRenderPass, pViewport, pViewportScissor) == W_FAILED)
{
release();
return W_FAILED;
}
//release content pipeline model
this->c_model->release();
this->c_model = nullptr;
auto _number_of_instances = static_cast<uint32_t>(this->instances_transforms.size());
if (_number_of_instances)
{
//create compute semaphore
if (this->_cs.semaphore.initialize(this->gDevice) == W_FAILED)
{
release();
V(W_FAILED,
w_log_type::W_WARNING,
"initializing compute semaphore for model: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
//build compute command buffer
if (_build_compute_command_buffer() == W_FAILED)
{
release();
V(W_FAILED,
w_log_type::W_WARNING,
"building compute command buffer for model: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
}
else
{
//we have only one model
this->visibilities.resize(1);
}
//get bounding sphere
auto _get_first_model_bsphere = w_bounding_sphere::create_from_bounding_box(this->sub_meshes_bounding_box.at(0));
this->_u1.data.texture_max_mip_maps_max_level = this->_textures[0]->get_mip_maps_level();
this->_u1.data.bounding_sphere_radius = _get_first_model_bsphere.radius;
if (this->_u1.update() == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"updating uniform u1(mipmaps) for model: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (_create_bounding_box_shapes(pRenderPass, pViewport, pViewportScissor) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"creaing shapes and bounding boxes for model: {}. trace info: {}", this->model_name, _trace_info);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++
return W_PASSED;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++
//The following codes have been added for this project
//++++++++++++++++++++++++++++++++++++++++++++++++++++
W_RESULT model_mesh::_build_compute_command_buffer()
{
const std::string _trace_info = this->name + "::_build_compute_command_buffer";
if (this->_cs.command_buffers.load(
this->gDevice,
1,
w_command_buffer_level::PRIMARY,
&gDevice->vk_compute_queue) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"creating compute command buffer for: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
auto _cmd = this->_cs.command_buffers.get_command_at(0);
this->_cs.command_buffers.begin(0);
{
auto _indirect_draws_buffer = this->indirect_draws.buffer.get_buffer_handle();
auto _size = this->indirect_draws.buffer.get_descriptor_info().range;
// Add memory barrier to ensure that the indirect commands have been consumed before the compute shader updates them
VkBufferMemoryBarrier _barrier = {};
_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
_barrier.buffer = _indirect_draws_buffer.handle;
_barrier.size = _size;
_barrier.srcAccessMask = VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
_barrier.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
_barrier.srcQueueFamilyIndex = this->gDevice->vk_graphics_queue.index;
_barrier.dstQueueFamilyIndex = this->gDevice->vk_compute_queue.index;
vkCmdPipelineBarrier(
_cmd.handle,
VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT,
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
0,
0, nullptr,
1, &_barrier,
0, nullptr);
if (this->_cs.pipeline.bind(_cmd, w_pipeline_bind_point::COMPUTE) == W_FAILED)
{
this->_cs.command_buffers.end(0);
V(W_FAILED,
w_log_type::W_ERROR,
"binding compute command buffer for: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
vkCmdDispatch(
_cmd.handle,
(uint32_t)(this->indirect_draws.drawing_commands.size() / this->_cs.batch_local_size),
1,
1);
// Add memory barrier to ensure that the compute shader has finished writing the indirect command buffer before it's consumed
_barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
_barrier.dstAccessMask = VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
_barrier.buffer = _indirect_draws_buffer.handle;
_barrier.size = _size;
_barrier.srcQueueFamilyIndex = this->gDevice->vk_compute_queue.index;
_barrier.dstQueueFamilyIndex = this->gDevice->vk_graphics_queue.index;
vkCmdPipelineBarrier(
_cmd.handle,
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT,
0,
0, nullptr,
1, &_barrier,
0, nullptr);
}
this->_cs.command_buffers.end(0);
return W_PASSED;
}
W_RESULT model_mesh::submit_compute_shader()
{
W_RESULT _hr = W_PASSED;
const std::string _trace_info = this->_name + "::submit_compute_shader";
auto _cam_pos = this->_camera_position;
auto _model_pos = glm::vec4(get_position(), 1.0f);
auto _distance_to_camera = glm::distance(_model_pos, _cam_pos);
auto _max_mip_map_level = this->_textures[0]->get_mip_maps_level();
if (this->_show_only_lod)
{
_cam_pos.x += 1000000;//set camera to far
_distance_to_camera = glm::distance(_model_pos, _cam_pos);
}
auto _number_of_instances = static_cast<uint32_t>(this->instances_transforms.size());
if (!_number_of_instances)
{
if (this->lods_info.size())
{
//find lod index for model which has not instnaces
this->_selected_lod_index = this->lods_info.size() - 1;
for (uint32_t i = 0; i < this->_selected_lod_index; ++i)
{
if (_distance_to_camera <= this->lods_info[i].distance)
{
_selected_lod_index = i;
break;
}
}
}
else
{
this->_selected_lod_index = 0;
}
//return W_FAILED, because we do not want to store compute shader's semaphore for this model
return W_FAILED;
}
switch (this->_cs.batch_local_size)
{
case 2:
this->_cs.unifrom_x2->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x2->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x2->data.is_visible));
_hr = this->_cs.unifrom_x2->update();
break;
case 4:
this->_cs.unifrom_x4->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x4->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x4->data.is_visible));
_hr = this->_cs.unifrom_x4->update();
break;
case 8:
this->_cs.unifrom_x8->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x8->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x8->data.is_visible));
_hr = this->_cs.unifrom_x8->update();
break;
case 16:
this->_cs.unifrom_x16->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x16->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x16->data.is_visible));
_hr = this->_cs.unifrom_x16->update();
break;
case 32:
this->_cs.unifrom_x32->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x32->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x32->data.is_visible));
_hr = this->_cs.unifrom_x32->update();
break;
case 64:
this->_cs.unifrom_x64->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x64->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x64->data.is_visible));
_hr = this->_cs.unifrom_x64->update();
break;
case 128:
this->_cs.unifrom_x128->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x128->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x128->data.is_visible));
_hr = this->_cs.unifrom_x128->update();
break;
case 256:
this->_cs.unifrom_x256->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x256->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x256->data.is_visible));
_hr = this->_cs.unifrom_x256->update();
break;
case 512:
this->_cs.unifrom_x512->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x512->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x512->data.is_visible));
_hr = this->_cs.unifrom_x512->update();
break;
case 1024:
this->_cs.unifrom_x1024->data.camera_pos = _cam_pos;
std::memcpy(
&this->_cs.unifrom_x1024->data.is_visible[0],
this->visibilities.data(),
sizeof(this->_cs.unifrom_x1024->data.is_visible));
_hr = this->_cs.unifrom_x1024->update();
break;
}
if (_hr == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"updating compute shader's unifrom for model: {}. trace info: {}", this->model_name, _trace_info);
}
auto _cmd = this->_cs.command_buffers.get_command_at(0);
if (this->gDevice->submit(
{ &_cmd },//command buffers
this->gDevice->vk_compute_queue, //graphics queue
{}, //destination masks
{}, //wait semaphores
{ this->_cs.semaphore }, //signal semaphores
nullptr,
false) == W_FAILED)
{
_hr = W_FAILED;
V(W_FAILED,
w_log_type::W_ERROR,
"submiting compute shader queue for model: {}. trace info: {}", this->model_name, _trace_info);
}
return _hr;
}
W_RESULT model_mesh::draw(_In_ const w_command_buffer& pCommandBuffer, _In_ const wolf::framework::w_first_person_camera* pCamera)
{
if (!this->global_visiblity) return W_PASSED;
const std::string _trace_info = this->_name + "::draw";
if (!this->_mesh) return W_FAILED;
W_RESULT _hr = W_FAILED;
if (pCamera)
{
auto _view = pCamera->get_view();
auto _projection = pCamera->get_projection();
auto _camera_position = pCamera->get_position();
set_view_projection_position(_view, _projection, _camera_position);
}
//bind pipeline
if (this->_show_wireframe)
{
this->_wireframe_pipeline.bind(pCommandBuffer, w_pipeline_bind_point::GRAPHICS);
}
else
{
this->_solid_pipeline.bind(pCommandBuffer, w_pipeline_bind_point::GRAPHICS);
}
if (get_instances_count())
{
auto _buffer_handle = this->_instances_buffer.get_buffer_handle();
_hr = this->_mesh->draw(
pCommandBuffer,
&_buffer_handle,
this->instances_transforms.size(),
0,
&this->indirect_draws);
}
else
{
if (this->_selected_lod_index < this->lods_info.size())
{
auto _lod_info = &this->lods_info[this->_selected_lod_index];
_hr = this->_mesh->draw(
pCommandBuffer,
nullptr,
0,
0,
nullptr,
0,
_lod_info->index_count,
_lod_info->first_index);
}
else
{
V(W_FAILED,
w_log_type::W_ERROR,
"drawing model, lod info is out of range for model: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
}
bool _error = false;
if (_hr == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"drawing model for model: {}. trace info: {}", this->model_name, _trace_info);
_error = true;
}
//show bounding box if needed
if (this->_show_bounding_box)
{
for (auto& _shape : this->_shapes)
{
if (_shape->draw(pCommandBuffer) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"drawing shape for model: {}. trace info: {}", this->model_name, _trace_info);
_error = true;
}
}
}
return _error ? W_FAILED : W_PASSED;
}
W_RESULT model_mesh::_store_indices_vertices_to_batch(
_In_ const wolf::render::vulkan::w_vertex_binding_attributes& pVertexBindingAttributes,
_In_ const float& pTextureUVIndex,
_In_ const std::vector<w_vertex_struct>& pVertices,
_In_ const std::vector<uint32_t>& pIndices,
_Inout_ std::vector<float>& pBatchVertices,
_Inout_ std::vector<uint32_t>& pBatchIndices,
_Inout_ uint32_t& pBaseVertexOffset)
{
if (!pVertices.size()) return W_FAILED;
uint32_t i = 0;
#pragma region store index buffer
for (i = 0; i < pIndices.size(); ++i)
{
pBatchIndices.push_back(pBaseVertexOffset + pIndices[i]);
}
#pragma endregion
#pragma region store vertex buffer
i = 0;
auto _vertex_dec = pVertexBindingAttributes.binding_attributes.find(0);
switch (pVertexBindingAttributes.declaration)
{
default:
//user defined, we need to find vertex declaration
if (_vertex_dec != pVertexBindingAttributes.binding_attributes.end())
{
for (auto& _data : pVertices)
{
for (auto _dec : _vertex_dec->second)
{
if (_dec == w_vertex_attribute::W_TEXTURE_INDEX)
{
pBatchVertices.push_back(pTextureUVIndex);
}
if (_dec == w_vertex_attribute::W_UV)
{
pBatchVertices.push_back(_data.uv[0]);
pBatchVertices.push_back(1 - _data.uv[1]);
}
else if (_dec == w_vertex_attribute::W_POS)
{
pBatchVertices.push_back(_data.position[0]);
pBatchVertices.push_back(_data.position[1]);
pBatchVertices.push_back(_data.position[2]);
}
else if (_dec == w_vertex_attribute::W_NORM)
{
pBatchVertices.push_back(_data.normal[0]);
pBatchVertices.push_back(_data.normal[1]);
pBatchVertices.push_back(_data.normal[2]);
}
else if (_dec == w_vertex_attribute::W_TANGENT)
{
pBatchVertices.push_back(_data.tangent[0]);
pBatchVertices.push_back(_data.tangent[1]);
pBatchVertices.push_back(_data.tangent[2]);
}
else if (_dec == w_vertex_attribute::W_BINORMAL)
{
pBatchVertices.push_back(_data.binormal[0]);
pBatchVertices.push_back(_data.binormal[1]);
pBatchVertices.push_back(_data.binormal[2]);
}
else if (_dec == w_vertex_attribute::W_COLOR)
{
pBatchVertices.push_back(_data.color[0]);
pBatchVertices.push_back(_data.color[1]);
pBatchVertices.push_back(_data.color[2]);
pBatchVertices.push_back(_data.color[3]);
}
else if (_dec == w_vertex_attribute::W_BLEND_WEIGHT)
{
pBatchVertices.push_back(_data.blend_weight[0]);
pBatchVertices.push_back(_data.blend_weight[1]);
pBatchVertices.push_back(_data.blend_weight[2]);
pBatchVertices.push_back(_data.blend_weight[3]);
}
else if (_dec == w_vertex_attribute::W_BLEND_INDICES)
{
pBatchVertices.push_back(_data.blend_indices[0]);
pBatchVertices.push_back(_data.blend_indices[1]);
pBatchVertices.push_back(_data.blend_indices[2]);
pBatchVertices.push_back(_data.blend_indices[3]);
}
}
pBaseVertexOffset++;
}
}
break;
case w_vertex_declaration::VERTEX_POSITION:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_COLOR:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _color = _data.color;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//color
pBatchVertices.push_back(_color[0]);
pBatchVertices.push_back(_color[1]);
pBatchVertices.push_back(_color[2]);
pBatchVertices.push_back(_color[3]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_UV:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _uv = _data.uv;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_UV_INDEX:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _uv = _data.uv;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
pBatchVertices.push_back(pTextureUVIndex);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_UV_COLOR:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _uv = _data.uv;
auto _color = _data.color;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
//color
pBatchVertices.push_back(_color[0]);
pBatchVertices.push_back(_color[1]);
pBatchVertices.push_back(_color[2]);
pBatchVertices.push_back(_color[3]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_UV_INDEX_COLOR:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _uv = _data.uv;
auto _color = _data.color;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
pBatchVertices.push_back(pTextureUVIndex);
//color
pBatchVertices.push_back(_color[0]);
pBatchVertices.push_back(_color[1]);
pBatchVertices.push_back(_color[2]);
pBatchVertices.push_back(_color[3]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_NORMAL_COLOR:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _nor = _data.normal;
auto _color = _data.color;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//normal
pBatchVertices.push_back(_nor[0]);
pBatchVertices.push_back(_nor[1]);
pBatchVertices.push_back(_nor[2]);
//color
pBatchVertices.push_back(_color[0]);
pBatchVertices.push_back(_color[1]);
pBatchVertices.push_back(_color[2]);
pBatchVertices.push_back(_color[3]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_NORMAL_UV:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _nor = _data.normal;
auto _uv = _data.uv;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//normal
pBatchVertices.push_back(_nor[0]);
pBatchVertices.push_back(_nor[1]);
pBatchVertices.push_back(_nor[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_NORMAL_UV_INDEX:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _nor = _data.normal;
auto _uv = _data.uv;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//normal
pBatchVertices.push_back(_nor[0]);
pBatchVertices.push_back(_nor[1]);
pBatchVertices.push_back(_nor[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
pBatchVertices.push_back(pTextureUVIndex);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_NORMAL_UV_TANGENT_BINORMAL:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _nor = _data.normal;
auto _uv = _data.uv;
auto _tangent = _data.tangent;
auto _binormal = _data.binormal;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//normal
pBatchVertices.push_back(_nor[0]);
pBatchVertices.push_back(_nor[1]);
pBatchVertices.push_back(_nor[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
//tangent
pBatchVertices.push_back(_tangent[0]);
pBatchVertices.push_back(_tangent[1]);
pBatchVertices.push_back(_tangent[2]);
//binormal
pBatchVertices.push_back(_binormal[0]);
pBatchVertices.push_back(_binormal[1]);
pBatchVertices.push_back(_binormal[2]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_NORMAL_UV_INDEX_TANGENT_BINORMAL:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _nor = _data.normal;
auto _uv = _data.uv;
auto _tangent = _data.tangent;
auto _binormal = _data.binormal;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//normal
pBatchVertices.push_back(_nor[0]);
pBatchVertices.push_back(_nor[1]);
pBatchVertices.push_back(_nor[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
pBatchVertices.push_back(pTextureUVIndex);
//tangent
pBatchVertices.push_back(_tangent[0]);
pBatchVertices.push_back(_tangent[1]);
pBatchVertices.push_back(_tangent[2]);
//binormal
pBatchVertices.push_back(_binormal[0]);
pBatchVertices.push_back(_binormal[1]);
pBatchVertices.push_back(_binormal[2]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_NORMAL_UV_TANGENT_BINORMAL_BLEND_WEIGHT_BLEND_INDICES:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _nor = _data.normal;
auto _uv = _data.uv;
auto _tangent = _data.tangent;
auto _binormal = _data.binormal;
auto _blend_weight = _data.blend_weight;
auto _blend_indices = _data.blend_indices;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//normal
pBatchVertices.push_back(_nor[0]);
pBatchVertices.push_back(_nor[1]);
pBatchVertices.push_back(_nor[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
//tangent
pBatchVertices.push_back(_tangent[0]);
pBatchVertices.push_back(_tangent[1]);
pBatchVertices.push_back(_tangent[2]);
//binormal
pBatchVertices.push_back(_binormal[0]);
pBatchVertices.push_back(_binormal[1]);
pBatchVertices.push_back(_binormal[2]);
//blend_weight
pBatchVertices.push_back(_blend_weight[0]);
pBatchVertices.push_back(_blend_weight[1]);
pBatchVertices.push_back(_blend_weight[2]);
//blend_indices
pBatchVertices.push_back(_blend_indices[0]);
pBatchVertices.push_back(_blend_indices[1]);
pBatchVertices.push_back(_blend_indices[2]);
pBaseVertexOffset++;
}
break;
case w_vertex_declaration::VERTEX_POSITION_NORMAL_UV_INDEX_TANGENT_BINORMAL_BLEND_WEIGHT_BLEND_INDICES:
for (auto& _data : pVertices)
{
auto _pos = _data.position;
auto _nor = _data.normal;
auto _uv = _data.uv;
auto _tangent = _data.tangent;
auto _binormal = _data.binormal;
auto _blend_weight = _data.blend_weight;
auto _blend_indices = _data.blend_indices;
//position
pBatchVertices.push_back(_pos[0]);
pBatchVertices.push_back(_pos[1]);
pBatchVertices.push_back(_pos[2]);
//normal
pBatchVertices.push_back(_nor[0]);
pBatchVertices.push_back(_nor[1]);
pBatchVertices.push_back(_nor[2]);
//uv
pBatchVertices.push_back(_uv[0]);
pBatchVertices.push_back(_uv[1]);
pBatchVertices.push_back(pTextureUVIndex);
//tangent
pBatchVertices.push_back(_tangent[0]);
pBatchVertices.push_back(_tangent[1]);
pBatchVertices.push_back(_tangent[2]);
//binormal
pBatchVertices.push_back(_binormal[0]);
pBatchVertices.push_back(_binormal[1]);
pBatchVertices.push_back(_binormal[2]);
//blend_weight
pBatchVertices.push_back(_blend_weight[0]);
pBatchVertices.push_back(_blend_weight[1]);
pBatchVertices.push_back(_blend_weight[2]);
//blend_indices
pBatchVertices.push_back(_blend_indices[0]);
pBatchVertices.push_back(_blend_indices[1]);
pBatchVertices.push_back(_blend_indices[2]);
pBaseVertexOffset++;
}
break;
};
#pragma endregion
return W_PASSED;
}
void model_mesh::_store_to_batch(
_In_ const std::vector<w_cpipeline_mesh*>& pModelMeshes,
_In_ const w_vertex_binding_attributes& pVertexBindingAttributes,
_In_ const uint32_t& pLodDistance,
_Inout_ uint32_t& pBaseVertexOffset,
_Inout_ std::vector<float>& pBatchVertices,
_Inout_ std::vector<uint32_t>& pBatchIndices,
_Inout_ std::vector<lod_info>& pLODInfos,
_Inout_ w_bounding_box* pMergedBoundingBox,
_Inout_ std::vector<w_bounding_box>* pSubMeshBoundingBoxes,
_Inout_ std::vector<std::string>* pTexturePathsToBeLoad)
{
auto _meshes_count = pModelMeshes.size();
int _texture_index = 0;
std::map<std::string, int> _textures_index;
std::vector<int> _texture_uv_indices;
_texture_uv_indices.resize(_meshes_count);
for (size_t i = 0; i < _meshes_count; ++i)
{
auto _mesh_data = pModelMeshes[i];
//check for finding uv index
if (pTexturePathsToBeLoad)
{
auto _find = _textures_index.find(_mesh_data->textures_path);
if (_textures_index.empty() && _find == _textures_index.end())
{
_texture_uv_indices[i] = _texture_index;
_textures_index.insert({ _mesh_data->textures_path, _texture_index++ });
pTexturePathsToBeLoad->push_back(_mesh_data->textures_path);
}
else
{
_texture_uv_indices[i] = _find->second;
}
}
//set bounding boxes
if (pMergedBoundingBox)
{
pMergedBoundingBox->merge(_mesh_data->bounding_box);
}
if (pSubMeshBoundingBoxes)
{
pSubMeshBoundingBoxes->push_back(_mesh_data->bounding_box);
}
_store_indices_vertices_to_batch(
pVertexBindingAttributes,
_texture_uv_indices[i],
_mesh_data->vertices,
_mesh_data->indices,
pBatchVertices,
pBatchIndices,
pBaseVertexOffset);
}
//now store the lods
float _lod_distance_index = 1.0f;
lod_info _first_lod_info;
_first_lod_info.first_index = 0;
_first_lod_info.index_count = pBatchIndices.size();// Index count for this LOD
_first_lod_info.distance = _lod_distance_index * pLodDistance;
pLODInfos.push_back(_first_lod_info);
bool _add_lod_info = false;
for (size_t i = 0; i < _meshes_count; ++i)
{
auto _mesh_data = pModelMeshes[i];
if (_store_indices_vertices_to_batch(
pVertexBindingAttributes,
_texture_uv_indices[i],
_mesh_data->lod_1_vertices,
_mesh_data->lod_1_indices,
pBatchVertices,
pBatchIndices,
pBaseVertexOffset) == W_PASSED)
{
_add_lod_info = true;
}
}
if (_add_lod_info)
{
_lod_distance_index++;
lod_info _second_lod_info;
_second_lod_info.first_index = _first_lod_info.index_count;
_second_lod_info.index_count = pBatchIndices.size() - _first_lod_info.index_count;
_second_lod_info.distance = _lod_distance_index * pLodDistance;
pLODInfos.push_back(_second_lod_info);
}
//clear resources
_textures_index.clear();
_texture_uv_indices.clear();
}
#pragma region create methods
W_RESULT model_mesh::_load_textures()
{
const std::string _trace_info = this->_name + "_load_textures";
if (!this->textures_paths.size()) return W_FAILED;
bool _problem = false;
for (auto& _path : this->textures_paths)
{
auto _file_path = wolf::system::io::get_file_name(_path);
auto _index = _file_path.find("_");
auto _texture_name = _file_path.substr(_index + 1, _file_path.size() - _index);
auto _texture = new (std::nothrow) w_texture();
if (_texture)
{
if (w_texture::load_to_shared_textures(
this->gDevice,
wolf::content_path + L"models/sponza/textures/" +
wolf::system::convert::string_to_wstring(_texture_name),
true,
&_texture) == W_PASSED)
{
this->_textures.push_back(_texture);
}
else
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading texture\"{}\" for model: {} . graphics device: {} . trace info: {}",
_path, this->model_name, this->gDevice->get_info(), _trace_info);
_problem = true;
//release texture
SAFE_DELETE(_texture);
}
}
else
{
V(W_FAILED,
w_log_type::W_ERROR,
"allocating memory of texture\"{}\" for model: {} . graphics device: {} . trace info: {}",
_path, this->model_name, this->gDevice->get_info(), _trace_info);
_problem = true;
}
}
return _problem ? W_FAILED : W_PASSED;
}
W_RESULT model_mesh::_create_buffers()
{
const std::string _trace_info = this->_name + "::_create_buffers";
auto _number_of_instances = static_cast<uint32_t>(this->instances_transforms.size());
if (!_number_of_instances) return W_PASSED;
//set compute shader batch size
uint32_t _draw_counts = 1 + _number_of_instances;
//find nearest pow of 2 for compute shader local batch size
this->_cs.batch_local_size = static_cast<uint32_t>(pow(2, ceil(log(_draw_counts) / log(2))));
this->indirect_draws.drawing_commands.resize(this->_cs.batch_local_size);
this->_cs_out_struct.draw_count = _draw_counts;
for (uint32_t i = 0; i < _draw_counts; ++i)
{
this->indirect_draws.drawing_commands[i].instanceCount = 1;
this->indirect_draws.drawing_commands[i].firstInstance = i;
//firstIndex and indexCount are written by the compute shader for models which has at least one instance
}
//load indirect draws
if (this->indirect_draws.load(this->gDevice, _draw_counts) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading indirect draws command buffer for model: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
//create instance buffers
if (_create_instance_buffers() == W_FAILED)
{
return W_FAILED;
}
//create compute shader lod buffer
if (_create_lod_levels_buffer() == W_FAILED)
{
return W_FAILED;
}
//create compute shader output buffer
if (_create_cs_out_buffer() == W_FAILED)
{
return W_FAILED;
}
return W_PASSED;
}
W_RESULT model_mesh::_create_instance_buffers()
{
const std::string _trace_info = this->_name + "::_create_instance_buffer";
auto _number_of_instances = static_cast<uint32_t>(this->instances_transforms.size());
if (!_number_of_instances) return W_PASSED;
w_buffer _staging_buffers[2];
defer _(nullptr, [&](...)
{
for (size_t i = 0; i < 2; ++i)
{
if (_staging_buffers[i].get_is_released()) continue;
_staging_buffers[i].release();
}
});
auto _draw_counts = 1 + _number_of_instances;
std::vector<vertex_instance_data> _vertex_instances_data(_draw_counts);
std::vector<compute_instance_data> _compute_instances_data(_draw_counts);
//first one is ref model
int _index = 0;
_vertex_instances_data[_index].pos[0] = this->transform->position[0];
_vertex_instances_data[_index].pos[1] = this->transform->position[1];
_vertex_instances_data[_index].pos[2] = this->transform->position[2];
_vertex_instances_data[_index].rot[0] = this->transform->rotation[0];
_vertex_instances_data[_index].rot[1] = this->transform->rotation[1];
_vertex_instances_data[_index].rot[2] = this->transform->rotation[2];
_compute_instances_data[_index].pos = glm::vec4(
this->transform->position[0],
this->transform->position[1],
this->transform->position[2],
1.0f);
_index++;
for (auto _ins : this->instances_transforms)
{
_vertex_instances_data[_index].pos[0] = _ins.position[0];
_vertex_instances_data[_index].pos[1] = _ins.position[1];
_vertex_instances_data[_index].pos[2] = _ins.position[2];
_vertex_instances_data[_index].rot[0] = _ins.rotation[0];
_vertex_instances_data[_index].rot[1] = _ins.rotation[1];
_vertex_instances_data[_index].rot[2] = _ins.rotation[2];
_compute_instances_data[_index].pos = glm::vec4(
_ins.position[0],
_ins.position[1],
_ins.position[2],
1.0f);
_index++;
}
#pragma region create vertex instances buffer
auto _buffer_size = static_cast<uint32_t>(_draw_counts * sizeof(vertex_instance_data));
if (_staging_buffers[0].allocate_as_staging(this->gDevice, _buffer_size) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading staging buffer of vertex instances buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (_staging_buffers[0].set_data(_vertex_instances_data.data()) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"setting data to staging buffer of vertex instances buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (this->_instances_buffer.allocate(
this->gDevice,
_buffer_size,
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
w_memory_usage_flag::MEMORY_USAGE_GPU_ONLY) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_WARNING,
"loading device buffer of vertex instances buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (_staging_buffers[0].copy_to(this->_instances_buffer) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_WARNING,
"copying to device buffer of vertex instances buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
//release buffer
_staging_buffers[0].release();
#pragma endregion
#pragma region create compute instances buffer
_buffer_size = _draw_counts * sizeof(compute_instance_data);
if (_staging_buffers[1].allocate_as_staging(this->gDevice, _buffer_size) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading staging buffer of compute instances buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (_staging_buffers[1].set_data(_compute_instances_data.data()) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_WARNING,
"setting data to staging buffer of compute instances buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (this->_cs.instances_buffer.allocate(
this->gDevice,
_buffer_size,
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
w_memory_usage_flag::MEMORY_USAGE_GPU_ONLY) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_WARNING,
"loading device buffer of compute instances buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (_staging_buffers[1].copy_to(_cs.instances_buffer) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_WARNING,
"copying to device buffer of compute instances buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
_staging_buffers[1].release();
#pragma endregion
return W_PASSED;
}
W_RESULT model_mesh::_create_lod_levels_buffer()
{
const std::string _trace_info = this->_name + "::_create_lod_levels_buffer";
auto _number_of_instances = static_cast<uint32_t>(this->instances_transforms.size());
if (!_number_of_instances) return W_PASSED;
w_buffer _staging_buffer;
defer _(nullptr, [&](...)
{
_staging_buffer.release();
});
auto _size = static_cast<uint32_t>(this->lods_info.size() * sizeof(lod_info));
if (_staging_buffer.allocate_as_staging(this->gDevice, _size) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading staging buffer for lod levels buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (_staging_buffer.set_data(this->lods_info.data()))
{
V(W_FAILED,
w_log_type::W_ERROR,
"setting data to staging buffer of lod levels buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (this->_cs.lod_levels_buffer.allocate(
this->gDevice,
_size,
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
w_memory_usage_flag::MEMORY_USAGE_GPU_TO_CPU) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading data to staging buffer of lod levels buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
if (_staging_buffer.copy_to(this->_cs.lod_levels_buffer) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"copy staging buffer to device buffer of lod levels buffer. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
return W_PASSED;
}
W_RESULT model_mesh::_create_cs_out_buffer()
{
const std::string _trace_info = this->_name + "::_create_cs_out_buffer";
auto _number_of_instances = static_cast<uint32_t>(this->instances_transforms.size());
if (!_number_of_instances) return W_PASSED;
//create buffer of compute stage output
auto _size = (uint32_t)sizeof(compute_stage_output);
if (this->_cs_out_buffer.allocate(
this->gDevice,
_size,
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
w_memory_usage_flag::MEMORY_USAGE_GPU_TO_CPU) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading compute shader stage output buffer for model: {}. trace info: {}", this->model_name, _trace_info);
return W_FAILED;
}
return W_PASSED;
}
W_RESULT model_mesh::_prepare_cs_path_uniform_based_on_local_size(
_Inout_ w_shader_binding_param& pShaderBindingParam,
_Inout_ std::wstring& pComputeShaderPath)
{
const std::string _trace_info = this->_name + "::_prepare_compute_shader_based_on_batch_local_size";
auto _lod_level = this->lods_info.size() ? this->lods_info.size() - 1 : 0;
pComputeShaderPath = L"lod_" + std::to_wstring(_lod_level) + L"_local_size_x" + std::to_wstring(this->_cs.batch_local_size) + L".comp.spv";
auto _hr = W_PASSED;
switch (this->_cs.batch_local_size)
{
default:
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"batch_local_size:{} not supported for model: {} . trace info: {}",
this->_cs.batch_local_size,
this->model_name,
_trace_info);
case 2:
this->visibilities.resize(1);
this->_cs.unifrom_x2 = new w_uniform<compute_unifrom_x2>();
if (this->_cs.unifrom_x2->load(this->gDevice) == W_FAILED)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x2 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x2->get_descriptor_info();
}
break;
case 4:
this->visibilities.resize(1);
this->_cs.unifrom_x4 = new w_uniform<compute_unifrom_x4>();
if (this->_cs.unifrom_x4->load(this->gDevice) == W_FAILED)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x4 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x4->get_descriptor_info();
}
break;
case 8:
this->visibilities.resize(8 / 4);
this->_cs.unifrom_x8 = new w_uniform<compute_unifrom_x8>();
if (this->_cs.unifrom_x8->load(this->gDevice) == W_FAILED)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x8 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x8->get_descriptor_info();
}
break;
case 16:
this->visibilities.resize(16 / 4);
this->_cs.unifrom_x16 = new w_uniform<compute_unifrom_x16>();
if (this->_cs.unifrom_x16->load(this->gDevice) == W_FAILED)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x16 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x16->get_descriptor_info();
}
break;
case 32:
this->visibilities.resize(32 / 4);
this->_cs.unifrom_x32 = new w_uniform<compute_unifrom_x32>();
if (this->_cs.unifrom_x32->load(this->gDevice) == W_FAILED)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x32 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x32->get_descriptor_info();
}
break;
case 64:
this->visibilities.resize(64 / 4);
this->_cs.unifrom_x64 = new w_uniform<compute_unifrom_x64>();
if (this->_cs.unifrom_x64->load(this->gDevice) == W_FAILED)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x64 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x64->get_descriptor_info();
}
break;
case 128:
this->visibilities.resize(128 / 4);
this->_cs.unifrom_x128 = new w_uniform<compute_unifrom_x128>();
if (this->_cs.unifrom_x128->load(this->gDevice) == W_FAILED)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x128 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x128->get_descriptor_info();
}
break;
case 256:
this->visibilities.resize(256 / 4);
this->_cs.unifrom_x256 = new w_uniform<compute_unifrom_x256>();
if (this->_cs.unifrom_x256->load(this->gDevice) == S_FALSE)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x256 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x256->get_descriptor_info();
}
break;
case 512:
this->visibilities.resize(512 / 4);
this->_cs.unifrom_x512 = new w_uniform<compute_unifrom_x512>();
if (this->_cs.unifrom_x512->load(this->gDevice) == S_FALSE)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x512 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x512->get_descriptor_info();
}
break;
case 1024:
this->visibilities.resize(1024 / 4);
this->_cs.unifrom_x1024 = new w_uniform<compute_unifrom_x1024>();
if (this->_cs.unifrom_x1024->load(this->gDevice) == S_FALSE)
{
_hr = W_FAILED;
V(_hr,
w_log_type::W_ERROR,
"loading compute shader unifrom_x1024 for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
else
{
pShaderBindingParam.buffer_info = this->_cs.unifrom_x1024->get_descriptor_info();
}
break;
}
return _hr;
}
W_RESULT model_mesh::_create_shader_modules(
_In_z_ const std::wstring& pVertexShaderPath,
_In_z_ const std::wstring& pFragmentShaderPath)
{
const std::string _trace_info = this->_name + "_create_shader_module";
W_RESULT _hr = W_FAILED;
std::vector<w_shader_binding_param> _shader_params;
w_shader_binding_param _shader_param;
_shader_param.index = 0;
_shader_param.type = w_shader_binding_type::UNIFORM;
_shader_param.stage = w_shader_stage_flag_bits::VERTEX_SHADER;
//set U0 uniform of instance vertex shader, which has seperate structure for basic model or instanced models
if (this->instances_transforms.size())
{
_hr = this->_instance_u0.load(this->gDevice);
if (_hr == W_FAILED)
{
V(_hr,
w_log_type::W_ERROR,
"loading vertex shader instance uniform for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
_shader_param.buffer_info = this->_instance_u0.get_descriptor_info();
}
else
{
_hr = this->_basic_u0.load(this->gDevice);
if (_hr == W_FAILED)
{
V(_hr,
w_log_type::W_ERROR,
"loading vertex shader basic uniform for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
_shader_param.buffer_info = this->_basic_u0.get_descriptor_info();
}
_shader_params.push_back(_shader_param);
//The texture lod index
_hr = this->_u1.load(this->gDevice);
if (_hr == W_FAILED)
{
V(_hr,
w_log_type::W_ERROR,
"loading vertex shader uniform 1 for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
_shader_param.index = 1;
_shader_param.type = w_shader_binding_type::UNIFORM;
_shader_param.stage = w_shader_stage_flag_bits::VERTEX_SHADER;
_shader_param.buffer_info = this->_u1.get_descriptor_info();
_shader_params.push_back(_shader_param);
//The sampler2D of fragment shader
_shader_param.index = 2;
_shader_param.type = w_shader_binding_type::SAMPLER2D;
_shader_param.stage = w_shader_stage_flag_bits::FRAGMENT_SHADER;
_shader_param.image_info = this->_textures[0]->get_descriptor_info(w_sampler_type::MIPMAP_AND_ANISOTROPY);
_shader_params.push_back(_shader_param);
//the U1 uniform of fragment shader
_hr = this->_u2.load(this->gDevice);
if (_hr == W_FAILED)
{
V(_hr,
w_log_type::W_ERROR,
"loading fragment shader uniform 2 for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
if (this->_is_sky)
{
this->_u2.data.cmds = 2;
auto _hr = this->_u2.update();
if (_hr == W_FAILED)
{
V(_hr,
w_log_type::W_ERROR,
"updating uniform u2(cmds) for sky: {}. trace info: {}",
this->model_name,
_trace_info);
}
}
_shader_param.index = 3;
_shader_param.type = w_shader_binding_type::UNIFORM;
_shader_param.stage = w_shader_stage_flag_bits::FRAGMENT_SHADER;
_shader_param.buffer_info = this->_u2.get_descriptor_info();
_shader_params.push_back(_shader_param);
//the following shader parameters will be added for models which have at least one instance
auto _number_of_instances = static_cast<uint32_t>(this->instances_transforms.size());
if (_number_of_instances)
{
_shader_param.index = 0;
_shader_param.type = w_shader_binding_type::STORAGE;
_shader_param.stage = w_shader_stage_flag_bits::COMPUTE_SHADER;
_shader_param.buffer_info = this->_cs.instances_buffer.get_descriptor_info();
_shader_params.push_back(_shader_param);
_shader_param.index = 1;
_shader_param.type = w_shader_binding_type::STORAGE;
_shader_param.stage = w_shader_stage_flag_bits::COMPUTE_SHADER;
_shader_param.buffer_info = this->indirect_draws.buffer.get_descriptor_info();
_shader_params.push_back(_shader_param);
_shader_param.index = 2;
_shader_param.type = w_shader_binding_type::UNIFORM;
_shader_param.stage = w_shader_stage_flag_bits::COMPUTE_SHADER;
std::wstring _compute_shader_path;
if (_prepare_cs_path_uniform_based_on_local_size(_shader_param, _compute_shader_path) == W_FAILED)
{
V(_hr,
w_log_type::W_ERROR,
"getting compute shader uniform and filename path for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
_shader_params.push_back(_shader_param);
_shader_param.index = 3;
_shader_param.type = w_shader_binding_type::STORAGE;
_shader_param.stage = w_shader_stage_flag_bits::COMPUTE_SHADER;
_shader_param.buffer_info = this->_cs_out_buffer.get_descriptor_info();
_shader_params.push_back(_shader_param);
_shader_param.index = 4;
_shader_param.type = w_shader_binding_type::STORAGE;
_shader_param.stage = w_shader_stage_flag_bits::COMPUTE_SHADER;
_shader_param.buffer_info = this->_cs.lod_levels_buffer.get_descriptor_info();
_shader_params.push_back(_shader_param);
//load shaders
if (w_shader::load_shader(
this->gDevice,
"model_mesh_" + wolf::system::convert::wstring_to_string(_compute_shader_path),
pVertexShaderPath,
L"",
L"",
L"",
pFragmentShaderPath,
shared::scene_content_path + L"shaders/compute/" + _compute_shader_path,
_shader_params,
false,
&this->_shader) == W_FAILED)
{
V(_hr,
w_log_type::W_ERROR,
"loading shader module for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
}
else
{
//load shaders
if (w_shader::load_shader(
this->gDevice,
"model_basic_mesh",
pVertexShaderPath,
L"",
L"",
L"",
pFragmentShaderPath,
L"",
_shader_params,
false,
&this->_shader) == W_FAILED)
{
V(_hr,
w_log_type::W_ERROR,
"loading shader module for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
}
_hr = this->_shader->set_shader_binding_params(_shader_params);
if (_hr == W_FAILED)
{
V(_hr,
w_log_type::W_ERROR,
"setting shader binding param for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
_shader_params.clear();
return W_PASSED;
}
W_RESULT model_mesh::_create_pipelines(
_In_z_ const std::string& pPipelineCacheName,
_In_z_ const std::string& pComputePipelineCacheName,
_In_ const w_render_pass& pRenderPass,
_In_ const w_viewport& pViewport,
_In_ const w_viewport_scissor& pViewportScissor)
{
const std::string _trace_info = this->_name + "_create_pipelines";
std::vector<w_viewport> _viewports = { pViewport };
std::vector<w_viewport_scissor> _viewport_scissors = { pViewportScissor };
std::vector<w_dynamic_state> _dynamic_states =
{
VIEWPORT,
SCISSOR,
};
if (this->_solid_pipeline.load(
this->gDevice,
this->vertex_binding_attributes,
w_primitive_topology::TRIANGLE_LIST,
&pRenderPass,
this->_shader,
_viewports,
_viewport_scissors,
pPipelineCacheName,
_dynamic_states) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading drawing pipeline for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
auto _rasterization_states = w_graphics_device::defaults_states::pipelines::rasterization_create_info;
_rasterization_states.set_polygon_mode(w_polygon_mode::LINE);
auto _hr = this->_wireframe_pipeline.load(
this->gDevice,
this->vertex_binding_attributes,
w_primitive_topology::TRIANGLE_LIST,
&pRenderPass,
this->_shader,
_viewports,
_viewport_scissors,
pComputePipelineCacheName,
_dynamic_states,
{},
0,//Disable tessellation stage
_rasterization_states);
_viewports.clear();
_viewport_scissors.clear();
if(_hr == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading drawing wireframe pipeline for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
auto _number_of_instances = static_cast<uint32_t>(this->instances_transforms.size());
if (_number_of_instances)
{
if (this->_cs.pipeline.load_compute(
this->gDevice,
this->_shader,
5,
pComputePipelineCacheName) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading computing pipeline for model: {}. trace info: {}",
this->model_name,
_trace_info);
return W_FAILED;
}
}
return W_PASSED;
}
W_RESULT model_mesh::_create_bounding_box_shapes(
_In_ const w_render_pass& pRenderPass,
_In_ const w_viewport& pViewport,
_In_ const w_viewport_scissor& pViewportScissor)
{
const std::string _trace_info = this->_name + "_create_bounding_box_shapes";
auto _hr = W_PASSED;
//create bounding box from world matrix of ref model and create a shape for it
if (this->sub_meshes_bounding_box.size())
{
//get ref bounding box
auto _ref_box = this->sub_meshes_bounding_box[0];
auto _min = glm::vec4(_ref_box.min[0], _ref_box.min[1], _ref_box.min[2], 1.0f);
auto _max = glm::vec4(_ref_box.max[0], _ref_box.max[1], _ref_box.max[2], 1.0f);
//clear all bounding boxes and create new aligned
this->sub_meshes_bounding_box.clear();
//align bounding box to ref model
glm::vec3 _position = get_position();
glm::vec3 _rotation = get_rotation();
glm::vec3 _scale(1.0f);
auto _transfer_mat = glm::translate(_position) * glm::rotate(_rotation) * glm::scale(_scale);
auto _transfer_min = _transfer_mat * _min;
auto _transfer_max = _transfer_mat * _max;
w_bounding_box _aligned;
std::memcpy(&_aligned.min[0], &_transfer_min[0], 3 * sizeof(float));
std::memcpy(&_aligned.max[0], &_transfer_max[0], 3 * sizeof(float));
this->sub_meshes_bounding_box.push_back(_aligned);
auto _shape = _create_shape(pRenderPass, pViewport, pViewportScissor, _aligned, w_color::RED());
if (_shape)
{
this->_shapes.push_back(_shape);
}
else
{
_hr = W_FAILED;
}
for (auto& ins : this->instances_transforms)
{
_position.x = ins.position[0]; _position.y = ins.position[1]; _position.z = ins.position[2];
_rotation.x = ins.rotation[0]; _rotation.y = ins.rotation[1]; _rotation.z = ins.rotation[2];
_transfer_mat = glm::translate(_position) * glm::rotate(_rotation) * glm::scale(_scale);
_transfer_min = _transfer_mat * _min;
_transfer_max = _transfer_mat * _max;
std::memcpy(&_aligned.min[0], &_transfer_min[0], 3 * sizeof(float));
std::memcpy(&_aligned.max[0], &_transfer_max[0], 3 * sizeof(float));
this->sub_meshes_bounding_box.push_back(_aligned);
_shape = _create_shape(pRenderPass, pViewport, pViewportScissor, _aligned, w_color::GREEN());
if (_shape)
{
this->_shapes.push_back(_shape);
}
else
{
_hr = W_FAILED;
}
}
}
return _hr;
}
w_shapes* model_mesh::_create_shape(
_In_ const w_render_pass& pRenderPass,
_In_ const w_viewport& pViewport,
_In_ const w_viewport_scissor& pViewportScissor,
_In_ const w_bounding_box& pBoundingBox,
_In_ const w_color& pColor)
{
const std::string _trace_info = this->_name + "_create_shape";
//create shape for root model
auto _shape_box = new (std::nothrow) w_shapes(pBoundingBox, pColor);
if (!_shape_box)
{
V(W_FAILED,
w_log_type::W_ERROR,
"allocating memory for shape(box) for model: {}. trace info: {}",
this->model_name,
_trace_info);
return nullptr;
}
if (_shape_box->load(
this->gDevice,
pRenderPass,
pViewport,
pViewportScissor) == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"loading shape(box) for model: {}. trace info: {}",
this->model_name,
_trace_info);
return nullptr;
}
return _shape_box;
}
#pragma endregion
ULONG model_mesh::release()
{
this->_name.clear();
this->model_name.clear();
this->instances_transforms.clear();
if (this->c_model)
{
this->c_model->release();
this->c_model = nullptr;
}
this->_solid_pipeline.release();
this->_wireframe_pipeline.release();
SAFE_RELEASE(this->_shader);
this->_basic_u0.release();
this->_instance_u0.release();
this->_u1.release();
this->_u2.release();
//release mesh resources
SAFE_RELEASE(this->_mesh);
this->_instances_buffer.release();
this->sub_meshes_bounding_box.clear();
//release textures
this->textures_paths.clear();
for (auto _t : this->_textures)
{
if (_t) _t->release();
}
this->_textures.clear();
this->_cs.release();
//release shapes
for (auto _shape : this->_shapes)
{
SAFE_RELEASE(_shape);
}
this->_shapes.clear();
this->gDevice = nullptr;
return 0;
}
#pragma region Getters
std::string model_mesh::get_model_name() const
{
return this->model_name;
}
glm::vec3 model_mesh::get_position() const
{
return glm::vec3(this->transform->position[0], this->transform->position[1], this->transform->position[2]);
}
glm::vec3 model_mesh::get_rotation() const
{
return glm::vec3(this->transform->rotation[0], this->transform->rotation[1], this->transform->rotation[2]);
}
//glm::vec3 model_mesh::get_scale() const
//{
// return glm::vec3(this->transform.scale[0], this->transform.scale[1], this->transform.scale[2]);
//}
std::vector<w_instance_info> model_mesh::get_instances() const
{
return this->instances_transforms;
}
const uint32_t model_mesh::get_instances_count() const
{
return static_cast<uint32_t>(this->instances_transforms.size());
}
w_bounding_box model_mesh::get_global_bounding_box() const
{
return this->merged_bounding_box;
}
bool model_mesh::get_enable_instances_colors() const
{
return this->_u2.data.cmds == 1;
}
bool model_mesh::get_global_visiblity() const
{
return this->global_visiblity;
}
bool model_mesh::get_visiblity(_In_ const uint32_t& pModelInstanceIndex) const
{
auto _size = this->visibilities.size();
uint32_t _base_index = pModelInstanceIndex % 4;
uint32_t _sec_index = pModelInstanceIndex - _base_index * 4;
return pModelInstanceIndex < _size ?
this->visibilities[_base_index][_sec_index] == 1.0f : false;
}
w_semaphore* model_mesh::get_compute_semaphore()
{
return &(this->_cs.semaphore);
}
compute_stage_output model_mesh::get_result_of_compute_shader()
{
// Get draw count from compute
auto _mapped = this->_cs_out_buffer.map();
if (_mapped)
{
memcpy(&this->_cs_out_struct, _mapped, sizeof(compute_stage_output));
}
this->_cs_out_buffer.unmap();
_mapped = nullptr;
return this->_cs_out_struct;
}
bool model_mesh::get_showing_wireframe() const
{
return this->_show_wireframe;
}
#pragma endregion
#pragma region Setters
void model_mesh::set_view_projection_position(
_In_ const glm::mat4& pView,
_In_ const glm::mat4& pProjection,
_In_ const glm::vec3& pPosition)
{
const std::string _trace_info = this->_name + "::set_view_projection";
this->_camera_position = glm::vec4(pPosition, 1.0f);
if (this->instances_transforms.size())
{
this->_instance_u0.data.view = pView;
this->_instance_u0.data.projection = pProjection;
this->_instance_u0.data.camera_pos = this->_camera_position;
auto _hr = this->_instance_u0.update();
if (_hr == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"updating instance uniform ViewProjection for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
}
else
{
auto _position = get_position();
auto _rotation = get_rotation();
glm::vec3 _scale(1.0f);
this->_basic_u0.data.model = glm::translate(_position) * glm::rotate(_rotation) * glm::scale(_scale);
this->_basic_u0.data.view = pView;
this->_basic_u0.data.projection = pProjection;
this->_basic_u0.data.camera_pos = glm::vec4(pPosition, 1.0f);
auto _hr = this->_basic_u0.update();
if (_hr == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"updating basic uniform ViewProjection for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
}
if (this->_show_bounding_box && this->_shapes.size())
{
auto _world = glm::mat4(1);
for (auto _shape : this->_shapes)
{
_shape->update(pProjection * pView * _world);
}
}
}
void model_mesh::set_enable_instances_colors(_In_ const bool& pEnable)
{
const std::string _trace_info = this->_name + "::set_enable_instances_colors";
if (!this->_is_sky)
{
this->_u2.data.cmds = pEnable ? 1 : 0;
auto _hr = this->_u2.update();
if (_hr == W_FAILED)
{
V(W_FAILED,
w_log_type::W_ERROR,
"updating uniform u2(cmds) for model: {}. trace info: {}",
this->model_name,
_trace_info);
}
}
}
void model_mesh::set_global_visiblity(_In_ const bool& pValue)
{
this->global_visiblity = pValue ? 1.0f : 0.0f;
for (size_t i = 0; i < this->visibilities.size(); ++i)
{
this->visibilities[i] = glm::vec4(this->global_visiblity);
}
}
void model_mesh::set_visiblity(_In_ const bool& pValue, _In_ const uint32_t& pModelInstanceIndex)
{
uint32_t _base_index = pModelInstanceIndex % 4;
if (_base_index < this->visibilities.size())
{
uint32_t _sec_index = pModelInstanceIndex - _base_index * 4;
this->visibilities[_base_index][_sec_index] = pValue ? 1.0f : 0.0f;
}
}
void model_mesh::set_show_only_lods(_In_ const bool& pValue)
{
this->_show_only_lod = pValue;
}
void model_mesh::set_showing_wireframe(_In_ const bool& pValue)
{
this->_show_wireframe = pValue;
}
void model_mesh::set_show_bounding_box(_In_ const bool& pValue)
{
this->_show_bounding_box = pValue;
}
#pragma endregion
//++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++
| 27.408255
| 140
| 0.713584
|
SiminBadri
|
b4e88f5b2e77ce14c7cf38ef8b337356acc09c14
| 3,294
|
cpp
|
C++
|
programs/sophiatxd_light/main.cpp
|
SophiaTX/SophiaTx-Blockchain
|
c964691c020962ad1aba8263c0d8a78a9fa27e45
|
[
"MIT"
] | 8
|
2018-07-25T20:42:43.000Z
|
2019-03-11T03:14:09.000Z
|
programs/sophiatxd_light/main.cpp
|
SophiaTX/SophiaTx-Blockchain
|
c964691c020962ad1aba8263c0d8a78a9fa27e45
|
[
"MIT"
] | 13
|
2018-07-25T17:41:28.000Z
|
2019-01-25T13:38:11.000Z
|
programs/sophiatxd_light/main.cpp
|
SophiaTX/SophiaTx-Blockchain
|
c964691c020962ad1aba8263c0d8a78a9fa27e45
|
[
"MIT"
] | 11
|
2018-07-25T14:34:13.000Z
|
2019-05-03T13:29:37.000Z
|
#include <appbase/application.hpp>
#include <sophiatx/manifest/plugins.hpp>
#include <sophiatx/protocol/types.hpp>
#include <sophiatx/protocol/version.hpp>
#include <sophiatx/utilities/key_conversion.hpp>
#include <sophiatx/utilities/git_revision.hpp>
#include <sophiatx/plugins/chain/chain_plugin.hpp>
#include <sophiatx/plugins/webserver/webserver_plugin.hpp>
#include <fc/exception/exception.hpp>
#include <fc/thread/thread.hpp>
#include <fc/interprocess/signals.hpp>
#include <fc/git_revision.hpp>
#include <fc/stacktrace.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/program_options.hpp>
#include <iostream>
#include <csignal>
#include <vector>
#include <fc/crypto/rand.hpp>
#include <sophiatx/plugins/chain/chain_plugin_lite.hpp>
namespace bpo = boost::program_options;
using sophiatx::protocol::version;
using std::string;
using std::vector;
string& version_string()
{
static string v_str =
"sophiatx_blockchain_version: " + std::string( SOPHIATX_BLOCKCHAIN_VERSION ) + "\n" +
"sophiatx_git_revision: " + std::string( sophiatx::utilities::git_revision_sha ) + "\n" +
"fc_git_revision: " + std::string( fc::git_revision_sha ) + "\n";
return v_str;
}
void info()
{
std::cerr << "------------------------------------------------------\n\n";
std::cerr << " STARTING SOPHIATX LIGHT CLIENT\n\n";
std::cerr << "------------------------------------------------------\n";
}
int main( int argc, char** argv )
{
try
{
appbase::app().register_plugin<sophiatx::plugins::chain::chain_plugin_lite>();
sophiatx::plugins::register_plugins();
// Reads main application config file
if( !appbase::app().load_config(argc, argv)) {
return 0;
}
auto& args = appbase::app().get_args();
// Initializes logger
fc::Logger::init("sophiatx-light"/* Do not change this parameter as syslog config depends on it !!! */, args.at("log-level").as< std::string >());
appbase::app().set_version_string( version_string() );
bool initialized = appbase::app().initialize<
sophiatx::plugins::chain::chain_plugin_lite,
sophiatx::plugins::json_rpc::json_rpc_plugin,
sophiatx::plugins::webserver::webserver_plugin >( argc, argv );
info();
if( !initialized ) {
return 0;
}
fc::ecc::public_key::init_cache(static_cast<uint32_t>(sophiatx::chain::sophiatx_config::get<uint32_t>("SOPHIATX_MAX_BLOCK_SIZE") / SOPHIATX_MIN_TRANSACTION_SIZE_LIMIT), std::chrono::milliseconds(2000));
if( args.at( "backtrace" ).as< string >() == "yes" )
{
fc::print_stacktrace_on_segfault();
ilog( "Backtrace on segfault is enabled." );
}
appbase::app().startup();
appbase::app().exec();
ilog("exited cleanly");
return 0;
}
catch ( const boost::exception& e )
{
std::cerr << boost::diagnostic_information(e) << "\n";
}
catch ( const fc::exception& e )
{
std::cerr << e.to_detail_string() << "\n";
}
catch ( const std::exception& e )
{
std::cerr << e.what() << "\n";
}
catch ( ... )
{
std::cerr << "unknown exception\n";
}
return -1;
}
| 29.150442
| 208
| 0.615058
|
SophiaTX
|
b4ee7580e7eb1cbe3d78f5fecdc1b8c58f7d8b79
| 2,500
|
cpp
|
C++
|
src/chip/nand3chip.cpp
|
flypie/atanua
|
aabeef9c8b49fb922dbfec44a0c6198b08f4a1e4
|
[
"Zlib"
] | null | null | null |
src/chip/nand3chip.cpp
|
flypie/atanua
|
aabeef9c8b49fb922dbfec44a0c6198b08f4a1e4
|
[
"Zlib"
] | null | null | null |
src/chip/nand3chip.cpp
|
flypie/atanua
|
aabeef9c8b49fb922dbfec44a0c6198b08f4a1e4
|
[
"Zlib"
] | null | null | null |
/*
Atanua Real-Time Logic Simulator
Copyright (c) 2008-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "atanua.h"
#include "nand3chip.h"
NAND3Chip::NAND3Chip(int aUS)
{
set(0,0,4,2,NULL);
mPin.push_back(&mInputPinA);
mInputPinA.set(0, 0.25, this, "Input A");
mPin.push_back(&mInputPinB);
mInputPinB.set(0, 0.75, this, "Input B");
mPin.push_back(&mInputPinC);
mInputPinC.set(0, 1.25, this, "Input C");
mPin.push_back(&mOutputPin);
mOutputPin.set(3.5, 0.75, this, "Output");
if (aUS)
mTexture = load_file_texture("data/nand3_us.png");
else
mTexture = load_file_texture("data/nand3_fi.png");
mInputPinA.mReadOnly = 1;
mInputPinB.mReadOnly = 1;
mInputPinC.mReadOnly = 1;
}
void NAND3Chip::render(int aChipId)
{
if (gBlackBackground)
drawtexturedrect(mTexture,mX,mY,mW,mH,0xffffffff);
else
drawtexturedrect(mTexture,mX,mY,mW,mH,0xff000000);
}
void NAND3Chip::update(float aTick)
{
if (mInputPinA.mNet == NULL ||
mInputPinB.mNet == NULL ||
mInputPinC.mNet == NULL ||
mInputPinA.mNet->mState == NETSTATE_INVALID ||
mInputPinB.mNet->mState == NETSTATE_INVALID ||
mInputPinC.mNet->mState == NETSTATE_INVALID)
{
mOutputPin.setState(gConfig.mPropagateInvalidState);
return;
}
if ((mInputPinA.mNet->mState == NETSTATE_HIGH || mInputPinA.mNet->mState == NETSTATE_NC) &&
(mInputPinB.mNet->mState == NETSTATE_HIGH || mInputPinB.mNet->mState == NETSTATE_NC) &&
(mInputPinC.mNet->mState == NETSTATE_HIGH || mInputPinC.mNet->mState == NETSTATE_NC))
mOutputPin.setState(PINSTATE_WRITE_LOW);
else
mOutputPin.setState(PINSTATE_WRITE_HIGH);
}
| 33.333333
| 95
| 0.7104
|
flypie
|
b4ef354c09bc91c83a8c6adfd7315b9f173268e2
| 5,213
|
cpp
|
C++
|
SHVX/framework/system/hashKey.cpp
|
PsychoDad9999/GTA5-Mods
|
38a3aa2ec48cd52cb851f1cda636c53bfbc058ad
|
[
"MIT"
] | 5
|
2020-09-23T06:03:48.000Z
|
2021-04-14T19:37:55.000Z
|
SHVX/framework/system/hashKey.cpp
|
PsychoDad9999/GTA5-Mods
|
38a3aa2ec48cd52cb851f1cda636c53bfbc058ad
|
[
"MIT"
] | null | null | null |
SHVX/framework/system/hashKey.cpp
|
PsychoDad9999/GTA5-Mods
|
38a3aa2ec48cd52cb851f1cda636c53bfbc058ad
|
[
"MIT"
] | null | null | null |
// ----------------------------------------------------------------------------
#include "HashKey.h"
#include <wchar.h>
#include <stdexcept>
// ----------------------------------------------------------------------------
const uint8_t HashKey::m_LookupTable[] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x5B, 0x2F, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
};
// ----------------------------------------------------------------------------
/// <summary>Gets the hash key of the specified string.</summary>
/// <param name="str">The string used to generate a hash key.</param>
/// <returns>A hash key compatible with GTA 5</returns>
// ----------------------------------------------------------------------------
Hash HashKey::GetHashKey(const char* str)
{
try
{
return GetHashKey(str, static_cast<Hash>(0));
}
catch (const std::invalid_argument&)
{
return 0;
}
}
// ----------------------------------------------------------------------------
/// <summary>Gets the hash key of the specified string, using an initial hash key value.</summary>
/// <param name="str">The string used to generate a hash key.</param>
/// <param name = "initialHash">The initial hash key value used to generate the result.</param>
/// <returns>A hash key compatible with GTA 5</returns>
// ----------------------------------------------------------------------------
Hash HashKey::GetHashKey(const char* str, Hash initialHash)
{
try
{
return GetHashKeyFinalize(str, initialHash);
}
catch (const std::invalid_argument&)
{
return 0;
}
}
// ----------------------------------------------------------------------------
/// <summary>Gets the hash key of the specified string concatenated with an additional string.</summary>
/// <param name="str">The string used to generate a hash key.</param>
/// <param name = "concat">The additional string to concatenate to the input string.</param>
/// <returns>A hash key compatible with GTA 5</returns>
// ----------------------------------------------------------------------------
Hash HashKey::GetHashKey(const char* str, const char* concat)
{
try
{
return GetHashKey(str, concat, static_cast<Hash>(0));
}
catch (const std::invalid_argument&)
{
return 0;
}
}
// ----------------------------------------------------------------------------
/// <summary>Gets the hash key of the specified string concatenated with an additional string, using an initial hash key value.</summary>
/// <param name="str">The string used to generate a hash key.</param>
/// <param name = "concat">The additional string to concatenate to the input string.</param>
/// <param name="initialHash">The initial hash key value used to generate the result.</param>
/// <returns>A hash key compatible with GTA 5</returns>
// ----------------------------------------------------------------------------
Hash HashKey::GetHashKey(const char* str, const char* concat, Hash initialHash)
{
try
{
return GetHashKeyFinalize(concat, GetHashKeySubString(str, initialHash));
}
catch (const std::invalid_argument&)
{
return 0;
}
}
Hash HashKey::GetHashKeySubString(const char* str, Hash initialHash)
{
Hash hash = initialHash;
// get length of string
const size_t strLen = strlen(str);
for (int i = 0; i < strLen; i++)
{
const char code = str[i];
// check array bounds
if (code < 0 || code > 255)
{
throw std::invalid_argument("unsupported string value");
}
hash += m_LookupTable[code];
hash += (hash << 10);
hash ^= (hash >> 6);
}
return hash;
}
Hash HashKey::GetHashKeyFinalize(const char* str, Hash initialHash)
{
Hash hash = GetHashKeySubString(str, initialHash);
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
| 36.454545
| 140
| 0.571456
|
PsychoDad9999
|
b4f316199ab01d835b04782d1f86e5881dbe2a29
| 2,127
|
cpp
|
C++
|
Projects/CoX/Utilities/SEGSAdmin/SyntaxHighlighter.cpp
|
HeraldOfOmega/Segs
|
0de876d7c28481dc2eab743781e86141be0fc8ba
|
[
"BSD-3-Clause"
] | 2
|
2019-11-17T19:45:41.000Z
|
2021-08-24T15:36:57.000Z
|
Projects/CoX/Utilities/SEGSAdmin/SyntaxHighlighter.cpp
|
HeraldOfOmega/Segs
|
0de876d7c28481dc2eab743781e86141be0fc8ba
|
[
"BSD-3-Clause"
] | null | null | null |
Projects/CoX/Utilities/SEGSAdmin/SyntaxHighlighter.cpp
|
HeraldOfOmega/Segs
|
0de876d7c28481dc2eab743781e86141be0fc8ba
|
[
"BSD-3-Clause"
] | 1
|
2021-04-13T16:04:08.000Z
|
2021-04-13T16:04:08.000Z
|
/*
* SEGS - Super Entity Game Server
* http://www.segs.io/
* Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
* This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
*/
/*!
* @addtogroup SEGSAdmin Projects/CoX/Utilities/SEGSAdmin
* @{
*/
#include "SyntaxHighlighter.h"
SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent)
: QSyntaxHighlighter(parent)
{
HighlightingRule rule;
keywordFormat.setForeground(Qt::darkCyan);
keywordFormat.setFontWeight(QFont::Bold);
QStringList keywordPatterns;
keywordPatterns << "</[^>]+>" << "<[^>]+>";
foreach (const QString &pattern, keywordPatterns)
{
rule.pattern = QRegularExpression(pattern);
rule.format = keywordFormat;
highlightingRules.append(rule);
}
commentStartExpression = QRegularExpression("/\\*");
commentEndExpression = QRegularExpression("\\*/");
}
void SyntaxHighlighter::highlightBlock(const QString &text)
{
foreach (const HighlightingRule &rule, highlightingRules)
{
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
while (matchIterator.hasNext())
{
QRegularExpressionMatch match = matchIterator.next();
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
}
}
setCurrentBlockState(0);
int startIndex = 0;
if(previousBlockState() != 1)
startIndex = text.indexOf(commentStartExpression);
while (startIndex >= 0) {
QRegularExpressionMatch match = commentEndExpression.match(text, startIndex);
int endIndex = match.capturedStart();
int commentLength = 0;
if(endIndex == -1) {
setCurrentBlockState(1);
commentLength = text.length() - startIndex;
} else {
commentLength = endIndex - startIndex
+ match.capturedLength();
}
setFormat(startIndex, commentLength, multiLineCommentFormat);
startIndex = text.indexOf(commentStartExpression, startIndex + commentLength);
}
}
//!@}
| 31.279412
| 101
| 0.660555
|
HeraldOfOmega
|
b4f62e91f06d2ce52853f268fdbca70eb43f48ea
| 2,260
|
cpp
|
C++
|
project/driver/src/SQLFreeHandle.cpp
|
mkhon/ezRETS
|
7040e80061da719b5a2d56a80431198962f57893
|
[
"ICU"
] | 20
|
2015-07-11T15:54:42.000Z
|
2022-02-05T04:55:24.000Z
|
project/driver/src/SQLFreeHandle.cpp
|
mkhon/ezRETS
|
7040e80061da719b5a2d56a80431198962f57893
|
[
"ICU"
] | 5
|
2015-01-12T22:38:56.000Z
|
2021-01-16T01:08:18.000Z
|
project/driver/src/SQLFreeHandle.cpp
|
NationalAssociationOfRealtors/ezRETS
|
7040e80061da719b5a2d56a80431198962f57893
|
[
"ICU"
] | 13
|
2015-04-05T03:28:20.000Z
|
2021-01-13T16:52:52.000Z
|
/*
* Copyright (C) 2005 National Association of REALTORS(R)
*
* All rights reserved.
*
* 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, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished
* to do so, provided that the above copyright notice(s) and this
* permission notice appear in all copies of the Software and that
* both the above copyright notice(s) and this permission notice
* appear in supporting documentation.
*/
#include "OdbcEntry.h"
#include "OdbcSqlException.h"
#include "SQLFreeEnv.h"
#include "RetsENV.h"
#include "RetsDBC.h"
#include "RetsSTMT.h"
namespace odbcrets
{
class SQLFreeHandle : public OdbcEntry
{
public:
SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
: mHandleType(HandleType), mHandle(Handle) { }
protected:
SQLRETURN UncaughtOdbcEntry()
{
SQLRETURN error = SQL_ERROR;
ENV* env;
DBC* dbc;
STMT* stmt;
switch (mHandleType)
{
case SQL_HANDLE_ENV:
error = rets_SQLFreeEnv((ENV *)mHandle);
break;
case SQL_HANDLE_DBC:
dbc = static_cast<DBC*>(mHandle);
env = dbc->getEnv();
error = env->SQLFreeConnect(dbc);
break;
case SQL_HANDLE_STMT:
stmt = static_cast<STMT*>(mHandle);
dbc = stmt->getDbc();
error = dbc->SQLFreeStmt(stmt, SQL_DROP);
break;
default:
break;
}
return error;
}
void assertPrecondition()
{
if (!mHandle)
{
throw OdbcSqlException(SQL_INVALID_HANDLE, "Bad handle to free");
}
}
private:
SQLSMALLINT mHandleType;
SQLHANDLE mHandle;
};
}
namespace o = odbcrets;
SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
{
o::SQLFreeHandle sqlFreeHandle(HandleType, Handle);
return sqlFreeHandle();
}
| 26.588235
| 77
| 0.625664
|
mkhon
|
b4f98c58086a7bab38dd815b7c6cbb54521ae62f
| 2,084
|
cpp
|
C++
|
ci-samples/CirclePackerSample/src/CirclePackerSampleApp.cpp
|
codeoncanvas/coc-circlepacker
|
de630a0df15a45fac9e4f7256126ddbffb85db03
|
[
"MIT"
] | null | null | null |
ci-samples/CirclePackerSample/src/CirclePackerSampleApp.cpp
|
codeoncanvas/coc-circlepacker
|
de630a0df15a45fac9e4f7256126ddbffb85db03
|
[
"MIT"
] | null | null | null |
ci-samples/CirclePackerSample/src/CirclePackerSampleApp.cpp
|
codeoncanvas/coc-circlepacker
|
de630a0df15a45fac9e4f7256126ddbffb85db03
|
[
"MIT"
] | null | null | null |
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "cinder/Utilities.h"
#include "ciCirclePacker.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class CirclePackerSampleApp : public App {
public:
void setup() override;
void update() override;
void draw() override;
void mouseMove( MouseEvent event ) override;
void mouseDown( MouseEvent event ) override;
void mouseDrag( MouseEvent event ) override;
void mouseUp( MouseEvent event ) override;
void keyDown( KeyEvent event ) override;
coc::ciCirclePackerRef circlePacker;
};
void CirclePackerSampleApp::setup() {
circlePacker = coc::ciCirclePacker::create();
}
void CirclePackerSampleApp::update() {
int circleAddPerFrame = 10;
for(int i=0; i<circleAddPerFrame; i++) {
float x = coc::rand(getWindowWidth());
float y = coc::rand(getWindowHeight());
float radiusMin = 2.0;
float radiusMax = 200.0;
float radiusGrowth = (radiusMax - radiusMin) / 100.0;
float gap = 1.0;
const coc::CirclePacker::CircleRef & circleRef = circlePacker->addCircle(x, y, radiusMin, radiusMax, radiusGrowth, gap);
coc::ciCirclePacker::ciCircle * circle = (coc::ciCirclePacker::ciCircle *)circleRef.get();
circle->colorFill = ci::ColorA(0.9, 0.9, 0.9, 1.0);
circle->colorStroke = ci::ColorA(0.0, 0.0, 0.0, 1.0);
}
circlePacker->update();
}
void CirclePackerSampleApp::draw() {
gl::clear(Color(1.0, 1.0, 1.0));
circlePacker->draw();
}
void CirclePackerSampleApp::mouseMove( MouseEvent event ) {
//
}
void CirclePackerSampleApp::mouseDown( MouseEvent event ) {
//
}
void CirclePackerSampleApp::mouseDrag( MouseEvent event ) {
//
}
void CirclePackerSampleApp::mouseUp( MouseEvent event ) {
//
}
void CirclePackerSampleApp::keyDown( KeyEvent event ) {
if(event.getChar() == 'r' || event.getChar() == 'R') {
circlePacker->reset();
}
}
CINDER_APP( CirclePackerSampleApp, RendererGl )
| 25.108434
| 128
| 0.659789
|
codeoncanvas
|
b4fca7b655bbc0b9a3d4bf329f233d4a0149c2f8
| 10,678
|
cc
|
C++
|
src/server/synergy_input/main.cc
|
m-stein/genode-world
|
206de6702d4670c2f911938e80afdc28acfb2f56
|
[
"MIT"
] | null | null | null |
src/server/synergy_input/main.cc
|
m-stein/genode-world
|
206de6702d4670c2f911938e80afdc28acfb2f56
|
[
"MIT"
] | null | null | null |
src/server/synergy_input/main.cc
|
m-stein/genode-world
|
206de6702d4670c2f911938e80afdc28acfb2f56
|
[
"MIT"
] | null | null | null |
/*
* \brief Synergy client
* \author Emery Hemingway
* \date 2015-06-14
*
* http://synergy-project.org/
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <base/log.h>
#include <input/component.h>
#include <framebuffer_session/connection.h>
#include <nitpicker_session/connection.h>
#include <timer_session/connection.h>
#include <os/static_root.h>
#include <base/attached_rom_dataspace.h>
#include <libc/component.h>
/* Synergy includes */
#include <uSynergy.h>
/* socket API */
extern "C" {
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
}
using namespace Genode;
Constructible<Attached_rom_dataspace> config;
Constructible<Timer::Connection> timer;
struct Session_component : Input::Session_component
{
/* Array for tracking the current keyboard state */
bool key_state[Input::KEY_MAX + 1];
int socket_fd;
uSynergyBool button_left;
uSynergyBool button_right;
uSynergyBool button_middle;
Session_component(Genode::Env &env)
: Input::Session_component(env, env.ram()), socket_fd(-1) { }
~Session_component()
{
::close(socket_fd);
}
void reset_keys()
{
for (int i = 0; i <= Input::KEY_MAX; i++)
key_state[i] = false;
button_left = USYNERGY_FALSE;
button_right = USYNERGY_FALSE;
button_right = USYNERGY_FALSE;
}
};
/***********************
** Synergy callbacks **
***********************/
static uSynergyBool connect(uSynergyCookie cookie)
{
Session_component *session = (Session_component*)cookie;
/******************
** Parse config **
******************/
char addr[INET_ADDRSTRLEN];
unsigned long port = 24800;
Xml_node config_node = config->xml();
try {
config_node.attribute("addr").value(addr, sizeof(addr));
} catch (Xml_node::Nonexistent_attribute) {
Genode::error("server address not set in config");
return USYNERGY_FALSE;
}
try {
config_node.attribute("port").value(&port);
} catch (...) { }
/*****************************
** Open and connect socket **
*****************************/
sockaddr_in sockaddr;
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = htons(port);
if (inet_pton(AF_INET, addr, &sockaddr.sin_addr.s_addr) == 0) {
Genode::error("bad IPv4 address ", Cstring(addr), " for server");
return USYNERGY_FALSE;
}
session->socket_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (session->socket_fd == -1)
return USYNERGY_FALSE;
if (::connect(session->socket_fd, (struct sockaddr*) &sockaddr, sizeof(sockaddr))) {
::close(session->socket_fd);
return USYNERGY_FALSE;
}
return USYNERGY_TRUE;
}
uSynergyBool send(uSynergyCookie cookie, const uint8_t *buffer, int length)
{
Session_component *session = (Session_component*)cookie;
return (length == ::write(session->socket_fd, buffer, length)) ?
USYNERGY_TRUE : USYNERGY_FALSE;
}
uSynergyBool receive(uSynergyCookie cookie, uint8_t *buffer, int maxLength, int* outLength)
{
Session_component *session = (Session_component*)cookie;
*outLength = ::read(session->socket_fd, buffer, maxLength);
if (!*outLength)
return USYNERGY_FALSE;
return USYNERGY_TRUE;
}
void sleep(uSynergyCookie, int timeMs) { timer->msleep(timeMs); }
uint32_t get_time() { return timer->elapsed_ms(); }
void trace_callback(uSynergyCookie cookie, const char *text) { Genode::log(text); }
void screen_active_callback(uSynergyCookie cookie, uSynergyBool active)
{
if (!active) {
Session_component *session = (Session_component*)cookie;
Input::Event_queue &queue = session->event_queue();
queue.reset();
queue.add(Input::Event(Input::Event::LEAVE, 0, 0, 0, 0, 0));
session->reset_keys();
}
}
void mouse_callback(uSynergyCookie cookie,
uint16_t x, uint16_t y,
int16_t wheelX, int16_t wheelY,
uSynergyBool buttonLeft,
uSynergyBool buttonRight,
uSynergyBool buttonMiddle)
{
Session_component *session = (Session_component*)cookie;
Input::Event_queue &queue = session->event_queue();
if (queue.avail_capacity() < 5)
queue.reset();
/* Defer sending a signal until all conditions are processed */
queue.add(Input::Event(Input::Event::MOTION, 0, x, y, 0, 0), false);
queue.add(Input::Event(Input::Event::WHEEL, 0, wheelX, wheelY, 0, 0), false);
if (buttonLeft != session->button_left)
queue.add(Input::Event((session->button_left = buttonLeft) ?
Input::Event::PRESS : Input::Event::RELEASE,
Input::BTN_LEFT, 0, 0, 0, 0), false);
if (buttonRight != session->button_right)
queue.add(Input::Event((session->button_right = buttonRight) ?
Input::Event::PRESS : Input::Event::RELEASE,
Input::BTN_RIGHT, 0, 0, 0, 0), false);
if (buttonMiddle != session->button_middle)
queue.add(Input::Event((session->button_middle = buttonMiddle) ?
Input::Event::PRESS : Input::Event::RELEASE,
Input::BTN_MIDDLE, 0, 0, 0, 0), false);
queue.submit_signal();
}
void keyboard_callback(uSynergyCookie cookie,
uint16_t key, uint16_t modifiers,
uSynergyBool down, uSynergyBool repeat)
{
Session_component *session = (Session_component*)cookie;
Input::Event_queue &queue = session->event_queue();
if (!queue.avail_capacity()) queue.reset();
key -= 8; // TODO what is <8?
if (key > Input::KEY_MAX) return;
queue.add(Input::Event(((session->key_state[key] = !session->key_state[key]) ?
Input::Event::PRESS : Input::Event::RELEASE),
key, 0, 0, 0, 0));
}
/*
* void joystick_callback(uSynergyCookie cookie,
* uint8_t joyNum,
* uint16_t buttons,
* int8_t leftStickX, int8_t leftStickY,
* int8_t rightStickX, int8_t rightStickY);
*/
/*******************************
** Network processing thread **
*******************************/
struct Synergy_thread : Thread
{
enum {
MAX_NAME_LEN = 256,
STACK_SIZE = 1024*sizeof(long)
};
Genode::Env &env;
char screen_name[MAX_NAME_LEN];
uSynergyContext context;
Signal_receiver config_rec;
Signal_context config_ctx;
Synergy_thread(Genode::Env &env, Session_component &session)
: Thread(env, "uSynergy", STACK_SIZE), env(env)
{
*screen_name = 0;
uSynergyInit(&context);
context.m_connectFunc = &connect; /* Connect function */
context.m_sendFunc = &send; /* Send data function */
context.m_receiveFunc = &receive; /* Receive data function */
context.m_sleepFunc = &sleep; /* Thread sleep function */
context.m_getTimeFunc = &get_time; /* Get current time function */
context.m_clientName = screen_name; /* Name of Synergy Screen */
context.m_cookie = (uSynergyCookie)&session; /* Cookie pointer passed to callback functions (can be NULL) */
context.m_traceFunc = &trace_callback; /* Function for tracing status (can be NULL) */
context.m_screenActiveCallback = &screen_active_callback; /* Callback for entering and leaving screen */
context.m_mouseCallback = &mouse_callback; /* Callback for mouse events */
context.m_keyboardCallback = &keyboard_callback; /* Callback for keyboard events */
config->sigh(config_rec.manage(&config_ctx));
}
~Synergy_thread()
{
config_rec.dissolve(&config_ctx);
}
/**
* Update configuration; return success state
*/
bool update_config()
{
/*
* TODO: detect changes to network config
* and trigger a reconnect if appropriate.
*/
Xml_node config_node = config->xml();
try {
config_node.attribute("addr");;
} catch (Xml_node::Nonexistent_attribute) {
Genode::error("server address not set in config");
return false;
}
try {
config_node.attribute("name").value(screen_name, sizeof(screen_name));
} catch (Xml_node::Nonexistent_attribute) {
Genode::error("client screen name not set in config, waiting for update");
return false;
}
/*
* TODO: just get the capability for framebuffer or nitpicker,
* then make a simple resolution client that wraps that.
*/
Genode::log("probing Nitpicker service");
try {
Nitpicker::Connection conn { env, "dimension" };
Framebuffer::Mode mode = conn.mode();
context.m_clientWidth = mode.width();
context.m_clientHeight = mode.height();
return true;
} catch (...) { }
Genode::log("probing Framebuffer service");
try {
Framebuffer::Connection conn { env, Framebuffer::Mode() };
Framebuffer::Mode mode = conn.mode();
context.m_clientWidth = mode.width();
context.m_clientHeight = mode.height();
return true;
} catch (...) { }
/*
* No real pointer space, but give the server a small holding area.
*
* XXX: drop pointer events without a screen?
*/
Genode::log("using a virtual screen area");
context.m_clientWidth = context.m_clientHeight = 64;
return true;
}
/**
* Parse the config, then spin on the Synergy update function.
*
* If the config is not valid, block until it is updated.
*/
void entry()
{
while (!update_config()) {
config_rec.wait_for_signal();
config->update();
}
for (;;) {
uSynergyUpdate(&context);
if (config_rec.pending()) {
while (!update_config())
config_rec.wait_for_signal();
config->update();
}
}
}
};
/******************
** Main program **
******************/
using namespace Genode;
struct Main
{
Genode::Env &env;
/*
* Input session provided to our client
*/
Session_component session_component { env };
/*
* Attach root interface to the entry point
*/
Static_root<Input::Session> input_root { env.ep().manage(session_component) };
/*
* Additional thread for processing incoming events.
*/
Synergy_thread synergy_thread { env, session_component };
/**
* Constructor
*/
Main(Genode::Env &env) : env(env)
{
session_component.event_queue().enabled(true);
env.parent().announce(env.ep().manage(input_root));
synergy_thread.start();
}
};
/***************
** Component **
***************/
void Libc::Component::construct(Libc::Env &env)
{
config.construct(env, "config");
timer.construct(env, "uSynergy");
static Main inst(env);
}
| 26.430693
| 110
| 0.640663
|
m-stein
|
b4fd22e0f87dd0e16a32478b5c45b9f21d366562
| 9,064
|
cpp
|
C++
|
TESTS/mbed_hal/trng/main.cpp
|
mtvg/mbed-os
|
df44c55cfd1b8323bb5368e2cdaffe1a284e8d01
|
[
"Apache-2.0"
] | 2
|
2018-09-05T12:04:05.000Z
|
2018-11-30T05:33:35.000Z
|
TESTS/mbed_hal/trng/main.cpp
|
mtvg/mbed-os
|
df44c55cfd1b8323bb5368e2cdaffe1a284e8d01
|
[
"Apache-2.0"
] | null | null | null |
TESTS/mbed_hal/trng/main.cpp
|
mtvg/mbed-os
|
df44c55cfd1b8323bb5368e2cdaffe1a284e8d01
|
[
"Apache-2.0"
] | 4
|
2018-12-10T12:03:54.000Z
|
2019-01-26T02:46:40.000Z
|
/*
* Copyright (c) 2018 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* The test is based on the assumption that trng will generate random data, random so
* there will not be any similar patterns in it, that kind of data will be impossible to
* compress, if compression will occur the test will result in failure.
*
* The test is composed out of three parts:
* the first, generate a trng buffer and try to compress it, at the end of first part
* we will reset the device.
* In second part we will generate a trng buffer with a different buffer size and try to
* compress it.
* In the third part we will again generate a trng buffer to see that the same trng output
* is not generated as the stored trng buffer from part one (before reseting), the new trng data will
* be concatenated to the trng data from the first part and then try to compress it
* together, if there are similar patterns the compression will succeed.
*
* We need to store and load the first part data before and after reset, the mechanism
* we will use is the mbed greentea platform for sending and receving the data from the device
* to the host running the test and back, the problem with this mechanism is that it doesn't
* handle well certain characters, especially non ASCII ones, so we use the base64 algorithm
* to ensure all characters will be transmitted correctly.
*/
#include "greentea-client/test_env.h"
#include "unity/unity.h"
#include "utest/utest.h"
#include "hal/trng_api.h"
#include "base64b.h"
#include "pithy.h"
#include <stdio.h>
#if !DEVICE_TRNG
#error [NOT_SUPPORTED] TRNG API not supported for this target
#endif
#define MSG_VALUE_DUMMY "0"
#define MSG_VALUE_LEN 64
#define MSG_KEY_LEN 32
#define BUFFER_LEN (MSG_VALUE_LEN/2)
#define MSG_TRNG_READY "ready"
#define MSG_TRNG_BUFFER "buffer"
#define MSG_TRNG_EXIT "exit"
#define MSG_TRNG_TEST_STEP1 "check_step1"
#define MSG_TRNG_TEST_STEP2 "check_step2"
#define MSG_TRNG_TEST_SUITE_ENDED "Test_suite_ended"
#define RESULT_SUCCESS 0
using namespace utest::v1;
static int fill_buffer_trng(uint8_t *buffer, trng_t *trng_obj, size_t trng_len)
{
size_t temp_size = 0, output_length = 0;
int trng_res = 0;
uint8_t *temp_in_buf = buffer;
trng_init(trng_obj);
memset(buffer, 0, BUFFER_LEN);
while (true) {
trng_res = trng_get_bytes(trng_obj, temp_in_buf, trng_len - temp_size, &output_length);
TEST_ASSERT_EQUAL_INT_MESSAGE(0, trng_res, "trng_get_bytes error!");
temp_size += output_length;
temp_in_buf += output_length;
if (temp_size >= trng_len) {
break;
}
}
temp_in_buf = NULL;
trng_free(trng_obj);
return 0;
}
void print_array(uint8_t *buffer, size_t size)
{
for (size_t i = 0; i < size; i++) {
utest_printf("%02x", buffer[i]);
}
utest_printf("\n");
}
static void compress_and_compare(char *key, char *value)
{
trng_t trng_obj;
uint8_t *out_comp_buf, *buffer;
uint8_t *input_buf, *temp_buf;
size_t comp_sz = 0;
unsigned int result = 0;
#define OUT_COMP_BUF_SIZE ((BUFFER_LEN * 5) + 32)
#define TEMP_BUF_SIZE (BUFFER_LEN * 2)
out_comp_buf = new uint8_t[OUT_COMP_BUF_SIZE];
buffer = new uint8_t[BUFFER_LEN];
temp_buf = new uint8_t[BUFFER_LEN * 2];
input_buf = new uint8_t[BUFFER_LEN * 4];
/*At the begining of step 2 load trng buffer from step 1*/
if (strcmp(key, MSG_TRNG_TEST_STEP2) == 0) {
/*Using base64 to decode data sent from host*/
uint32_t lengthWritten = 0;
uint32_t charsProcessed = 0;
result = trng_DecodeNBase64((const char *)value,
MSG_VALUE_LEN,
buffer,
BUFFER_LEN,
&lengthWritten,
&charsProcessed);
TEST_ASSERT_EQUAL(0, result);
memcpy(input_buf, buffer, BUFFER_LEN);
}
if (strcmp(key, MSG_TRNG_TEST_STEP1) == 0) {
/*Fill buffer with trng values*/
result = fill_buffer_trng(buffer, &trng_obj, BUFFER_LEN);
TEST_ASSERT_EQUAL(0, result);
memcpy(input_buf, buffer, BUFFER_LEN);
}
/*pithy_Compress will try to compress the random data, if it succeeded it means the data is not really random*/
else if (strcmp(key, MSG_TRNG_TEST_STEP2) == 0) {
comp_sz = pithy_Compress((char *)buffer,
BUFFER_LEN,
(char *)out_comp_buf,
OUT_COMP_BUF_SIZE,
9);
if (comp_sz <= BUFFER_LEN) {
print_array(buffer, BUFFER_LEN);
}
TEST_ASSERT_MESSAGE(comp_sz > BUFFER_LEN,
"TRNG_TEST_STEP1: trng_get_bytes was able to compress thus not random");
/*pithy_Compress will try to compress the random data with a different buffer size*/
result = fill_buffer_trng(temp_buf, &trng_obj, TEMP_BUF_SIZE);
TEST_ASSERT_EQUAL(0, result);
comp_sz = pithy_Compress((char *)temp_buf,
TEMP_BUF_SIZE,
(char *)out_comp_buf,
OUT_COMP_BUF_SIZE,
9);
if (comp_sz <= TEMP_BUF_SIZE) {
print_array(temp_buf, TEMP_BUF_SIZE);
}
TEST_ASSERT_MESSAGE(comp_sz > TEMP_BUF_SIZE,
"TRNG_TEST_STEP2: trng_get_bytes was able to compress thus not random");
memcpy(input_buf + BUFFER_LEN, temp_buf, TEMP_BUF_SIZE);
/*pithy_Compress will try to compress the random data from before reset concatenated with new random data*/
comp_sz = pithy_Compress((char *)input_buf,
TEMP_BUF_SIZE + BUFFER_LEN,
(char *)out_comp_buf,
OUT_COMP_BUF_SIZE,
9);
if (comp_sz <= TEMP_BUF_SIZE + BUFFER_LEN) {
print_array(input_buf, TEMP_BUF_SIZE + BUFFER_LEN);
}
TEST_ASSERT_MESSAGE(comp_sz > TEMP_BUF_SIZE + BUFFER_LEN,
"TRNG_TEST_STEP3: concatenated buffer after reset was able to compress thus not random");
greentea_send_kv(MSG_TRNG_TEST_SUITE_ENDED, MSG_VALUE_DUMMY);
}
/*At the end of step 1 store trng buffer and reset the device*/
if (strcmp(key, MSG_TRNG_TEST_STEP1) == 0) {
int result = 0;
/*Using base64 to encode data sending from host*/
result = trng_EncodeBase64(buffer,
BUFFER_LEN,
(char *)out_comp_buf,
OUT_COMP_BUF_SIZE);
TEST_ASSERT_EQUAL(RESULT_SUCCESS, result);
greentea_send_kv(MSG_TRNG_BUFFER, (const char *)out_comp_buf);
}
delete[] out_comp_buf;
delete[] buffer;
delete[] input_buf;
delete[] temp_buf;
}
/*This method call first and second steps, it directs by the key received from the host*/
void trng_test()
{
greentea_send_kv(MSG_TRNG_READY, MSG_VALUE_DUMMY);
char key[MSG_KEY_LEN + 1] = { };
char *value = new char[MSG_VALUE_LEN + 1];
do {
memset(key, 0, MSG_KEY_LEN + 1);
memset(value, 0, MSG_VALUE_LEN + 1);
greentea_parse_kv(key, value, MSG_KEY_LEN, MSG_VALUE_LEN);
if (strcmp(key, MSG_TRNG_TEST_STEP1) == 0) {
/*create trng data buffer and try to compress it, store it for later checks*/
compress_and_compare(key, value);
}
if (strcmp(key, MSG_TRNG_TEST_STEP2) == 0) {
/*create another trng data buffer and concatenate it to the stored trng data buffer
try to compress them both*/
compress_and_compare(key, value);
}
} while (strcmp(key, MSG_TRNG_EXIT) != 0);
delete[] value;
}
Case cases[] = {
Case("TRNG: trng_test", trng_test),
};
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
{
GREENTEA_SETUP(100, "trng_reset");
return greentea_test_setup_handler(number_of_cases);
}
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
int main()
{
bool ret = !Harness::run(specification);
return ret;
}
| 36.548387
| 117
| 0.630075
|
mtvg
|
3701cd6b4fcfed7439f3e2936e10bf4c96ac7d89
| 419
|
hpp
|
C++
|
injectable/v8_adapters/base_adapter.hpp
|
viniciuslrangel/FuelInjector
|
6c2fc60ef61dcc2e467aae9316c646daf6ebba49
|
[
"MIT"
] | null | null | null |
injectable/v8_adapters/base_adapter.hpp
|
viniciuslrangel/FuelInjector
|
6c2fc60ef61dcc2e467aae9316c646daf6ebba49
|
[
"MIT"
] | null | null | null |
injectable/v8_adapters/base_adapter.hpp
|
viniciuslrangel/FuelInjector
|
6c2fc60ef61dcc2e467aae9316c646daf6ebba49
|
[
"MIT"
] | 1
|
2022-03-18T21:50:15.000Z
|
2022-03-18T21:50:15.000Z
|
#pragma once
#include <Windows.h>
#include "../utility.hpp"
namespace Fuel {
class V8BaseAdapter {
protected:
HANDLE thread{};
CONTEXT context{};
bool paused = false;
public:
static V8BaseAdapter* AutoSelectVersion(HMODULE mod = 0);
static HMODULE FindModule(std::string_view name = "");
virtual void Setup(HMODULE mod) = 0;
virtual void Shutdown() = 0;
virtual ~V8BaseAdapter() = 0;
};
}
| 14.964286
| 59
| 0.680191
|
viniciuslrangel
|
37088df2d7cfca324f87c2b889e61dcf374c041a
| 1,944
|
cc
|
C++
|
node/src/node_bindings/index.cc
|
perjonsson/DeskGap
|
5e74de37c057de3bac3ac16b3fabdb79b934d21e
|
[
"MIT"
] | 1,910
|
2019-02-08T05:41:48.000Z
|
2022-03-24T23:41:33.000Z
|
node/src/node_bindings/index.cc
|
perjonsson/DeskGap
|
5e74de37c057de3bac3ac16b3fabdb79b934d21e
|
[
"MIT"
] | 73
|
2019-02-13T02:58:20.000Z
|
2022-03-02T05:49:34.000Z
|
node/src/node_bindings/index.cc
|
ci010/DeskGap
|
b3346fea3dd3af7df9a0420131da7f4ac1518092
|
[
"MIT"
] | 88
|
2019-02-13T12:41:00.000Z
|
2022-03-25T05:04:31.000Z
|
#include <memory>
#include <sstream>
#include <napi.h>
#include "index.hpp"
#include "app/app_wrap.h"
#include "window/browser_window_wrap.h"
#include "menu/menu_wrap.h"
#include "shell/shell_wrap.h"
#include "webview/webview_wrap.h"
#include "system_preferences/system_preferences_wrap.h"
#include "dialog/dialog_wrap.h"
#include "dispatch/dispatch.h"
#include "native_exception.h"
namespace {
std::unique_ptr<Napi::FunctionReference> nativeExceptionConstructor;
inline void ExportFunction(Napi::Object& exports, const Napi::Function& function) {
exports.Set(function.Get("name"), function);
}
}
Napi::Object DeskGap::InitNodeNativeModule(Napi::Env env, Napi::Object exports) {
exports.Set("appNative", DeskGap::AppWrap::AppObject(env));
ExportFunction(exports, DeskGap::BrowserWindowWrap::Constructor(env));
ExportFunction(exports, DeskGap::MenuWrap::Constructor(env));
ExportFunction(exports, DeskGap::MenuItemWrap::Constructor(env));
ExportFunction(exports, DeskGap::WebViewWrap::Constructor(env));
ExportFunction(exports, Napi::Function::New(env, [](const Napi::CallbackInfo&) {
DeskGap::DelayUISync();
}, "delayUISync"));
ExportFunction(exports, Napi::Function::New(env, [](const Napi::CallbackInfo& info) {
DeskGap::CommitUISync(info.Env());
}, "commitUISync"));
ExportFunction(exports, Napi::Function::New(env, [](const Napi::CallbackInfo& info) {
nativeExceptionConstructor = std::make_unique<Napi::FunctionReference>(Persistent(info[0].As<Napi::Function>()));
}, "setNativeExceptionConstructor"));
exports.Set("shellNative", DeskGap::ShellObject(env));
exports.Set("systemPreferencesNative", DeskGap::SystemPreferencesObject(env));
exports.Set("dialogNative", DeskGap::DialogObject(env));
return exports;
}
const Napi::FunctionReference& DeskGap::NativeExceptionConstructor() {
return *nativeExceptionConstructor;
}
| 36.679245
| 121
| 0.731481
|
perjonsson
|
370940a38118988e3d5c689340aa481627daa08d
| 998
|
cpp
|
C++
|
problems/minimum_digit_sum.cpp
|
NavinShrinivas/Algorithm-Grind
|
d2d05341662de9e390a828bcedae9d1c9f52b9ad
|
[
"Unlicense"
] | 1
|
2021-11-16T15:18:37.000Z
|
2021-11-16T15:18:37.000Z
|
problems/minimum_digit_sum.cpp
|
NavinShrinivas/Algorithm-Grind
|
d2d05341662de9e390a828bcedae9d1c9f52b9ad
|
[
"Unlicense"
] | null | null | null |
problems/minimum_digit_sum.cpp
|
NavinShrinivas/Algorithm-Grind
|
d2d05341662de9e390a828bcedae9d1c9f52b9ad
|
[
"Unlicense"
] | 5
|
2021-09-28T07:16:27.000Z
|
2021-11-17T00:54:39.000Z
|
#include<bits/stdc++.h>
#include<math.h>
typedef long long int ll;
#define intlimit 2147483647;
using namespace std;
#define loop(n) for(int i=0;i<n;i++);
#define maploop(m) for(auto it=m.begin();it!=m.end();it++);
// void swap(int a[],int i,int j)
// {
// int temp=a[i];
// a[i]=a[j];
// a[j]=temp;
// }
int recursive_sum(int n , int b)
{
if(n/b==1)
{
return n%b;
}
return (n%b)+recursive_sum(n/b,b);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
cout<<t;
while(t)
{
int end_flag=0;
int n,l,r;
cin>>n>>l>>r;
cout<<"HALO";
for(int i=l;i<=r;i++)
{
cout<<"HALO";
int sum=recursive_sum(n,i);
if(sum==1) //1 is minimum anyhow
{
cout<<i<<"\n";
end_flag=1;
break;
}
if(end_flag==1)
break;
}
t--;
}
}
| 18.481481
| 59
| 0.443888
|
NavinShrinivas
|
370b425558bbd9068df35f43c414bfc8f7b6a18a
| 787
|
hpp
|
C++
|
littleVulkanEngine/tutorial21/first_app.hpp
|
JohnCWakley/littleVulkanEngine
|
1c2d92a9ac60a1c53c3c29b389eda87e6ed46bb8
|
[
"MIT"
] | 324
|
2020-12-14T22:59:26.000Z
|
2022-03-30T08:06:39.000Z
|
littleVulkanEngine/tutorial21/first_app.hpp
|
JohnCWakley/littleVulkanEngine
|
1c2d92a9ac60a1c53c3c29b389eda87e6ed46bb8
|
[
"MIT"
] | 21
|
2020-12-20T13:04:49.000Z
|
2022-03-24T19:59:39.000Z
|
littleVulkanEngine/tutorial21/first_app.hpp
|
JohnCWakley/littleVulkanEngine
|
1c2d92a9ac60a1c53c3c29b389eda87e6ed46bb8
|
[
"MIT"
] | 76
|
2021-01-25T18:05:49.000Z
|
2022-03-29T07:22:08.000Z
|
#pragma once
#include "lve_descriptors.hpp"
#include "lve_device.hpp"
#include "lve_game_object.hpp"
#include "lve_renderer.hpp"
#include "lve_window.hpp"
// std
#include <memory>
#include <vector>
namespace lve {
class FirstApp {
public:
static constexpr int WIDTH = 800;
static constexpr int HEIGHT = 600;
FirstApp();
~FirstApp();
FirstApp(const FirstApp &) = delete;
FirstApp &operator=(const FirstApp &) = delete;
void run();
private:
void loadGameObjects();
LveWindow lveWindow{WIDTH, HEIGHT, "Vulkan Tutorial"};
LveDevice lveDevice{lveWindow};
LveRenderer lveRenderer{lveWindow, lveDevice};
// note: order of declarations matters
std::unique_ptr<LveDescriptorPool> globalPool{};
std::vector<LveGameObject> gameObjects;
};
} // namespace lve
| 20.179487
| 56
| 0.72554
|
JohnCWakley
|
370d304b28f48518268e3a81ef57ec919c64fd77
| 1,242
|
cpp
|
C++
|
cpp05/ex00/main.cpp
|
ndeana-21/cpp
|
98932eab0c1d57a715b6deb76c7a294c1e86f2fd
|
[
"MIT"
] | null | null | null |
cpp05/ex00/main.cpp
|
ndeana-21/cpp
|
98932eab0c1d57a715b6deb76c7a294c1e86f2fd
|
[
"MIT"
] | null | null | null |
cpp05/ex00/main.cpp
|
ndeana-21/cpp
|
98932eab0c1d57a715b6deb76c7a294c1e86f2fd
|
[
"MIT"
] | null | null | null |
#include "Bureaucrat.hpp"
void printHeader(std::string header)
{
std::cout << "\033[1;35m"
<< "<<<<< "
<< header
<< " >>>>>"
<< "\033[0m"
<< std::endl;
}
int main() {
printHeader("WITHOUT exception");
try {
Bureaucrat pop("Pop", 75);
std::cout << pop;
pop.incGrade();
std::cout << pop;
pop.decGrade();
std::cout << pop;
}
catch(std::exception & e) {
std::cerr << "[Error]: " << e.what() << std::endl;
}
printHeader("WITH exception");
try {
Bureaucrat jack("Jack", 0);
std::cout << jack;
}
catch(std::exception & e) {
std::cerr << "[Error]: " << e.what() << std::endl;
}
try {
Bureaucrat bob("Bob", 151);
std::cout << bob;
}
catch(std::exception & e)
{
std::cerr << "[Error]: " << e.what() << std::endl;
}
try {
Bureaucrat bill("Bill", 1);
std::cout << bill;
bill.decGrade();
std::cout << bill;
bill.incGrade();
std::cout << bill;
}
catch(std::exception & e) {
std::cerr << "[Error]: " << e.what() << std::endl;
}
try {
Bureaucrat tod("Tod", 150);
std::cout << tod;
tod.incGrade();
std::cout << tod;
tod.decGrade();
std::cout << tod;
}
catch(std::exception & e) {
std::cerr << "[Error]: " << e.what() << std::endl;
}
return (0);
}
| 18.537313
| 52
| 0.521739
|
ndeana-21
|
3714f62a410f9575d1a5b641829b89622b6d591d
| 2,731
|
cpp
|
C++
|
dbms/src/Functions/registerFunctionsDateTime.cpp
|
margaritiko/ClickHouse
|
6f28e69e97c73a71091efa3dfc891c43371f2348
|
[
"Apache-2.0"
] | 1
|
2019-12-27T14:15:09.000Z
|
2019-12-27T14:15:09.000Z
|
dbms/src/Functions/registerFunctionsDateTime.cpp
|
margaritiko/ClickHouse
|
6f28e69e97c73a71091efa3dfc891c43371f2348
|
[
"Apache-2.0"
] | null | null | null |
dbms/src/Functions/registerFunctionsDateTime.cpp
|
margaritiko/ClickHouse
|
6f28e69e97c73a71091efa3dfc891c43371f2348
|
[
"Apache-2.0"
] | null | null | null |
#include "registerFunctions.h"
namespace DB
{
void registerFunctionsDateTime(FunctionFactory & factory)
{
registerFunctionToYear(factory);
registerFunctionToQuarter(factory);
registerFunctionToMonth(factory);
registerFunctionToDayOfMonth(factory);
registerFunctionToDayOfWeek(factory);
registerFunctionToDayOfYear(factory);
registerFunctionToHour(factory);
registerFunctionToMinute(factory);
registerFunctionToSecond(factory);
registerFunctionToStartOfDay(factory);
registerFunctionToMonday(factory);
registerFunctionToISOWeek(factory);
registerFunctionToISOYear(factory);
registerFunctionToCustomWeek(factory);
registerFunctionToStartOfMonth(factory);
registerFunctionToStartOfQuarter(factory);
registerFunctionToStartOfYear(factory);
registerFunctionToStartOfMinute(factory);
registerFunctionToStartOfFiveMinute(factory);
registerFunctionToStartOfTenMinutes(factory);
registerFunctionToStartOfFifteenMinutes(factory);
registerFunctionToStartOfHour(factory);
registerFunctionToStartOfInterval(factory);
registerFunctionToStartOfISOYear(factory);
registerFunctionToRelativeYearNum(factory);
registerFunctionToRelativeQuarterNum(factory);
registerFunctionToRelativeMonthNum(factory);
registerFunctionToRelativeWeekNum(factory);
registerFunctionToRelativeDayNum(factory);
registerFunctionToRelativeHourNum(factory);
registerFunctionToRelativeMinuteNum(factory);
registerFunctionToRelativeSecondNum(factory);
registerFunctionToTime(factory);
registerFunctionNow(factory);
registerFunctionNow64(factory);
registerFunctionToday(factory);
registerFunctionYesterday(factory);
registerFunctionTimeSlot(factory);
registerFunctionTimeSlots(factory);
registerFunctionToYYYYMM(factory);
registerFunctionToYYYYMMDD(factory);
registerFunctionToYYYYMMDDhhmmss(factory);
registerFunctionAddSeconds(factory);
registerFunctionAddMinutes(factory);
registerFunctionAddHours(factory);
registerFunctionAddDays(factory);
registerFunctionAddWeeks(factory);
registerFunctionAddMonths(factory);
registerFunctionAddQuarters(factory);
registerFunctionAddYears(factory);
registerFunctionSubtractSeconds(factory);
registerFunctionSubtractMinutes(factory);
registerFunctionSubtractHours(factory);
registerFunctionSubtractDays(factory);
registerFunctionSubtractWeeks(factory);
registerFunctionSubtractMonths(factory);
registerFunctionSubtractQuarters(factory);
registerFunctionSubtractYears(factory);
registerFunctionDateDiff(factory);
registerFunctionToTimeZone(factory);
registerFunctionFormatDateTime(factory);
}
}
| 39.014286
| 57
| 0.812523
|
margaritiko
|
3717e38a36dd97be972b1d93e490036e8dfe74eb
| 4,509
|
cpp
|
C++
|
Source/AllProjects/CIDKernel/Win32/CIDKernel_LowLevelPopUp_Win32.cpp
|
eudora-jia/CIDLib
|
02795d283d95f8a5a4fafa401b6189851901b81b
|
[
"MIT"
] | 1
|
2019-05-28T06:33:01.000Z
|
2019-05-28T06:33:01.000Z
|
Source/AllProjects/CIDKernel/Win32/CIDKernel_LowLevelPopUp_Win32.cpp
|
eudora-jia/CIDLib
|
02795d283d95f8a5a4fafa401b6189851901b81b
|
[
"MIT"
] | null | null | null |
Source/AllProjects/CIDKernel/Win32/CIDKernel_LowLevelPopUp_Win32.cpp
|
eudora-jia/CIDLib
|
02795d283d95f8a5a4fafa401b6189851901b81b
|
[
"MIT"
] | null | null | null |
//
// FILE NAME: CIDKernel_LowLevelPopUp_Win32.Cpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 09/12/1998
//
// COPYRIGHT: Charmed Quark Systems, Ltd @ 2019
//
// This software is copyrighted by 'Charmed Quark Systems, Ltd' and
// the author (Dean Roddey.) It is licensed under the MIT Open Source
// license:
//
// https://opensource.org/licenses/MIT
//
// DESCRIPTION:
//
// This file provides the Win32 specific implementation for the TKrnlPopup
// namespace. We just use a message box. It's a little tight for the amount
// of info, but doing a full dialog would be messy.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
// $_CIDLib_Log_$
//
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "CIDKernel_.hpp"
#include "CIDKernel_InternalHelpers_.hpp"
// ---------------------------------------------------------------------------
// Local functions
// ---------------------------------------------------------------------------
//
// A simple function to write out a string of text to the low level log file
// if we are in a service and cannot show the popop.
//
static tCIDLib::TVoid LogText( HANDLE hFile
, const tCIDLib::TCh* const pszText
, tCIDLib::TSCh* const pszTmp
, const tCIDLib::TCard4 c4TmpSz
, const tCIDLib::TBoolean bNewLine)
{
if (!pszText)
return;
// Use the temp buffer to transcode to ASCII
TRawStr::pszConvert(pszText, pszTmp, c4TmpSz);
tCIDLib::TCard4 c4Len = TRawStr::c4StrLen(pszTmp);
// Add the new line if asked
if (bNewLine)
{
*(pszTmp + c4Len) = 0xA;
c4Len++;
}
// And write this to the file
tCIDLib::TCard4 c4Written;
::WriteFile(hFile, pszTmp, c4Len, &c4Written, 0);
}
static tCIDLib::TVoid LogText( HANDLE hFile
, tCIDLib::TSCh* const pszText
, const tCIDLib::TBoolean bNewLine)
{
if (!pszText)
return;
tCIDLib::TCard4 c4Len = TRawStr::c4StrLen(pszText);
tCIDLib::TCard4 c4Written;
::WriteFile(hFile, pszText, c4Len, &c4Written, 0);
if (bNewLine)
{
tCIDLib::TCard1 c1NL = 0xA;
::WriteFile(hFile, &c1NL, 1, &c4Written, 0);
}
}
// ---------------------------------------------------------------------------
// NAMESPACE: TKrnlPopup
// ---------------------------------------------------------------------------
// We have to be very conservative here and use the lowest level stuff
tCIDLib::TVoid TKrnlPopup::Show(const tCIDLib::TCh* const pszFileName
, const tCIDLib::TCard4 c4LineNum
, const tCIDLib::TCh* const pszTitle1
, const tCIDLib::TCh* const pszTitle2
, const tCIDLib::TErrCode errcId
, const tCIDLib::TErrCode errcKrnlId
, const tCIDLib::TOSErrCode errcHostId
, const tCIDLib::TCh* const pszMsg
, const tCIDLib::TCh* const pszMsg2)
{
const tCIDLib::TCard4 c4BufLen = 4095;
tCIDLib::TCh achBuffer[c4BufLen + 1];
achBuffer[0] = kCIDLib::chNull;
const tCIDLib::TCard4 c4TmpBufLen = 63;
tCIDLib::TCh achTmpBuf[c4TmpBufLen + 1];
achTmpBuf[0] = kCIDLib::chNull;
const tCIDLib::TCh* achNL(L"\r\n");
TRawStr::CopyStr(achBuffer, pszFileName, c4BufLen);
TRawStr::CatStr(achBuffer, L".", c4BufLen);
TRawStr::bFormatVal(c4LineNum, achTmpBuf, c4TmpBufLen);
TRawStr::CatStr(achBuffer, achTmpBuf, c4BufLen);
TRawStr::CatStr(achBuffer, achNL, c4BufLen);
if (pszMsg2)
TRawStr::CopyCatStr(achBuffer, c4BufLen, pszMsg2, achNL);
TRawStr::bFormatVal(errcId, achTmpBuf, c4TmpBufLen);
TRawStr::CopyCatStr(achBuffer, c4BufLen, achTmpBuf, L"/");
TRawStr::bFormatVal(errcKrnlId, achTmpBuf, c4TmpBufLen);
TRawStr::CopyCatStr(achBuffer, c4BufLen, achTmpBuf, L"/");
TRawStr::bFormatVal(errcHostId, achTmpBuf, c4TmpBufLen);
TRawStr::CatStr(achBuffer, achNL, c4BufLen);
UINT uType = MB_OK | MB_ICONERROR | MB_APPLMODAL;
::MessageBox(0, achBuffer, L"Unhandled Error", uType);
}
| 33.649254
| 78
| 0.531382
|
eudora-jia
|
371987b5003ccff8cf7fa7a5b4829d95e8476531
| 3,561
|
cxx
|
C++
|
Plugins/SciberQuestToolKit/SciberQuest/FieldTopologyMapData.cxx
|
demarle/ParaView
|
ec9642303012a3344f9be7a0acea45cc2b329720
|
[
"Apache-2.0",
"BSD-3-Clause"
] | 1
|
2019-04-22T09:09:18.000Z
|
2019-04-22T09:09:18.000Z
|
Plugins/SciberQuestToolKit/SciberQuest/FieldTopologyMapData.cxx
|
JamesLinus/ParaView
|
d0dd28e0527c230044f1891db2d8ad0170a04af0
|
[
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null |
Plugins/SciberQuestToolKit/SciberQuest/FieldTopologyMapData.cxx
|
JamesLinus/ParaView
|
d0dd28e0527c230044f1891db2d8ad0170a04af0
|
[
"Apache-2.0",
"BSD-3-Clause"
] | 1
|
2020-06-23T09:05:08.000Z
|
2020-06-23T09:05:08.000Z
|
/*
* Copyright 2012 SciberQuest Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither name of SciberQuest Inc. nor the names of any contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "FieldTopologyMapData.h"
#include "TerminationCondition.h"
#include "vtkDataSet.h"
#include "vtkCellData.h"
#include "vtkIntArray.h"
//-----------------------------------------------------------------------------
FieldTopologyMapData::FieldTopologyMapData()
:
IntersectColor(0)
//SourceId(0)
{
this->IntersectColor=vtkIntArray::New();
this->IntersectColor->SetName("IntersectColor");
// this->SourceId=vtkIntArray::New();
// this->SourceId->SetName("SourceId");
}
//-----------------------------------------------------------------------------
FieldTopologyMapData::~FieldTopologyMapData()
{
this->IntersectColor->Delete();
// this->SourceId->Delete();
}
//-----------------------------------------------------------------------------
void FieldTopologyMapData::SetOutput(vtkDataSet *o)
{
o->GetCellData()->AddArray(this->IntersectColor);
// o->GetCellData()->AddArray(this->SourceId);
}
//-----------------------------------------------------------------------------
int *FieldTopologyMapData::Append(vtkIntArray *ia, int nn)
{
vtkIdType ne=ia->GetNumberOfTuples();
return ia->WritePointer(ne,nn);
}
//-----------------------------------------------------------------------------
int FieldTopologyMapData::SyncScalars()
{
vtkIdType nLines=this->Lines.size();
vtkIdType lastLineId=this->IntersectColor->GetNumberOfTuples();
int *pColor=this->IntersectColor->WritePointer(lastLineId,nLines);
// int *pId=this->SourceId->WritePointer(lastLineId,nLines);
for (vtkIdType i=0; i<nLines; ++i)
{
FieldLine *line=this->Lines[i];
*pColor=this->Tcon->GetTerminationColor(line);
pColor+=1;
// *pId=line->GetSeedId();
// ++pId;
}
return 1;
}
//-----------------------------------------------------------------------------
void FieldTopologyMapData::PrintLegend(int reduce)
{
if (reduce)
{
this->Tcon->SqueezeColorMap(this->IntersectColor);
}
else
{
this->Tcon->PrintColorMap();
}
}
| 33.59434
| 80
| 0.629879
|
demarle
|
3719baa080f9ac6f740845093e15ec0fc6adce6e
| 37,128
|
cpp
|
C++
|
communication_lite/lwip_posix/src/ActsLwipTest.cpp
|
tomaytotomatof/leonspoks
|
8a385cfafa74fa5bcb8b0c465e0ac01d600a9b29
|
[
"Apache-2.0"
] | null | null | null |
communication_lite/lwip_posix/src/ActsLwipTest.cpp
|
tomaytotomatof/leonspoks
|
8a385cfafa74fa5bcb8b0c465e0ac01d600a9b29
|
[
"Apache-2.0"
] | null | null | null |
communication_lite/lwip_posix/src/ActsLwipTest.cpp
|
tomaytotomatof/leonspoks
|
8a385cfafa74fa5bcb8b0c465e0ac01d600a9b29
|
[
"Apache-2.0"
] | null | null | null |
/**
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <sys/wait.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <signal.h>
#include "securec.h"
using namespace std;
using namespace testing::ext;
static const int TEST_FD_COUNT = 10;
static const int STACK_PORT = 2277;
static const int PEER_PORT = 2277;
static const int BUF_SIZE = (1024 * 8);
static const char* g_udpMsg = "Hi, I am UDP";
static const char* g_srvMsg = "Hi, I am TCP server";
static const char* g_cliMsg = "Hi, I am TCP client";
static const char* g_localHost = "127.0.0.1";
static pthread_barrier_t g_barrier;
#define WAIT() pthread_barrier_wait(&g_barrier)
class ActsLwipTest : public testing::Test {
protected:
// SetUpTestCase: Testsuit setup, run before 1st testcase
static void SetUpTestCase(void)
{
// Ignore SIGPIPE Signals
signal(SIGPIPE, SIG_IGN);
}
// TearDownTestCase: Testsuit teardown, run after last testcase
static void TearDownTestCase(void) {}
// Testcase setup
virtual void SetUp() {}
// Testcase teardown
virtual void TearDown() {}
};
static int CommInitTcpServer(int port)
{
int srvFd = socket(AF_INET, SOCK_STREAM, 0);
if (srvFd == -1) {
printf("CommInitTcpServer]socket fail!\n");
return -1;
}
int flag = 1;
int ret = setsockopt(srvFd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(int));
if (ret != 0) {
printf("[CommInitTcpServer]setsockopt fail, ret[%d]!\n", ret);
}
struct sockaddr_in srvAddr = {0};
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(g_localHost);
srvAddr.sin_port = htons(port);
ret = ::bind(srvFd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
if (ret != 0) {
printf("[CommInitTcpServer]::bind fail!\n");
close(srvFd);
return -1;
}
int backlog = 5;
ret = listen(srvFd, backlog);
if (ret != 0) {
printf("[CommInitTcpServer]listen fail!\n");
close(srvFd);
return -1;
}
printf("[CommInitTcpServer]success,Fd[%d]\n", srvFd);
return srvFd;
}
static void* CommTcpClientTask(void* param)
{
int* ret = (int *)malloc(sizeof(int));
if (ret == nullptr) {
printf("[comm client]malloc fail\n");
return nullptr;
}
*ret = 0;
int clnFd = socket(AF_INET, SOCK_STREAM, 0);
if (clnFd == -1) {
printf("[comm client]socket fail\n");
*ret = -1;
return ret;
}
struct sockaddr_in srvAddr = {0};
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(g_localHost);
srvAddr.sin_port = htons(PEER_PORT + 1);
int rst = connect(clnFd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
if (rst != 0) {
printf("[comm client]connect fail\n");
close(clnFd);
*ret = -1;
return ret;
}
int sleepSecond = *((int *)param);
int count = 4;
char dataBuf[50] = {0};
char sendMsgList[5][50] = {"Hi, I'm client,FD:[%d]", "client:123456789abcdefg,FD:[%d]",
"client:!!@@##$$%%^^&&**(()),FD:[%d]", "client:(((112233445566778899))),FD:[%d]", "bye"};
for (int i = 0; i < count; i++) {
sleep(sleepSecond);
(void) memset_s(dataBuf, sizeof(dataBuf), 0, sizeof(dataBuf));
rst = sprintf_s(dataBuf, sizeof(dataBuf), sendMsgList[i], clnFd);
if (rst < 0) {
printf("[comm client]sprintf_s error!\n");
continue;
}
rst = send(clnFd, dataBuf, strlen(dataBuf), 0);
if (rst <= 0) {
*ret = -1;
printf("[comm client][%d]send fail\n", clnFd);
}
(void) memset_s(dataBuf, sizeof(dataBuf), 0, sizeof(dataBuf));
rst = recv(clnFd, dataBuf, sizeof(dataBuf), 0);
if (rst > 0) {
printf("[comm client][%d]recv msg[%s]\n", clnFd, dataBuf);
} else {
printf("[comm client][%d]recv no data\n", clnFd);
}
}
// send 'bye', finish
rst = send(clnFd, sendMsgList[count], strlen(sendMsgList[count]), 0);
if (rst <= 0) {
*ret = -1;
printf("[comm client][%d]send fail\n", clnFd);
}
rst = close(clnFd);
if (rst != 0) {
*ret = -1;
printf("[comm client][%d]close fd fail\n", clnFd);
}
return ret;
}
static void* SampleTcpServerTask(void* p)
{
int srvFd = CommInitTcpServer(STACK_PORT);
EXPECT_NE(-1, srvFd);
WAIT();
struct sockaddr_in clnAddr = {0};
socklen_t clnAddrLen = sizeof(clnAddr);
int clnFd = accept(srvFd, (struct sockaddr*)&clnAddr, &clnAddrLen);
printf("[tcp server]accept <%s:%d>\n", inet_ntoa(clnAddr.sin_addr), ntohs(clnAddr.sin_port));
EXPECT_NE(-1, clnFd);
printf("[tcp server]lsfd[%d], sfd[%d]\n", srvFd, clnFd);
struct sockaddr addr = {0};
socklen_t addrLen = sizeof(addr);
int ret = getsockname(clnFd, &addr, &addrLen);
printf("[tcp server]getsockname %s:%d\n", inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr),
ntohs(((struct sockaddr_in*)&addr)->sin_port));
EXPECT_EQ(0, ret);
EXPECT_EQ(inet_addr(g_localHost), ((struct sockaddr_in*)&addr)->sin_addr.s_addr);
ret = getpeername(clnFd, &addr, &addrLen);
printf("[tcp server]getpeername %s:%d\n", inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr),
ntohs(((struct sockaddr_in*)&addr)->sin_port));
EXPECT_EQ(0, ret);
EXPECT_EQ(inet_addr(g_localHost), ((struct sockaddr_in*)&addr)->sin_addr.s_addr);
static char buf[BUF_SIZE + 1] = {0};
unsigned int srvMsgLen = strlen(g_srvMsg);
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_srvMsg);
EXPECT_EQ(0, ret);
ret = send(clnFd, buf, srvMsgLen, 0);
printf("[tcp server]send, ret=%d\n", ret);
EXPECT_EQ(srvMsgLen, (unsigned int)ret);
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(clnFd, buf, sizeof(buf), 0);
printf("[tcp server]recv, ret=%d, msg[%s]\n", ret, buf);
EXPECT_EQ(strlen(g_cliMsg), (unsigned int)ret);
WAIT();
int len = 2;
struct msghdr msg = {0};
struct iovec iov[2] = {0};
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(g_localHost);
clnAddr.sin_port = htons(PEER_PORT);
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_srvMsg);
EXPECT_EQ(0, ret);
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = len;
iov[0].iov_base = buf;
iov[0].iov_len = srvMsgLen;
iov[1].iov_base = buf;
iov[1].iov_len = srvMsgLen;
ret = sendmsg(clnFd, &msg, 0);
printf("[tcp server]sendmsg, ret=%d\n", ret);
EXPECT_EQ(len * srvMsgLen, (unsigned int)ret);
WAIT();
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
(void) memset_s(&msg, sizeof(msg), 0, sizeof(msg));
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
iov[0].iov_base = buf;
iov[0].iov_len = sizeof(buf);
ret = recvmsg(clnFd, &msg, 0);
printf("[tcp server]recvmsg on socket %d:%d, msg[%s]\n", clnFd, ret, buf);
EXPECT_EQ(len * strlen(g_cliMsg), (unsigned int)ret);
ret = shutdown(clnFd, SHUT_RDWR);
printf("[tcp server]shutdown\n");
EXPECT_EQ(0, ret);
ret = close(clnFd);
EXPECT_NE(-1, ret);
ret = close(srvFd);
EXPECT_NE(-1, ret);
return nullptr;
}
static void* SampleTcpClientTask(void* p)
{
int clnFd = socket(AF_INET, SOCK_STREAM, 0);
printf("[tcp client]create socket\n");
EXPECT_NE(-1, clnFd);
WAIT();
struct sockaddr_in srvAddr = {0};
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(g_localHost);
srvAddr.sin_port = htons(PEER_PORT);
int ret = connect(clnFd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
printf("[tcp client]connect %s:%d, fd[%d]\n", inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), clnFd);
EXPECT_EQ(0, ret);
struct sockaddr addr = {0};
socklen_t addrLen = sizeof(addr);
ret = getpeername(clnFd, &addr, &addrLen);
printf("[tcp client]getpeername %s:%d\n", inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr),
ntohs(((struct sockaddr_in*)&addr)->sin_port));
EXPECT_EQ(0, ret);
EXPECT_EQ(inet_addr(g_localHost), ((struct sockaddr_in*)&addr)->sin_addr.s_addr);
ret = getsockname(clnFd, &addr, &addrLen);
printf("[tcp client]getsockname %s:%d\n", inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr),
ntohs(((struct sockaddr_in*)&addr)->sin_port));
EXPECT_EQ(0, ret);
EXPECT_EQ(inet_addr(g_localHost), ((struct sockaddr_in*)&addr)->sin_addr.s_addr);
static char buf[BUF_SIZE + 1] = {0};
unsigned int cliMsgLen = strlen(g_cliMsg);
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_cliMsg);
EXPECT_EQ(0, ret);
ret = send(clnFd, buf, cliMsgLen, 0);
printf("[tcp client]send, ret=%d\n", ret);
EXPECT_EQ(cliMsgLen, (unsigned int)ret);
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(clnFd, buf, sizeof(buf), 0);
printf("[tcp client]recv, ret=%d, msg[%s]\n", ret, buf);
EXPECT_EQ(strlen(g_srvMsg), (unsigned int)ret);
WAIT();
int len = 2;
struct msghdr msg = {0};
struct iovec iov[2] = {0};
struct sockaddr_in clnAddr = {0};
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(g_localHost);
clnAddr.sin_port = htons(PEER_PORT);
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_cliMsg);
EXPECT_EQ(0, ret);
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = len;
iov[0].iov_base = buf;
iov[0].iov_len = cliMsgLen;
iov[1].iov_base = buf;
iov[1].iov_len = cliMsgLen;
ret = sendmsg(clnFd, &msg, 0);
printf("[tcp client]sendmsg, ret=%d\n", ret);
EXPECT_EQ(len * cliMsgLen, (unsigned int)ret);
WAIT();
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
(void) memset_s(&msg, sizeof(msg), 0, sizeof(msg));
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
iov[0].iov_base = buf;
iov[0].iov_len = sizeof(buf);
ret = recvmsg(clnFd, &msg, 0);
printf("[tcp client]recvmsg, ret=%d, msg[%s]\n", ret, buf);
EXPECT_EQ(len * strlen(g_srvMsg), (unsigned int)ret);
ret = shutdown(clnFd, SHUT_RDWR);
printf("[tcp client]shutdown\n");
EXPECT_EQ(0, ret);
ret = close(clnFd);
EXPECT_NE(-1, ret);
return nullptr;
}
static int TcpServerForFork()
{
int timeout = 10;
char dataBuf[50] = {0};
int srvFd = CommInitTcpServer(STACK_PORT + 1);
if (srvFd == -1) {
return -1;
}
printf("[server process]wait client...\n");
int ret = -1;
struct sockaddr_in clnAddr = {0};
socklen_t clnAddrLen = sizeof(clnAddr);
int cliFd = accept(srvFd, (struct sockaddr*)&clnAddr, &clnAddrLen);
if (cliFd == -1) {
printf("[server process]accept fail!\n");
goto FINALLY;
}
while (timeout > 0) {
(void) memset_s(dataBuf, sizeof(dataBuf), 0, sizeof(dataBuf));
ret = recv(cliFd, dataBuf, sizeof(dataBuf), 0);
if (ret > 0) {
printf("[server process]recv msg[%s]\n", dataBuf);
if (strcmp(dataBuf, "bye") == 0) {
printf("[server process]break\n");
break;
}
} else {
printf("[server process]recv no data\n");
}
(void) memset_s(dataBuf, sizeof(dataBuf), 0, sizeof(dataBuf));
sprintf_s(dataBuf, sizeof(dataBuf), "server timeout:%d", timeout);
ret = send(cliFd, dataBuf, strlen(dataBuf), 0);
if (ret > 0) {
printf("[server process]send success, msg[%s]\n", dataBuf);
} else {
printf("[server process]send fail!\n");
}
timeout--;
}
close(cliFd);
printf("[server process]over\n");
FINALLY:
close(srvFd);
return ret;
}
static int WaitProcessExit(int pid, int* code)
{
int status;
int rt = waitpid(pid, &status, 0);
errno = 0;
int retError = -2;
if (rt == -1) {
printf("[WaitProcessExit]waitpid return -1, errno=%d:%s\n", errno, strerror(errno));
return -1;
} else if (rt == 0) {
return 0;
} else if (rt != pid) { // waitpid return error
printf("[WaitProcessExit]waitpid error\n");
return retError;
}
int retWterm = 2;
int retWstop = 3;
int other = 4;
if (WIFEXITED(status)) {
*code = WEXITSTATUS(status);
return 1;
} else if (WIFSIGNALED(status)) {
*code = WTERMSIG(status);
return retWterm;
} else if (WIFSTOPPED(status)) {
*code = WSTOPSIG(status);
return retWstop;
}
return other;
}
static int SelectServerForFork(unsigned int timeoutSec)
{
int srvFd = CommInitTcpServer(STACK_PORT + 1);
if (srvFd == -1) {
return -1;
}
int ret;
int cliCount = 0;
int maxFd = srvFd;
fd_set readSet;
char dataBuf[50] = {0};
int fds[TEST_FD_COUNT] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
fds[0] = srvFd;
long timeout = static_cast<long>(timeoutSec);
struct timeval timev = {.tv_sec = timeout, .tv_usec = 0};
struct sockaddr_in clnAddr = {0};
socklen_t clnAddrLen = sizeof(clnAddr);
while (1) {
FD_ZERO(&readSet);
for (int i = 0; i < TEST_FD_COUNT; i++) {
if (fds[i] != -1) {
FD_SET(fds[i], &readSet);
if (maxFd < fds[i]) {
maxFd = fds[i];
}
printf("[select process]fd info[%d:%d]\n", i, fds[i]);
}
}
ret = select(maxFd + 1, &readSet, NULL, NULL, &timev);
if (ret == 0) {
printf("[select process]select timeout!\n");
ret = -2;
break;
}
if (ret == -1) {
fprintf(stderr, "[select process]select fail[%s]\n", strerror(errno));
break;
}
if (FD_ISSET(srvFd, &readSet)) {
int cliFd = accept(srvFd, (struct sockaddr*)&clnAddr, &clnAddrLen);
if (cliFd == -1) {
printf("[select process]accept fail!\n");
ret = -1;
break;
} else {
for (int i = 0; i < TEST_FD_COUNT; i++) {
if (fds[i] == -1) {
fds[i] = cliFd;
break;
}
}
cliCount++;
printf("[select process]accept success, cliCount[%d]\n", cliCount);
}
continue;
}
for (int i = 0; i < TEST_FD_COUNT; i++) {
if (fds[i] == -1) {
continue;
}
if (FD_ISSET(fds[i], &readSet)) {
(void) memset_s(dataBuf, sizeof(dataBuf), 0, sizeof(dataBuf));
int len = recv(fds[i], dataBuf, sizeof(dataBuf), 0);
if (len > 0) {
printf("[select process][%d]recv msg[%s]\n", fds[i], dataBuf);
if (strcmp(dataBuf, "bye") == 0) {
printf("[select process][%d]client bye,cliCount[%d]\n", fds[i], cliCount);
FD_CLR(fds[i], &readSet);
close(fds[i]);
fds[i] = -1;
cliCount--;
continue;
}
len = send(fds[i], dataBuf, strlen(dataBuf), 0);
if (len > 0) {
printf("[select process][%d]send success\n", fds[i]);
} else {
printf("[select process][%d]send fail\n", fds[i]);
}
}
}
}
if (cliCount == 0) {
ret = 0;
printf("[select process]cliCount=0, over!\n");
break;
}
}
close(srvFd);
return ret;
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0100
* @tc.name : sample test tcp
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testTcpSample, Function | MediumTest | Level1)
{
pthread_t srv;
pthread_t cli;
int ret = pthread_barrier_init(&g_barrier, 0, 2);
EXPECT_EQ(0, ret);
ret = pthread_create(&srv, nullptr, SampleTcpServerTask, nullptr);
EXPECT_EQ(0, ret);
ret = pthread_create(&cli, nullptr, SampleTcpClientTask, nullptr);
EXPECT_EQ(0, ret);
ret = pthread_join(cli, nullptr);
EXPECT_EQ(0, ret);
ret = pthread_join(srv, nullptr);
EXPECT_EQ(0, ret);
ret = pthread_barrier_destroy(&g_barrier);
EXPECT_EQ(0, ret);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0200
* @tc.name : sample test udp
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testUdpSample, Function | MediumTest | Level2)
{
int len = 2;
char buf[BUF_SIZE + 1];
struct msghdr msg = {0};
struct iovec iov[2] = {0};
struct sockaddr_in srvAddr = {0};
struct sockaddr_in clnAddr = {0};
socklen_t clnAddrLen = sizeof(clnAddr);
int sfd = socket(AF_INET, SOCK_DGRAM, 0);
ASSERT_NE(-1, sfd);
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(g_localHost);
srvAddr.sin_port = htons(STACK_PORT);
int ret = ::bind(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
ASSERT_EQ(0, ret);
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(g_localHost);
clnAddr.sin_port = htons(PEER_PORT);
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_udpMsg);
EXPECT_EQ(0, ret);
ret = sendto(sfd, buf, strlen(g_udpMsg), 0, (struct sockaddr*)&clnAddr, (socklen_t)sizeof(clnAddr));
EXPECT_NE(-1, ret);
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recvfrom(sfd, buf, sizeof(buf), 0, (struct sockaddr*)&clnAddr, &clnAddrLen);
EXPECT_EQ(strlen(g_udpMsg), (unsigned int)ret);
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(g_localHost);
clnAddr.sin_port = htons(PEER_PORT);
(void) memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_udpMsg);
EXPECT_EQ(0, ret);
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = len;
iov[0].iov_base = buf;
iov[0].iov_len = strlen(g_udpMsg);
iov[1].iov_base = buf;
iov[1].iov_len = strlen(g_udpMsg);
ret = sendmsg(sfd, &msg, 0);
EXPECT_EQ(len*strlen(g_udpMsg), (unsigned int)ret);
ret = close(sfd);
EXPECT_NE(-1, ret);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0300
* @tc.name : test inter-process network communication
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInterProcessComm, Function | MediumTest | Level2)
{
pid_t pid = fork();
ASSERT_TRUE(pid >= 0) << "======== Fork Error! =========";
if (pid == 0) {
// child:tcp server
int exitCode = 0;
int ret = TcpServerForFork();
if (ret == -1) {
printf("[tcp server]run fail\n");
exitCode = 1;
}
exit(exitCode);
} else {
// parent:tcp client
sleep(2);
int second = 1;
void *ret = CommTcpClientTask(&second);
if (ret == nullptr) {
printf("[test select]CommClientTask ret is null\n");
EXPECT_TRUE(0);
} else {
printf("[test select]CommClientTask ret...\n");
int rst = *((int *)ret);
printf("[test select]CommClientTask ret [%d]\n", rst);
EXPECT_EQ(0, rst);
free(ret);
}
int exitCode;
int procStat = WaitProcessExit(pid, &exitCode);
ASSERT_EQ(1, procStat);
ASSERT_EQ(0, exitCode);
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0400
* @tc.name : test select timeout
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testSelectTimeout, Function | MediumTest | Level2)
{
pid_t pid = fork();
ASSERT_TRUE(pid >= 0) << "======== Fork Error! =========";
if (pid == 0) {
// child: server
int ret = SelectServerForFork(2);
if (ret == -2) {
exit(0);
} else {
printf("[select server]fail, ret is[%d]\n", ret);
exit(1);
}
} else {
int exitCode;
int procStat = WaitProcessExit(pid, &exitCode);
ASSERT_EQ(procStat, 1);
ASSERT_EQ(exitCode, 0);
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0500
* @tc.name : test select with one client
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testSelectOneClient, Function | MediumTest | Level2)
{
pid_t pid = fork();
ASSERT_TRUE(pid >= 0) << "======== Fork Error! =========";
if (pid == 0) {
// child: server
int exitCode = 0;
int ret = SelectServerForFork(15);
if (ret != 0) {
printf("[select server]run fail\n");
exitCode = 1;
}
printf("[select server]ret[%d]\n", ret);
exit(exitCode);
} else {
// parent: client
sleep(2);
int second = 1;
void *ret = CommTcpClientTask(&second);
if (ret == nullptr) {
printf("[test select]CommClientTask ret is null\n");
EXPECT_TRUE(0);
} else {
int rst = *((int *)ret);
printf("[test select]CommClientTask ret [%d]\n", rst);
EXPECT_EQ(0, rst);
free(ret);
}
int exitCode;
int procStat = WaitProcessExit(pid, &exitCode);
ASSERT_EQ(1, procStat);
ASSERT_EQ(0, exitCode);
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0600
* @tc.name : test select with multi clients
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testSelectMultiClients, Function | MediumTest | Level2)
{
pid_t pid = fork();
ASSERT_TRUE(pid >= 0) << "======== Fork Error! =========";
if (pid == 0) {
// child: server
int exitCode = 0;
int ret = SelectServerForFork(15);
if (ret != 0) {
printf("[select server]run fail\n");
exitCode = 1;
}
printf("[select server]ret[%d]\n", ret);
exit(exitCode);
} else {
// parent: client
sleep(2);
int ret;
pthread_t pCli[4];
int interval[4] = {2, 1, 3, 1};
for (int i = 0; i < 4; i++) {
ret = pthread_create(&pCli[i], nullptr, CommTcpClientTask, &interval[i]);
EXPECT_EQ(0, ret) << "Errinfo:pthread_create index is [" << i << "]";
}
void *rst = nullptr;
for (int i = 0; i < 4; i++) {
ret = pthread_join(pCli[i], &rst);
EXPECT_EQ(0, ret) << "Errinfo:pthread_join index is [" << i << "]";
if (rst != nullptr) {
printf("[test select]client thread[%d] return[%d]\n", i, *((int *)rst));
EXPECT_EQ(0, *((int *)rst));
free(rst);
}
}
int exitCode;
int procStat = WaitProcessExit(pid, &exitCode);
ASSERT_EQ(1, procStat);
ASSERT_EQ(0, exitCode);
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0700
* @tc.name : test socket operation
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testSocketOpt, Function | MediumTest | Level2)
{
socklen_t len;
struct timeval timeout = {0};
int fd = socket(AF_INET, SOCK_STREAM, 0);
EXPECT_NE(-1, fd);
int error = -1;
len = sizeof(error);
int ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
EXPECT_EQ(0, ret);
EXPECT_EQ(0, error);
len = sizeof(timeout);
ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
EXPECT_EQ(0, ret);
timeout.tv_sec = 1000;
len = sizeof(timeout);
ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, len);
EXPECT_EQ(0, ret);
(void) memset_s(&timeout, len, 0, len);
ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
EXPECT_EQ(0, ret);
EXPECT_EQ(1000, timeout.tv_sec);
int flag = 1;
ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
EXPECT_EQ(0, ret);
flag = 0;
len = sizeof(flag);
ret = getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, &len);
EXPECT_EQ(0, ret);
EXPECT_EQ(1, flag);
error = -1;
len = sizeof(error);
ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
EXPECT_EQ(0, ret);
EXPECT_EQ(0, error);
ret = close(fd);
EXPECT_EQ(0, ret);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0800
* @tc.name : test getsockname and getpeername invalid input
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testGetSocketNameInvalidInput, Function | MediumTest | Level3)
{
struct sockaddr addr = {0};
socklen_t addrLen = sizeof(addr);
int ret = getsockname(-1, &addr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getpeername(-1, &addr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getsockname(0, &addr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getpeername(0, &addr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getsockname(1, &addr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getpeername(1, &addr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getsockname(130, &addr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getpeername(130, &addr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getsockname(10, nullptr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getpeername(10, nullptr, &addrLen);
EXPECT_EQ(-1, ret);
ret = getsockname(10, &addr, nullptr);
EXPECT_EQ(-1, ret);
ret = getpeername(10, &addr, nullptr);
EXPECT_EQ(-1, ret);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0900
* @tc.name : test inet_pton IPv4 normal
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetPtonIpv4Normal, Function | MediumTest | Level2)
{
int ret;
struct in_addr rst = {0};
char cpAddrs[4][16] = {"10.58.212.100", "0.0.0.0", "255.0.0.0", "255.255.255.255"};
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
unsigned int expectLittle[4] = {1691630090, 0, 255, 4294967295};
#else
unsigned int expectBig[4] = {171627620, 0, 4278190080, 4294967295};
#endif
for (int i = 0; i < 4; i++) {
ret = inet_pton(AF_INET, cpAddrs[i], &rst);
EXPECT_EQ(1, ret);
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
EXPECT_EQ(expectLittle[i], rst.s_addr);
#else
EXPECT_EQ(expectBig[i], rst.s_addr);
#endif
printf("inet_pton %s: un[%u],s[%d],hex[%x]\n", cpAddrs[i], rst.s_addr, rst.s_addr, rst.s_addr);
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1000
* @tc.name : test inet_pton IPv4 abnormal
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetPtonIpv4Abnormal, Function | MediumTest | Level2)
{
int ret;
struct in_addr rst = {0};
char cpAddrs[6][16] = {"256.0.0.1", "a.a.a.a", "....", "#", "127.0.0.f", "0:0:0:0:0:0:0:1"};
for (int i = 0; i < 6; i++) {
ret = inet_pton(AF_INET, cpAddrs[i], &rst);
EXPECT_EQ(0, ret) << "ErrInfo:inet_pton abnormal [" << cpAddrs[i] << "]";
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1100
* @tc.name : test inet_pton IPv6 normal
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetPtonIpv6Normal, Function | MediumTest | Level2)
{
int ret;
struct in6_addr rst = {0};
char cpAddrs[6][40] = {"fc00:0101:0011:0011:0011:0011:0011:0011", "0:0:0:0:0:0:0:0",
"FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", "::", "1::", "fc00:0011:0011:0011:0011:11:11:11"};
for (int i = 0; i < 6; i++) {
ret = inet_pton(AF_INET6, cpAddrs[i], &rst);
EXPECT_EQ(1, ret) << "ErrInfo:inet_pton [" << cpAddrs[i] << "]";
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1200
* @tc.name : test inet_pton IPv6 abnormal
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetPtonIpv6Abnormal, Function | MediumTest | Level2)
{
int ret;
struct in6_addr rst = {0};
char cpAddrs[7][40] = {"127.0.0.1", "f", ":", "0:0", "1:::", ":::::::",
"1111:1111:1111:1111:1111:1111:1111:111G"};
for (int i = 0; i < 7; i++) {
ret = inet_pton(AF_INET6, cpAddrs[i], &rst);
EXPECT_EQ(0, ret) << "ErrInfo:inet_pton abnormal [" << cpAddrs[i] << "]";
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1300
* @tc.name : test inet_pton with invalid family
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetPtonInvalidFamily, Function | MediumTest | Level2)
{
struct in_addr rst = {0};
int ret = inet_pton(AF_IPX, "127.0.0.1", &rst);
EXPECT_EQ(-1, ret);
ret = inet_pton(-1, "127.0.0.1", &rst);
EXPECT_EQ(-1, ret);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1400
* @tc.name : test inet_ntop IPv4 normal
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetNtopIpv4Normal, Function | MediumTest | Level2)
{
const char* ret = nullptr;
struct in_addr inputAddr = {0};
char rstBuff[INET_ADDRSTRLEN];
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
unsigned int inputLittle[4] = {0x64d43a0a, 0, 255, 4294967295};
#else
unsigned int inputBig[4] = {171627620, 0, 4278190080, 4294967295};
#endif
char expectAddrs[4][16] = {"10.58.212.100", "0.0.0.0", "255.0.0.0", "255.255.255.255"};
for (int i = 0; i < 4; i++) {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
inputAddr.s_addr = inputLittle[i];
#else
inputAddr.s_addr = inputBig[i];
#endif
ret = inet_ntop(AF_INET, &inputAddr, rstBuff, sizeof(rstBuff));
ASSERT_NE(ret, nullptr);
printf("inet_ntop expect [%s]: ret[%s], buf[%s]\n", expectAddrs[i], ret, rstBuff);
EXPECT_STREQ(expectAddrs[i], ret);
EXPECT_STREQ(expectAddrs[i], rstBuff);
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1500
* @tc.name : test inet_ntop IPv4 boundary input
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetNtopIpv4Abnormal, Function | MediumTest | Level2)
{
const char* ret = nullptr;
struct in_addr inputAddr = {0};
char rstBuff[INET_ADDRSTRLEN];
char expectStr[2][16] = {"255.255.255.255", "0.0.0.0"};
for (int i = 0; i < 2; i++) {
inputAddr.s_addr = (i == 0 ? -1 : 4294967296);
ret = inet_ntop(AF_INET, &inputAddr, rstBuff, sizeof(rstBuff));
ASSERT_TRUE(ret != NULL);
EXPECT_STREQ(expectStr[i], ret);
EXPECT_STREQ(expectStr[i], rstBuff);
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1600
* @tc.name : test inet_ntop IPv6 normal
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetNtopIpv6Normal, Function | MediumTest | Level2)
{
int iret;
const char* ret = nullptr;
struct in6_addr inputAddr = {0};
char rstBuff[INET6_ADDRSTRLEN];
char inputAddrs[6][40] = {"fc00:0101:0011:0011:0011:0011:0011:0011", "0:0:0:0:0:0:0:0",
"FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", "::", "1::", "fc00:0011:0011:0011:1100:11:11:11"};
char expectAddrs[6][40] = {"fc00:101:11:11:11:11:11:11", "::",
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "::", "1::", "fc00:11:11:11:1100:11:11:11"};
for (int i = 0; i < 6; i++) {
iret = inet_pton(AF_INET6, inputAddrs[i], &inputAddr);
ASSERT_EQ(1, iret);
ret = inet_ntop(AF_INET6, &inputAddr, rstBuff, sizeof(rstBuff));
if (ret == nullptr) {
EXPECT_TRUE(ret != NULL) << "ErrInfo:inet_ntop NULL [" << expectAddrs[i] << "]";
} else {
printf("inet_ntop expect [%s]: ret[%s], buf[%s]\n", expectAddrs[i], ret, rstBuff);
EXPECT_STREQ(expectAddrs[i], ret);
EXPECT_STREQ(expectAddrs[i], rstBuff);
}
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1700
* @tc.name : test inet_ntop IPv6 boundary input
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetNtopIpv6Abnormal, Function | MediumTest | Level2)
{
const char* ret = nullptr;
struct in6_addr inputAddr = {0};
char rstBuff[INET6_ADDRSTRLEN];
char expectStr[2][40] = {"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "::"};
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 16; j++) {
inputAddr.s6_addr[j] = (i == 0 ? -1 : 256);
}
ret = inet_ntop(AF_INET6, &inputAddr, rstBuff, sizeof(rstBuff));
ASSERT_TRUE(ret != NULL);
EXPECT_STREQ(expectStr[i], ret);
EXPECT_STREQ(expectStr[i], rstBuff);
}
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1800
* @tc.name : test inet_ntop with invalid family
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInetNtopInvalidFamily, Function | MediumTest | Level2)
{
int iret;
const char* ret = nullptr;
struct in6_addr inputAddr = {0};
char rstBuff[INET6_ADDRSTRLEN];
iret = inet_pton(AF_INET6, "1::", &inputAddr);
ASSERT_EQ(1, iret);
ret = inet_ntop(AF_IPX, &inputAddr, rstBuff, sizeof(rstBuff));
EXPECT_TRUE(ret == NULL);
ret = inet_ntop(-1, &inputAddr, rstBuff, sizeof(rstBuff));
EXPECT_TRUE(ret == NULL);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_1900
* @tc.name : test invalid parameter
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F(ActsLwipTest, testInvalidParameter, Function | MediumTest | Level3)
{
int ret;
int fdFail = -1;
int fdSuccess = -1;
fdFail = socket(0, 0, 0);
EXPECT_EQ(-1, fdFail);
fdSuccess = socket(AF_INET, SOCK_STREAM, 0);
EXPECT_NE(-1, fdSuccess);
ret = ::bind(fdFail, nullptr, sizeof(struct sockaddr_in));
EXPECT_EQ(-1, ret);
ret = ::bind(fdSuccess, nullptr, sizeof(struct sockaddr_in));
EXPECT_EQ(-1, ret);
ret = connect(fdFail, nullptr, sizeof(struct sockaddr));
EXPECT_EQ(-1, ret);
ret = connect(fdSuccess, nullptr, sizeof(struct sockaddr));
EXPECT_EQ(-1, ret);
ret = accept(fdFail, nullptr, nullptr);
EXPECT_EQ(-1, ret);
ret = accept(fdSuccess, nullptr, nullptr);
EXPECT_EQ(-1, ret);
ret = getsockname(fdFail, nullptr, nullptr);
EXPECT_EQ(-1, ret);
ret = getsockname(fdSuccess, nullptr, nullptr);
EXPECT_EQ(-1, ret);
ret = getpeername(fdFail, nullptr, nullptr);
EXPECT_EQ(-1, ret);
ret = getpeername(fdSuccess, nullptr, nullptr);
EXPECT_EQ(-1, ret);
ret = send(fdFail, nullptr, strlen(g_srvMsg), 0);
EXPECT_EQ(-1, ret);
ret = send(fdSuccess, nullptr, strlen(g_srvMsg), 0);
EXPECT_EQ(-1, ret);
ret = sendto(fdFail, nullptr, strlen(g_srvMsg), 0, nullptr, (socklen_t)sizeof(struct sockaddr_in));
EXPECT_EQ(-1, ret);
ret = sendto(fdSuccess, nullptr, strlen(g_srvMsg), 0, nullptr, (socklen_t)sizeof(struct sockaddr_in));
EXPECT_EQ(-1, ret);
ret = recv(fdFail, nullptr, strlen(g_srvMsg), 0);
EXPECT_EQ(-1, ret);
ret = recv(fdSuccess, nullptr, strlen(g_srvMsg), 0);
EXPECT_EQ(-1, ret);
struct msghdr msg = {0};
ret = recvmsg(fdFail, &msg, 0);
EXPECT_EQ(-1, ret);
ret = recvmsg(fdSuccess, &msg, 0);
EXPECT_EQ(-1, ret);
ret = recvfrom(fdFail, nullptr, strlen(g_srvMsg), 0, nullptr, nullptr);
EXPECT_EQ(-1, ret);
ret = recvfrom(fdSuccess, nullptr, strlen(g_srvMsg), 0, nullptr, nullptr);
EXPECT_EQ(-1, ret);
ret = setsockopt(fdFail, SOL_SOCKET, SO_RCVTIMEO, nullptr, (socklen_t)sizeof(struct timeval));
EXPECT_EQ(-1, ret);
ret = setsockopt(fdSuccess, SOL_SOCKET, SO_RCVTIMEO, nullptr, (socklen_t)sizeof(struct timeval));
EXPECT_EQ(-1, ret);
ret = getsockopt(fdFail, SOL_SOCKET, SO_RCVTIMEO, nullptr, (socklen_t*)sizeof(struct timeval));
EXPECT_EQ(-1, ret);
ret = getsockopt(fdSuccess, SOL_SOCKET, SO_RCVTIMEO, nullptr, (socklen_t*)sizeof(struct timeval));
EXPECT_EQ(-1, ret);
ret = sendmsg(fdFail, nullptr, 0);
EXPECT_EQ(-1, ret);
ret = sendmsg(fdSuccess, nullptr, 0);
EXPECT_EQ(-1, ret);
ret = listen(fdFail, 0);
EXPECT_EQ(-1, ret);
ret = select(fdFail, nullptr, nullptr, nullptr, nullptr);
EXPECT_EQ(-1, ret);
ret = shutdown(fdFail, SHUT_RD);
EXPECT_EQ(-1, ret);
ret = shutdown(fdSuccess, -1);
EXPECT_EQ(-1, ret);
ret = close(fdSuccess);
EXPECT_EQ(0, ret);
}
| 32.798587
| 111
| 0.584572
|
tomaytotomatof
|
7debfea14eeab402d275d4fd2b61721ec62a8ee1
| 80,201
|
cc
|
C++
|
src/ndarray/ndarray.cc
|
moshelooks/incubator-mxnet
|
5245ef68191a6d47594bf331ec6e20ba6e93ad4c
|
[
"Apache-2.0"
] | null | null | null |
src/ndarray/ndarray.cc
|
moshelooks/incubator-mxnet
|
5245ef68191a6d47594bf331ec6e20ba6e93ad4c
|
[
"Apache-2.0"
] | null | null | null |
src/ndarray/ndarray.cc
|
moshelooks/incubator-mxnet
|
5245ef68191a6d47594bf331ec6e20ba6e93ad4c
|
[
"Apache-2.0"
] | null | null | null |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*!
* Copyright (c) 2015 by Contributors
* \file ndarray.cc
* \brief ndarry module of mxnet
*/
#include <dmlc/io.h>
#include <dmlc/memory_io.h>
#include <dmlc/logging.h>
#include <dmlc/registry.h>
#include <mxnet/base.h>
#include <mxnet/ndarray.h>
#include <mxnet/resource.h>
#include <mxnet/imperative.h>
#include <mshadow/tensor.h>
#if MXNET_USE_MKLDNN == 1
#include <mkldnn.hpp>
#endif
#include "./ndarray_function.h"
#include "../common/utils.h"
#include "../operator/tensor/matrix_op-inl.h"
#include "../operator/tensor/init_op.h"
#include "../operator/nn/mkldnn/mkldnn_base-inl.h"
#if MXNET_USE_OPENCV
#include <opencv2/opencv.hpp>
#endif // MXNET_USE_OPENCV
namespace dmlc {
DMLC_REGISTRY_ENABLE(::mxnet::NDArrayFunctionReg);
} // namespace dmlc
namespace mxnet {
NDArray::NDArray(const NDArrayStorageType stype, const TShape &shape, Context ctx,
bool delay_alloc, int dtype, std::vector<int> aux_types,
std::vector<TShape> aux_shapes, TShape storage_shape) : shape_(shape),
dtype_(dtype), storage_type_(stype), entry_({nullptr, 0, 0}) {
// Assign default aux types if not given
if (aux_types.size() == 0
&& stype != kDefaultStorage) {
if (stype == kRowSparseStorage) {
aux_types = {mshadow::kInt64};
} else if (stype == kCSRStorage) {
aux_types = {mshadow::kInt64, mshadow::kInt64};
} else {
LOG(FATAL) << "Unknown storage type " << stype;
}
}
// Assign default shapes if not given
// unknown shapes are intialized as {0} such that Size() would return 0
if (aux_shapes.size() == 0
&& stype != kDefaultStorage) {
if (stype == kRowSparseStorage) {
aux_shapes = {TShape(mshadow::Shape1(0))};
} else if (stype == kCSRStorage) {
// aux shapes for indptr and indices
aux_shapes = {TShape(mshadow::Shape1(0)), TShape(mshadow::Shape1(0))};
} else {
LOG(FATAL) << "Unknown storage type " << stype;
}
}
if (storage_shape.Size() == 0
&& stype != kDefaultStorage) {
if (stype == kRowSparseStorage) {
storage_shape = shape;
storage_shape[0] = aux_shapes[rowsparse::kIdx][0];
} else if (stype == kCSRStorage) {
storage_shape = aux_shapes[csr::kIdx];
} else {
LOG(FATAL) << "Unknown storage type " << stype;
}
}
if (stype == kDefaultStorage)
ptr_ = std::make_shared<Chunk>(shape, ctx, delay_alloc, dtype);
else
ptr_ = std::make_shared<Chunk>(stype, storage_shape, ctx, delay_alloc,
dtype, aux_types, aux_shapes);
}
struct ChunkMem {
Storage::Handle h;
std::vector<Storage::Handle> aux_h;
#if MXNET_USE_MKLDNN == 1
std::shared_ptr<mkldnn::memory> mem;
#endif
};
NDArray::Chunk::~Chunk() {
bool skip_free = static_data || delay_alloc;
ChunkMem mem;
mem.h = this->shandle;
mem.aux_h = this->aux_handles;
#if MXNET_USE_MKLDNN == 1
// We want to delete mkldnn memory after deleting the variable.
mem.mem = this->mkl_mem_;
#endif
Engine::Get()->DeleteVariable([mem, skip_free](RunContext s) {
if (skip_free == false) {
#if MXNET_USE_MKLDNN == 1
if (mem.mem) {
CHECK_LE(mem.mem->get_primitive_desc().get_size(), mem.h.size);
CHECK_EQ(mem.mem->get_data_handle(), mem.h.dptr);
}
#endif
if (mem.h.size > 0) Storage::Get()->Free(mem.h);
for (size_t i = 0; i < mem.aux_h.size(); i++) {
if (mem.aux_h[i].size > 0) Storage::Get()->Free(mem.aux_h[i]);
}
}
}, shandle.ctx, var);
}
void NDArray::Chunk::CheckAndAllocData(const TShape &shape, int dtype) {
CHECK_NE(aux_shapes.size(), 0)
<< "data is expected to be allocated after aux_data";
auto dbytes = shape.Size() * mshadow::mshadow_sizeof(dtype);
if (shandle.size < dbytes) {
// free storage if necessary and alloc again
if (shandle.size > 0) Storage::Get()->Free(shandle);
// init storage
shandle = Storage::Get()->Alloc(dbytes, ctx);
#if MXNET_USE_MKLDNN == 1
mkl_mem_ = nullptr;
#endif
}
// init shape
storage_shape = shape;
// delay_alloc is only set when data storage handle is present
delay_alloc = false;
}
NDArray NDArray::grad() const {
if (Imperative::AGInfo::IsNone(*this)) return NDArray();
Imperative::AGInfo& info = Imperative::AGInfo::Get(entry_.node);
if (info.out_grads.size()) {
CHECK_EQ(info.out_grads.size(), 1);
return info.out_grads[0];
}
return NDArray();
}
nnvm::Symbol NDArray::get_autograd_symbol() const {
CHECK(!Imperative::AGInfo::IsNone(*this))
<< "NDArray is not part of a computation graph. Did you forget to turn on recording?";
nnvm::Symbol ret;
ret.outputs.emplace_back(entry_);
return ret;
}
#if MXNET_USE_MKLDNN == 1
NDArray NDArray::MKLDNNDataReshape(const TShape &shape) const {
CHECK(!is_none()) << "NDArray is not initialized";
CHECK_GE(shape_.Size(), shape.Size())
<< "NDArray.Reshape: target shape size is larger current shape";
CHECK_EQ(storage_type(), kDefaultStorage);
if (!IsMKLDNNData()) {
NDArray ret = this->Detach();
ret.shape_ = shape;
return ret;
} else {
NDArray ret(shape, ctx(), true, dtype());
// We shouldn't submit the reorder primitive here because submit will
// be called in operators.
auto format = GetDefaultFormat(ptr_->mkl_mem_->get_primitive_desc().desc());
CHECK_NE(format, ptr_->mkl_mem_->get_primitive_desc().desc().data.format);
auto def_pd = GetPrimitiveDesc(ptr_->mkl_mem_->get_primitive_desc(), format);
auto def_mem = TmpMemMgr::Get()->Alloc(def_pd);
MKLDNNStream *stream = MKLDNNStream::Get();
stream->RegisterMem(ptr_->mkl_mem_);
stream->RegisterPrim(mkldnn::reorder(*ptr_->mkl_mem_, *def_mem));
// def_mem points to a memory region in the temp space. It's only valid
// inside an operator. As such, the returned NDArray can only be valid
// inside an operator and the shared point doesn't need to do anything
// when it's destroyed.
ret.ptr_->mkl_mem_ = std::shared_ptr<mkldnn::memory>(def_mem,
[](mkldnn::memory *mem){});
ret.ptr_->shandle.dptr = def_mem->get_data_handle();
ret.ptr_->shandle.size = def_mem->get_primitive_desc().get_size();
ret.ptr_->delay_alloc = false;
ret.ptr_->static_data = true;
ret.byte_offset_ = byte_offset_;
return ret;
}
}
#endif
NDArray NDArray::Reshape(const TShape &shape) const {
CHECK(!is_none()) << "NDArray is not initialized";
CHECK_GE(shape_.Size(), shape.Size())
<< "NDArray.Reshape: target shape size is larger current shape";
NDArray ret = this->Detach();
// If the shape doesn't change, we can just return it now.
if (ret.shape_ == shape)
return ret;
// Otherwise, reshape only works on the default layout.
CHECK_EQ(storage_type(), kDefaultStorage);
ret.shape_ = shape;
return ret;
}
NDArray NDArray::ReshapeWithRecord(const TShape &shape) {
NDArray ret = this->Reshape(shape);
if (!Imperative::Get()->is_recording()) return ret;
CHECK_EQ(shape_.Size(), shape.Size())
<< "NDArray.Reshape: target shape must have the same size as "
<< "current shape when recording with autograd.";
nnvm::NodeAttrs attrs;
attrs.op = nnvm::Op::Get("Reshape");;
std::ostringstream os;
os << shape;
attrs.dict.insert({"shape", os.str()});
attrs.op->attr_parser(&attrs);
std::vector<NDArray*> inputs(1, this), outputs(1, &ret);
Imperative::Get()->RecordOp(std::move(attrs), inputs, outputs);
return ret;
}
NDArray NDArray::Slice(index_t begin, index_t end) const {
CHECK(!is_none()) << "NDArray is empty";
CHECK_LE(begin, end)
<< "Invalid slicing range [" << begin << ", " << end << ")";
CHECK_GE(shape_[0], end) << "Slice end index out of range";
CHECK_EQ(storage_type(), kDefaultStorage);
NDArray ret = this->Detach();
size_t length = shape_.ProdShape(1, shape_.ndim());
MSHADOW_TYPE_SWITCH(ret.dtype(), DType, {
ret.byte_offset_ += begin * length * sizeof(DType);
});
ret.shape_[0] = end - begin;
return ret;
}
NDArray NDArray::SliceWithRecord(index_t begin, index_t end) {
NDArray ret = this->Slice(begin, end);
if (!Imperative::Get()->is_recording()) return ret;
// fake a slice_axis op
nnvm::NodeAttrs attrs;
attrs.op = nnvm::Op::Get("slice_axis");
attrs.dict.insert({"axis", "0"});
attrs.dict.insert({"begin", std::to_string(begin)});
attrs.dict.insert({"end", std::to_string(end)});
attrs.op->attr_parser(&attrs);
std::vector<NDArray*> inputs(1, this), outputs(1, &ret);
Imperative::Get()->RecordOp(std::move(attrs), inputs, outputs);
return ret;
}
NDArray NDArray::At(index_t idx) const {
CHECK(storage_type() == kDefaultStorage)
<< "Storage type " << storage_type() << " doesn't support At()";
NDArray ret = this->Slice(idx, idx+1);
if (shape_.ndim() > 1) {
return ret.Reshape(TShape(shape_.data()+1, shape_.data()+shape_.ndim()));
} else {
return ret;
}
}
NDArray NDArray::AtWithRecord(index_t idx) {
CHECK(storage_type() == kDefaultStorage)
<< "Storage type " << storage_type() << " doesn't support At()";
NDArray ret = this->SliceWithRecord(idx, idx+1);
if (shape_.ndim() > 1) {
return ret.ReshapeWithRecord(TShape(shape_.data()+1, shape_.data()+shape_.ndim()));
} else {
return ret;
}
}
/*!
* \brief Return deep copy of the current ndarry's aux_data(i)
* as an NDArray of default storage type. This function blocks.
*/
NDArray NDArray::aux_ndarray(size_t i) const {
CHECK_NE(storage_type(), kDefaultStorage);
CHECK(i < ptr_->aux_shapes.size());
// create a delay_alloc default ndarray as output
NDArray ret(TShape(), ctx(), true, aux_type(i));
ret.SyncCopyFromNDArray(*this, i);
return ret;
}
NDArray NDArray::data_ndarray() const {
NDArray ret(TShape(), ctx(), true, dtype_);
ret.SyncCopyFromNDArray(*this);
return ret;
}
bool NDArray::fresh_out_grad() const {
if (Imperative::AGInfo::IsNone(*this)) return false;
Imperative::AGInfo& info = Imperative::AGInfo::Get(entry_.node);
return info.fresh_out_grad;
}
void NDArray::set_fresh_out_grad(bool state) const {
CHECK(!Imperative::AGInfo::IsNone(*this))
<< "NDArray has not been marked as a variable and does not have gradient state";
Imperative::AGInfo& info = Imperative::AGInfo::Get(entry_.node);
info.fresh_out_grad = state;
}
#if MXNET_USE_MKLDNN == 1
static inline bool same_shape(const TShape &shape, mkldnn_dims_t dims, int ndims) {
if (shape.ndim() != (size_t)ndims)
return false;
for (int i = 0; i < ndims; i++)
if (shape[i] != dims[i])
return false;
return true;
}
static inline bool same_shape(const TShape &shape, int dtype, mkldnn::memory::desc desc) {
return same_shape(shape, desc.data.dims, desc.data.ndims)
&& get_mkldnn_type(dtype) == desc.data.data_type;
}
bool NDArray::Chunk::IsMKLDNN() const {
if (storage_type != kDefaultStorage)
return false;
if (mkl_mem_ == nullptr)
return false;
auto desc = mkl_mem_->get_primitive_desc().desc();
return desc.data.format != GetDefaultFormat(desc);
}
bool NDArray::Chunk::IsDefault() const {
if (storage_type != kDefaultStorage)
return false;
// If we don't have mkldnn memory yet, we just assume it's not the default
// format.
if (mkl_mem_ == nullptr)
return true;
auto desc = mkl_mem_->get_primitive_desc().desc();
return desc.data.format == GetDefaultFormat(desc);
}
void NDArray::Chunk::Reorder2Default() {
if (mkl_mem_ == nullptr)
return;
auto format = GetDefaultFormat(mkl_mem_->get_primitive_desc().desc());
CHECK(format != mkl_mem_->get_primitive_desc().desc().data.format);
auto def_pd = GetPrimitiveDesc(mkl_mem_->get_primitive_desc(), format);
mkldnn_mem_ptr def_mem(new mkldnn::memory(def_pd));
// This may be called in MKLDNN operators. We can't use MKLDNNStream here.
std::vector<mkldnn::primitive> net;
net.push_back(mkldnn::reorder(*mkl_mem_, *def_mem));
mkldnn::stream(mkldnn::stream::kind::eager).submit(net).wait();
CHECK(shandle.size >= def_pd.get_size());
CheckAndAlloc(def_pd.get_size());
// TODO(zhengda) We need to avoid memory copy here.
memcpy(shandle.dptr, def_mem->get_data_handle(), def_pd.get_size());
mkl_mem_ = nullptr;
}
void NDArray::Chunk::MKLDNNDataReorder(const mkldnn::memory::primitive_desc &pd) {
// If the memory already uses the specified layout, don't do anything.
if (mkl_mem_ != nullptr && mkl_mem_->get_primitive_desc() == pd)
return;
auto _pd = pd;
auto _desc = _pd.desc();
auto def_format = GetDefaultFormat(_desc);
// If the memory is default, don't do anything.
if (def_format == _desc.data.format && IsDefault())
return;
// If the specified layout is default, we should use Reorder2Default.
if (def_format == _desc.data.format) {
Reorder2Default();
return;
}
std::shared_ptr<mkldnn::memory> new_mem(new mkldnn::memory(pd));
std::shared_ptr<mkldnn::memory> old_mem;
if (IsDefault()) {
auto def_pd = GetPrimitiveDesc(pd, def_format);
old_mem.reset(new mkldnn::memory(def_pd, shandle.dptr));
} else {
old_mem = this->mkl_mem_;
}
CHECK(old_mem->get_primitive_desc().desc().data.ndims == _desc.data.ndims);
// This may be called in MKLDNN operators. We can't use MKLDNNStream here.
std::vector<mkldnn::primitive> net;
net.push_back(mkldnn::reorder(*old_mem, *new_mem));
mkldnn::stream(mkldnn::stream::kind::eager).submit(net).wait();
CHECK(shandle.size >= pd.get_size());
CheckAndAlloc(pd.get_size());
// TODO(zhengda) We need to avoid memory copy here.
memcpy(shandle.dptr, new_mem->get_data_handle(), pd.get_size());
mkl_mem_.reset(new mkldnn::memory(pd, shandle.dptr));
}
void NDArray::Chunk::SetMKLMem(const TShape &shape, int dtype) {
// The shape of the array and the one of the MKL memory may mismatch.
// For example, if the array stores parameters, the MKL memory may store data
// in 5 dimensions while the NDArray stores data in 4 dimensions.
if (mkl_mem_ && mkl_mem_->get_data_handle() == shandle.dptr
&& same_shape(shape, dtype, mkl_mem_->get_primitive_desc().desc())) {
return;
}
mkldnn::memory::dims dims;
// These are shapes supprted by MKLDNN.
if (shape.ndim() == 1 || shape.ndim() == 2 || shape.ndim() == 4
|| shape.ndim() == 5) {
dims.resize(shape.ndim());
for (size_t i = 0; i < dims.size(); i++)
dims[i] = shape[i];
} else if (shape.ndim() == 3) {
// If there are 3 dimensions, we'll force it to 4 dimensions.
dims.resize(shape.ndim() + 1);
dims[0] = 1;
for (size_t i = 0; i < shape.ndim(); i++)
dims[i + 1] = shape[i];
} else {
LOG(FATAL) << "MKLDNN doesn't support " << shape.ndim() << " dimensions";
}
mkldnn::memory::format layout = mkldnn::memory::format::format_undef;
switch (dims.size()) {
case 1: layout = mkldnn::memory::format::x; break;
case 2: layout = mkldnn::memory::format::nc; break;
case 4: layout = mkldnn::memory::format::nchw; break;
// This isn't the right layout when the data has 5 dimensions in MXNet.
// MXNet interprets 5 dimensions as ncdhw, but MKLDNN doesn't have
// a corresponding format.
case 5: layout = mkldnn::memory::format::goihw; break;
}
mkldnn::memory::desc data_md{dims, get_mkldnn_type(dtype), layout};
auto cpu_engine = CpuEngine::Get()->get_engine();
if (shandle.dptr == nullptr) {
CHECK(delay_alloc);
CheckAndAlloc();
}
mkldnn::memory::primitive_desc pd(data_md, cpu_engine);
CHECK(shandle.size >= pd.get_size());
mkl_mem_.reset(new mkldnn::memory(pd, shandle.dptr));
}
/*
* Here we want to get MKLDNN memory whose primitive desc is exactly the same as
* the given one. operator== can't guarantee that. == can return true even if
* the formats are different. I need to double check its format.
*/
static inline mkldnn::memory *GetMKLDNNExact(
const mkldnn::memory *mem, mkldnn::memory::primitive_desc desc) {
auto src_desc = mem->get_primitive_desc();
if (desc == src_desc && desc.desc().data.format == src_desc.desc().data.format) {
return const_cast<mkldnn::memory *>(mem);
} else {
std::shared_ptr<mkldnn::memory> ret(new mkldnn::memory(
desc, mem->get_data_handle()));
MKLDNNStream::Get()->RegisterMem(ret);
return ret.get();
}
}
const mkldnn::memory *NDArray::GetMKLDNNData(
const mkldnn::memory::primitive_desc &desc) const {
if (desc.get_size() != shape().Size() * GetTypeSize(dtype_)) {
LOG(FATAL) << "The size of NDArray doesn't match the requested MKLDNN memory desc";
return nullptr;
}
auto mem = GetMKLDNNData();
mkldnn::memory::primitive_desc _desc = desc;
auto desc1 = mem->get_primitive_desc().desc();
auto desc2 = _desc.desc();
// The MKL memory has the same format and shape as required,
// or both use the default format, we can return the MKL memory.
if (mem->get_primitive_desc() == desc
|| (desc1.data.format == GetDefaultFormat(desc1)
&& desc2.data.format == GetDefaultFormat(desc2))) {
return GetMKLDNNExact(ptr_->mkl_mem_.get(), desc);
} else {
return nullptr;
}
}
const mkldnn::memory *NDArray::GetMKLDNNDataReorder(
const mkldnn::memory::primitive_desc &desc) const {
if (desc.get_size() != shape().Size() * GetTypeSize(dtype_)) {
LOG(FATAL) << "The size of NDArray doesn't match the requested MKLDNN memory desc";
return nullptr;
}
CHECK(storage_type() == kDefaultStorage);
auto mem = GetMKLDNNData();
// If the memory descriptor matches, it's easy.
MKLDNNStream *stream = MKLDNNStream::Get();
if (mem->get_primitive_desc() == desc) {
return GetMKLDNNExact(mem, desc);
}
mkldnn::memory::primitive_desc _desc = desc;
// Now we need to determine if we should reorder the memory.
// If both use the default formats, we think we don't need to reorder.
auto desc1 = mem->get_primitive_desc().desc();
auto desc2 = _desc.desc();
if (desc1.data.format == GetDefaultFormat(desc1) &&
desc2.data.format == GetDefaultFormat(desc2)) {
mkldnn_mem_ptr ret(new mkldnn::memory(desc, mem->get_data_handle()));
stream->RegisterMem(ret);
return ret.get();
} else {
auto ret = TmpMemMgr::Get()->Alloc(desc);
stream->RegisterPrim(mkldnn::reorder(*mem, *ret));
return ret;
}
}
NDArray NDArray::Reorder2Default() const {
CHECK(storage_type() == kDefaultStorage);
if (ptr_->mkl_mem_ == nullptr)
return *this;
auto format = GetDefaultFormat(ptr_->mkl_mem_->get_primitive_desc().desc());
if (format == ptr_->mkl_mem_->get_primitive_desc().desc().data.format)
return *this;
NDArray ret(shape(), ctx(), false, dtype());
auto def_pd = GetPrimitiveDesc(ptr_->mkl_mem_->get_primitive_desc(), format);
CHECK(ret.ptr_->shandle.size >= def_pd.get_size());
mkldnn::memory def_mem(def_pd, ret.ptr_->shandle.dptr);
// This may be called in MKLDNN operators. We can't use MKLDNNStream here.
std::vector<mkldnn::primitive> net;
net.push_back(mkldnn::reorder(*ptr_->mkl_mem_, def_mem));
mkldnn::stream(mkldnn::stream::kind::eager).submit(net).wait();
return ret;
}
void NDArray::Reorder2DefaultAsync() {
std::vector<Engine::VarHandle> const_vars;
std::vector<Engine::VarHandle> mutable_vars(1, this->var());
NDArray tmp = *this;
Engine::Get()->PushAsync(
[tmp](RunContext ctx, Engine::CallbackOnComplete on_complete) {
tmp.ptr_->Reorder2Default();
on_complete();
}, ctx(), const_vars, mutable_vars,
FnProperty::kNormal, 0, "Reorder2Default");
}
void NDArray::MKLDNNDataReorderAsync(const mkldnn::memory::primitive_desc &desc) {
std::vector<Engine::VarHandle> const_vars;
std::vector<Engine::VarHandle> mutable_vars(1, this->var());
NDArray tmp = *this;
Engine::Get()->PushAsync(
[tmp, desc](RunContext ctx, Engine::CallbackOnComplete on_complete) {
tmp.ptr_->MKLDNNDataReorder(desc);
on_complete();
}, ctx(), const_vars, mutable_vars,
FnProperty::kNormal, 0, "Reorder");
}
const mkldnn::memory *NDArray::GetMKLDNNData() const {
CHECK(storage_type() == kDefaultStorage);
// If this array uses MKLDNN layout, we have to make sure it's not a view.
// Otherwise, we'll have to change the layout inside the array.
if (IsMKLDNNData())
CHECK(!IsView());
ptr_->SetMKLMem(IsView() ? ptr_->storage_shape : shape_, dtype_);
// If shandle has data, the data in shandle and mkl_mem_ should match.
if (ptr_->shandle.dptr)
CHECK(ptr_->shandle.dptr == ptr_->mkl_mem_->get_data_handle());
MKLDNNStream::Get()->RegisterMem(ptr_->mkl_mem_);
auto pd = ptr_->mkl_mem_->get_primitive_desc();
if (IsView()) {
// Sliced array must use the default layout.
CHECK_EQ(GetDefaultFormat(pd.desc()), pd.desc().data.format);
}
if (IsView()) {
void *off_addr = static_cast<char *>(ptr_->mkl_mem_->get_data_handle())
+ byte_offset_;
// Create the primitive desc for the new mkldnn memory.
mkldnn::memory::dims dims(shape().ndim());
for (size_t i = 0; i < dims.size(); i++)
dims[i] = shape()[i];
mkldnn::memory::format cpp_format = static_cast<mkldnn::memory::format>(
GetDefaultFormat(shape().ndim()));
mkldnn::memory::data_type cpp_type = static_cast<mkldnn::memory::data_type>(
pd.desc().data.data_type);
mkldnn::memory::desc data_md(dims, cpp_type, cpp_format);
mkldnn::memory::primitive_desc new_pd(data_md, pd.get_engine());
std::shared_ptr<mkldnn::memory> ret(new mkldnn::memory(new_pd, off_addr));
MKLDNNStream::Get()->RegisterMem(ret);
return ret.get();
} else {
return ptr_->mkl_mem_.get();
}
}
void NDArray::CopyFrom(const mkldnn::memory &mem) {
CHECK(ptr_ != nullptr) << "The NDArray hasn't been initialized";
if (ptr_->mkl_mem_.get() == &mem)
return;
CHECK(mem.get_primitive_desc().get_size() == shape().Size() * GetTypeSize(dtype_))
<< "The size of NDArray doesn't match the requested MKLDNN memory desc";
MKLDNNStream *stream = MKLDNNStream::Get();
// If this array uses MKLDNN layout, we have to make sure it's not a view.
// Otherwise, we'll have to change the layout inside the array.
if (IsMKLDNNData())
CHECK(!IsView());
ptr_->SetMKLMem(IsView() ? ptr_->storage_shape : shape_,
dtype_);
stream->RegisterMem(ptr_->mkl_mem_);
auto from_desc = mem.get_primitive_desc().desc();
auto this_desc = ptr_->mkl_mem_->get_primitive_desc().desc();
auto from_def_format = GetDefaultFormat(from_desc);
if (IsView()) {
// Sliced array must use the default layout.
CHECK_EQ(GetDefaultFormat(this_desc), this_desc.data.format);
}
// It's possible that the memory and the NDArray don't have the same shape.
if (!same_shape(shape_, from_desc.data.dims, from_desc.data.ndims)
// If the source memory uses the default layout, we can reshape directly.
&& from_def_format == from_desc.data.format) {
// In this case, we can simply create a new MKLDNN memory for the required
// shape.
mkldnn::memory::dims dims(this_desc.data.dims,
this_desc.data.dims + this_desc.data.ndims);
auto this_dtype = static_cast<mkldnn::memory::data_type>(this_desc.data.data_type);
auto this_format = static_cast<mkldnn::memory::format>(GetDefaultFormat(this_desc));
mkldnn::memory::desc data_md(dims, this_dtype, this_format);
mkldnn::memory::primitive_desc pd(data_md, mem.get_primitive_desc().get_engine());
mkldnn_mem_ptr tmp_mem(new mkldnn::memory(pd, mem.get_data_handle()));
stream->RegisterMem(tmp_mem);
stream->RegisterPrim(mkldnn::reorder(*tmp_mem, *ptr_->mkl_mem_));
} else if (!same_shape(shape_, from_desc.data.dims, from_desc.data.ndims)) {
// In this case, the source memory stores data in a customized layout. We
// need to reorganize the data in memory before we can reshape.
auto def_pd = GetPrimitiveDesc(mem.get_primitive_desc(), from_def_format);
auto def_mem = TmpMemMgr::Get()->Alloc(def_pd);
stream->RegisterPrim(mkldnn::reorder(mem, *def_mem));
// Now we can reshape it
mkldnn::memory::dims dims(this_desc.data.dims,
this_desc.data.dims + this_desc.data.ndims);
auto this_dtype = static_cast<mkldnn::memory::data_type>(this_desc.data.data_type);
auto this_format = static_cast<mkldnn::memory::format>(GetDefaultFormat(this_desc));
mkldnn::memory::desc data_md(dims, this_dtype, this_format);
mkldnn::memory::primitive_desc pd(data_md, mem.get_primitive_desc().get_engine());
mkldnn_mem_ptr tmp_mem(new mkldnn::memory(pd, def_mem->get_data_handle()));
stream->RegisterMem(tmp_mem);
stream->RegisterPrim(mkldnn::reorder(*tmp_mem, *ptr_->mkl_mem_));
} else if (mem.get_primitive_desc() == ptr_->mkl_mem_->get_primitive_desc()) {
// If the layout is the same, we can just copy data.
stream->RegisterPrim(mkldnn::reorder(mem, *ptr_->mkl_mem_));
} else {
auto src_def = GetDefaultFormat(mem.get_primitive_desc().desc());
auto dst_def = GetDefaultFormat(ptr_->mkl_mem_->get_primitive_desc().desc());
// If both are not using the default layouts. There isn't much we can do,
// other than reorder data layout directly.
if (dst_def != ptr_->mkl_mem_->get_primitive_desc().desc().data.format
&& src_def != mem.get_primitive_desc().desc().data.format) {
stream->RegisterPrim(mkldnn::reorder(mem, *ptr_->mkl_mem_));
} else if (dst_def == ptr_->mkl_mem_->get_primitive_desc().desc().data.format) {
// If the dest mem uses the default memory layout, we can simply use
// the default format of the source memory to improve perf of reorder.
auto pd = GetPrimitiveDesc(ptr_->mkl_mem_->get_primitive_desc(), src_def);
mkldnn_mem_ptr tmp_mem(new mkldnn::memory(pd, ptr_->mkl_mem_->get_data_handle()));
stream->RegisterMem(tmp_mem);
stream->RegisterPrim(mkldnn::reorder(mem, *tmp_mem));
} else {
// If the src mem uses the default memory layout, we can use
// the default format of the source memory to improve perf.
auto pd = GetPrimitiveDesc(mem.get_primitive_desc(), dst_def);
mkldnn_mem_ptr tmp_mem(new mkldnn::memory(pd, mem.get_data_handle()));
stream->RegisterMem(tmp_mem);
stream->RegisterPrim(mkldnn::reorder(*tmp_mem, *ptr_->mkl_mem_));
}
}
}
mkldnn::memory::primitive_desc GetPrimitiveDesc(mkldnn::memory::primitive_desc pd,
mkldnn_memory_format_t format);
mkldnn::memory *NDArray::CreateMKLDNNData(const mkldnn::memory::primitive_desc &desc) {
// This array shouldn't be a view.
CHECK(!IsView());
if (desc.get_size() != shape().Size() * GetTypeSize(dtype_)) {
LOG(FATAL) << "The size of NDArray doesn't match the requested MKLDNN memory desc";
return nullptr;
}
mkldnn::memory::primitive_desc _desc = desc;
auto required_format = _desc.desc().data.format;
auto def_format = GetDefaultFormat(_desc.desc());
// If the required format is a default format, we don't need to worry about the shape.
// If the shape isn't the same, it actually implicitly reshapes data.
if (required_format == def_format) {
ptr_->SetMKLMem(shape_, dtype_);
MKLDNNStream::Get()->RegisterMem(ptr_->mkl_mem_);
return GetMKLDNNExact(ptr_->mkl_mem_.get(), desc);
}
if (ptr_->mkl_mem_)
CHECK(ptr_->mkl_mem_->get_data_handle() == ptr_->shandle.dptr);
if (ptr_->mkl_mem_ && ptr_->mkl_mem_->get_primitive_desc() == desc) {
MKLDNNStream::Get()->RegisterMem(ptr_->mkl_mem_);
return GetMKLDNNExact(ptr_->mkl_mem_.get(), desc);
}
CHECK(ptr_->shandle.size >= desc.get_size());
ptr_->CheckAndAlloc(desc.get_size());
ptr_->mkl_mem_.reset(new mkldnn::memory(desc, ptr_->shandle.dptr));
MKLDNNStream::Get()->RegisterMem(ptr_->mkl_mem_);
return ptr_->mkl_mem_.get();
}
#endif
void NDArray::SetTBlob() const {
CHECK(ptr_ != nullptr);
TShape shape = shape_;
char *dptr = static_cast<char*>(ptr_->shandle.dptr);
auto stype = storage_type();
if (stype == kDefaultStorage) {
#if MXNET_USE_MKLDNN == 1
CHECK(!IsMKLDNNData()) << "We can't generate TBlob for MKLDNN data. "
<< "Please use Reorder2Default() to generate a new NDArray first";
#endif
dptr += byte_offset_;
} else if (stype == kCSRStorage || stype == kRowSparseStorage) {
CHECK_EQ(byte_offset_, 0);
shape = storage_shape();
} else {
LOG(FATAL) << "unknown storage type " << stype;
}
tblob_.dptr_ = dptr;
tblob_.shape_ = shape;
tblob_.type_flag_ = dtype_;
tblob_.SetDLTensor(ptr_->shandle.ctx.dev_mask(), ptr_->shandle.ctx.dev_id);
}
/*!
* \brief run a ternary operation
* \param lhs left operand
* \param mhs middle operand
* \param rhs right operand
* \param out the output ndarray
*/
template<typename OP>
void TernaryOp(const NDArray &lhs,
const NDArray &mhs,
const NDArray &rhs,
NDArray *out) {
// no check if all of them are on cpu
if (lhs.ctx().dev_mask() != cpu::kDevMask || mhs.ctx().dev_mask() != cpu::kDevMask
|| rhs.ctx().dev_mask() != cpu::kDevMask) {
CHECK((lhs.ctx() == mhs.ctx()) && (mhs.ctx() == rhs.ctx())) << "operands context mismatch";
}
// if out is none, allocate space
if (out->is_none()) {
*out = NDArray(OP::GetShape(lhs.shape(), mhs.shape(), rhs.shape()), lhs.ctx(), true);
} else {
// no check if both of them are on cpu
if (lhs.ctx().dev_mask() != cpu::kDevMask ||
out->ctx().dev_mask() != cpu::kDevMask) {
CHECK(out->ctx() == lhs.ctx()) << "target context mismatch";
}
CHECK(out->shape() == OP::GetShape(lhs.shape(), mhs.shape(), rhs.shape()))
<< "target shape mismatch";
}
// important: callback must always capture by value
NDArray ret = *out;
// get the const variables
std::vector<Engine::VarHandle> const_vars;
if (lhs.var() != ret.var()) const_vars.push_back(lhs.var());
if (mhs.var() != ret.var()) const_vars.push_back(mhs.var());
if (rhs.var() != ret.var()) const_vars.push_back(rhs.var());
// redirect everything to mshadow operations
switch (lhs.ctx().dev_mask()) {
case cpu::kDevMask: {
Engine::Get()->PushSync([lhs, mhs, rhs, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::Eval<cpu, OP>(lhs.data(), mhs.data(), rhs.data(), &tmp, ctx);
}, lhs.ctx(), const_vars, { ret.var() },
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#if MXNET_USE_CUDA
case gpu::kDevMask: {
Engine::Get()->PushSync([lhs, mhs, rhs, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::Eval<gpu, OP>(lhs.data(), mhs.data(), rhs.data(), &tmp, ctx);
// Wait GPU kernel to complete
ctx.get_stream<gpu>()->Wait();
}, lhs.ctx(), const_vars, { ret.var() },
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#endif
default: LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
}
}
/*!
* \brief Performs some preparation required to apply binary operators.
* Checks context and shape of ndarrays, allocates space for output
* and prepares const variables for engine
* \param lhs left operand
* \param rhs right operand
* \param out the output ndarray
* \param binary_op the real operation
*/
template<typename OP>
std::vector<Engine::VarHandle> BinaryOpPrepare(const NDArray &lhs,
const NDArray &rhs,
NDArray *out) {
// no check if both of them are on cpu
if (lhs.ctx().dev_mask() != cpu::kDevMask || rhs.ctx().dev_mask() != cpu::kDevMask) {
CHECK(lhs.ctx() == rhs.ctx()) << "operands context mismatch";
}
// if out is none, allocate space
if (out->is_none()) {
*out = NDArray(OP::GetShape(lhs.shape(), rhs.shape()), lhs.ctx(), true, lhs.dtype());
} else {
// no check if both of them are on cpu
if (lhs.ctx().dev_mask() != cpu::kDevMask ||
out->ctx().dev_mask() != cpu::kDevMask) {
CHECK(out->ctx() == lhs.ctx()) << "target context mismatch";
}
CHECK(out->shape() == OP::GetShape(lhs.shape(), rhs.shape()))
<< "target shape mismatch";
}
std::vector<Engine::VarHandle> const_vars;
// prepare const variables for engine
if (lhs.var() != out->var()) const_vars.push_back(lhs.var());
if (rhs.var() != out->var()) const_vars.push_back(rhs.var());
return const_vars;
}
/*!
* \brief run a binary operation using the kernel launch method
* \param lhs left operand
* \param rhs right operand
* \param out the output ndarray
* \param binary_op the real operation
*/
template<typename OP>
void BinaryOpKernel(const NDArray &lhs,
const NDArray &rhs,
NDArray *out) {
std::vector<Engine::VarHandle> const_vars = BinaryOpPrepare<OP>(lhs, rhs, out);
// important: callback must always capture by value
NDArray ret = *out;
switch (lhs.ctx().dev_mask()) {
case cpu::kDevMask: {
Engine::Get()->PushSync([lhs, rhs, ret](RunContext ctx) {
TBlob tmp = ret.data();
mshadow::Stream<cpu>* s = ctx.get_stream<cpu>();
ndarray::BinaryOpKernelImpl<OP>(s, lhs.data(), rhs.data(), &tmp);
},
lhs.ctx(), const_vars, {ret.var()},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#if MXNET_USE_CUDA
case gpu::kDevMask: {
Engine::Get()->PushSync([lhs, rhs, ret](RunContext ctx) {
TBlob tmp = ret.data();
mshadow::Stream<gpu>* s = ctx.get_stream<gpu>();
ndarray::BinaryOpKernelImpl<OP>(s, lhs.data(), rhs.data(), &tmp);
// Wait GPU kernel to complete
ctx.get_stream<gpu>()->Wait();
}, lhs.ctx(), const_vars, {ret.var()},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#endif
default: LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
}
}
/*!
* \brief run a binary operation using mshadow operations
* \param lhs left operand
* \param rhs right operand
* \param out the output ndarray
* \param binary_op the real operation
*/
template<typename OP>
void BinaryOp(const NDArray &lhs,
const NDArray &rhs,
NDArray *out) {
std::vector<Engine::VarHandle> const_vars = BinaryOpPrepare<OP>(lhs, rhs, out);
// important: callback must always capture by value
NDArray ret = *out;
// redirect everything to mshadow operations
switch (lhs.ctx().dev_mask()) {
case cpu::kDevMask: {
Engine::Get()->PushSync([lhs, rhs, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::Eval<cpu, OP>(lhs.data(), rhs.data(), &tmp, ctx);
}, lhs.ctx(), const_vars, {ret.var()},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#if MXNET_USE_CUDA
case gpu::kDevMask: {
Engine::Get()->PushSync([lhs, rhs, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::Eval<gpu, OP>(lhs.data(), rhs.data(), &tmp, ctx);
// Wait GPU kernel to complete
ctx.get_stream<gpu>()->Wait();
}, lhs.ctx(), const_vars, {ret.var()},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#endif
default: LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
}
}
void SetValueOp(const real_t &rhs, NDArray *out) {
CHECK_NE(out->is_none(), true) << "Set value target must not be empty";
// important: callback must always capture by value
NDArray ret = *out;
const NDArrayStorageType stype = ret.storage_type();
Engine::Get()->PushSync([rhs, ret, stype](RunContext ctx) {
TBlob tmp = ret.data();
switch (ret.ctx().dev_mask()) {
case cpu::kDevMask: {
if (stype == kDefaultStorage) {
ndarray::Eval<cpu>(rhs, &tmp, ctx);
} else {
ndarray::Eval(ctx.get_stream<cpu>(), rhs, ret);
}
break;
}
#if MXNET_USE_CUDA
case gpu::kDevMask: {
if (stype == kDefaultStorage) {
ndarray::Eval<gpu>(rhs, &tmp, ctx);
} else {
ndarray::Eval(ctx.get_stream<gpu>(), rhs, ret);
}
// Wait GPU kernel to complete
ctx.get_stream<gpu>()->Wait();
break;
}
#endif
default: LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
}
}, ret.ctx(), {}, {ret.var()},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
}
/*!
* \brief run a binary operation
* \param lhs left operand
* \param rhs right operand
* \param out the output ndarray
* \param binary_op the real
*/
template<typename OP, bool reverse>
void ScalarOp(const NDArray &lhs,
const real_t &rhs,
NDArray *out) {
if (out->is_none()) {
*out = NDArray(lhs.shape(), lhs.ctx(), true, lhs.dtype());
} else {
CHECK(out->ctx() == lhs.ctx()) << "target context mismatch";
CHECK(out->shape() == lhs.shape()) << "target shape mismatch";
}
// important: callback must always capture by value
NDArray ret = *out;
// get the const variables
std::vector<Engine::VarHandle> const_vars;
if (lhs.var() != ret.var()) const_vars.push_back(lhs.var());
// redirect everything to mshadow operations
switch (lhs.ctx().dev_mask()) {
case cpu::kDevMask: {
Engine::Get()->PushSync([lhs, rhs, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::Eval<cpu, OP, reverse>(lhs.data(), rhs, &tmp, ctx);
}, lhs.ctx(), const_vars, {ret.var()},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#if MXNET_USE_CUDA
case gpu::kDevMask: {
Engine::Get()->PushSync([lhs, rhs, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::Eval<gpu, OP, reverse>(lhs.data(), rhs, &tmp, ctx);
// Wait GPU kernel to complete
ctx.get_stream<gpu>()->Wait();
}, lhs.ctx(), const_vars, {ret.var()},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#endif
default: LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
}
}
size_t num_aux_data(NDArrayStorageType stype) {
size_t num = 0;
switch (stype) {
case kDefaultStorage: num = 0; break;
case kCSRStorage: num = 2; break;
case kRowSparseStorage: num = 1; break;
default: LOG(FATAL) << "Unknown storage type" << stype; break;
}
return num;
}
// Make a copy of a CSR NDArray
template<typename from_xpu, typename to_xpu>
inline void CopyFromToCsrImpl(const NDArray& from, const NDArray& to, RunContext ctx) {
using namespace mshadow;
CHECK_EQ(from.storage_type(), to.storage_type()) << "Copying with different storage type";
// if source storage is not initialized, fill destination with zeros
auto s = ctx.get_stream<to_xpu>();
if (!from.storage_initialized()) {
op::FillZerosCsrImpl(s, to);
return;
}
// Allocate storage
to.CheckAndAllocAuxData(csr::kIndPtr, from.aux_shape(csr::kIndPtr));
to.CheckAndAllocAuxData(csr::kIdx, from.aux_shape(csr::kIdx));
to.CheckAndAllocData(from.aux_shape(csr::kIdx));
TBlob val = to.data();
TBlob indptr = to.aux_data(csr::kIndPtr);
TBlob idx = to.aux_data(csr::kIdx);
ndarray::Copy<from_xpu, to_xpu>(from.data(), &val,
from.ctx(), to.ctx(), ctx);
ndarray::Copy<from_xpu, to_xpu>(from.aux_data(csr::kIndPtr), &indptr,
from.ctx(), to.ctx(), ctx);
ndarray::Copy<from_xpu, to_xpu>(from.aux_data(csr::kIdx), &idx,
from.ctx(), to.ctx(), ctx);
}
// Make a copy of a row-sparse NDArray
template<typename from_xpu, typename to_xpu>
inline void CopyFromToRspImpl(const NDArray& from, const NDArray& to, RunContext ctx) {
using namespace mshadow;
CHECK_EQ(from.storage_type(), to.storage_type()) << "Copying with different storage type";
// if source is zeros, fill destination with zeros, too
auto s = ctx.get_stream<to_xpu>();
if (!from.storage_initialized()) {
op::FillZerosRspImpl(s, to);
return;
}
auto aux_shape = from.aux_shape(rowsparse::kIdx);
to.CheckAndAlloc({aux_shape});
TBlob val = to.data();
TBlob idx = to.aux_data(rowsparse::kIdx);
ndarray::Copy<from_xpu, to_xpu>(from.data(), &val,
from.ctx(), to.ctx(), ctx);
ndarray::Copy<from_xpu, to_xpu>(from.aux_data(rowsparse::kIdx), &idx,
from.ctx(), to.ctx(), ctx);
}
// Make a copy of a dense NDArray
template<typename from_xpu, typename to_xpu>
inline void CopyFromToDnsImpl(const NDArray& from, const NDArray& to, RunContext ctx) {
#if MXNET_USE_MKLDNN == 1
// If neither is MKLDNN, we can copy data normally.
if (!from.IsMKLDNNData() && !to.IsMKLDNNData()) {
#endif
using namespace mshadow;
CHECK_EQ(from.storage_type(), to.storage_type()) << "Copying with different storage type";
TBlob tmp = to.data();
ndarray::Copy<from_xpu, to_xpu>(from.data(), &tmp,
from.ctx(), to.ctx(), ctx);
#if MXNET_USE_MKLDNN == 1
} else if (SupportMKLDNN(from.dtype(), from.shape())
&& SupportMKLDNN(to.dtype(), to.shape())
&& from.ctx().dev_mask() == cpu::kDevMask
&& to.ctx().dev_mask() == cpu::kDevMask) {
// If we copy data directly, we need to make sure both NDArrays are supported
// by MKLDNN.
auto from_mem = from.GetMKLDNNData();
auto to_mem = to.GetMKLDNNData();
if (from_mem->get_primitive_desc() == to_mem->get_primitive_desc()) {
size_t size = std::min(from_mem->get_primitive_desc().get_size(),
to_mem->get_primitive_desc().get_size());
memcpy(to_mem->get_data_handle(), from_mem->get_data_handle(), size);
} else {
std::vector<mkldnn::primitive> net;
net.push_back(mkldnn::reorder(*from_mem, *to_mem));
mkldnn::stream(mkldnn::stream::kind::eager).submit(net).wait();
}
} else {
// In this case, one of the NDArray isn't supported by MKLDNN, we need
// to convert the MKLDNN array to the default format first and copy data
// with Copy().
NDArray tmp_from = from;
if (tmp_from.IsMKLDNNData()) {
// TODO(zhengda) tmp_from should be cached.
tmp_from = NDArray(from.shape(), from.ctx(), false, from.dtype());
auto tmp_mem = from.GetMKLDNNData();
tmp_from.CopyFrom(*tmp_mem);
MKLDNNStream::Get()->Submit();
}
CHECK(tmp_from.IsDefaultData());
CHECK(to.IsDefaultData());
TBlob tmp = to.data();
ndarray::Copy<from_xpu, to_xpu>(tmp_from.data(), &tmp,
from.ctx(), to.ctx(), ctx);
}
#endif
}
// Make a copy of an NDArray based on storage type
template<typename from_xpu, typename to_xpu>
void CopyFromToImpl(const NDArray& from, const NDArray& to,
RunContext rctx, const std::vector<Resource>& requested) {
using namespace std;
using namespace mshadow;
// if storage type doesn't match, cast the storage first
const NDArrayStorageType from_stype = from.storage_type();
const NDArrayStorageType to_stype = to.storage_type();
CHECK(from_stype == kDefaultStorage
|| to_stype == kDefaultStorage
|| from_stype == to_stype)
<< "Copying ndarray of stype = " << from_stype
<< " to stype = " << to_stype << " is not supported";
const Context from_ctx = from.ctx();
const Context to_ctx = to.ctx();
bool is_train = Imperative::Get()->is_training();
OpContext opctx{is_train,
rctx,
engine::CallbackOnComplete(),
requested};
if (from_ctx == to_ctx && from_stype != to_stype) {
// same ctx, different stypes, use cast op directly without copying
common::CastStorageDispatch<from_xpu>(opctx, from, to);
} else {
NDArray casted_nd; // an intermediate result before copying from to to
if (from_stype == to_stype) {
casted_nd = from; // same stype, no need to cast from
} else { // different stypes on different ctx needs an temporary casted_nd
TShape shape = from.shape();
if (to_stype == kDefaultStorage) {
casted_nd = NDArray(shape, from_ctx);
} else {
casted_nd = NDArray(to_stype, shape, from_ctx);
}
// convert from_nd to the same stype as to_nd
common::CastStorageDispatch<from_xpu>(opctx, from, casted_nd);
}
if (to_stype == kDefaultStorage) {
CopyFromToDnsImpl<from_xpu, to_xpu>(casted_nd, to, rctx);
} else if (to_stype == kRowSparseStorage) {
CopyFromToRspImpl<from_xpu, to_xpu>(casted_nd, to, rctx);
} else if (to_stype == kCSRStorage) {
CopyFromToCsrImpl<from_xpu, to_xpu>(casted_nd, to, rctx);
} else {
LOG(FATAL) << "unknown storage type" << to_stype;
}
}
}
void CopyFromTo(const NDArray& from, const NDArray& to, int priority) {
if (from.var() == to.var() && from.byte_offset() == to.byte_offset()) {
// skip to copy to itself
return;
}
CHECK(from.shape() == to.shape())
<< "operands shape mismatch"
<< "from.shape = " << from.shape() << " to.shape=" << to.shape();
CHECK(from.shape().ndim() != 0)
<< "source operands have zero dimension shape";
// important: callback must always capture by value
const Context from_ctx = from.ctx();
const int a = from_ctx.dev_mask();
const int b = to.ctx().dev_mask();
std::vector<Engine::VarHandle> const_vars;
if (from.var() != to.var()) const_vars.push_back(from.var());
const NDArrayStorageType from_stype = from.storage_type();
const NDArrayStorageType to_stype = to.storage_type();
std::vector<Engine::VarHandle> mutable_vars(1, to.var());
std::vector<Resource> requested;
if (from_stype != to_stype) {
using namespace common;
static bool log = dmlc::GetEnv("MXNET_STORAGE_FALLBACK_LOG_VERBOSE", true);
if (log) {
std::ostringstream os;
os << "\nStorage fallback detected:\n"
<< "Copy from " << stype_string(from_stype) << " storage type on " << dev_type_string(a)
<< " to " << stype_string(to_stype) << " storage type on " << dev_type_string(b)
<< ".\nA temporary ndarray with " << stype_string(to_stype)
<< " storage type will be generated in order to perform the copy. "
<< "You can set environment variable "
<< "MXNET_STORAGE_FALLBACK_LOG_VERBOSE to 0 to suppress this warning.";
LogOnce(os.str());
}
// request temp resource if cast_storage performs on GPU
if (a == gpu::kDevMask) {
Resource rsc = ResourceManager::Get()->Request(from_ctx,
ResourceRequest(ResourceRequest::kTempSpace));
requested.push_back(rsc);
mutable_vars.push_back(rsc.var);
}
}
if (a == cpu::kDevMask && b == cpu::kDevMask) {
Engine::Get()->PushAsync(
[from, to, requested](RunContext ctx, Engine::CallbackOnComplete on_complete) {
CopyFromToImpl<cpu, cpu>(from, to, ctx, requested);
on_complete();
}, from.ctx(), const_vars, mutable_vars,
FnProperty::kNormal, priority, "CopyCPU2CPU");
} else {
#if MXNET_USE_CUDA
if (a == cpu::kDevMask && b == gpu::kDevMask) {
Engine::Get()->PushAsync(
[from, to, requested](RunContext ctx, Engine::CallbackOnComplete on_complete) {
CopyFromToImpl<cpu, gpu>(from, to, ctx, requested);
ctx.get_stream<gpu>()->Wait();
on_complete();
}, to.ctx(), const_vars, mutable_vars,
FnProperty::kCopyToGPU, priority, "CopyCPU2GPU");
} else if (a == gpu::kDevMask && b == cpu::kDevMask) {
Engine::Get()->PushAsync(
[from, to, requested](RunContext ctx, Engine::CallbackOnComplete on_complete) {
CopyFromToImpl<gpu, cpu>(from, to, ctx, requested);
ctx.get_stream<gpu>()->Wait();
on_complete();
}, from.ctx(), const_vars, mutable_vars,
FnProperty::kCopyFromGPU, priority, "CopyGPU2CPU");
} else if (a == gpu::kDevMask && b == gpu::kDevMask) {
Engine::Get()->PushAsync(
[from, to, requested](RunContext ctx, Engine::CallbackOnComplete on_complete) {
CopyFromToImpl<gpu, gpu>(from, to, ctx, requested);
ctx.get_stream<gpu>()->Wait();
on_complete();
}, from.ctx(), const_vars, mutable_vars,
from.dtype() != to.dtype() ? FnProperty::kNormal : FnProperty::kCopyFromGPU,
priority, "CopyGPU2GPU");
} else {
LOG(FATAL) << "unknown device mask";
}
#else
LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
#endif
}
}
void CopyFromTo(const NDArray& from, const NDArray *to, int priority) {
CopyFromTo(from, *to, priority);
}
void ElementwiseSum(const std::vector<NDArray> &source, NDArray *out, int priority) {
std::vector<Engine::VarHandle> const_vars;
const_vars.reserve(source.size());
for (size_t i = 0; i < source.size(); ++i) {
if (source[i].var() != out->var()) {
const_vars.push_back(source[i].var());
}
CHECK_EQ(source[i].shape() , out->shape())
<< "operands shape mismatch";
if (out->ctx().dev_mask() == Context::kCPU) {
CHECK_EQ(source[i].ctx().dev_mask(), Context::kCPU)
<< "operands context mismatch";
} else {
CHECK(source[i].ctx() == out->ctx())
<< "operands context mismatch";
}
}
// important: callback must always capture by value
NDArray ret = *out;
const NDArrayStorageType stype = ret.storage_type();
if (stype == kDefaultStorage) {
switch (out->ctx().dev_mask()) {
case cpu::kDevMask: {
Engine::Get()->PushSync([source, ret](RunContext ctx) {
std::vector<TBlob> source_tblob(source.size());
for (size_t i = 0; i < source.size(); ++i) {
source_tblob[i] = source[i].data();
}
TBlob tmp = ret.data();
ndarray::ElementwiseSum<cpu>(source_tblob, &tmp, ctx);
}, out->ctx(), const_vars, {ret.var()},
FnProperty::kNormal, priority, PROFILER_MESSAGE_FUNCNAME);
break;
}
#if MXNET_USE_CUDA
case gpu::kDevMask: {
Engine::Get()->PushSync([source, ret](RunContext ctx) {
std::vector<TBlob> source_tblob(source.size());
for (size_t i = 0; i < source.size(); ++i) {
source_tblob[i] = source[i].data();
}
TBlob tmp = ret.data();
ndarray::ElementwiseSum<gpu>(source_tblob, &tmp, ctx);
// Wait GPU kernel to complete
ctx.get_stream<gpu>()->Wait();
}, out->ctx(), const_vars, {ret.var()},
FnProperty::kNormal, priority, "DenseElementwiseSum");
break;
}
#endif
default: LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
}
} else if (stype == kRowSparseStorage) {
Resource rsc = ResourceManager::Get()->Request(ret.ctx(),
ResourceRequest(ResourceRequest::kTempSpace));
Engine::Get()->PushSync(
[source, ret, rsc](RunContext rctx) {
NDArray result = ret;
switch (ret.ctx().dev_mask()) {
case cpu::kDevMask: {
mxnet::ndarray::ElementwiseSum(rctx.get_stream<cpu>(), rsc, source, &result);
break;
}
#if MXNET_USE_CUDA
case gpu::kDevMask: {
mxnet::ndarray::ElementwiseSum(rctx.get_stream<gpu>(), rsc, source, &result);
// wait for GPU operations to complete
rctx.get_stream<gpu>()->Wait();
break;
}
#endif
default: LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
}
}, ret.ctx(), const_vars, {ret.var(), rsc.var},
FnProperty::kNormal, priority, "RowSparseElementwiseSum");
} else {
LOG(FATAL) << "Not implemented for storage_type " << common::stype_string(stype);
}
}
void ClipOp(const NDArray &src,
const real_t &a_min, const real_t &a_max,
NDArray *out) {
if (out->is_none()) {
*out = NDArray(src.shape(), src.ctx(), true, src.dtype());
} else {
CHECK(out->ctx() == src.ctx()) << "target context mismatch";
CHECK(out->shape() == src.shape()) << "target shape mismatch";
}
NDArray ret = *out;
std::vector<Engine::VarHandle> const_vars;
if (src.var() != ret.var()) const_vars.push_back(src.var());
switch (src.ctx().dev_mask()) {
case cpu::kDevMask: {
Engine::Get()->PushSync([src, a_min, a_max, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::EvalClip<cpu>(src.data(), a_min, a_max, &tmp, ctx);
}, src.ctx(), const_vars, {ret.var()},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#if MXNET_USE_CUDA
case gpu::kDevMask: {
Engine::Get()->PushSync([src, a_min, a_max, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::EvalClip<gpu>(src.data(), a_min, a_max, &tmp, ctx);
}, src.ctx(), const_vars, {ret.var()},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#endif
default: LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
}
}
template<typename Distribution>
void SampleOP(const real_t &a,
const real_t &b,
NDArray *out) {
CHECK(!out->is_none());
Resource resource = ResourceManager::Get()->Request(
out->ctx(), ResourceRequest::kRandom);
// important: callback must always capture by value
NDArray ret = *out;
// redirect everything to mshadow operations
switch (out->ctx().dev_mask()) {
case cpu::kDevMask: {
Engine::Get()->PushSync([a, b, resource, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::EvalRandom<cpu, Distribution>(a, b, resource, &tmp, ctx);
}, out->ctx(), {}, {ret.var(), resource.var},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#if MXNET_USE_CUDA
case gpu::kDevMask: {
Engine::Get()->PushSync([a, b, resource, ret](RunContext ctx) {
TBlob tmp = ret.data();
ndarray::EvalRandom<gpu, Distribution>(a, b, resource, &tmp, ctx);
// Wait GPU kernel to complete
ctx.get_stream<gpu>()->Wait();
}, out->ctx(), {}, {ret.var(), resource.var},
FnProperty::kNormal, 0, PROFILER_MESSAGE_FUNCNAME);
break;
}
#endif
default: LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
}
}
void SampleUniform(real_t begin, real_t end, NDArray *out) {
SampleOP<ndarray::UniformDistribution>(begin, end, out);
}
void SampleGaussian(real_t mu, real_t sigma, NDArray *out) {
SampleOP<ndarray::GaussianDistribution>(mu, sigma, out);
}
void SampleExponential(real_t lambda, NDArray *out) {
if ( out->ctx().dev_mask() != cpu::kDevMask ) {
LOG(FATAL) <<"exponential sampling only valid on cpu";
}
real_t dummy;
SampleOP<ndarray::ExponentialDistribution>(lambda, dummy, out);
}
void SamplePoisson(real_t lambda, NDArray *out) {
if ( out->ctx().dev_mask() != cpu::kDevMask ) {
LOG(FATAL) <<"poisson sampling only valid on cpu";
}
real_t dummy;
SampleOP<ndarray::PoissonDistribution>(lambda, dummy, out);
}
void SampleNegBinomial(int32_t k, real_t p, NDArray *out) {
if ( out->ctx().dev_mask() != cpu::kDevMask ) {
LOG(FATAL) <<"negative binomial sampling only valid on cpu";
}
SampleOP<ndarray::NegBinomialDistribution>(k, p, out);
}
void SampleGenNegBinomial(real_t mu, real_t alpha, NDArray *out) {
if ( out->ctx().dev_mask() != cpu::kDevMask ) {
LOG(FATAL) <<"negative binomial sampling only valid on cpu";
}
SampleOP<ndarray::GenNegBinomialDistribution>(mu, alpha, out);
}
void RandomSeed(uint32_t seed) {
ResourceManager::Get()->SeedRandom(seed);
}
template<typename OP>
inline NDArray BinaryOpRet(const NDArray &lhs,
const NDArray &rhs) {
NDArray ret;
BinaryOpKernel<OP>(lhs, rhs, &ret);
return ret;
}
template<typename OP, bool reverse>
inline NDArray ScalarOpRet(const NDArray &lhs,
const real_t &rhs) {
NDArray ret;
ScalarOp<OP, reverse>(lhs, rhs, &ret);
return ret;
}
template<typename OP>
inline NDArray &BinaryOpApply(NDArray *dst,
const NDArray &src) {
BinaryOpKernel<OP>(*dst, src, dst);
return *dst;
}
template<typename OP>
inline NDArray &ScalarOpApply(NDArray *dst,
const real_t &src) {
ScalarOp<OP, false>(*dst, src, dst);
return *dst;
}
// Binary
NDArray operator+(const NDArray &lhs, const NDArray &rhs) {
return BinaryOpRet<ndarray::Plus>(lhs, rhs);
}
NDArray operator-(const NDArray &lhs, const NDArray &rhs) {
return BinaryOpRet<ndarray::Minus>(lhs, rhs);
}
NDArray operator*(const NDArray &lhs, const NDArray &rhs) {
return BinaryOpRet<ndarray::Mul>(lhs, rhs);
}
NDArray operator/(const NDArray &lhs, const NDArray &rhs) {
return BinaryOpRet<ndarray::Div>(lhs, rhs);
}
// Scalar
NDArray operator+(const NDArray &lhs, const real_t &rhs) {
return ScalarOpRet<ndarray::Plus, false>(lhs, rhs);
}
NDArray operator-(const NDArray &lhs, const real_t &rhs) {
return ScalarOpRet<ndarray::Minus, false>(lhs, rhs);
}
NDArray operator*(const NDArray &lhs, const real_t &rhs) {
return ScalarOpRet<ndarray::Mul, false>(lhs, rhs);
}
NDArray operator/(const NDArray &lhs, const real_t &rhs) {
return ScalarOpRet<ndarray::Div, false>(lhs, rhs);
}
// Binary
NDArray &NDArray::operator=(real_t scalar) {
SetValueOp(scalar, this);
return *this;
}
NDArray &NDArray::operator+=(const NDArray &src) {
return BinaryOpApply<ndarray::Plus>(this, src);
}
NDArray &NDArray::operator-=(const NDArray &src) {
return BinaryOpApply<ndarray::Minus>(this, src);
}
NDArray &NDArray::operator*=(const NDArray &src) {
return BinaryOpApply<ndarray::Mul>(this, src);
}
NDArray &NDArray::operator/=(const NDArray &src) {
return BinaryOpApply<ndarray::Div>(this, src);
}
// Scalar
NDArray &NDArray::operator+=(const real_t &src) {
return ScalarOpApply<ndarray::Plus>(this, src);
}
NDArray &NDArray::operator-=(const real_t &src) {
return ScalarOpApply<ndarray::Minus>(this, src);
}
NDArray &NDArray::operator*=(const real_t &src) {
return ScalarOpApply<ndarray::Mul>(this, src);
}
NDArray &NDArray::operator/=(const real_t &src) {
return ScalarOpApply<ndarray::Div>(this, src);
}
/* magic number for ndarray version 1, with int64_t TShape */
static const uint32_t NDARRAY_V1_MAGIC = 0xF993fac8;
/* magic number for ndarray version 2, with storage type */
static const uint32_t NDARRAY_V2_MAGIC = 0xF993fac9;
void NDArray::Save(dmlc::Stream *strm) const {
// write magic number to mark this version
// for storage type
strm->Write(NDARRAY_V2_MAGIC);
// save storage type
int32_t stype = storage_type();
strm->Write(&stype, sizeof(stype));
const int32_t nad = num_aux_data(storage_type());
// save storage shape if ndarray is sparse
if (nad > 0) {
storage_shape().Save(strm);
}
// save shape
shape_.Save(strm);
if (is_none()) return;
// save context
Context ctx = this->ctx();
ctx.Save(strm);
TBlob save_data;
NDArray nd_cpu; // a copy of *this on cpu
if (ctx.dev_mask() != cpu::kDevMask) {
nd_cpu = this->Copy(Context::CPU());
nd_cpu.WaitToRead();
save_data = nd_cpu.data();
} else {
this->WaitToRead();
save_data = this->data();
nd_cpu = *this;
}
// save type flag
int32_t type_flag = save_data.type_flag_;
strm->Write(&type_flag, sizeof(type_flag));
// save aux_types and aux_shapes
if (nad > 0) {
for (int i = 0; i < nad; ++i) {
int32_t aux_type_flag = aux_type(i);
strm->Write(&aux_type_flag, sizeof(aux_type_flag));
aux_shape(i).Save(strm);
}
}
// save data
CHECK(save_data.CheckContiguous());
size_t type_size = mshadow::mshadow_sizeof(type_flag);
// save data could be values of sparse tensors
// must use save_data.shape_ instead of this->shape_
strm->Write(save_data.dptr_, type_size * save_data.shape_.Size());
// save aux data
if (nad > 0) {
for (int i = 0; i < nad; ++i) {
TBlob save_data = nd_cpu.aux_data(i);
// save aux_data
CHECK(save_data.CheckContiguous());
size_t aux_type_size = mshadow::mshadow_sizeof(aux_type(i));
strm->Write(save_data.dptr_, aux_type_size * save_data.Size());
}
}
}
bool LegacyTShapeLoad(dmlc::Stream *strm, TShape *shape, const uint32_t magic) {
switch (magic) {
case NDARRAY_V1_MAGIC:
return shape->Load(strm);
default:
// meet legacy TShape, magic is ndim here
uint32_t ndim = magic;
*shape = TShape(ndim);
std::vector<uint32_t> buffer(ndim);
size_t nread = ndim * sizeof(uint32_t);
if (strm->Read(buffer.data(), nread) != nread) return false;
nnvm::ShapeTypeCast(buffer.begin(), buffer.end(), shape->begin());
return true;
}
}
bool NDArray::LegacyLoad(dmlc::Stream *strm, const uint32_t magic) {
// load shape
TShape shape;
if (!LegacyTShapeLoad(strm, &shape, magic)) return false;
if (shape.ndim() == 0) {
*this = NDArray(); return true;
}
// load context
Context ctx;
if (!ctx.Load(strm)) return false;
// load type flag
int32_t type_flag;
if (strm->Read(&type_flag, sizeof(type_flag)) != sizeof(type_flag)) return false;
// load data into CPU
NDArray temp(shape, Context::CPU(), false, type_flag);
TBlob load_data = temp.data();
size_t type_size = mshadow::mshadow_sizeof(type_flag);
size_t nread = type_size * shape.Size();
if (strm->Read(load_data.dptr_, nread) != nread) return false;
if (ctx.dev_mask() == cpu::kDevMask) {
*this = std::move(temp); return true;
} else {
#if MXNET_USE_CUDA
*this = temp.Copy(ctx); return true;
#else
*this = std::move(temp); return true;
#endif
}
}
bool NDArray::Load(dmlc::Stream *strm) {
uint32_t magic;
if (strm->Read(&magic, sizeof(uint32_t)) != sizeof(uint32_t)) return false;
if (magic != NDARRAY_V2_MAGIC) {
return LegacyLoad(strm, magic);
}
// load storage type
int32_t stype;
if (strm->Read(&stype, sizeof(stype)) != sizeof(stype)) return false;
const int32_t nad = num_aux_data(static_cast<NDArrayStorageType>(stype));
// load storage shape
TShape sshape;
if (nad > 0) {
if (!sshape.Load(strm)) return false;
}
// load shape
TShape shape;
if (!shape.Load(strm)) return false;
if (shape.ndim() == 0) {
*this = NDArray(); return true;
}
// load context
Context ctx;
if (!ctx.Load(strm)) return false;
// load type flag
int32_t type_flag;
if (strm->Read(&type_flag, sizeof(type_flag)) != sizeof(type_flag)) return false;
// load aux_types and aux_shapes
std::vector<int32_t> aux_types;
std::vector<TShape> aux_shapes;
if (nad > 0) {
aux_types.resize(nad);
aux_shapes.resize(nad);
for (int i = 0; i < nad; ++i) {
// load aux_type(i)
if (strm->Read(&aux_types[i], sizeof(aux_types[i])) != sizeof(aux_types[i])) return false;
// load aux_shapes(i)
if (!aux_shapes[i].Load(strm)) return false;
}
}
// load data into CPU
NDArray temp;
if (0 == nad) {
temp = NDArray(shape, Context::CPU(), false, type_flag);
} else {
temp = NDArray(static_cast<NDArrayStorageType>(stype), shape,
Context::CPU(), false, type_flag,
aux_types, aux_shapes, sshape);
}
// load data
TBlob load_data = temp.data();
size_t type_size = mshadow::mshadow_sizeof(type_flag);
size_t nread = type_size * load_data.Size();
if (strm->Read(load_data.dptr_, nread) != nread) return false;
// load aux_data
if (nad > 0) {
for (int i = 0; i < nad; ++i) {
load_data = temp.aux_data(i);
type_size = mshadow::mshadow_sizeof(load_data.type_flag_);
nread = type_size * load_data.Size();
if (strm->Read(load_data.dptr_, nread) != nread) return false;
}
}
if (ctx.dev_mask() == cpu::kDevMask) {
*this = std::move(temp); return true;
} else {
#if MXNET_USE_CUDA
*this = temp.Copy(ctx); return true;
#else
*this = std::move(temp); return true;
#endif
}
}
const uint64_t kMXAPINDArrayListMagic = 0x112;
void NDArray::Save(dmlc::Stream* fo,
const std::vector<NDArray>& data,
const std::vector<std::string>& names) {
uint64_t header = kMXAPINDArrayListMagic, reserved = 0;
fo->Write(&header, sizeof(header));
fo->Write(&reserved, sizeof(reserved));
fo->Write(data);
fo->Write(names);
}
void NDArray::Load(dmlc::Stream* fi,
std::vector<NDArray>* data,
std::vector<std::string>* keys) {
uint64_t header, reserved;
CHECK(fi->Read(&header))
<< "Invalid NDArray file format";
CHECK(fi->Read(&reserved))
<< "Invalid NDArray file format";
CHECK(header == kMXAPINDArrayListMagic)
<< "Invalid NDArray file format";
CHECK(fi->Read(data))
<< "Invalid NDArray file format";
CHECK(fi->Read(keys))
<< "Invalid NDArray file format";
CHECK(keys->size() == 0 || keys->size() == data->size())
<< "Invalid NDArray file format";
}
NDArray NDArray::Copy(Context ctx) const {
NDArray ret;
if (kDefaultStorage == storage_type()) {
ret = NDArray(shape(), ctx, true, dtype_);
} else if (kUndefinedStorage != storage_type()) {
ret = NDArray(storage_type(), shape(), ctx, true, dtype_,
ptr_->aux_types, ptr_->aux_shapes, storage_shape());
} else {
LOG(FATAL) << "NDArray::Copy cannot copy undefined storage-type ndarray to ctx.dev_type="
<< ctx.dev_type << ", ctx.dev_id=" << ctx.dev_id;
}
CopyFromTo(*this, ret);
return ret;
}
void NDArray::SyncCopyFromCPU(const void *data, size_t size) const {
TShape dshape = this->shape();
CHECK_EQ(dshape.Size(), size)
<< "Memory size do not match";
TBlob src((void*)data, dshape, cpu::kDevMask, this->dtype_, 0); // NOLINT(*)
if (this->ctx().dev_mask() == cpu::kDevMask) {
this->WaitToWrite();
RunContext rctx{this->ctx(), nullptr};
TBlob dst = this->data();
ndarray::Copy<cpu, cpu>(src, &dst, Context::CPU(), Context::CPU(), rctx);
} else {
#if MXNET_USE_CUDA
Engine::Get()->PushAsync(
[&](RunContext rctx, Engine::CallbackOnComplete on_complete) {
TBlob dst = this->data();
ndarray::Copy<cpu, gpu>(src, &dst,
Context::CPU(), this->ctx(), rctx);
// Wait GPU kernel to complete
rctx.get_stream<gpu>()->Wait();
on_complete();
}, this->ctx(), {}, {this->var()},
FnProperty::kCopyToGPU, 0, "SyncCopyCPU2GPU");
this->WaitToRead();
#else
LOG(FATAL) << "GPU is not enabled";
#endif
}
}
/*!
* \brief Copy src.data()/aux_data(i) to dst->data()/aux_data(j).
*/
void NDArray::SyncCopyFromNDArray(const NDArray& src, int i, int j) {
if (i >= 0) {
CHECK_NE(src.storage_type(), kDefaultStorage);
} else {
CHECK(!src.is_none()) << "src dense ndarray must have been initialized";
}
if (j >= 0) {
CHECK_NE(storage_type(), kDefaultStorage);
} else {
CHECK(!this->is_none()) << "dst dense ndarray must have been initialized";
}
if (src.var() == var()) {
// skip to copy to itself
LOG(WARNING) << "SyncCopyFromNDArray does not support copying to self";
return;
}
const int src_dev_mask = src.ctx().dev_mask();
const int dst_dev_mask = ctx().dev_mask();
std::vector<Engine::VarHandle> const_vars;
const_vars.push_back(src.var());
// get or create a dst tblob for copying src to it
// if dst is a dense format and has not been allocated, allocate memory for it
// else if dst is not initialized, allocate corresponding data blob for it
auto get_dst_data = [&](const TShape& src_shape) {
if (this->storage_type() == kDefaultStorage) {
this->ReshapeAndAlloc(src_shape);
} else if (!this->storage_initialized()) {
if (j < 0) {
this->CheckAndAllocData(src_shape);
} else {
this->CheckAndAllocAuxData(j, src_shape);
}
}
TBlob dst_data = (j >= 0? this->aux_data(j) : this->data());
CHECK_LE(src_shape.Size(), dst_data.shape_.Size());
return dst_data;
};
if (src_dev_mask == cpu::kDevMask && dst_dev_mask == cpu::kDevMask) {
Engine::Get()->PushSync([&](RunContext rctx) {
const TBlob src_data = (i >= 0? src.aux_data(i) : src.data());
TBlob dst_data = get_dst_data(src_data.shape_);
ndarray::Copy<cpu, cpu>(src_data, &dst_data, src.ctx(), this->ctx(), rctx);
}, this->ctx(), const_vars, {this->var()},
FnProperty::kNormal, 0, "SyncCopyFromNDArrayCPU2CPU");
} else {
#if MXNET_USE_CUDA
if (src_dev_mask == cpu::kDevMask && dst_dev_mask == gpu::kDevMask) {
Engine::Get()->PushAsync(
[&](RunContext rctx, Engine::CallbackOnComplete on_complete) {
const TBlob src_data = (i >= 0? src.aux_data(i) : src.data());
TBlob dst_data = get_dst_data(src_data.shape_);
ndarray::Copy<cpu, gpu>(src_data, &dst_data, src.ctx(), this->ctx(), rctx);
rctx.get_stream<gpu>()->Wait();
on_complete();
}, this->ctx(), const_vars, {this->var()},
FnProperty::kCopyToGPU, 0, "SyncCopyFromNDArrayCPU2GPU");
} else if (src_dev_mask == gpu::kDevMask && dst_dev_mask == cpu::kDevMask) {
Engine::Get()->PushAsync(
[&](RunContext rctx, Engine::CallbackOnComplete on_complete) {
const TBlob src_data = (i >= 0? src.aux_data(i) : src.data());
TBlob dst_data = get_dst_data(src_data.shape_);
ndarray::Copy<gpu, cpu>(src_data, &dst_data, src.ctx(), this->ctx(), rctx);
rctx.get_stream<gpu>()->Wait();
on_complete();
}, this->ctx(), const_vars, {this->var()},
FnProperty::kCopyFromGPU, 0, "SyncCopyFromNDArrayGPU2CPU");
} else if (src_dev_mask == gpu::kDevMask && dst_dev_mask == gpu::kDevMask) {
Engine::Get()->PushAsync(
[&](RunContext rctx, Engine::CallbackOnComplete on_complete) {
const TBlob src_data = (i >= 0? src.aux_data(i) : src.data());
TBlob dst_data = get_dst_data(src_data.shape_);
ndarray::Copy<gpu, gpu>(src_data, &dst_data, src.ctx(), this->ctx(), rctx);
rctx.get_stream<gpu>()->Wait();
on_complete();
}, this->ctx(), const_vars, {this->var()},
src.dtype() != this->dtype() ? FnProperty::kNormal : FnProperty::kCopyFromGPU,
0, "SyncCopyFromNDArrayGPU2GPU");
} else {
LOG(FATAL) << "unknown device mask";
}
#else
LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
#endif
}
// The copy operation was pushed to engine to execute.
// Need to wait here for it being completed.
// The reason for pushing the copy operation to engine
// is because when copying data from a sparse tensor
// to the current one, that sparse ndarray's storage_shape/aux_shape
// may not be ready or changed and we need to ensure
// thread safty for reading the correct shape info to allocate
// memory for the current ndarray.
WaitToRead();
}
void NDArray::SyncCopyToCPU(void *data, size_t size) const {
TShape dshape = this->shape();
CHECK_EQ(dshape.Size(), size)
<< "Memory size do not match";
TBlob dst(data, dshape, cpu::kDevMask, this->dtype_, 0); // NOLINT(*)
if (this->ctx().dev_mask() == cpu::kDevMask) {
this->WaitToRead();
RunContext rctx{this->ctx(), nullptr};
NDArray src = *this;
#if MXNET_USE_MKLDNN == 1
if (src.IsMKLDNNData())
src = this->Reorder2Default();
#endif
ndarray::Copy<cpu, cpu>(src.data(), &dst,
Context::CPU(), Context::CPU(), rctx);
} else {
#if MXNET_USE_CUDA
Engine::Get()->PushAsync(
[&](RunContext rctx, Engine::CallbackOnComplete on_complete) {
ndarray::Copy<gpu, cpu>(this->data(), &dst,
this->ctx(), Context::CPU(), rctx);
// Wait GPU kernel to complete
rctx.get_stream<gpu>()->Wait();
on_complete();
}, this->ctx(), {this->var()}, {},
FnProperty::kCopyFromGPU, 0, "SyncCopyGPU2CPU");
this->WaitToWrite();
#else
LOG(FATAL) << "GPU is not enabled";
#endif
}
}
void NDArray::SyncCheckFormat(const bool full_check) const {
int32_t err = kNormalErr;
TBlob err_cpu(&err, mshadow::Shape1(1), cpu::kDevMask, 0);
if (this->ctx().dev_mask() == cpu::kDevMask) {
Engine::Get()->PushSync([&](RunContext rctx) {
common::CheckFormatWrapper<cpu>(rctx, *this, err_cpu, full_check);
}, this->ctx(), {this->var()}, {},
FnProperty::kNormal, 0, "CheckFormat");
} else {
#if MXNET_USE_CUDA
Engine::Get()->PushSync([&](RunContext rctx) {
common::CheckFormatWrapper<gpu>(rctx, *this, err_cpu, full_check);
rctx.get_stream<gpu>()->Wait();
}, this->ctx(), {this->var()}, {},
FnProperty::kNormal, 0, "CheckFormat");
#else
LOG(FATAL) << "GPU is not enabled";
#endif
}
this->WaitToWrite();
CHECK_NE(err, kCSRShapeErr) << "Shape mismatch of this csr NDArray";
CHECK_NE(err, kCSRIndPtrErr)
<< "IndPtr of csr NDArray should be non-negative, in non-decreasing order, "
<< "start with 0, and end with value equal with size of indices.";
CHECK_NE(err, kCSRIdxErr)
<< "Indices of csr NDArray should be non-negative, in ascending order per row "
<< " and less than the number of columns.";
CHECK_NE(err, kRSPShapeErr) << "Shape mismatch of this row_sparse NDArray";
CHECK_NE(err, kRSPIdxErr)
<< "Indices of row_sparse NDArray should be non-negative, "
<< "less than the size of first dimension and in ascending order";
CHECK_EQ(err, kNormalErr) << "Check the validity of this sparse NDArray";
}
#if MXNET_PREDICT_ONLY == 0
// register API function
// those with underscore will be registered at NDArray
MXNET_REGISTER_NDARRAY_FUN(_set_value)
.set_function(SetValueOp);
MXNET_REGISTER_NDARRAY_FUN(_onehot_encode)
.set_function(BinaryOp<ndarray::OneHotEncode>);
MXNET_REGISTER_NDARRAY_FUN(choose_element_0index)
.set_function(BinaryOp<ndarray::MatChooseRowElem>)
.describe("Choose one element from each line(row for python, column for R/Julia)"
" in lhs according to index indicated by rhs."
" This function assume rhs uses 0-based index.");
MXNET_REGISTER_NDARRAY_FUN(fill_element_0index)
.set_function(TernaryOp<ndarray::MatFillRowElem>)
.describe("Fill one element of each line(row for python, column for R/Julia)"
" in lhs according to index indicated by rhs and values indicated by mhs."
" This function assume rhs uses 0-based index.");
// register API function
// those with underscore will be registered at NDArray
void CopyFromToSimple(
const nnvm::NodeAttrs& attrs,
const OpContext& ctx,
const std::vector<NDArray>& inputs,
const std::vector<OpReqType>& req,
const std::vector<NDArray>& outputs) {
CopyFromTo(inputs[0], outputs[0], 0);
}
// copy function is special
// that we need to remove kAcceptEmptyMutateTarget from it
NNVM_REGISTER_OP(_copyto)
.set_num_inputs(1)
.set_num_outputs(1)
.set_attr<nnvm::FInferShape>("FInferShape", op::ElemwiseShape<1, 1>)
.set_attr<nnvm::FInferType>("FInferType",
[](const NodeAttrs& attrs, std::vector<int> *in_type, std::vector<int> *out_type) {
return !op::type_is_none((*in_type)[0]) && !op::type_is_none((*out_type)[0]);
})
.set_attr<FInferStorageType>("FInferStorageType",
[](const NodeAttrs& attrs,
const int dev_mask,
DispatchMode* dispatch_mode,
std::vector<int>* in_attrs,
std::vector<int>* out_attrs) {
op::dispatch_mode_assign(dispatch_mode, DispatchMode::kFComputeEx);
if (op::storage_type_is_none((*out_attrs)[0])) {
(*out_attrs)[0] = (*in_attrs)[0];
}
return true;
})
.set_attr<FExecType>("FExecType", [](const NodeAttrs& attrs) {
return ExecType::kCrossDeviceCopy;
})
.set_attr<nnvm::FGradient>("FGradient", op::ElemwiseGradUseNone{"_copyto"})
.set_attr<bool>("TIsBackward", true)
.set_attr<FComputeEx>("FComputeEx<cpu>", CopyFromToSimple)
.set_attr<FComputeEx>("FComputeEx<gpu>", CopyFromToSimple)
.add_argument("data", "NDArray", "input data");
void Imdecode(NDArray *ret, NDArray mean, size_t index,
size_t x0, size_t y0, size_t x1, size_t y1, size_t n_channels,
size_t size, char *str_img) {
#if MXNET_USE_OPENCV
cv::Mat buf(1, size, CV_8U, str_img);
cv::Mat res = cv::imdecode(buf, n_channels == 1 ? 0 : -1);
CHECK(res.data != NULL) << "OpenCV Failed to decode image";
CHECK_LE(n_channels, static_cast<size_t>(res.channels()));
if (y1 - y0 == 0) {
x0 = 0;
x1 = res.cols;
y0 = 0;
y1 = res.rows;
}
CHECK(x1 <= static_cast<size_t>(res.cols) &&
y1 <= static_cast<size_t>(res.rows));
if (ret->is_none()) {
*ret = NDArray(mshadow::Shape3(n_channels, y1-y0, x1-x0),
Context::CPU(), false,
mean.is_none() ? mshadow::default_type_flag : mean.dtype());
}
NDArray buff;
if (ret->shape().ndim() == 3) {
buff = ret->Reshape(mshadow::Shape4(1, ret->shape()[0], ret->shape()[1], ret->shape()[2]));
} else {
CHECK_EQ(ret->shape().ndim(), 4U);
buff = ret->Slice(index, index+1);
}
CHECK_EQ(buff.ctx().dev_mask(), Context::kCPU);
CHECK_EQ(n_channels, buff.shape()[1]);
CHECK_EQ(y1-y0, buff.shape()[2]);
CHECK_EQ(x1-x0, buff.shape()[3]);
buff.WaitToWrite();
if (mean.is_none()) {
MSHADOW_TYPE_SWITCH(buff.dtype(), DType, {
mshadow::Tensor<cpu, 4, DType> tensor = buff.data().get<cpu, 4, DType>();
for (index_t i = 0; i < y1-y0; i++) {
uchar* im_data = res.ptr<uchar>(y0+i) + res.channels()*x0;
for (index_t j = 0; j < x1-x0; j++) {
for (index_t k = 0; k < n_channels; k++) {
tensor[0][k][i][j] = DType(im_data[k]); // NOLINT(*)
}
im_data += res.channels();
}
}
})
} else {
CHECK_EQ(mean.dtype(), buff.dtype());
CHECK_EQ(mean.ctx().dev_mask(), Context::kCPU);
CHECK_EQ(mean.shape()[0], buff.shape()[1]);
CHECK_EQ(mean.shape()[1], buff.shape()[2]);
CHECK_EQ(mean.shape()[2], buff.shape()[3]);
mean.WaitToRead();
MSHADOW_TYPE_SWITCH(buff.dtype(), DType, {
mshadow::Tensor<cpu, 4, DType> tensor = buff.data().get<cpu, 4, DType>();
mshadow::Tensor<cpu, 3, DType> tmean = mean.data().get<cpu, 3, DType>();
for (index_t i = 0; i < y1-y0; i++) {
uchar* im_data = res.ptr<uchar>(y0+i) + res.channels()*x0;
for (index_t j = 0; j < x1-x0; j++) {
for (index_t k = 0; k < n_channels; k++) {
tensor[0][k][i][j] = DType(im_data[k]) - tmean[k][i][j]; // NOLINT(*)
}
im_data += res.channels();
}
}
})
}
#else
LOG(FATAL) << "Compile with OpenCV for image decoding.";
#endif // MXNET_USE_OPENCV
}
MXNET_REGISTER_NDARRAY_FUN(_imdecode)
.set_type_mask(kAcceptEmptyMutateTarget | kNDArrayArgBeforeScalar)
.set_body([](NDArray **u, real_t *s, NDArray **out,
int num_params, char **param_keys, char **param_vals) {
CHECK_EQ(num_params, 1);
Imdecode(out[0], *u[0],
static_cast<size_t>(s[0]),
static_cast<size_t>(s[1]),
static_cast<size_t>(s[2]),
static_cast<size_t>(s[3]),
static_cast<size_t>(s[4]),
static_cast<size_t>(s[5]),
static_cast<size_t>(s[6]),
param_vals[0]);
})
.set_num_use_vars(1)
.set_num_scalars(7)
.set_num_mutate_vars(1)
.describe("Decode an image, clip to (x0, y0, x1, y1), subtract mean, and write to buffer")
.add_argument("mean", "NDArray-or-Symbol", "image mean")
.add_argument("index", "int", "buffer position for output")
.add_argument("x0", "int", "x0")
.add_argument("y0", "int", "y0")
.add_argument("x1", "int", "x1")
.add_argument("y1", "int", "y1")
.add_argument("c", "int", "channel")
.add_argument("size", "int", "length of str_img");
#endif
} // namespace mxnet
| 36.806333
| 97
| 0.645453
|
moshelooks
|
7dedf10cd28c751c181cd74e4b06e479c34cd1d8
| 1,568
|
cpp
|
C++
|
src/view/codeeditor/keybehavior/backtabkeybehavior.cpp
|
Tatsu015/markdownmindmap
|
93e305c04d3adb59073612a5843579d5ce11c79e
|
[
"MIT"
] | null | null | null |
src/view/codeeditor/keybehavior/backtabkeybehavior.cpp
|
Tatsu015/markdownmindmap
|
93e305c04d3adb59073612a5843579d5ce11c79e
|
[
"MIT"
] | 1
|
2022-01-18T16:10:11.000Z
|
2022-01-18T16:11:33.000Z
|
src/view/codeeditor/keybehavior/backtabkeybehavior.cpp
|
Tatsu015/markdownmindmap
|
93e305c04d3adb59073612a5843579d5ce11c79e
|
[
"MIT"
] | null | null | null |
#include "backtabkeybehavior.h"
#include "view/codeeditor/codeeditor.h"
#include <QTextBlock>
BackTabKeyBehavior::BackTabKeyBehavior() : AbstractKeyBehavior() {
}
BackTabKeyBehavior::~BackTabKeyBehavior() {
}
void BackTabKeyBehavior::noModifierKeyPressEvent(CodeEditor* codeEditor) {
QTextCursor cursor = codeEditor->textCursor();
cursor.beginEditBlock();
if (cursor.hasSelection()) {
int32_t start = cursor.selectionStart();
int32_t end = cursor.selectionEnd();
cursor.setPosition(end);
cursor.movePosition(cursor.EndOfLine);
end = cursor.position();
cursor.setPosition(start);
cursor.movePosition(cursor.StartOfLine);
start = cursor.position();
cursor.beginEditBlock();
while (cursor.position() < end) {
cursor.movePosition(cursor.StartOfLine);
QChar c = codeEditor->document()->characterAt(cursor.position());
if (' ' == c) {
cursor.deleteChar();
end -= QString(" ").length();
}
cursor.movePosition(cursor.Down);
cursor.movePosition(cursor.EndOfLine);
}
cursor.movePosition(cursor.StartOfLine);
cursor.deleteChar();
cursor.endEditBlock();
} else {
QString nowLine = cursor.block().text();
if ((!nowLine.isEmpty()) && (' ' == nowLine.at(0))) {
cursor.select(QTextCursor::BlockUnderCursor);
cursor.removeSelectedText();
cursor.insertText("\n" + nowLine.mid(1));
}
}
cursor.endEditBlock();
}
void BackTabKeyBehavior::shiftModifierKeyPressEvent(CodeEditor* codeEditor) {
noModifierKeyPressEvent(codeEditor);
}
| 29.037037
| 77
| 0.684949
|
Tatsu015
|
7df50a6d1cf3528057a217df1291f1fa9cdeab2e
| 1,611
|
cpp
|
C++
|
test/src/startup.cpp
|
Squantor/CortexM_startup
|
df5ed9c52edde0905011a6ba7ad8c272bfd10ed5
|
[
"MIT"
] | 3
|
2020-05-08T12:49:06.000Z
|
2020-11-14T10:59:22.000Z
|
test/src/startup.cpp
|
Squantor/CortexM_startup
|
df5ed9c52edde0905011a6ba7ad8c272bfd10ed5
|
[
"MIT"
] | null | null | null |
test/src/startup.cpp
|
Squantor/CortexM_startup
|
df5ed9c52edde0905011a6ba7ad8c272bfd10ed5
|
[
"MIT"
] | null | null | null |
/*
* Unified Cortex Startup - C++ startup file
*
* This file is in public domain
*
* Put together by Paul Sokolovsky based on article by Vanya Sergeev
* http://dev.frozeneskimo.com/notes/cortex_cmsis/ , GNU ld documentation
* and numerous other public resources.
*
*/
#include <stdint.h>
extern int main(void);
#if defined (__cplusplus)
extern "C" {
#endif
/* Linker symbols that are used to prepare the C/C++ environment */
extern uint32_t _data_flash;
extern uint32_t _start_data;
extern uint32_t _end_data;
extern uint32_t _start_bss;
extern uint32_t _end_bss;
extern void _end_stack(void);
extern void (*__preinit_array_start []) (void);
extern void (*__preinit_array_end []) (void);
extern void (*__init_array_start []) (void);
extern void (*__init_array_end []) (void);
void Reset_Handler(void);
#if defined (__cplusplus)
} // extern "C"
#endif
void Reset_Handler(void)
{
uint32_t *src, *dst;
/* Copy data section from flash to RAM */
src = &_data_flash;
dst = &_start_data;
while (dst < &_end_data)
*dst++ = *src++;
/* Clear the bss section*/
dst = &_start_bss;
while (dst < &_end_bss)
*dst++ = 0;
/* execute c++ constructors */
auto preInitFunc = __preinit_array_start;
while(preInitFunc < __preinit_array_end)
{
(*preInitFunc)();
preInitFunc++;
}
auto initFunc = __init_array_start;
while(initFunc < __init_array_end)
{
(*initFunc)();
initFunc++;
}
main();
/* we omit executing destructors so gcc can optimize them away*/
while (1);
}
| 22.068493
| 73
| 0.65239
|
Squantor
|
7df7d45ff3c6f5168bd5517e437b25f49011350f
| 19,444
|
cpp
|
C++
|
src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.cpp
|
Vxider/ClickHouse
|
cc7a3ea9ff4127d2d7c7f80c752fbc6d6a87b2ef
|
[
"Apache-2.0"
] | 15,577
|
2019-09-23T11:57:53.000Z
|
2022-03-31T18:21:48.000Z
|
src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.cpp
|
Vxider/ClickHouse
|
cc7a3ea9ff4127d2d7c7f80c752fbc6d6a87b2ef
|
[
"Apache-2.0"
] | 16,476
|
2019-09-23T11:47:00.000Z
|
2022-03-31T23:06:01.000Z
|
src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.cpp
|
Vxider/ClickHouse
|
cc7a3ea9ff4127d2d7c7f80c752fbc6d6a87b2ef
|
[
"Apache-2.0"
] | 3,633
|
2019-09-23T12:18:28.000Z
|
2022-03-31T15:55:48.000Z
|
#include <Storages/MergeTree/ReplicatedMergeTreePartCheckThread.h>
#include <Storages/MergeTree/checkDataPart.h>
#include <Storages/MergeTree/ReplicatedMergeTreePartHeader.h>
#include <Storages/StorageReplicatedMergeTree.h>
#include <Interpreters/Context.h>
namespace ProfileEvents
{
extern const Event ReplicatedPartChecks;
extern const Event ReplicatedPartChecksFailed;
extern const Event ReplicatedDataLoss;
}
namespace DB
{
namespace ErrorCodes
{
extern const int TABLE_DIFFERS_TOO_MUCH;
extern const int LOGICAL_ERROR;
}
static const auto PART_CHECK_ERROR_SLEEP_MS = 5 * 1000;
ReplicatedMergeTreePartCheckThread::ReplicatedMergeTreePartCheckThread(StorageReplicatedMergeTree & storage_)
: storage(storage_)
, log_name(storage.getStorageID().getFullTableName() + " (ReplicatedMergeTreePartCheckThread)")
, log(&Poco::Logger::get(log_name))
{
task = storage.getContext()->getSchedulePool().createTask(log_name, [this] { run(); });
task->schedule();
}
ReplicatedMergeTreePartCheckThread::~ReplicatedMergeTreePartCheckThread()
{
stop();
}
void ReplicatedMergeTreePartCheckThread::start()
{
std::lock_guard lock(start_stop_mutex);
need_stop = false;
task->activateAndSchedule();
}
void ReplicatedMergeTreePartCheckThread::stop()
{
//based on discussion on https://github.com/ClickHouse/ClickHouse/pull/1489#issuecomment-344756259
//using the schedule pool there is no problem in case stop is called two time in row and the start multiple times
std::lock_guard lock(start_stop_mutex);
need_stop = true;
task->deactivate();
}
void ReplicatedMergeTreePartCheckThread::enqueuePart(const String & name, time_t delay_to_check_seconds)
{
std::lock_guard lock(parts_mutex);
if (parts_set.count(name))
return;
parts_queue.emplace_back(name, time(nullptr) + delay_to_check_seconds);
parts_set.insert(name);
task->schedule();
}
size_t ReplicatedMergeTreePartCheckThread::size() const
{
std::lock_guard lock(parts_mutex);
return parts_set.size();
}
ReplicatedMergeTreePartCheckThread::MissingPartSearchResult ReplicatedMergeTreePartCheckThread::searchForMissingPartOnOtherReplicas(const String & part_name)
{
auto zookeeper = storage.getZooKeeper();
/// If the part is not in ZooKeeper, we'll check if it's at least somewhere.
auto part_info = MergeTreePartInfo::fromPartName(part_name, storage.format_version);
/** The logic is as follows:
* - if some live or inactive replica has such a part, or a part covering it
* - it is Ok, nothing is needed, it is then downloaded when processing the queue, when the replica comes to life;
* - or, if the replica never comes to life, then the administrator will delete or create a new replica with the same address and see everything from the beginning;
* - if no one has such part or a part covering it, then
* - if there are two smaller parts, one with the same min block and the other with the same
* max block, we hope that all parts in between are present too and the needed part
* will appear on other replicas as a result of a merge.
* - otherwise, consider the part lost and delete the entry from the queue.
*
* Note that this logic is not perfect - some part in the interior may be missing and the
* needed part will never appear. But precisely determining whether the part will appear as
* a result of a merge is complicated - we can't just check if all block numbers covered
* by the missing part are present somewhere (because gaps between blocks are possible)
* and to determine the constituent parts of the merge we need to query the replication log
* (both the common log and the queues of the individual replicas) and then, if the
* constituent parts are in turn not found, solve the problem recursively for them.
*
* Considering the part lost when it is not in fact lost is very dangerous because it leads
* to divergent replicas and intersecting parts. So we err on the side of caution
* and don't delete the queue entry when in doubt.
*/
LOG_WARNING(log, "Checking if anyone has a part {} or covering part.", part_name);
bool found_part_with_the_same_min_block = false;
bool found_part_with_the_same_max_block = false;
Strings replicas = zookeeper->getChildren(storage.zookeeper_path + "/replicas");
/// Move our replica to the end of replicas
for (auto it = replicas.begin(); it != replicas.end(); ++it)
{
String replica_path = storage.zookeeper_path + "/replicas/" + *it;
if (replica_path == storage.replica_path)
{
std::iter_swap(it, replicas.rbegin());
break;
}
}
/// Check all replicas and our replica must be this last one
for (const String & replica : replicas)
{
String replica_path = storage.zookeeper_path + "/replicas/" + replica;
Strings parts = zookeeper->getChildren(replica_path + "/parts");
for (const String & part_on_replica : parts)
{
auto part_on_replica_info = MergeTreePartInfo::fromPartName(part_on_replica, storage.format_version);
if (part_info == part_on_replica_info)
{
/// Found missing part at ourself. If we are here then something wrong with this part, so skipping.
if (replica_path == storage.replica_path)
continue;
LOG_WARNING(log, "Found the missing part {} at {} on {}", part_name, part_on_replica, replica);
return MissingPartSearchResult::FoundAndNeedFetch;
}
if (part_on_replica_info.contains(part_info))
{
LOG_WARNING(log, "Found part {} on {} that covers the missing part {}", part_on_replica, replica, part_name);
return MissingPartSearchResult::FoundAndDontNeedFetch;
}
if (part_info.contains(part_on_replica_info))
{
if (part_on_replica_info.min_block == part_info.min_block)
found_part_with_the_same_min_block = true;
if (part_on_replica_info.max_block == part_info.max_block)
found_part_with_the_same_max_block = true;
if (found_part_with_the_same_min_block && found_part_with_the_same_max_block)
{
/// FIXME It may never appear
LOG_WARNING(log, "Found parts with the same min block and with the same max block as the missing part {} on replica {}. Hoping that it will eventually appear as a result of a merge.", part_name, replica);
return MissingPartSearchResult::FoundAndDontNeedFetch;
}
}
}
}
/// No one has such a part and the merge is impossible.
String not_found_msg;
if (found_part_with_the_same_max_block)
not_found_msg = "a smaller part with the same max block.";
else if (found_part_with_the_same_min_block)
not_found_msg = "a smaller part with the same min block.";
else
not_found_msg = "smaller parts with either the same min block or the same max block.";
LOG_ERROR(log, "No replica has part covering {} and a merge is impossible: we didn't find {}", part_name, not_found_msg);
return MissingPartSearchResult::LostForever;
}
void ReplicatedMergeTreePartCheckThread::searchForMissingPartAndFetchIfPossible(const String & part_name, bool exists_in_zookeeper)
{
auto zookeeper = storage.getZooKeeper();
auto missing_part_search_result = searchForMissingPartOnOtherReplicas(part_name);
/// If the part is in ZooKeeper, remove it from there and add the task to download it to the queue.
if (exists_in_zookeeper)
{
/// If part found on some other replica
if (missing_part_search_result == MissingPartSearchResult::FoundAndNeedFetch)
{
LOG_WARNING(log, "Part {} exists in ZooKeeper but not locally and found on other replica. Removing from ZooKeeper and queueing a fetch.", part_name);
storage.removePartAndEnqueueFetch(part_name);
}
else /// If we have covering part on other replica or part is lost forever we don't need to fetch anything
{
LOG_WARNING(log, "Part {} exists in ZooKeeper but not locally and not found on other replica. Removing it from ZooKeeper.", part_name);
storage.removePartFromZooKeeper(part_name);
}
}
ProfileEvents::increment(ProfileEvents::ReplicatedPartChecksFailed);
if (missing_part_search_result == MissingPartSearchResult::LostForever)
{
auto lost_part_info = MergeTreePartInfo::fromPartName(part_name, storage.format_version);
if (lost_part_info.level != 0 || lost_part_info.mutation != 0)
{
Strings source_parts;
bool part_in_queue = storage.queue.checkPartInQueueAndGetSourceParts(part_name, source_parts);
/// If it's MERGE/MUTATION etc. we shouldn't replace result part with empty part
/// because some source parts can be lost, but some of them can exist.
if (part_in_queue && !source_parts.empty())
{
LOG_ERROR(log, "Part {} found in queue and some source parts for it was lost. Will check all source parts.", part_name);
for (const String & source_part_name : source_parts)
enqueuePart(source_part_name);
return;
}
}
if (storage.createEmptyPartInsteadOfLost(zookeeper, part_name))
{
/** This situation is possible if on all the replicas where the part was, it deteriorated.
* For example, a replica that has just written it has power turned off and the data has not been written from cache to disk.
*/
LOG_ERROR(log, "Part {} is lost forever.", part_name);
ProfileEvents::increment(ProfileEvents::ReplicatedDataLoss);
}
else
{
LOG_WARNING(log, "Cannot create empty part {} instead of lost. Will retry later", part_name);
}
}
}
std::pair<bool, MergeTreeDataPartPtr> ReplicatedMergeTreePartCheckThread::findLocalPart(const String & part_name)
{
auto zookeeper = storage.getZooKeeper();
String part_path = storage.replica_path + "/parts/" + part_name;
/// It's important to check zookeeper first and after that check local storage,
/// because our checks of local storage and zookeeper are not consistent.
/// If part exists in zookeeper and doesn't exists in local storage definitely require
/// to fetch this part. But if we check local storage first and than check zookeeper
/// some background process can successfully commit part between this checks (both to the local storage and zookeeper),
/// but checker thread will remove part from zookeeper and queue fetch.
bool exists_in_zookeeper = zookeeper->exists(part_path);
/// If the part is still in the PreCommitted -> Committed transition, it is not lost
/// and there is no need to go searching for it on other replicas. To definitely find the needed part
/// if it exists (or a part containing it) we first search among the PreCommitted parts.
auto part = storage.getPartIfExists(part_name, {MergeTreeDataPartState::PreCommitted});
if (!part)
part = storage.getActiveContainingPart(part_name);
return std::make_pair(exists_in_zookeeper, part);
}
CheckResult ReplicatedMergeTreePartCheckThread::checkPart(const String & part_name)
{
LOG_WARNING(log, "Checking part {}", part_name);
ProfileEvents::increment(ProfileEvents::ReplicatedPartChecks);
auto [exists_in_zookeeper, part] = findLocalPart(part_name);
LOG_TRACE(log, "Part {} in zookeeper: {}, locally: {}", part_name, exists_in_zookeeper, part != nullptr);
/// We do not have this or a covering part.
if (!part)
{
searchForMissingPartAndFetchIfPossible(part_name, exists_in_zookeeper);
return {part_name, false, "Part is missing, will search for it"};
}
/// We have this part, and it's active. We will check whether we need this part and whether it has the right data.
if (part->name == part_name)
{
auto zookeeper = storage.getZooKeeper();
auto table_lock = storage.lockForShare(RWLockImpl::NO_QUERY, storage.getSettings()->lock_acquire_timeout_for_background_operations);
auto local_part_header = ReplicatedMergeTreePartHeader::fromColumnsAndChecksums(
part->getColumns(), part->checksums);
/// The double get scheme is needed to retain compatibility with very old parts that were created
/// before the ReplicatedMergeTreePartHeader was introduced.
String part_path = storage.replica_path + "/parts/" + part_name;
String part_znode;
/// If the part is in ZooKeeper, check its data with its checksums, and them with ZooKeeper.
if (zookeeper->tryGet(part_path, part_znode))
{
LOG_WARNING(log, "Checking data of part {}.", part_name);
try
{
ReplicatedMergeTreePartHeader zk_part_header;
if (!part_znode.empty())
zk_part_header = ReplicatedMergeTreePartHeader::fromString(part_znode);
else
{
String columns_znode = zookeeper->get(part_path + "/columns");
String checksums_znode = zookeeper->get(part_path + "/checksums");
zk_part_header = ReplicatedMergeTreePartHeader::fromColumnsAndChecksumsZNodes(
columns_znode, checksums_znode);
}
if (local_part_header.getColumnsHash() != zk_part_header.getColumnsHash())
throw Exception("Columns of local part " + part_name + " are different from ZooKeeper", ErrorCodes::TABLE_DIFFERS_TOO_MUCH);
zk_part_header.getChecksums().checkEqual(local_part_header.getChecksums(), true);
checkDataPart(
part,
true,
[this] { return need_stop.load(); });
if (need_stop)
{
LOG_INFO(log, "Checking part was cancelled.");
return {part_name, false, "Checking part was cancelled"};
}
LOG_INFO(log, "Part {} looks good.", part_name);
}
catch (const Exception & e)
{
/// Don't count the part as broken if there is not enough memory to load it.
/// In fact, there can be many similar situations.
/// But it is OK, because there is a safety guard against deleting too many parts.
if (isNotEnoughMemoryErrorCode(e.code()))
throw;
tryLogCurrentException(log, __PRETTY_FUNCTION__);
String message = "Part " + part_name + " looks broken. Removing it and will try to fetch.";
LOG_ERROR(log, message);
/// Delete part locally.
storage.forgetPartAndMoveToDetached(part, "broken");
/// Part is broken, let's try to find it and fetch.
searchForMissingPartAndFetchIfPossible(part_name, exists_in_zookeeper);
return {part_name, false, message};
}
}
else if (part->modification_time + MAX_AGE_OF_LOCAL_PART_THAT_WASNT_ADDED_TO_ZOOKEEPER < time(nullptr))
{
/// If the part is not in ZooKeeper, delete it locally.
/// Probably, someone just wrote down the part, and has not yet added to ZK.
/// Therefore, delete only if the part is old (not very reliable).
ProfileEvents::increment(ProfileEvents::ReplicatedPartChecksFailed);
String message = "Unexpected part " + part_name + " in filesystem. Removing.";
LOG_ERROR(log, message);
storage.forgetPartAndMoveToDetached(part, "unexpected");
return {part_name, false, message};
}
else
{
/// TODO You need to make sure that the part is still checked after a while.
/// Otherwise, it's possible that the part was not added to ZK,
/// but remained in the filesystem and in a number of active parts.
/// And then for a long time (before restarting), the data on the replicas will be different.
LOG_TRACE(log, "Young part {} with age {} seconds hasn't been added to ZooKeeper yet. It's ok.", part_name, (time(nullptr) - part->modification_time));
}
}
else
{
/// If we have a covering part, ignore all the problems with this part.
/// In the worst case, errors will still appear `old_parts_lifetime` seconds in error log until the part is removed as the old one.
LOG_WARNING(log, "We have part {} covering part {}", part->name, part_name);
}
return {part_name, true, ""};
}
void ReplicatedMergeTreePartCheckThread::run()
{
if (need_stop)
return;
try
{
time_t current_time = time(nullptr);
/// Take part from the queue for verification.
PartsToCheckQueue::iterator selected = parts_queue.end(); /// end from std::list is not get invalidated
time_t min_check_time = std::numeric_limits<time_t>::max();
{
std::lock_guard lock(parts_mutex);
if (parts_queue.empty())
{
if (!parts_set.empty())
{
parts_set.clear();
throw Exception(ErrorCodes::LOGICAL_ERROR, "Non-empty parts_set with empty parts_queue. This is a bug.");
}
}
else
{
for (auto it = parts_queue.begin(); it != parts_queue.end(); ++it)
{
if (it->second <= current_time)
{
selected = it;
break;
}
if (it->second < min_check_time)
min_check_time = it->second;
}
}
}
if (selected == parts_queue.end())
return;
checkPart(selected->first);
if (need_stop)
return;
/// Remove the part from check queue.
{
std::lock_guard lock(parts_mutex);
if (parts_queue.empty())
{
throw Exception(ErrorCodes::LOGICAL_ERROR, "Someone erased checking part from parts_queue. This is a bug.");
}
else
{
parts_set.erase(selected->first);
parts_queue.erase(selected);
}
}
task->schedule();
}
catch (const Coordination::Exception & e)
{
tryLogCurrentException(log, __PRETTY_FUNCTION__);
if (e.code == Coordination::Error::ZSESSIONEXPIRED)
return;
task->scheduleAfter(PART_CHECK_ERROR_SLEEP_MS);
}
catch (...)
{
tryLogCurrentException(log, __PRETTY_FUNCTION__);
task->scheduleAfter(PART_CHECK_ERROR_SLEEP_MS);
}
}
}
| 41.815054
| 224
| 0.6421
|
Vxider
|
7dfc822ee4e1c9fe432b749bacf08e07ee50abf1
| 50,729
|
cpp
|
C++
|
src/tests/fetcher_cache_tests.cpp
|
ruhip/mesos1.2.0
|
6f6d6786a91ee96fcd7cd435eee8933496c9903e
|
[
"Apache-2.0"
] | null | null | null |
src/tests/fetcher_cache_tests.cpp
|
ruhip/mesos1.2.0
|
6f6d6786a91ee96fcd7cd435eee8933496c9903e
|
[
"Apache-2.0"
] | null | null | null |
src/tests/fetcher_cache_tests.cpp
|
ruhip/mesos1.2.0
|
6f6d6786a91ee96fcd7cd435eee8933496c9903e
|
[
"Apache-2.0"
] | null | null | null |
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <unistd.h>
#include <list>
#include <string>
#include <vector>
#include <gmock/gmock.h>
#include <mesos/executor.hpp>
#include <mesos/scheduler.hpp>
#include <process/check.hpp>
#include <process/clock.hpp>
#include <process/collect.hpp>
#include <process/future.hpp>
#include <process/gmock.hpp>
#include <process/latch.hpp>
#include <process/message.hpp>
#include <process/owned.hpp>
#include <process/pid.hpp>
#include <process/process.hpp>
#include <process/queue.hpp>
#include <process/subprocess.hpp>
#include <stout/option.hpp>
#include <stout/os.hpp>
#include <stout/path.hpp>
#include <stout/try.hpp>
#include "master/flags.hpp"
#include "master/master.hpp"
#include "slave/constants.hpp"
#include "slave/gc.hpp"
#include "slave/flags.hpp"
#include "slave/paths.hpp"
#include "slave/slave.hpp"
#include "slave/containerizer/fetcher.hpp"
#include "tests/containerizer.hpp"
#include "tests/flags.hpp"
#include "tests/mesos.hpp"
using mesos::fetcher::FetcherInfo;
using mesos::internal::master::Master;
using mesos::internal::slave::Slave;
using mesos::internal::slave::Containerizer;
using mesos::internal::slave::MesosContainerizer;
using mesos::internal::slave::MesosContainerizerProcess;
using mesos::internal::slave::Fetcher;
using mesos::internal::slave::FetcherProcess;
using mesos::master::detector::MasterDetector;
using process::Future;
using process::HttpEvent;
using process::Latch;
using process::Owned;
using process::PID;
using process::Process;
using process::Promise;
using process::Queue;
using process::Subprocess;
using std::cout;
using std::endl;
using std::list;
using std::string;
using std::vector;
using testing::_;
using testing::DoAll;
using testing::DoDefault;
using testing::Eq;
using testing::Invoke;
using testing::InvokeWithoutArgs;
using testing::Return;
namespace mesos {
namespace internal {
namespace tests {
static const string ASSETS_DIRECTORY_NAME = "mesos-fetcher-test-assets";
static const string COMMAND_NAME = "mesos-fetcher-test-cmd";
static const string ARCHIVE_NAME = "mesos-fetcher-test-archive.tgz";
static const string ARCHIVED_COMMAND_NAME = "mesos-fetcher-test-acmd";
// Every task executes one of these shell scripts, which create a
// file that includes the current task name in its name. The latter
// is expected to be passed in as a script argument. The existence
// of the file with that name is then used as proof that the task
// ran successfully.
static const string COMMAND_SCRIPT = "touch " + COMMAND_NAME + "$1";
static const string ARCHIVED_COMMAND_SCRIPT =
"touch " + ARCHIVED_COMMAND_NAME + "$1";
class FetcherCacheTest : public MesosTest
{
public:
// A helper struct that captures useful information for each of the
// tasks that we have launched to help test expectations.
struct Task
{
Path runDirectory;
Queue<TaskStatus> statusQueue;
};
void setupCommandFileAsset();
protected:
void setupArchiveAsset();
virtual void SetUp();
virtual void TearDown();
// Sets up the slave and starts it. Calling this late in the test
// instead of having it included in SetUp() gives us the opportunity
// to manipulate values in 'flags', first.
void startSlave();
// Stops the slave, deleting the containerizer, for subsequent
// recovery testing.
void stopSlave();
Try<Task> launchTask(const CommandInfo& commandInfo, const size_t taskIndex);
Try<vector<Task>> launchTasks(const vector<CommandInfo>& commandInfos);
// Promises whose futures indicate that FetcherProcess::_fetch() has been
// called for a task with a given index.
vector<Owned<Promise<Nothing>>> fetchContentionWaypoints;
string assetsDirectory;
string commandPath;
string archivePath;
string cacheDirectory;
Owned<cluster::Master> master;
Owned<cluster::Slave> slave;
slave::Flags flags;
SlaveID slaveId;
Owned<MasterDetector> detector;
Owned<MesosContainerizer> containerizer;
// NOTE: This is technically owned by the `fetcher`, but we violate
// this ownership in the tests.
MockFetcherProcess* fetcherProcess;
MockScheduler scheduler;
Owned<MesosSchedulerDriver> driver;
private:
Owned<Fetcher> fetcher;
FrameworkID frameworkId;
// If this test did not succeed as indicated by the above variable,
// the contents of these sandboxes will be dumped during tear down.
vector<Path> sandboxes;
};
void FetcherCacheTest::SetUp()
{
MesosTest::SetUp();
flags = CreateSlaveFlags();
flags.resources = "cpus:1000;mem:1000";
assetsDirectory = path::join(flags.work_dir, ASSETS_DIRECTORY_NAME);
ASSERT_SOME(os::mkdir(assetsDirectory));
setupCommandFileAsset();
setupArchiveAsset();
Try<Owned<cluster::Master>> _master = StartMaster();
ASSERT_SOME(_master);
master = _master.get();
fetcherProcess = new MockFetcherProcess();
fetcher.reset(new Fetcher(Owned<FetcherProcess>(fetcherProcess)));
FrameworkInfo frameworkInfo;
frameworkInfo.set_name("default");
frameworkInfo.set_checkpoint(true);
driver.reset(new MesosSchedulerDriver(
&scheduler, frameworkInfo, master->pid, DEFAULT_CREDENTIAL));
EXPECT_CALL(scheduler, registered(driver.get(), _, _))
.Times(1);
// This installs a temporary reaction to resourceOffers calls, which
// must be in place BEFORE starting the scheduler driver. This
// "cover" is necessary, because we only add relevant mock actions
// in launchTask() and launchTasks() AFTER starting the driver.
EXPECT_CALL(scheduler, resourceOffers(driver.get(), _))
.WillRepeatedly(DeclineOffers());
}
// Dumps the contents of a text file to cout, assuming
// there are only text files.
static void logFile(const Path& path, const string& filename)
{
string filePath = path::join(path.string(), filename);
Try<string> text = os::read(filePath);
if (text.isSome()) {
cout << "Begin file contents of `" << filename << "`:" << endl;
cout << text.get() << endl;
cout << "End file" << endl;
} else {
cout << "File `" << filename << "` not readable: " << text.error() << endl;
}
}
// Dumps the contents of all files in the sandbox to cout, assuming
// there are only text files.
static void logSandbox(const Path& path)
{
Try<list<string>> entries = os::ls(path.string());
if (entries.isSome()) {
cout << "Begin listing sandbox `" << path.string() << "`:" << endl;
foreach (const string& entry, entries.get()) {
logFile(path, entry);
}
cout << "End sandbox" << endl;
} else {
cout << "Could not list sandbox `" << path.string()
<< "`: " << entries.error() << endl;
}
}
void FetcherCacheTest::TearDown()
{
if (HasFatalFailure()) {
// A gtest macro has terminated the test prematurely. Now stream
// additional info that might help debug the situation to where
// gtest writes its output: cout.
cout << "Begin listing sandboxes" << endl;
foreach (const Path& path, sandboxes) {
logSandbox(path);
}
cout << "End sandboxes" << endl;
}
driver->stop();
driver->join();
master.reset();
slave.reset();
MesosTest::TearDown();
}
// TODO(bernd-mesos): Make this abstractions as generic and generally
// available for all testing as possible.
void FetcherCacheTest::startSlave()
{
Try<MesosContainerizer*> create = MesosContainerizer::create(
flags, true, fetcher.get());
ASSERT_SOME(create);
containerizer.reset(create.get());
Future<SlaveRegisteredMessage> slaveRegisteredMessage =
FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);
detector = master->createDetector();
Try<Owned<cluster::Slave>> _slave =
StartSlave(detector.get(), containerizer.get(), flags);
ASSERT_SOME(_slave);
slave = _slave.get();
AWAIT_READY(slaveRegisteredMessage);
slaveId = slaveRegisteredMessage.get().slave_id();
cacheDirectory =
slave::paths::getSlavePath(flags.fetcher_cache_dir, slaveId);
}
void FetcherCacheTest::setupCommandFileAsset()
{
commandPath = path::join(assetsDirectory, COMMAND_NAME);
ASSERT_SOME(os::write(commandPath, COMMAND_SCRIPT));
// Make the command file read-only, so we can discern the URI
// executable flag.
ASSERT_SOME(os::chmod(commandPath, S_IRUSR | S_IRGRP | S_IROTH));
}
void FetcherCacheTest::setupArchiveAsset()
{
string path = path::join(assetsDirectory, ARCHIVED_COMMAND_NAME);
ASSERT_SOME(os::write(path, ARCHIVED_COMMAND_SCRIPT));
// Make the archived command file executable before archiving it,
// since the executable flag for CommandInfo::URI has no effect on
// what comes out of an archive.
ASSERT_SOME(os::chmod(path, S_IRWXU | S_IRWXG | S_IRWXO));
const string cwd = os::getcwd();
ASSERT_SOME(os::chdir(assetsDirectory));
// Create an uncompressed archive (see MESOS-3579).
ASSERT_SOME(os::shell(
"tar cf '" + ARCHIVE_NAME + "' '" + ARCHIVED_COMMAND_NAME + "' 2>&1"));
ASSERT_SOME(os::chdir(cwd));
archivePath = path::join(assetsDirectory, ARCHIVE_NAME);
// Make the archive file read-only, so we can tell if it becomes
// executable by acccident.
ASSERT_SOME(os::chmod(archivePath, S_IRUSR | S_IRGRP | S_IROTH));
}
static string taskName(int taskIndex)
{
return stringify(taskIndex);
}
// TODO(bernd-mesos): Use Path, not string, create Path::executable().
static bool isExecutable(const string& path)
{
Try<bool> access = os::access(path, X_OK);
EXPECT_SOME(access);
return access.isSome() && access.get();
}
// Create a future that indicates that the task observed by the given
// status queue is finished.
static Future<Nothing> awaitFinished(FetcherCacheTest::Task task)
{
return task.statusQueue.get()
.then([=](const TaskStatus& status) -> Future<Nothing> {
if (status.state() == TASK_FINISHED) {
return Nothing();
}
return awaitFinished(task);
});
}
// Create a future that indicates that all tasks are finished.
// TODO(bernd-mesos): Make this abstractions as generic and generally
// available for all testing as possible.
static Future<list<Nothing>> awaitFinished(
vector<FetcherCacheTest::Task> tasks)
{
list<Future<Nothing>> futures;
foreach (FetcherCacheTest::Task task, tasks) {
futures.push_back(awaitFinished(task));
}
return collect(futures);
}
// Pushes the TaskStatus value in mock call argument #1 into the
// given queue, which later on shall be queried by awaitFinished().
ACTION_P(PushTaskStatus, taskStatusQueue)
{
TaskStatus taskStatus = arg1;
// Input parameters of ACTION_P are const. We make a mutable copy
// so that we can use put().
Queue<TaskStatus> queue = taskStatusQueue;
queue.put(taskStatus);
}
// Launches a task as described by its CommandInfo and returns its sandbox
// run directory path. Its completion will be indicated by the result of
// awaitFinished(task), where `task` is the return value of this method.
// TODO(bernd-mesos): Make this abstraction as generic and generally
// available for all testing as possible.
Try<FetcherCacheTest::Task> FetcherCacheTest::launchTask(
const CommandInfo& commandInfo,
const size_t taskIndex)
{
Future<vector<Offer>> offers;
EXPECT_CALL(scheduler, resourceOffers(driver.get(), _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(DeclineOffers());
// The default timeout in AWAIT_READY is 15 seconds,
// so we use that amount here.
// TODO(bernd-mesos): Make this a symbolic constant in "gtest.hpp"
// that we can reference here.
offers.await(Seconds(15));
if (!offers.isReady()) {
return Error("Failed to wait for resource offers: " +
(offers.isFailed() ? offers.failure() : "discarded"));
}
if (offers->empty()) {
return Error("Received empty list of offers");
}
const Offer offer = offers.get()[0];
TaskInfo task;
task.set_name(taskName(taskIndex));
task.mutable_task_id()->set_value(taskName(taskIndex));
task.mutable_slave_id()->CopyFrom(offer.slave_id());
// We don't care about resources in these tests. This small amount
// will always succeed.
task.mutable_resources()->CopyFrom(
Resources::parse("cpus:1;mem:1").get());
task.mutable_command()->CopyFrom(commandInfo);
// Since we are always using a command executor here, the executor
// ID can be determined by copying the task ID.
ExecutorID executorId;
executorId.set_value(task.task_id().value());
vector<TaskInfo> tasks;
tasks.push_back(task);
Queue<TaskStatus> taskStatusQueue;
EXPECT_CALL(scheduler, statusUpdate(driver.get(), _))
.WillRepeatedly(PushTaskStatus(taskStatusQueue));
driver->launchTasks(offer.id(), tasks);
const Path sandboxPath = Path(slave::paths::getExecutorLatestRunPath(
flags.work_dir,
slaveId,
offer.framework_id(),
executorId));
sandboxes.push_back(sandboxPath);
return Task{sandboxPath, taskStatusQueue};
}
// Pushes the task status value of a task status update callback
// into the task status queue that corresponds to the task index/ID
// for which the status update is being reported. 'tasks' must be a
// 'vector<Task>>', where every slot index corresponds to a task
// index/ID.
// TODO(bernd-mesos): Make this abstractions as generic and generally
// available for all testing as possible.
ACTION_TEMPLATE(PushIndexedTaskStatus,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(tasks))
{
TaskStatus taskStatus = ::std::tr1::get<k>(args);
Try<int> taskId = numify<int>(taskStatus.task_id().value());
ASSERT_SOME(taskId);
Queue<TaskStatus> queue = (tasks)[taskId.get()].statusQueue;
queue.put(taskStatus);
}
// Satisfies the first promise in the list that is not satisfied yet.
ACTION_P(SatisfyOne, promises)
{
foreach (const Owned<Promise<Nothing>>& promise, *promises) {
if (promise->future().isPending()) {
promise->set(Nothing());
return;
}
}
FAIL() << "Tried to call FetcherProcess::_fetch() "
<< "for more tasks than launched";
}
// Launches the tasks described by the given CommandInfo and returns a
// vector holding the run directory paths. All these tasks run
// concurrently. Their completion will be indicated by the result of
// awaitFinished(tasks), where `tasks` is the return value of this
// method.
// TODO(bernd-mesos): Make this abstraction as generic and generally
// available for all testing as possible.
Try<vector<FetcherCacheTest::Task>> FetcherCacheTest::launchTasks(
const vector<CommandInfo>& commandInfos)
{
vector<FetcherCacheTest::Task> result;
// When _fetch() is called, notify us by satisfying a promise that
// a task has passed the code stretch in which it competes for cache
// entries.
EXPECT_CALL(*fetcherProcess, _fetch(_, _, _, _, _, _))
.WillRepeatedly(
DoAll(SatisfyOne(&fetchContentionWaypoints),
Invoke(fetcherProcess, &MockFetcherProcess::unmocked__fetch)));
Future<vector<Offer>> offers;
EXPECT_CALL(scheduler, resourceOffers(driver.get(), _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(DeclineOffers());
// The default timeout in AWAIT_READY is 15 seconds,
// so we use that amount here.
// TODO(bernd-mesos): Make this a symbolic constant in "gtest.hpp"
// that we can reference here.
offers.await(Seconds(15));
if (!offers.isReady()) {
return Error("Failed to wait for resource offers: " +
(offers.isFailed() ? offers.failure() : "discarded"));
}
EXPECT_NE(0u, offers.get().size());
const Offer offer = offers.get()[0];
vector<TaskInfo> tasks;
foreach (const CommandInfo& commandInfo, commandInfos) {
size_t taskIndex = tasks.size();
// Grabbing the framework ID from somewhere. It should not matter
// if this happens several times, as we expect the framework ID to
// remain the same.
frameworkId = offer.framework_id();
TaskInfo task;
task.set_name(taskName(taskIndex));
task.mutable_task_id()->set_value(taskName(taskIndex));
task.mutable_slave_id()->CopyFrom(offer.slave_id());
// We don't care about resources in these tests. This small amount
// will always succeed.
task.mutable_resources()->CopyFrom(
Resources::parse("cpus:1;mem:1").get());
task.mutable_command()->CopyFrom(commandInfo);
tasks.push_back(task);
// Since we are always using a command executor here, the executor
// ID can be determined by copying the task ID.
ExecutorID executorId;
executorId.set_value(task.task_id().value());
Path sandboxPath = Path(slave::paths::getExecutorLatestRunPath(
flags.work_dir,
slaveId,
frameworkId,
executorId));
sandboxes.push_back(sandboxPath);
// Grabbing task status futures to wait for. We make a queue of futures
// for each task. We can then wait until the front element indicates
// status TASK_FINISHED. We use a queue, because we never know which
// status update will be the one we have been waiting for.
Queue<TaskStatus> taskStatusQueue;
result.push_back(Task {sandboxPath, taskStatusQueue});
auto waypoint = Owned<Promise<Nothing>>(new Promise<Nothing>());
fetchContentionWaypoints.push_back(waypoint);
}
EXPECT_CALL(scheduler, statusUpdate(driver.get(), _))
.WillRepeatedly(PushIndexedTaskStatus<1>(result));
driver->launchTasks(offer.id(), tasks);
return result;
}
// Tests fetching from the local asset directory without cache. This
// gives us a baseline for the following tests and lets us debug our
// test infrastructure without extra complications.
TEST_F(FetcherCacheTest, LocalUncached)
{
startSlave();
driver->start();
const int index = 0;
CommandInfo::URI uri;
uri.set_value(commandPath);
uri.set_executable(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + COMMAND_NAME + " " + taskName(index));
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, index);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
EXPECT_EQ(0u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(0u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
const string path = path::join(task->runDirectory.string(), COMMAND_NAME);
EXPECT_TRUE(isExecutable(path));
EXPECT_TRUE(os::exists(path + taskName(index)));
}
// Tests fetching from the local asset directory with simple caching.
// Only one download must occur. Fetching is serialized, to cover
// code areas without overlapping/concurrent fetch attempts.
TEST_F(FetcherCacheTest, LocalCached)
{
startSlave();
driver->start();
for (size_t i = 0; i < 2; i++) {
CommandInfo::URI uri;
uri.set_value(commandPath);
uri.set_executable(true);
uri.set_cache(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + COMMAND_NAME + " " + taskName(i));
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, i);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
const string path = path::join(task->runDirectory.string(), COMMAND_NAME);
EXPECT_TRUE(isExecutable(path));
EXPECT_TRUE(os::exists(path + taskName(i)));
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
}
}
TEST_F(FetcherCacheTest, CachedCustomFilename)
{
startSlave();
driver->start();
const int index = 0;
const string customOutputFile = "my-command";
CommandInfo::URI uri;
uri.set_value(commandPath);
uri.set_executable(true);
uri.set_cache(true);
uri.set_output_file(customOutputFile);
CommandInfo commandInfo;
commandInfo.set_value("./" + customOutputFile + " " + taskName(index));
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, index);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
// Verify that the downloaded executable lives at our custom output path.
const string executablePath = path::join(
task->runDirectory.string(), customOutputFile);
EXPECT_TRUE(isExecutable(executablePath));
// The script specified by COMMAND_SCRIPT just statically touches a file
// named $COMMAND_NAME + $1, so if we want to verify that it ran here we have
// to check this path in addition to the custom-named executable we saved.
const string outputPath = path::join(
task->runDirectory.string(), COMMAND_NAME);
EXPECT_TRUE(os::exists(outputPath + taskName(index)));
}
TEST_F(FetcherCacheTest, CachedCustomOutputFileWithSubdirectory)
{
startSlave();
driver->start();
const int index = 0;
const string customOutputFile = "subdir/my-command";
CommandInfo::URI uri;
uri.set_value(commandPath);
uri.set_executable(true);
uri.set_cache(true);
uri.set_output_file(customOutputFile);
CommandInfo commandInfo;
commandInfo.set_value("./" + customOutputFile + " " + taskName(index));
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, index);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
// Verify that the downloaded executable lives at our custom output file
// path.
const string executablePath = path::join(
task->runDirectory.string(), customOutputFile);
EXPECT_TRUE(isExecutable(executablePath));
// The script specified by COMMAND_SCRIPT just statically touches a file
// named $COMMAND_NAME + $1, so if we want to verify that it ran here we have
// to check this path in addition to the custom-named executable we saved.
const string outputPath = path::join(
task->runDirectory.string(), COMMAND_NAME);
EXPECT_TRUE(os::exists(outputPath + taskName(index)));
}
// Tests falling back on bypassing the cache when fetching the download
// size of a URI that is supposed to be cached fails.
TEST_F(FetcherCacheTest, CachedFallback)
{
startSlave();
driver->start();
// Make sure the content-length request fails.
ASSERT_SOME(os::rm(commandPath));
CommandInfo::URI uri;
uri.set_value(commandPath);
uri.set_executable(true);
uri.set_cache(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + COMMAND_NAME + " " + taskName(0));
commandInfo.add_uris()->CopyFrom(uri);
// Bring back the asset just before running mesos-fetcher to fetch it.
Future<FetcherInfo> fetcherInfo;
EXPECT_CALL(*fetcherProcess, run(_, _, _, _, _))
.WillOnce(DoAll(FutureArg<3>(&fetcherInfo),
InvokeWithoutArgs(this,
&FetcherCacheTest::setupCommandFileAsset),
Invoke(fetcherProcess,
&MockFetcherProcess::unmocked_run)));
const Try<Task> task = launchTask(commandInfo, 0);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
const string path = path::join(task->runDirectory.string(), COMMAND_NAME);
EXPECT_TRUE(isExecutable(path));
EXPECT_TRUE(os::exists(path + taskName(0)));
AWAIT_READY(fetcherInfo);
ASSERT_EQ(1, fetcherInfo.get().items_size());
EXPECT_EQ(FetcherInfo::Item::BYPASS_CACHE,
fetcherInfo.get().items(0).action());
EXPECT_EQ(0u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(0u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
}
// Tests archive extraction without caching as a baseline for the
// subsequent test below.
TEST_F(FetcherCacheTest, LocalUncachedExtract)
{
startSlave();
driver->start();
const int index = 0;
CommandInfo::URI uri;
uri.set_value(archivePath);
uri.set_extract(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + ARCHIVED_COMMAND_NAME + " " + taskName(index));
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, index);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
EXPECT_TRUE(os::exists(
path::join(task->runDirectory.string(), ARCHIVE_NAME)));
EXPECT_FALSE(isExecutable(
path::join(task->runDirectory.string(), ARCHIVE_NAME)));
const string path =
path::join(task->runDirectory.string(), ARCHIVED_COMMAND_NAME);
EXPECT_TRUE(isExecutable(path));
EXPECT_TRUE(os::exists(path + taskName(index)));
EXPECT_EQ(0u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(0u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
}
// Tests archive extraction in combination with caching.
TEST_F(FetcherCacheTest, LocalCachedExtract)
{
startSlave();
driver->start();
for (size_t i = 0; i < 2; i++) {
CommandInfo::URI uri;
uri.set_value(archivePath);
uri.set_extract(true);
uri.set_cache(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + ARCHIVED_COMMAND_NAME + " " + taskName(i));
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, i);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
EXPECT_FALSE(os::exists(
path::join(task->runDirectory.string(), ARCHIVE_NAME)));
const string path =
path::join(task->runDirectory.string(), ARCHIVED_COMMAND_NAME);
EXPECT_TRUE(isExecutable(path));
EXPECT_TRUE(os::exists(path + taskName(i)));
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
}
}
class FetcherCacheHttpTest : public FetcherCacheTest
{
public:
// A minimal HTTP server (NOTE: not written as an actor, but this is
// deprecated, see below) just reusing what is already implemented
// somewhere to serve some HTTP requests for file downloads. Plus
// counting how many requests are made. Plus the ability to pause
// answering requests, stalling them.
//
// TODO(bernd-mesos): This class follows a dangerous style of mixing
// actors and non-actors, DO NOT REPLICATE. Ultimately we want to
// replace this with a generic HTTP server that can be used by other
// tests as well and enables things like pausing requests,
// manipulating requests, mocking, etc.
class HttpServer : public Process<HttpServer>
{
public:
public:
HttpServer(const string& _commandPath, const string& _archivePath)
: countRequests(0),
countCommandRequests(0),
countArchiveRequests(0),
commandPath(_commandPath),
archivePath(_archivePath)
{
CHECK(!_commandPath.empty());
CHECK(!_archivePath.empty());
}
virtual void initialize()
{
provide(COMMAND_NAME, commandPath);
provide(ARCHIVE_NAME, archivePath);
}
string url()
{
return "http://" + stringify(self().address) + "/" + self().id + "/";
}
// Stalls the execution of future HTTP requests inside visit().
void pause()
{
// If there is no latch or if the existing latch has already been
// triggered, create a new latch.
if (latch.get() == nullptr || latch->await(Duration::min())) {
latch.reset(new Latch());
}
}
void resume()
{
if (latch.get() != nullptr) {
latch->trigger();
}
}
virtual void visit(const HttpEvent& event)
{
if (latch.get() != nullptr) {
latch->await();
}
countRequests++;
if (strings::contains(event.request->url.path, COMMAND_NAME)) {
countCommandRequests++;
}
if (strings::contains(event.request->url.path, ARCHIVE_NAME)) {
countArchiveRequests++;
}
ProcessBase::visit(event);
}
void resetCounts()
{
countRequests = 0;
countCommandRequests = 0;
countArchiveRequests = 0;
}
size_t countRequests;
size_t countCommandRequests;
size_t countArchiveRequests;
private:
const string commandPath;
const string archivePath;
Owned<Latch> latch;
};
virtual void SetUp()
{
FetcherCacheTest::SetUp();
httpServer = new HttpServer(commandPath, archivePath);
spawn(httpServer);
}
virtual void TearDown()
{
terminate(httpServer);
wait(httpServer);
delete httpServer;
FetcherCacheTest::TearDown();
}
HttpServer* httpServer;
};
// Tests fetching via HTTP with caching. Only one download must
// occur. Fetching is serialized, to cover code areas without
// overlapping/concurrent fetch attempts.
TEST_F(FetcherCacheHttpTest, HttpCachedSerialized)
{
startSlave();
driver->start();
for (size_t i = 0; i < 3; i++) {
CommandInfo::URI uri;
uri.set_value(httpServer->url() + COMMAND_NAME);
uri.set_executable(true);
uri.set_cache(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + COMMAND_NAME + " " + taskName(i));
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, i);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
const string path =
path::join(task->runDirectory.string(), COMMAND_NAME);
EXPECT_TRUE(isExecutable(path));
EXPECT_TRUE(os::exists(path + taskName(i)));
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
// 2 requests: 1 for content-length, 1 for download.
EXPECT_EQ(2u, httpServer->countCommandRequests);
}
}
// Tests multiple concurrent fetching efforts that require some
// concurrency control. One task must "win" and perform the size
// and download request for the URI alone. The others must reuse
// the result.
TEST_F(FetcherCacheHttpTest, HttpCachedConcurrent)
{
startSlave();
driver->start();
// Causes fetch contention. No task can run yet until resume().
httpServer->pause();
vector<CommandInfo> commandInfos;
const size_t countTasks = 5;
for (size_t i = 0; i < countTasks; i++) {
CommandInfo::URI uri0;
uri0.set_value(httpServer->url() + COMMAND_NAME);
uri0.set_executable(true);
uri0.set_cache(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + COMMAND_NAME + " " + taskName(i));
commandInfo.add_uris()->CopyFrom(uri0);
// Not always caching this URI causes that it will be downloaded
// some of the time. Thus we exercise code paths that eagerly fetch
// new assets while waiting for pending downloads of cached assets
// as well as code paths where no downloading occurs at all.
if (i % 2 == 1) {
CommandInfo::URI uri1;
uri1.set_value(httpServer->url() + ARCHIVE_NAME);
commandInfo.add_uris()->CopyFrom(uri1);
}
commandInfos.push_back(commandInfo);
}
Try<vector<Task>> tasks = launchTasks(commandInfos);
ASSERT_SOME(tasks);
ASSERT_EQ(countTasks, tasks.get().size());
// Having paused the HTTP server, ensure that FetcherProcess::_fetch()
// has been called for each task, which means that all tasks are competing
// for downloading the same URIs.
foreach (const Owned<Promise<Nothing>>& waypoint, fetchContentionWaypoints) {
AWAIT(waypoint->future());
}
// Now let the tasks run.
httpServer->resume();
AWAIT_READY(awaitFinished(tasks.get()));
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
// HTTP requests regarding the archive asset as follows. Archive
// "content-length" requests: 1, archive file downloads: 2.
EXPECT_EQ(2u, httpServer->countCommandRequests);
// HTTP requests regarding the command asset as follows. Command
// "content-length" requests: 0, command file downloads: 2.
EXPECT_EQ(2u, httpServer->countArchiveRequests);
for (size_t i = 0; i < countTasks; i++) {
EXPECT_EQ(i % 2 == 1, os::exists(
path::join(tasks->at(i).runDirectory.string(), ARCHIVE_NAME)));
EXPECT_TRUE(isExecutable(
path::join(tasks->at(i).runDirectory.string(), COMMAND_NAME)));
EXPECT_TRUE(os::exists(
path::join(tasks->at(i).runDirectory.string(),
COMMAND_NAME + taskName(i))));
}
}
// Tests using multiple URIs per command, variations of caching,
// setting the executable flag, and archive extraction.
TEST_F(FetcherCacheHttpTest, HttpMixed)
{
startSlave();
driver->start();
// Causes fetch contention. No task can run yet until resume().
httpServer->pause();
vector<CommandInfo> commandInfos;
// Task 0.
CommandInfo::URI uri00;
uri00.set_value(httpServer->url() + ARCHIVE_NAME);
uri00.set_cache(true);
uri00.set_extract(false);
uri00.set_executable(false);
CommandInfo::URI uri01;
uri01.set_value(httpServer->url() + COMMAND_NAME);
uri01.set_extract(false);
uri01.set_executable(true);
CommandInfo commandInfo0;
commandInfo0.set_value("./" + COMMAND_NAME + " " + taskName(0));
commandInfo0.add_uris()->CopyFrom(uri00);
commandInfo0.add_uris()->CopyFrom(uri01);
commandInfos.push_back(commandInfo0);
// Task 1.
CommandInfo::URI uri10;
uri10.set_value(httpServer->url() + ARCHIVE_NAME);
uri10.set_extract(true);
uri10.set_executable(false);
CommandInfo::URI uri11;
uri11.set_value(httpServer->url() + COMMAND_NAME);
uri11.set_extract(true);
uri11.set_executable(false);
CommandInfo commandInfo1;
commandInfo1.set_value("./" + ARCHIVED_COMMAND_NAME + " " + taskName(1));
commandInfo1.add_uris()->CopyFrom(uri10);
commandInfo1.add_uris()->CopyFrom(uri11);
commandInfos.push_back(commandInfo1);
// Task 2.
CommandInfo::URI uri20;
uri20.set_value(httpServer->url() + ARCHIVE_NAME);
uri20.set_cache(true);
uri20.set_extract(true);
uri20.set_executable(false);
CommandInfo::URI uri21;
uri21.set_value(httpServer->url() + COMMAND_NAME);
uri21.set_extract(false);
uri21.set_executable(false);
CommandInfo commandInfo2;
commandInfo2.set_value("./" + ARCHIVED_COMMAND_NAME + " " + taskName(2));
commandInfo2.add_uris()->CopyFrom(uri20);
commandInfo2.add_uris()->CopyFrom(uri21);
commandInfos.push_back(commandInfo2);
Try<vector<Task>> tasks = launchTasks(commandInfos);
ASSERT_SOME(tasks);
ASSERT_EQ(3u, tasks.get().size());
// Having paused the HTTP server, ensure that FetcherProcess::_fetch()
// has been called for each task, which means that all tasks are competing
// for downloading the same URIs.
foreach (const Owned<Promise<Nothing>>& waypoint, fetchContentionWaypoints) {
AWAIT(waypoint->future());
}
// Now let the tasks run.
httpServer->resume();
AWAIT_READY(awaitFinished(tasks.get()));
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
// HTTP requests regarding the command asset as follows. Command
// "content-length" requests: 0, command file downloads: 3.
EXPECT_EQ(3u, httpServer->countCommandRequests);
// HTTP requests regarding the archive asset as follows. Archive
// "content-length" requests: 1, archive file downloads: 2.
EXPECT_EQ(3u, httpServer->countArchiveRequests);
// Task 0.
EXPECT_FALSE(isExecutable(
path::join(tasks->at(0).runDirectory.string(), ARCHIVE_NAME)));
EXPECT_FALSE(os::exists(
path::join(tasks->at(0).runDirectory.string(), ARCHIVED_COMMAND_NAME)));
EXPECT_TRUE(isExecutable(
path::join(tasks->at(0).runDirectory.string(), COMMAND_NAME)));
EXPECT_TRUE(os::exists(
path::join(tasks->at(0).runDirectory.string(),
COMMAND_NAME + taskName(0))));
// Task 1.
EXPECT_FALSE(isExecutable(path::join(
tasks->at(1).runDirectory.string(),
ARCHIVE_NAME)));
EXPECT_TRUE(isExecutable(path::join(
tasks->at(1).runDirectory.string(),
ARCHIVED_COMMAND_NAME)));
EXPECT_TRUE(os::exists(path::join(
tasks->at(1).runDirectory.string(),
ARCHIVED_COMMAND_NAME + taskName(1))));
EXPECT_FALSE(isExecutable(path::join(
tasks->at(1).runDirectory.string(),
COMMAND_NAME)));
// Task 2.
EXPECT_FALSE(os::exists(path::join(
tasks->at(2).runDirectory.string(),
ARCHIVE_NAME)));
EXPECT_TRUE(isExecutable(path::join(
tasks->at(2).runDirectory.string(),
ARCHIVED_COMMAND_NAME)));
EXPECT_TRUE(os::exists(path::join(
tasks->at(2).runDirectory.string(),
ARCHIVED_COMMAND_NAME + taskName(2))));
EXPECT_FALSE(isExecutable(path::join(
tasks->at(2).runDirectory.string(),
COMMAND_NAME)));
}
// Tests slave recovery of the fetcher cache. The cache must be
// wiped clean on recovery, causing renewed downloads.
// TODO(bernd-mesos): Debug flaky behavior reported in MESOS-2871,
// then reenable this test.
TEST_F(FetcherCacheHttpTest, DISABLED_HttpCachedRecovery)
{
startSlave();
driver->start();
for (size_t i = 0; i < 3; i++) {
CommandInfo::URI uri;
uri.set_value(httpServer->url() + COMMAND_NAME);
uri.set_executable(true);
uri.set_cache(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + COMMAND_NAME + " " + taskName(i));
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, i);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
const string path = path::join(task->runDirectory.string(), COMMAND_NAME);
EXPECT_TRUE(isExecutable(path));
EXPECT_TRUE(os::exists(path + taskName(i)));
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
// content-length requests: 1
// downloads: 1
EXPECT_EQ(2u, httpServer->countCommandRequests);
}
// Stop and destroy the current slave.
slave->terminate();
// Start over.
httpServer->resetCounts();
// Don't reuse the old fetcher, which has stale state after
// stopping the slave.
Fetcher fetcher2;
Try<MesosContainerizer*> _containerizer =
MesosContainerizer::create(flags, true, &fetcher2);
ASSERT_SOME(_containerizer);
containerizer.reset(_containerizer.get());
// Set up so we can wait until the new slave updates the container's
// resources (this occurs after the executor has re-registered).
Future<Nothing> update =
FUTURE_DISPATCH(_, &MesosContainerizerProcess::update);
Try<Owned<cluster::Slave>> _slave =
StartSlave(detector.get(), containerizer.get(), flags);
ASSERT_SOME(_slave);
slave = _slave.get();
// Wait until the containerizer is updated.
AWAIT_READY(update);
// Recovery must have cleaned the cache by now.
EXPECT_FALSE(os::exists(cacheDirectory));
// Repeat of the above to see if it works the same.
for (size_t i = 0; i < 3; i++) {
CommandInfo::URI uri;
uri.set_value(httpServer->url() + COMMAND_NAME);
uri.set_executable(true);
uri.set_cache(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + COMMAND_NAME + " " + taskName(i));
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, i);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
const string path =
path::join(task->runDirectory.string(), COMMAND_NAME);
EXPECT_TRUE(isExecutable(path));
EXPECT_TRUE(os::exists(path + taskName(i)));
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
// content-length requests: 1
// downloads: 1
EXPECT_EQ(2u, httpServer->countCommandRequests);
}
}
// Tests cache eviction. Limits the available cache space then fetches
// more task scripts than fit into the cache and runs them all. We
// observe how the number of cache files rises and then stays constant.
TEST_F(FetcherCacheTest, SimpleEviction)
{
const size_t countCacheEntries = 2;
// Let only the first 'countCacheEntries' downloads fit in the cache.
flags.fetcher_cache_size = COMMAND_SCRIPT.size() * countCacheEntries;
startSlave();
driver->start();
for (size_t i = 0; i < countCacheEntries + 2; i++) {
string commandFilename = "cmd" + stringify(i);
string command = commandFilename + " " + taskName(i);
commandPath = path::join(assetsDirectory, commandFilename);
ASSERT_SOME(os::write(commandPath, COMMAND_SCRIPT));
CommandInfo::URI uri;
uri.set_value(commandPath);
uri.set_executable(true);
uri.set_cache(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + command);
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, i);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
// Check that the task succeeded.
EXPECT_TRUE(isExecutable(
path::join(task->runDirectory.string(), commandFilename)));
EXPECT_TRUE(os::exists(
path::join(task->runDirectory.string(), COMMAND_NAME + taskName(i))));
if (i < countCacheEntries) {
EXPECT_EQ(i + 1, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(i+1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
} else {
EXPECT_EQ(countCacheEntries, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(countCacheEntries,
fetcherProcess->cacheFiles(slaveId, flags).get().size());
}
}
}
// Tests cache eviction fallback to bypassing the cache. A first task
// runs normally. Then a second succeeds using eviction. Then a third
// task fails to evict, but still gets executed bypassing the cache.
TEST_F(FetcherCacheTest, FallbackFromEviction)
{
// The size by which every task's URI download is going to be larger
// than the previous one.
const size_t growth = 10;
// Let only the first two downloads fit into the cache, one at a time,
// the second evicting the first. The third file won't fit any more,
// being larger than the entire cache.
flags.fetcher_cache_size = COMMAND_SCRIPT.size() + growth;
startSlave();
driver->start();
// We'll run 3 tasks and these are the task completion futures to wait
// for each time.
Future<FetcherInfo> fetcherInfo0;
Future<FetcherInfo> fetcherInfo1;
Future<FetcherInfo> fetcherInfo2;
EXPECT_CALL(*fetcherProcess, run(_, _, _, _, _))
.WillOnce(DoAll(FutureArg<3>(&fetcherInfo0),
Invoke(fetcherProcess,
&MockFetcherProcess::unmocked_run)))
.WillOnce(DoAll(FutureArg<3>(&fetcherInfo1),
Invoke(fetcherProcess,
&MockFetcherProcess::unmocked_run)))
.WillOnce(DoAll(FutureArg<3>(&fetcherInfo2),
Invoke(fetcherProcess,
&MockFetcherProcess::unmocked_run)));
// Task 0:
const string commandFilename0 = "cmd0";
const string command0 = commandFilename0 + " " + taskName(0);
commandPath = path::join(assetsDirectory, commandFilename0);
// Write the command into the script that gets fetched.
ASSERT_SOME(os::write(commandPath, COMMAND_SCRIPT));
CommandInfo::URI uri0;
uri0.set_value(commandPath);
uri0.set_executable(true);
uri0.set_cache(true);
CommandInfo commandInfo0;
commandInfo0.set_value("./" + command0);
commandInfo0.add_uris()->CopyFrom(uri0);
const Try<Task> task0 = launchTask(commandInfo0, 0);
ASSERT_SOME(task0) << task0.error();
AWAIT_READY(awaitFinished(task0.get()));
// Check that the task succeeded.
EXPECT_TRUE(isExecutable(
path::join(task0->runDirectory.string(), commandFilename0)));
EXPECT_TRUE(os::exists(
path::join(task0->runDirectory.string(), COMMAND_NAME + taskName(0))));
AWAIT_READY(fetcherInfo0);
ASSERT_EQ(1, fetcherInfo0.get().items_size());
EXPECT_EQ(FetcherInfo::Item::DOWNLOAD_AND_CACHE,
fetcherInfo0.get().items(0).action());
// We have put a file of size 'COMMAND_SCRIPT.size()' in the cache
// with space 'COMMAND_SCRIPT.size() + growth'. So we must have 'growth'
// space left.
ASSERT_EQ(Bytes(growth), fetcherProcess->availableCacheSpace());
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
// Task 1:
const string commandFilename1 = "cmd1";
const string command1 = commandFilename1 + " " + taskName(1);
commandPath = path::join(assetsDirectory, commandFilename1);
// Write the command into the script that gets fetched. Add 'growth'
// extra characters so the cache will fill up to the last byte.
ASSERT_SOME(os::write(
commandPath,
COMMAND_SCRIPT + string(growth, '\n')));
CommandInfo::URI uri1;
uri1.set_value(commandPath);
uri1.set_executable(true);
uri1.set_cache(true);
CommandInfo commandInfo1;
commandInfo1.set_value("./" + command1);
commandInfo1.add_uris()->CopyFrom(uri1);
const Try<Task> task1 = launchTask(commandInfo1, 1);
ASSERT_SOME(task1) << task1.error();
AWAIT_READY(awaitFinished(task1.get()));
// Check that the task succeeded.
EXPECT_TRUE(isExecutable(
path::join(task1->runDirectory.string(), commandFilename1)));
EXPECT_TRUE(os::exists(
path::join(task1->runDirectory.string(), COMMAND_NAME + taskName(1))));
AWAIT_READY(fetcherInfo1);
ASSERT_EQ(1, fetcherInfo1.get().items_size());
EXPECT_EQ(FetcherInfo::Item::DOWNLOAD_AND_CACHE,
fetcherInfo1.get().items(0).action());
// The cache must now be full.
ASSERT_EQ(Bytes(0u), fetcherProcess->availableCacheSpace());
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
// Task 2:
const string commandFilename2 = "cmd2";
const string command2 = commandFilename2 + " " + taskName(2);
commandPath = path::join(assetsDirectory, commandFilename2);
// Write the command into the script that gets fetched. Add
// '2 * growth' now. Thus the file will be so big that it will not
// fit into the cache any more.
ASSERT_SOME(os::write(
commandPath,
COMMAND_SCRIPT + string(2 * growth, '\n')));
CommandInfo::URI uri2;
uri2.set_value(commandPath);
uri2.set_executable(true);
uri2.set_cache(true);
CommandInfo commandInfo2;
commandInfo2.set_value("./" + command2);
commandInfo2.add_uris()->CopyFrom(uri2);
const Try<Task> task2 = launchTask(commandInfo2, 2);
ASSERT_SOME(task2) << task2.error();
AWAIT_READY(awaitFinished(task2.get()));
// Check that the task succeeded.
EXPECT_TRUE(isExecutable(
path::join(task2->runDirectory.string(), commandFilename2)));
EXPECT_TRUE(os::exists(
path::join(task2->runDirectory.string(), COMMAND_NAME + taskName(2))));
AWAIT_READY(fetcherInfo2);
ASSERT_EQ(1, fetcherInfo2.get().items_size());
EXPECT_EQ(FetcherInfo::Item::BYPASS_CACHE,
fetcherInfo2.get().items(0).action());
EXPECT_EQ(1u, fetcherProcess->cacheSize());
ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
EXPECT_EQ(1u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
}
// Tests LRU cache eviction strategy.
TEST_F(FetcherCacheTest, RemoveLRUCacheEntries)
{
// Let only two downloads fit in the cache.
flags.fetcher_cache_size = COMMAND_SCRIPT.size() * 2;
startSlave();
driver->start();
// Start commands using a pattern that will fill the cache with two entries
// and request the second entry again. The first entry is then the LRU.
// Adding a new entry should therefore evict the first entry.
vector<int> commandCreationPattern;
commandCreationPattern.push_back(0);
commandCreationPattern.push_back(1);
commandCreationPattern.push_back(1);
commandCreationPattern.push_back(2);
int taskIndex = 0;
// Fill up the cache
foreach (const int i, commandCreationPattern) {
string commandFilename = "cmd" + stringify(i);
string command = commandFilename + " " + taskName(taskIndex);
commandPath = path::join(assetsDirectory, commandFilename);
ASSERT_SOME(os::write(commandPath, COMMAND_SCRIPT));
CommandInfo::URI uri;
uri.set_value(commandPath);
uri.set_executable(true);
uri.set_cache(true);
CommandInfo commandInfo;
commandInfo.set_value("./" + command);
commandInfo.add_uris()->CopyFrom(uri);
const Try<Task> task = launchTask(commandInfo, taskIndex);
ASSERT_SOME(task);
AWAIT_READY(awaitFinished(task.get()));
// Check that the task succeeded.
EXPECT_TRUE(isExecutable(
path::join(task->runDirectory.string(), commandFilename)));
EXPECT_TRUE(os::exists(path::join(task->runDirectory.string(),
COMMAND_NAME + taskName(taskIndex))));
++taskIndex;
}
EXPECT_EQ(2u, fetcherProcess->cacheSize());
// FetcherProcess::cacheFiles returns all cache files that are in the cache
// directory. We expect cmd1 and cmd2 to be there, cmd0 should have been
// evicted.
Try<list<Path>> cacheFiles = fetcherProcess->cacheFiles(slaveId, flags);
ASSERT_SOME(cacheFiles);
bool cmd1Found = false;
bool cmd2Found = false;
foreach (const Path& cacheFile, cacheFiles.get()) {
if (strings::contains(cacheFile.basename(), "cmd1")) {
cmd1Found = true;
}
if (strings::contains(cacheFile.basename(), "cmd2")) {
cmd2Found = true;
}
}
EXPECT_TRUE(cmd1Found);
EXPECT_TRUE(cmd2Found);
}
} // namespace tests {
} // namespace internal {
} // namespace mesos {
| 30.651964
| 80
| 0.704114
|
ruhip
|
7dff539671f31fec0fd2f5d8f6be2507674a24aa
| 24,782
|
cpp
|
C++
|
gtaRenderHook/SampHaxx.cpp
|
petrgeorgievsky/gtaRenderHook
|
124358410c3edca56de26381e239ca29aa6dc1cc
|
[
"MIT"
] | 232
|
2016-08-29T00:33:32.000Z
|
2022-03-29T22:39:51.000Z
|
gtaRenderHook/SampHaxx.cpp
|
petrgeorgievsky/gtaRenderHook
|
124358410c3edca56de26381e239ca29aa6dc1cc
|
[
"MIT"
] | 10
|
2021-01-02T12:40:49.000Z
|
2021-08-31T06:31:04.000Z
|
gtaRenderHook/SampHaxx.cpp
|
petrgeorgievsky/gtaRenderHook
|
124358410c3edca56de26381e239ca29aa6dc1cc
|
[
"MIT"
] | 40
|
2017-12-18T06:14:39.000Z
|
2022-01-29T16:35:23.000Z
|
#include "stdafx.h"
#include <d3d9types.h>
#include "SampHaxx.h"
class IDirect3D9Wrapper : public IDirect3D9
{
// Унаследовано через IDirect3D9
virtual HRESULT __stdcall QueryInterface( REFIID riid,
void **ppvObj ) override
{
return E_NOTIMPL;
}
virtual ULONG __stdcall AddRef( void ) override { return 0; }
virtual ULONG __stdcall Release( void ) override { return 0; }
virtual HRESULT __stdcall RegisterSoftwareDevice(
void *pInitializeFunction ) override
{
return E_NOTIMPL;
}
virtual UINT __stdcall GetAdapterCount( void ) override { return 0; }
virtual HRESULT __stdcall GetAdapterIdentifier(
UINT Adapter, DWORD Flags,
D3DADAPTER_IDENTIFIER9 *pIdentifier ) override
{
return E_NOTIMPL;
}
virtual UINT __stdcall GetAdapterModeCount( UINT Adapter,
D3DFORMAT Format ) override
{
return 0;
}
virtual HRESULT __stdcall EnumAdapterModes( UINT Adapter, D3DFORMAT Format,
UINT Mode,
D3DDISPLAYMODE *pMode ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetAdapterDisplayMode(
UINT Adapter, D3DDISPLAYMODE *pMode ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CheckDeviceType( UINT Adapter, D3DDEVTYPE DevType,
D3DFORMAT AdapterFormat,
D3DFORMAT BackBufferFormat,
BOOL bWindowed ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CheckDeviceFormat(
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat ) override
{
//if ( CheckFormat == Ada)
return D3D_OK;
//return E_NOTIMPL;
}
virtual HRESULT __stdcall CheckDeviceMultiSampleType(
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType,
DWORD *pQualityLevels ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CheckDepthStencilMatch(
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CheckDeviceFormatConversion(
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat,
D3DFORMAT TargetFormat ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetDeviceCaps( UINT Adapter,
D3DDEVTYPE DeviceType,
D3DCAPS9 * pCaps ) override
{
return E_NOTIMPL;
}
virtual HMONITOR __stdcall GetAdapterMonitor( UINT Adapter ) override
{
return HMONITOR();
}
virtual HRESULT __stdcall CreateDevice(
UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters,
IDirect3DDevice9 **ppReturnedDeviceInterface ) override
{
return E_NOTIMPL;
}
};
class IDirect3DDevice9Wrapper : public IDirect3DDevice9
{
// Унаследовано через IDirect3DDevice9
virtual HRESULT __stdcall QueryInterface( REFIID riid,
void **ppvObj ) override
{
return E_NOTIMPL;
}
virtual ULONG __stdcall AddRef( void ) override { return 0; }
virtual ULONG __stdcall Release( void ) override { return 0; }
virtual HRESULT __stdcall TestCooperativeLevel( void ) override
{
return E_NOTIMPL;
}
virtual UINT __stdcall GetAvailableTextureMem( void ) override { return 0; }
virtual HRESULT __stdcall EvictManagedResources( void ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetDirect3D( IDirect3D9 **ppD3D9 ) override
{
*ppD3D9 = Wrapper<IDirect3D9Wrapper>::Inst().Get();
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetDeviceCaps( D3DCAPS9 *pCaps ) override
{
auto &caps = ( *pCaps );
caps = {};
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetDisplayMode( UINT iSwapChain,
D3DDISPLAYMODE *pMode ) override
{
auto &mode = *pMode;
mode.Width = 800;
mode.Height = 600;
mode.Format = D3DFORMAT::D3DFMT_A8R8G8B8;
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetCreationParameters(
D3DDEVICE_CREATION_PARAMETERS *pParameters ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetCursorProperties(
UINT XHotSpot, UINT YHotSpot,
IDirect3DSurface9 *pCursorBitmap ) override
{
return E_NOTIMPL;
}
virtual void __stdcall SetCursorPosition( int X, int Y,
DWORD Flags ) override
{
}
virtual BOOL __stdcall ShowCursor( BOOL bShow ) override { return 0; }
virtual HRESULT __stdcall CreateAdditionalSwapChain(
D3DPRESENT_PARAMETERS *pPresentationParameters,
IDirect3DSwapChain9 ** pSwapChain ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetSwapChain(
UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain ) override
{
return E_NOTIMPL;
}
virtual UINT __stdcall GetNumberOfSwapChains( void ) override { return 0; }
virtual HRESULT __stdcall Reset(
D3DPRESENT_PARAMETERS *pPresentationParameters ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall Present( const RECT * pSourceRect,
const RECT * pDestRect,
HWND hDestWindowOverride,
const RGNDATA *pDirtyRegion ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetBackBuffer(
UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type,
IDirect3DSurface9 **ppBackBuffer ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetRasterStatus(
UINT iSwapChain, D3DRASTER_STATUS *pRasterStatus ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetDialogBoxMode( BOOL bEnableDialogs ) override
{
return E_NOTIMPL;
}
virtual void __stdcall SetGammaRamp( UINT iSwapChain, DWORD Flags,
const D3DGAMMARAMP *pRamp ) override
{
}
virtual void __stdcall GetGammaRamp( UINT iSwapChain,
D3DGAMMARAMP *pRamp ) override
{
}
virtual HRESULT __stdcall CreateTexture( UINT Width, UINT Height,
UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
IDirect3DTexture9 **ppTexture,
HANDLE *pSharedHandle ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateVolumeTexture(
UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage,
D3DFORMAT Format, D3DPOOL Pool,
IDirect3DVolumeTexture9 **ppVolumeTexture,
HANDLE * pSharedHandle ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateCubeTexture(
UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format,
D3DPOOL Pool, IDirect3DCubeTexture9 **ppCubeTexture,
HANDLE *pSharedHandle ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateVertexBuffer(
UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool,
IDirect3DVertexBuffer9 **ppVertexBuffer,
HANDLE * pSharedHandle ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateIndexBuffer(
UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
IDirect3DIndexBuffer9 **ppIndexBuffer, HANDLE *pSharedHandle ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateRenderTarget(
UINT Width, UINT Height, D3DFORMAT Format,
D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,
BOOL Lockable, IDirect3DSurface9 **ppSurface,
HANDLE *pSharedHandle ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateDepthStencilSurface(
UINT Width, UINT Height, D3DFORMAT Format,
D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard,
IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall UpdateSurface(
IDirect3DSurface9 *pSourceSurface, const RECT *pSourceRect,
IDirect3DSurface9 *pDestinationSurface,
const POINT * pDestPoint ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall UpdateTexture(
IDirect3DBaseTexture9 *pSourceTexture,
IDirect3DBaseTexture9 *pDestinationTexture ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetRenderTargetData(
IDirect3DSurface9 *pRenderTarget,
IDirect3DSurface9 *pDestSurface ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetFrontBufferData(
UINT iSwapChain, IDirect3DSurface9 *pDestSurface ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall StretchRect(
IDirect3DSurface9 *pSourceSurface, const RECT *pSourceRect,
IDirect3DSurface9 *pDestSurface, const RECT *pDestRect,
D3DTEXTUREFILTERTYPE Filter ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall ColorFill( IDirect3DSurface9 *pSurface,
const RECT * pRect,
D3DCOLOR color ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateOffscreenPlainSurface(
UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool,
IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetRenderTarget(
DWORD RenderTargetIndex, IDirect3DSurface9 *pRenderTarget ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetRenderTarget(
DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetDepthStencilSurface(
IDirect3DSurface9 *pNewZStencil ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetDepthStencilSurface(
IDirect3DSurface9 **ppZStencilSurface ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall BeginScene( void ) override { return E_NOTIMPL; }
virtual HRESULT __stdcall EndScene( void ) override { return E_NOTIMPL; }
virtual HRESULT __stdcall Clear( DWORD Count, const D3DRECT *pRects,
DWORD Flags, D3DCOLOR Color, float Z,
DWORD Stencil ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetTransform( D3DTRANSFORMSTATETYPE State,
const D3DMATRIX *pMatrix ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetTransform( D3DTRANSFORMSTATETYPE State,
D3DMATRIX *pMatrix ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall MultiplyTransform( D3DTRANSFORMSTATETYPE,
const D3DMATRIX * ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetViewport(
const D3DVIEWPORT9 *pViewport ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetViewport( D3DVIEWPORT9 *pViewport ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetMaterial(
const D3DMATERIAL9 *pMaterial ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetMaterial( D3DMATERIAL9 *pMaterial ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetLight( DWORD Index,
const D3DLIGHT9 * ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetLight( DWORD Index, D3DLIGHT9 * ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall LightEnable( DWORD Index, BOOL Enable ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetLightEnable( DWORD Index,
BOOL *pEnable ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetClipPlane( DWORD Index,
const float *pPlane ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetClipPlane( DWORD Index,
float *pPlane ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetRenderState( D3DRENDERSTATETYPE State,
DWORD Value ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetRenderState( D3DRENDERSTATETYPE State,
DWORD *pValue ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateStateBlock(
D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9 **ppSB ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall BeginStateBlock( void ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall EndStateBlock(
IDirect3DStateBlock9 **ppSB ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetClipStatus(
const D3DCLIPSTATUS9 *pClipStatus ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetClipStatus(
D3DCLIPSTATUS9 *pClipStatus ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetTexture(
DWORD Stage, IDirect3DBaseTexture9 **ppTexture ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetTexture(
DWORD Stage, IDirect3DBaseTexture9 *pTexture ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetTextureStageState(
DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetTextureStageState(
DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetSamplerState( DWORD Sampler,
D3DSAMPLERSTATETYPE Type,
DWORD *pValue ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetSamplerState( DWORD Sampler,
D3DSAMPLERSTATETYPE Type,
DWORD Value ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall ValidateDevice( DWORD *pNumPasses ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetPaletteEntries(
UINT PaletteNumber, const PALETTEENTRY *pEntries ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetPaletteEntries(
UINT PaletteNumber, PALETTEENTRY *pEntries ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetCurrentTexturePalette(
UINT PaletteNumber ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetCurrentTexturePalette(
UINT *PaletteNumber ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetScissorRect( const RECT *pRect ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetScissorRect( RECT *pRect ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetSoftwareVertexProcessing(
BOOL bSoftware ) override
{
return E_NOTIMPL;
}
virtual BOOL __stdcall GetSoftwareVertexProcessing( void ) override
{
return 0;
}
virtual HRESULT __stdcall SetNPatchMode( float nSegments ) override
{
return E_NOTIMPL;
}
virtual float __stdcall GetNPatchMode( void ) override { return 0.0f; }
virtual HRESULT __stdcall DrawPrimitive( D3DPRIMITIVETYPE PrimitiveType,
UINT StartVertex,
UINT PrimitiveCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall DrawIndexedPrimitive(
D3DPRIMITIVETYPE, INT BaseVertexIndex, UINT MinVertexIndex,
UINT NumVertices, UINT startIndex, UINT primCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall DrawPrimitiveUP(
D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,
const void *pVertexStreamZeroData,
UINT VertexStreamZeroStride ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall DrawIndexedPrimitiveUP(
D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices,
UINT PrimitiveCount, const void *pIndexData, D3DFORMAT IndexDataFormat,
const void *pVertexStreamZeroData,
UINT VertexStreamZeroStride ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall ProcessVertices(
UINT SrcStartIndex, UINT DestIndex, UINT VertexCount,
IDirect3DVertexBuffer9 * pDestBuffer,
IDirect3DVertexDeclaration9 *pVertexDecl, DWORD Flags ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateVertexDeclaration(
const D3DVERTEXELEMENT9 * pVertexElements,
IDirect3DVertexDeclaration9 **ppDecl ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetVertexDeclaration(
IDirect3DVertexDeclaration9 *pDecl ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetVertexDeclaration(
IDirect3DVertexDeclaration9 **ppDecl ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetFVF( DWORD FVF ) override { return E_NOTIMPL; }
virtual HRESULT __stdcall GetFVF( DWORD *pFVF ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateVertexShader(
const DWORD *pFunction, IDirect3DVertexShader9 **ppShader ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetVertexShader(
IDirect3DVertexShader9 *pShader ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetVertexShader(
IDirect3DVertexShader9 **ppShader ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetVertexShaderConstantF(
UINT StartRegister, const float *pConstantData,
UINT Vector4fCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetVertexShaderConstantF(
UINT StartRegister, float *pConstantData, UINT Vector4fCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetVertexShaderConstantI(
UINT StartRegister, const int *pConstantData,
UINT Vector4iCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetVertexShaderConstantI(
UINT StartRegister, int *pConstantData, UINT Vector4iCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetVertexShaderConstantB(
UINT StartRegister, const BOOL *pConstantData, UINT BoolCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetVertexShaderConstantB(
UINT StartRegister, BOOL *pConstantData, UINT BoolCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetStreamSource(
UINT StreamNumber, IDirect3DVertexBuffer9 *pStreamData,
UINT OffsetInBytes, UINT Stride ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetStreamSource(
UINT StreamNumber, IDirect3DVertexBuffer9 **ppStreamData,
UINT *pOffsetInBytes, UINT *pStride ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetStreamSourceFreq( UINT StreamNumber,
UINT Setting ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetStreamSourceFreq( UINT StreamNumber,
UINT *pSetting ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetIndices(
IDirect3DIndexBuffer9 *pIndexData ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetIndices(
IDirect3DIndexBuffer9 **ppIndexData ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreatePixelShader(
const DWORD *pFunction, IDirect3DPixelShader9 **ppShader ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetPixelShader(
IDirect3DPixelShader9 *pShader ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetPixelShader(
IDirect3DPixelShader9 **ppShader ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetPixelShaderConstantF(
UINT StartRegister, const float *pConstantData,
UINT Vector4fCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetPixelShaderConstantF(
UINT StartRegister, float *pConstantData, UINT Vector4fCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetPixelShaderConstantI(
UINT StartRegister, const int *pConstantData,
UINT Vector4iCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetPixelShaderConstantI(
UINT StartRegister, int *pConstantData, UINT Vector4iCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall SetPixelShaderConstantB(
UINT StartRegister, const BOOL *pConstantData, UINT BoolCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall GetPixelShaderConstantB( UINT StartRegister,
BOOL *pConstantData,
UINT BoolCount ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall DrawRectPatch(
UINT Handle, const float *pNumSegs,
const D3DRECTPATCH_INFO *pRectPatchInfo ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall DrawTriPatch(
UINT Handle, const float *pNumSegs,
const D3DTRIPATCH_INFO *pTriPatchInfo ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall DeletePatch( UINT Handle ) override
{
return E_NOTIMPL;
}
virtual HRESULT __stdcall CreateQuery( D3DQUERYTYPE Type,
IDirect3DQuery9 **ppQuery ) override
{
return E_NOTIMPL;
}
};
template <>
Wrapper<IDirect3DDevice9Wrapper> &Wrapper<IDirect3DDevice9Wrapper>::Inst()
{
static Wrapper<IDirect3DDevice9Wrapper> w;
return w;
}
template<>
Wrapper<IDirect3DDevice9Wrapper>::Wrapper()
{
mData = new IDirect3DDevice9Wrapper();
}
template <> Wrapper<IDirect3DDevice9Wrapper>::~Wrapper() { delete mData; }
template <> Wrapper<IDirect3D9Wrapper>::Wrapper() { mData = new IDirect3D9Wrapper(); }
template <> Wrapper<IDirect3D9Wrapper>::~Wrapper() { delete mData; }
template <> Wrapper<IDirect3D9Wrapper> &Wrapper<IDirect3D9Wrapper>::Inst()
{
static Wrapper<IDirect3D9Wrapper> w;
return w;
}
void SampHaxx::Patch()
{
static IDirect3DDevice9 *&dev_ptr =
*reinterpret_cast<IDirect3DDevice9 **>( 0xC97C28 );
dev_ptr = reinterpret_cast<IDirect3DDevice9 *>(
Wrapper<IDirect3DDevice9Wrapper>::Inst().Get() );
//IDirect3D9Wrapper
}
| 33.855191
| 86
| 0.624405
|
petrgeorgievsky
|
7dffe85dfff785eab7570854f253bef9c5cafc39
| 5,395
|
hpp
|
C++
|
libhail/src/hail/query/backend/stype.hpp
|
MariusDanner/hail
|
5ca0305f8243b5888931b1afaa1fbfb617dee097
|
[
"MIT"
] | null | null | null |
libhail/src/hail/query/backend/stype.hpp
|
MariusDanner/hail
|
5ca0305f8243b5888931b1afaa1fbfb617dee097
|
[
"MIT"
] | null | null | null |
libhail/src/hail/query/backend/stype.hpp
|
MariusDanner/hail
|
5ca0305f8243b5888931b1afaa1fbfb617dee097
|
[
"MIT"
] | null | null | null |
#ifndef HAIL_QUERY_BACKEND_STYPE_HPP_INCLUDED
#define HAIL_QUERY_BACKEND_STYPE_HPP_INCLUDED 1
#include <llvm/IR/Value.h>
#include <hail/hash.hpp>
#include <hail/tunion.hpp>
#include <hail/type.hpp>
#include <vector>
namespace hail {
class EmitType;
class SValue;
class EmitValue;
class CompileFunction;
class MemorySize;
class VTuple;
enum class PrimitiveType {
VOID,
INT8,
INT32,
INT64,
FLOAT32,
FLOAT64,
POINTER
};
class STypeContextToken {
friend class STypeContext;
STypeContextToken() {}
};
class SType {
public:
using BaseType = SType;
enum class Tag {
BOOL,
INT32,
INT64,
FLOAT32,
FLOAT64,
CANONICALTUPLE,
STACKTUPLE
};
const Tag tag;
const Type *const type;
SType(Tag tag, const Type *type) : tag(tag), type(type) {}
virtual ~SType();
// FIXME make return value an iterator? A generator!
void get_constituent_types(std::vector<PrimitiveType> &constituent_types) const;
SValue *from_llvm_values(const std::vector<llvm::Value *> &llvm_values, size_t i) const;
const SValue *load_from_address(CompileFunction &cf, llvm::Value *address) const;
const SValue *construct_from_value(CompileFunction &cf, const SValue *from) const;
void construct_at_address_from_value(CompileFunction &cf, llvm::Value *address, const SValue *from) const;
MemorySize get_memory_size() const;
template<typename F> auto dispatch(F f) const;
};
class MemorySize {
public:
const size_t byte_size;
const size_t alignment;
public:
MemorySize(size_t byte_size, size_t alignment)
: byte_size(byte_size), alignment(alignment) {}
};
template<typename T> inline constexpr bool
is_heap_stype() {
static_assert(std::is_base_of_v<SType, T>);
return std::is_base_of_v<MemorySize, T>;
}
class SBool : public SType, public MemorySize {
public:
static bool is_instance_tag(Tag tag) { return tag == SType::Tag::BOOL; }
SBool(STypeContextToken, const Type *type);
};
class SInt32 : public SType, public MemorySize {
public:
static bool is_instance_tag(Tag tag) { return tag == SType::Tag::INT32; }
SInt32(STypeContextToken, const Type *type);
};
class SInt64 : public SType, public MemorySize {
public:
static bool is_instance_tag(Tag tag) { return tag == SType::Tag::INT64; }
SInt64(STypeContextToken, const Type *type);
};
class SFloat32 : public SType, public MemorySize {
public:
static bool is_instance_tag(Tag tag) { return tag == SType::Tag::FLOAT32; }
SFloat32(STypeContextToken, const Type *type);
};
class SFloat64 : public SType, public MemorySize {
public:
static bool is_instance_tag(Tag tag) { return tag == SType::Tag::FLOAT64; }
SFloat64(STypeContextToken, const Type *type);
};
class SCanonicalTuple : public SType, public MemorySize {
public:
static bool is_instance_tag(Tag tag) { return tag == SType::Tag::CANONICALTUPLE; }
std::vector<EmitType> element_types;
std::vector<size_t> element_offsets;
SCanonicalTuple(STypeContextToken,
const Type *type,
std::vector<EmitType> element_types,
size_t byte_size,
size_t alignment,
std::vector<size_t> element_offsets);
void set_element_missing(CompileFunction &cf, llvm::Value *address, size_t i, bool missing) const;
};
class SStackTuple : public SType {
public:
static bool is_instance_tag(Tag tag) { return tag == SType::Tag::STACKTUPLE; }
std::vector<EmitType> element_types;
SStackTuple(STypeContextToken, const Type *type, std::vector<EmitType> element_types);
};
class EmitType {
public:
const SType *const stype;
EmitType(const SType *stype) : stype(stype) {}
bool operator==(EmitType that) const { return stype == that.stype; }
bool operator!=(EmitType that) const { return stype != that.stype; }
void get_constituent_types(std::vector<PrimitiveType> &constituent_types) const;
EmitValue from_llvm_values(const std::vector<llvm::Value *> &llvm_values, size_t i) const;
EmitValue make_na(CompileFunction &cf) const;
};
}
namespace std {
template<>
struct hash<hail::EmitType> {
size_t operator()(hail::EmitType emit_type) const {
return hash_value(emit_type.stype);
}
};
}
namespace hail {
class STypeContext {
TypeContext &tc;
ArenaAllocator arena;
std::unordered_map<std::vector<EmitType>, const SCanonicalTuple *> canonical_stuples;
std::unordered_map<std::vector<EmitType>, const SStackTuple *> stack_stuples;
public:
const SBool *const sbool;
const SInt32 *const sint32;
const SInt64 *const sint64;
const SFloat32 *const sfloat32;
const SFloat64 *const sfloat64;
STypeContext(HeapAllocator &heap, TypeContext &tc);
const SCanonicalTuple *canonical_stuple(const Type *type, const std::vector<EmitType> &element_types, const VTuple *vtuple);
const SStackTuple *stack_stuple(const Type *type, const std::vector<EmitType> &element_types);
EmitType emit_type_from(const VType *vtype);
const SType *stype_from(const VType *vtype);
};
template<typename F> auto
SType::dispatch(F f) const {
switch(tag) {
case Tag::BOOL: return f(cast<SBool>(this));
case Tag::INT32: return f(cast<SInt32>(this));
case Tag::INT64: return f(cast<SInt64>(this));
case Tag::FLOAT32: return f(cast<SFloat32>(this));
case Tag::FLOAT64: return f(cast<SFloat64>(this));
case Tag::CANONICALTUPLE: return f(cast<SCanonicalTuple>(this));
case Tag::STACKTUPLE: return f(cast<SStackTuple>(this));
default:
abort();
}
}
}
#endif
| 25.9375
| 126
| 0.731974
|
MariusDanner
|
b40101217d761fded8a8a5c3f89d499501415801
| 8,295
|
cc
|
C++
|
CaloReco/src/CaloHitMakerFast_module.cc
|
NamithaChitrazee/Offline-1
|
bcb6c74954f95dd48433d79a69d3ef3bdb99022e
|
[
"Apache-2.0"
] | null | null | null |
CaloReco/src/CaloHitMakerFast_module.cc
|
NamithaChitrazee/Offline-1
|
bcb6c74954f95dd48433d79a69d3ef3bdb99022e
|
[
"Apache-2.0"
] | null | null | null |
CaloReco/src/CaloHitMakerFast_module.cc
|
NamithaChitrazee/Offline-1
|
bcb6c74954f95dd48433d79a69d3ef3bdb99022e
|
[
"Apache-2.0"
] | null | null | null |
#include "art/Framework/Core/EDProducer.h"
#include "art/Framework/Principal/Event.h"
#include "Offline/GeneralUtilities/inc/ParameterSetHelpers.hh"
#include "art/Framework/Principal/Handle.h"
#include "fhiclcpp/types/Sequence.h"
#include "Offline/CalorimeterGeom/inc/Calorimeter.hh"
#include "Offline/ConditionsService/inc/ConditionsHandle.hh"
#include "Offline/ConditionsService/inc/CalorimeterCalibrations.hh"
#include "Offline/GeometryService/inc/GeomHandle.hh"
#include "Offline/RecoDataProducts/inc/CaloDigi.hh"
#include "Offline/RecoDataProducts/inc/CaloHit.hh"
#include "Offline/RecoDataProducts/inc/ProtonBunchTime.hh"
namespace
{
struct HitInfo {
HitInfo(float time, float eDep) : nSiPM_(1), time_(time), eDep_(eDep) {}
void add(float time, float eDep) {time_ = (nSiPM_*time_+time)/(nSiPM_+1); eDep_=(nSiPM_*eDep_+eDep)/(nSiPM_+1); ++nSiPM_;}
unsigned nSiPM_;
float time_, eDep_;
};
}
namespace mu2e {
class CaloHitMakerFast : public art::EDProducer {
public:
struct Config
{
using Name = fhicl::Name;
using Comment = fhicl::Comment;
fhicl::Atom<art::InputTag> caloDigiCollection { Name("caloDigiCollection"), Comment("CaloDigi collection name") };
fhicl::Atom<art::InputTag> pbttoken { Name("ProtonBunchTimeTag"), Comment("ProtonBunchTime producer")};
fhicl::Atom<double> digiSampling { Name("digiSampling"), Comment("Digitization time sampling") };
fhicl::Atom<double> deltaTPulses { Name("deltaTPulses"), Comment("Maximum time difference between two signals") };
fhicl::Atom<double> nPEperMeV { Name("nPEperMeV"), Comment("number of photo-electrons per MeV") };
fhicl::Atom<double> noiseLevelMeV { Name("noiseLevelMeV"), Comment("Noise level in MeV") };
fhicl::Atom<double> nSigmaNoise { Name("nSigmaNoise"), Comment("Maxnumber of sigma Noise to combine digi") };
fhicl::Sequence<int> caphriCrystalID { Name("caphriCrystalID"), Comment("List of caphri crystal ID") };
fhicl::Atom<int> diagLevel { Name("diagLevel"), Comment("Diag Level"),0 };
};
explicit CaloHitMakerFast(const art::EDProducer::Table<Config>& config) :
EDProducer{config},
caloDigisToken_ {consumes<CaloDigiCollection>(config().caloDigiCollection())},
pbttoken_ {consumes<ProtonBunchTime>(config().pbttoken())},
digiSampling_ (config().digiSampling()),
deltaTPulses_ (config().deltaTPulses()),
nPEperMeV_ (config().nPEperMeV()),
noise2_ (config().noiseLevelMeV()*config().noiseLevelMeV()),
nSigmaNoise_ (config().nSigmaNoise()),
caphriCrystalID_ (config().caphriCrystalID()),
diagLevel_ (config().diagLevel())
{
produces<CaloHitCollection>("calo");
produces<CaloHitCollection>("caphri");
}
void produce(art::Event& e) override;
private:
using pulseMapType = std::unordered_map<unsigned, std::vector<HitInfo>>;
void extractHits(const CaloDigiCollection& caloDigis, CaloHitCollection& caloHitsColl, CaloHitCollection& caphriHitsColl, double pbtOffset);
void addPulse(pulseMapType& pulseMap, unsigned crystalID, float time, float eDep);
art::ProductToken<CaloDigiCollection> caloDigisToken_;
const art::ProductToken<ProtonBunchTime> pbttoken_;
double digiSampling_;
double deltaTPulses_;
double nPEperMeV_;
double noise2_;
double nSigmaNoise_;
std::vector<int> caphriCrystalID_;
int diagLevel_;
};
//--------------------------------------------------------------------------------------------------------------
void CaloHitMakerFast::produce(art::Event& event)
{
if (diagLevel_ > 0) std::cout<<"[FastRecoDigiFromDigi] begin"<<std::endl;
auto pbtH = event.getValidHandle(pbttoken_);
const ProtonBunchTime& pbt(*pbtH);
double pbtOffset = pbt.pbtime_;
const auto& caloDigisHandle = event.getValidHandle(caloDigisToken_);
const auto& caloDigis(*caloDigisHandle);
auto caloHitsColl = std::make_unique<CaloHitCollection>();
auto caphriHitsColl = std::make_unique<CaloHitCollection>();
extractHits(caloDigis,*caloHitsColl,*caphriHitsColl,pbtOffset);
event.put(std::move(caloHitsColl), "calo");
event.put(std::move(caphriHitsColl),"caphri");
if (diagLevel_ > 0) std::cout<<"[FastRecoDigiFromDigi] end"<<std::endl;
return;
}
//--------------------------------------------------------------------------------------------------------------
void CaloHitMakerFast::extractHits(const CaloDigiCollection& caloDigis, CaloHitCollection& caloHitsColl, CaloHitCollection& caphriHitsColl, double pbtOffset)
{
const Calorimeter& cal = *(GeomHandle<Calorimeter>());
ConditionsHandle<CalorimeterCalibrations> calorimeterCalibrations("ignored");
pulseMapType pulseMap;
for (const auto& caloDigi : caloDigis)
{
int crystalID = cal.caloIDMapper().crystalIDFromSiPMID(caloDigi.SiPMID());
size_t nSamPed = caloDigi.peakpos() > 3 ? 4 : std::max(caloDigi.peakpos()-1, 1);
double baseline(0);
for (size_t i=0; i<nSamPed; ++i){ baseline += caloDigi.waveform().at(i);}
baseline /= nSamPed;
double eDep = (caloDigi.waveform().at(caloDigi.peakpos())-baseline)*calorimeterCalibrations->ADC2MeV(caloDigi.SiPMID());//FIXME! we should use the function ::Peak2MeV, I also think that we should: (i) discard the hit if eDep is <0 (noise/stange pulse), (ii) require a minimum pulse length. gianipez
double time = caloDigi.t0() + caloDigi.peakpos()*digiSampling_ - pbtOffset; //Giani's definition
//double time = caloDigi.t0() + (caloDigi.peakpos()+0.5)*digiSampling_ - shiftTime_; //Bertrand's definition
addPulse(pulseMap, crystalID, time, eDep);
if (diagLevel_ > 2) std::cout<<"[FastRecoDigiFromDigi] extracted Digi with crystalID="<<crystalID<<" eDep="<<eDep<<"\t time=" <<time<<std::endl;
}
for (auto& crystal : pulseMap)
{
int crID = crystal.first;
bool isCaphri = std::find(caphriCrystalID_.begin(), caphriCrystalID_.end(), crID) != caphriCrystalID_.end();
for (auto& info : crystal.second)
{
if (diagLevel_ > 1) std::cout<<"[FastRecoDigiFromDigi] extracted Hit with crystalID="<<crID<<" eDep="<<info.eDep_<<"\t time=" <<info.time_<<"\t nSiPM= "<<info.nSiPM_<<std::endl;
if (isCaphri) caphriHitsColl.emplace_back(CaloHit(crID, info.nSiPM_, info.time_,info.eDep_));
else caloHitsColl.emplace_back( CaloHit(crID, info.nSiPM_, info.time_,info.eDep_));
}
}
if ( diagLevel_ > 0 ) std::cout<<"[CaloHitMakerFast] extracted "<<caloHitsColl.size()<<" CaloDigis"<<std::endl;
if ( diagLevel_ > 0 ) std::cout<<"[CaloHitMakerFast] extracted "<<caphriHitsColl.size()<<" CapriDigis"<<std::endl;
}
//--------------------------------------------------------------------------------------------------------------
void CaloHitMakerFast::addPulse(pulseMapType& pulseMap, unsigned crystalID, float time, float eDep)
{
bool addNewHit(true);
for (auto& pulse : pulseMap[crystalID])
{
if (std::fabs(pulse.time_ - time) > deltaTPulses_) continue;
float ratio = (eDep-pulse.eDep_)/(eDep+pulse.eDep_);
float eMean = (eDep+pulse.eDep_)/2.0;
float sigmaR = 0.707*sqrt(1.0/eMean/nPEperMeV_ + noise2_/eMean/eMean);
if (abs(ratio) > nSigmaNoise_*sigmaR) continue;
pulse.add(time,eDep);
addNewHit = false;
break;
}
if (addNewHit) pulseMap[crystalID].push_back(HitInfo(time, eDep));
}
}
DEFINE_ART_MODULE(mu2e::CaloHitMakerFast);
| 46.340782
| 314
| 0.605787
|
NamithaChitrazee
|
b40304fe413b42da7ec4cfc80aed0f2ede31061c
| 7,688
|
cpp
|
C++
|
src/Legacy/crypter.cpp
|
bibbityjibbity/LLL-TAO
|
4073ba412f71bf27d21fd297497a7c276ebd2d67
|
[
"MIT"
] | null | null | null |
src/Legacy/crypter.cpp
|
bibbityjibbity/LLL-TAO
|
4073ba412f71bf27d21fd297497a7c276ebd2d67
|
[
"MIT"
] | null | null | null |
src/Legacy/crypter.cpp
|
bibbityjibbity/LLL-TAO
|
4073ba412f71bf27d21fd297497a7c276ebd2d67
|
[
"MIT"
] | null | null | null |
/*__________________________________________________________________________________________
(c) Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014] ++
(c) Copyright The Nexus Developers 2014 - 2019
Distributed under the MIT software license, see the accompanying
file COPYING or http://www.opensource.org/licenses/mit-license.php.
"ad vocem populi" - To the Voice of the People
____________________________________________________________________________________________*/
#ifdef WIN32
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600 //targeting minimum Windows Vista version for winsock2, etc.
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1 //prevents windows.h from including winsock.h and messing up winsock2.h definitions we use
#endif
#ifndef NOMINMAX
#define NOMINMAX //prevents windows.h from including min/max and potentially interfering with std::min/std::max
#endif
#include <windows.h>
#endif
#include <Legacy/wallet/crypter.h>
#include <openssl/aes.h>
#include <openssl/evp.h>
#include <algorithm>
#include <string>
#include <vector>
namespace Legacy
{
/* Default constructor */
Crypter::Crypter()
: fKeySet(false)
{
}
/* Destructor */
Crypter::~Crypter()
{
CleanKey();
}
/* Assign new encryption key context (chKey and chIV). */
bool Crypter::SetKey(const CKeyingMaterial& chNewKey, const std::vector<uint8_t>& chNewIV)
{
if(chNewKey.size() != WALLET_CRYPTO_KEY_SIZE || chNewIV.size() != WALLET_CRYPTO_KEY_SIZE)
return false;
/* Try to keep the keydata out of swap
* Note that this does nothing about suspend-to-disk (which will put all our key data on disk)
* Note as well that at no point in this program is any attempt made to prevent stealing of keys
* by reading the memory of the running process.
*/
mlock(&chKey[0], sizeof(chKey));
mlock(&chIV[0], sizeof(chIV));
//memcpy(&chKey[0], &chNewKey[0], sizeof(chKey));
//memcpy(&chIV[0], &chNewIV[0], sizeof(chIV));
std::copy((uint8_t *)&chNewKey[0], (uint8_t *)&chNewKey[0] + sizeof(chKey), &chKey[0]);
std::copy(&chNewIV[0], &chNewIV[0] + sizeof(chIV), &chIV[0]);
fKeySet = true;
return true;
}
/* Generate new encryption key context (chKey and chIV) from a passphrase. */
bool Crypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector<uint8_t>& chSalt, const uint32_t nRounds, const uint32_t nDerivationMethod)
{
if(nRounds < 1 || chSalt.size() != WALLET_CRYPTO_SALT_SIZE)
return false;
/* Try to keep the keydata out of swap
* Note that this does nothing about suspend-to-disk (which will put all our key data on disk)
* Note as well that at no point in this program is any attempt made to prevent stealing of keys
* by reading the memory of the running process.
*/
mlock(&chKey[0], sizeof chKey);
mlock(&chIV[0], sizeof chIV);
int i = 0;
if(nDerivationMethod == 0)
i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha512(), &chSalt[0],
(uint8_t *)&strKeyData[0], strKeyData.size(), nRounds, chKey, chIV);
if(i != (int) 32)
{
memset(&chKey, 0, sizeof chKey);
memset(&chIV, 0, sizeof chIV);
return false;
}
fKeySet = true;
return true;
}
/* Clear the current encryption key from memory. */
void Crypter::CleanKey()
{
memset(&chKey, 0, sizeof chKey);
memset(&chIV, 0, sizeof chIV);
munlock(&chKey, sizeof chKey);
munlock(&chIV, sizeof chIV);
fKeySet = false;
}
/* Encrypt a plain text value using the current encryption key settings. */
bool Crypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector<uint8_t>& vchCiphertext)
{
if(!IsKeySet())
return false;
/* max ciphertext len for a n bytes of plaintext is (n + AES_BLOCK_SIZE - 1) bytes */
int nLen = vchPlaintext.size();
int nCLen = nLen + AES_BLOCK_SIZE, nFLen = 0;
vchCiphertext = std::vector<uint8_t> (nCLen);
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
if(nullptr == ctx)
return false;
bool fOk = true;
EVP_CIPHER_CTX_init(ctx);
if(fOk) fOk = EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), nullptr, chKey, chIV);
if(fOk) fOk = EVP_EncryptUpdate(ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen);
if(fOk) fOk = EVP_EncryptFinal_ex(ctx, (&vchCiphertext[0])+nCLen, &nFLen);
EVP_CIPHER_CTX_free(ctx);
if(!fOk) return false;
vchCiphertext.resize(nCLen + nFLen);
return true;
}
/* Decrypt an encrypted text value using the current encryption key settings. */
bool Crypter::Decrypt(const std::vector<uint8_t>& vchCiphertext, CKeyingMaterial& vchPlaintext)
{
if(!IsKeySet())
return false;
/* Plain text will always be equal to or lesser than length of ciphertext */
int nLen = vchCiphertext.size();
int nPLen = nLen, nFLen = 0;
vchPlaintext = CKeyingMaterial(nPLen);
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
if(nullptr == ctx)
return false;
bool fOk = true;
EVP_CIPHER_CTX_init(ctx);
if(fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), nullptr, chKey, chIV);
if(fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen);
if(fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0])+nPLen, &nFLen);
EVP_CIPHER_CTX_free(ctx);
if(!fOk) return false;
vchPlaintext.resize(nPLen + nFLen);
return true;
}
/* Function to encrypt a private key using a master key and IV pair. */
bool EncryptSecret(const CKeyingMaterial& vMasterKey, const LLC::CSecret& vchPlaintext, const uint576_t& nIV, std::vector<uint8_t>& vchCiphertext)
{
Crypter cKeyCrypter;
std::vector<uint8_t> chIV(WALLET_CRYPTO_KEY_SIZE);
//memcpy(&chIV[0], &nIV, WALLET_CRYPTO_KEY_SIZE);
std::copy((uint8_t *)&nIV, (uint8_t *)&nIV + WALLET_CRYPTO_KEY_SIZE, &chIV[0]);
if(!cKeyCrypter.SetKey(vMasterKey, chIV))
return false;
/* This works on the assumption that CKeyingMaterial and CSecret are both std::vector<uint8_t, secure_allocator<uint8_t> > */
/* Can remove this assumption (and the old fashioned C-style cast) by copying CSecret into a CKeyMaterial variable */
return cKeyCrypter.Encrypt((CKeyingMaterial)vchPlaintext, vchCiphertext);
}
/* Function to encrypt a private key using a master key and IV pair. */
bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector<uint8_t>& vchCiphertext, const uint576_t& nIV, LLC::CSecret& vchPlaintext)
{
Crypter cKeyCrypter;
std::vector<uint8_t> chIV(WALLET_CRYPTO_KEY_SIZE);
//memcpy(&chIV[0], &nIV, WALLET_CRYPTO_KEY_SIZE);
std::copy((uint8_t *)&nIV, (uint8_t *)&nIV + WALLET_CRYPTO_KEY_SIZE, &chIV[0]);
if(!cKeyCrypter.SetKey(vMasterKey, chIV))
return false;
/* This works on the assumption that CKeyingMaterial and CSecret are both std::vector<uint8_t, secure_allocator<uint8_t> > */
/* Can remove this assumption (and the old fashioned C-style cast) by copying CSecret into a CKeyMaterial variable */
return cKeyCrypter.Decrypt(vchCiphertext, *((CKeyingMaterial*)&vchPlaintext));
}
}
| 34.321429
| 164
| 0.648803
|
bibbityjibbity
|
b4040ec2cf001906f8443256ebe063b4ceb69f53
| 2,491
|
cpp
|
C++
|
Tea Bubble Edition/Tea Bubble Edition Project/j1Entities.cpp
|
Skyway666/Tea-Bubble-Edition
|
3cffe55fa686ae34135e518bbc030de4040e13f7
|
[
"MIT"
] | null | null | null |
Tea Bubble Edition/Tea Bubble Edition Project/j1Entities.cpp
|
Skyway666/Tea-Bubble-Edition
|
3cffe55fa686ae34135e518bbc030de4040e13f7
|
[
"MIT"
] | null | null | null |
Tea Bubble Edition/Tea Bubble Edition Project/j1Entities.cpp
|
Skyway666/Tea-Bubble-Edition
|
3cffe55fa686ae34135e518bbc030de4040e13f7
|
[
"MIT"
] | null | null | null |
#include "j1Entities.h"
#include "p2Log.h"
#include "j1App.h"
#include "j1Input.h"
#include "j1Textures.h"
#include "CupDispenser.h"
#include "TeaDispenser.h"
#include "TeaDispenserButton.h"
j1Entities::j1Entities(): j1Module() {
}
j1Entities::~j1Entities() {
}
bool j1Entities::Awake(pugi::xml_node& config) {
return true;
}
bool j1Entities::Start() {
static_entities_tex = App->tex->Load("textures/Sprites_fondo.png");
player_tex = App->tex->Load("textures/Sprites_vaso.png");
CreatePlayer();
return true;
}
bool j1Entities::PreUpdate() {
if (App->input->GetKey(SDL_SCANCODE_F1) == KEY_DOWN)
debug_draw = !debug_draw;
return true;
}
bool j1Entities::Update(float dt) {
// Update entities and manage hover
for (uint i = 0; i < static_entities.count(); ++i) {
static_entities[i]->Update();
static_entities[i]->Draw(static_entities_tex);
if (debug_draw) static_entities[i]->DebugDraw();
ManageHover(static_entities[i]);
}
// Update Player
if(player){
player->Update();
player->Draw(player_tex);
if (debug_draw) player->DebugDraw();
}
return true;
}
bool j1Entities::PostUpdate() {
return true;
}
bool j1Entities::CleanUp() {
return true;
}
void j1Entities::CreatePlayer() {
if (player)
delete player;
player = new Player();
}
StaticEntity* j1Entities::CreateStaticEntity(STATIC_ELEMENT_TYPE element, iPoint position) {
StaticEntity* new_entity = nullptr;
switch (element) {
case CUP_DISPENSER:
new_entity = new CupDispenser(position);
break;
case TEA_DISPENSER:
new_entity = new TeaDispenser(position);
break;
case TEA_DISPENSER_BUTTON:
new_entity = new TeaDispenserButton(position);
break;
case CONDIMENT_DISPENSER:
break;
}
static_entities.add(new_entity);
return new_entity;
}
void j1Entities::DrawObject(iPoint position, Object object) {
switch (object.type) {
case EMPTY_CUP:
App->render->Blit(player_tex, position.x, position.y, 1, false, &(object.current_animation.GetCurrentFrame()));
break;
}
}
void j1Entities::ManageHover(StaticEntity * entity_check) {
// Player is hovering object
if (CheckCollision(entity_check->collider, player->position) && entity_check != player->hovered_entity) {
entity_check->Hover();
player->hovered_entity = entity_check;
}
// Player is unhovering object
if (!CheckCollision(entity_check->collider, player->position) && entity_check == player->hovered_entity) {
entity_check->UnHover();
player->hovered_entity = nullptr;
}
}
| 19.769841
| 114
| 0.717784
|
Skyway666
|
b40732d72a5fb15f6e61ee7654debf2a034c2179
| 3,389
|
cpp
|
C++
|
tesseract_common/src/types.cpp
|
traclabs/tesseract
|
dcf16da38f3ef41226a599299d48498c4c60bf5e
|
[
"BSD-3-Clause",
"BSD-2-Clause",
"Apache-2.0"
] | 118
|
2018-07-10T13:08:19.000Z
|
2021-09-17T20:39:32.000Z
|
tesseract_common/src/types.cpp
|
traclabs/tesseract
|
dcf16da38f3ef41226a599299d48498c4c60bf5e
|
[
"BSD-3-Clause",
"BSD-2-Clause",
"Apache-2.0"
] | 493
|
2018-08-06T13:24:51.000Z
|
2021-09-27T19:18:16.000Z
|
tesseract_common/src/types.cpp
|
traclabs/tesseract
|
dcf16da38f3ef41226a599299d48498c4c60bf5e
|
[
"BSD-3-Clause",
"BSD-2-Clause",
"Apache-2.0"
] | 60
|
2018-07-11T07:32:09.000Z
|
2021-09-27T07:42:05.000Z
|
/**
* @file types.cpp
* @brief Common Tesseract Types
*
* @author Levi Armstrong
* @date January 18, 2018
* @version TODO
* @bug No known bugs
*
* @copyright Copyright (c) 2017, Southwest Research Institute
*
* @par License
* Software License Agreement (Apache License)
* @par
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* @par
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tesseract_common/types.h>
namespace tesseract_common
{
void PluginInfoContainer::clear()
{
default_plugin.clear();
plugins.clear();
}
void KinematicsPluginInfo::insert(const KinematicsPluginInfo& other)
{
search_paths.insert(other.search_paths.begin(), other.search_paths.end());
search_libraries.insert(other.search_libraries.begin(), other.search_libraries.end());
fwd_plugin_infos.insert(other.fwd_plugin_infos.begin(), other.fwd_plugin_infos.end());
inv_plugin_infos.insert(other.inv_plugin_infos.begin(), other.inv_plugin_infos.end());
}
void KinematicsPluginInfo::clear()
{
search_paths.clear();
search_libraries.clear();
fwd_plugin_infos.clear();
inv_plugin_infos.clear();
}
bool KinematicsPluginInfo::empty() const
{
return (search_paths.empty() && search_libraries.empty() && fwd_plugin_infos.empty() && inv_plugin_infos.empty());
}
void ContactManagersPluginInfo::insert(const ContactManagersPluginInfo& other)
{
search_paths.insert(other.search_paths.begin(), other.search_paths.end());
search_libraries.insert(other.search_libraries.begin(), other.search_libraries.end());
discrete_plugin_infos.plugins.insert(other.discrete_plugin_infos.plugins.begin(),
other.discrete_plugin_infos.plugins.end());
continuous_plugin_infos.plugins.insert(other.continuous_plugin_infos.plugins.begin(),
other.continuous_plugin_infos.plugins.end());
if (!other.discrete_plugin_infos.default_plugin.empty())
discrete_plugin_infos.default_plugin = other.discrete_plugin_infos.default_plugin;
if (!other.continuous_plugin_infos.default_plugin.empty())
continuous_plugin_infos.default_plugin = other.continuous_plugin_infos.default_plugin;
}
void ContactManagersPluginInfo::clear()
{
search_paths.clear();
search_libraries.clear();
discrete_plugin_infos.clear();
continuous_plugin_infos.clear();
}
bool ContactManagersPluginInfo::empty() const
{
return (search_paths.empty() && search_libraries.empty() && discrete_plugin_infos.plugins.empty() &&
continuous_plugin_infos.plugins.empty());
}
std::size_t PairHash::operator()(const LinkNamesPair& pair) const
{
return std::hash<std::string>()(pair.first + pair.second);
}
LinkNamesPair makeOrderedLinkPair(const std::string& link_name1, const std::string& link_name2)
{
if (link_name1 <= link_name2)
return std::make_pair(link_name1, link_name2);
return std::make_pair(link_name2, link_name1);
}
} // namespace tesseract_common
| 33.22549
| 116
| 0.749779
|
traclabs
|
b40826305db0919837946d78af98c24d471db788
| 45,924
|
cpp
|
C++
|
Samples/UWP/D3D12LinkedGpus/src/LinkedGpusAffinity/D3D12LinkedGpusAffinity.cpp
|
HanmingZhang/DirectX-Graphics-Samples
|
5e98d453be61c200fd2ea4736d97ee08c5ed760f
|
[
"MIT"
] | 2,503
|
2015-07-29T03:00:27.000Z
|
2019-05-06T07:08:48.000Z
|
Samples/UWP/D3D12LinkedGpus/src/LinkedGpusAffinity/D3D12LinkedGpusAffinity.cpp
|
HanmingZhang/DirectX-Graphics-Samples
|
5e98d453be61c200fd2ea4736d97ee08c5ed760f
|
[
"MIT"
] | 329
|
2015-07-31T10:46:29.000Z
|
2019-05-04T11:06:34.000Z
|
Samples/UWP/D3D12LinkedGpus/src/LinkedGpusAffinity/D3D12LinkedGpusAffinity.cpp
|
HanmingZhang/DirectX-Graphics-Samples
|
5e98d453be61c200fd2ea4736d97ee08c5ed760f
|
[
"MIT"
] | 1,081
|
2015-07-29T12:20:57.000Z
|
2019-05-06T05:31:30.000Z
|
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "stdafx.h"
#include "D3D12LinkedGpusAffinity.h"
// Precompiled shaders.
#include "SceneVS.hlsl.h"
#include "ScenePS.hlsl.h"
#include "PostVS.hlsl.h"
#include "PostPS.hlsl.h"
using namespace DirectX;
D3D12LinkedGpusAffinity::D3D12LinkedGpusAffinity(UINT width, UINT height, std::wstring name) :
DXSample(width, height, name),
m_frameIndex(0),
m_frameId(0),
m_simulatedGpuLoad(0x1000),
m_syncInterval(0),
m_windowVisible(true),
m_windowedMode(true),
m_syncSceneRenderTargets(false)
{
m_sceneData.resize(Settings::TriangleCount);
}
void D3D12LinkedGpusAffinity::OnInit()
{
LoadPipeline();
LoadAssets();
UpdateWindowTitle();
}
void D3D12LinkedGpusAffinity::LoadPipeline()
{
UINT dxgiFactoryFlags = 0;
#if defined(_DEBUG)
// Enable the debug layer (requires the Graphics Tools "optional feature").
// NOTE: Enabling the debug layer after device creation will invalidate the active device.
{
ComPtr<ID3D12Debug> debugController;
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController))))
{
debugController->EnableDebugLayer();
// Enable additional debug layers.
dxgiFactoryFlags |= DXGI_CREATE_FACTORY_DEBUG;
}
}
#endif
ComPtr<ID3D12Device> device;
ComPtr<IDXGIFactory4> factory;
ThrowIfFailed(CreateDXGIFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&factory)));
if (m_useWarpDevice)
{
ComPtr<IDXGIAdapter> warpAdapter;
ThrowIfFailed(factory->EnumWarpAdapter(IID_PPV_ARGS(&warpAdapter)));
ThrowIfFailed(D3D12CreateDevice(
warpAdapter.Get(),
D3D_FEATURE_LEVEL_11_0,
IID_PPV_ARGS(&device)
));
}
else
{
ComPtr<IDXGIAdapter1> hardwareAdapter;
GetHardwareAdapter(factory.Get(), &hardwareAdapter);
ThrowIfFailed(D3D12CreateDevice(
hardwareAdapter.Get(),
D3D_FEATURE_LEVEL_11_0,
IID_PPV_ARGS(&device)
));
}
ThrowIfFailed(D3DX12AffinityCreateLDADevice(device.Get(), &m_device));
// Query capabilities of the device to configure the sample.
Settings::Initialize(m_device.Get(), m_width, m_height);
// Initialize member variables dependent on the Settings.
m_syncSceneRenderTargets = (Settings::NodeCount > 1);
m_sceneRenderTargets.resize(Settings::SceneHistoryCount);
m_postRenderTargets.resize(Settings::BackBufferCount);
m_sceneCommandAllocators.resize(Settings::FrameCount);
m_postCommandAllocators.resize(Settings::FrameCount);
// Describe and create the command queues.
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
ThrowIfFailed(m_device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&m_graphicsQueue)));
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
swapChainDesc.BufferCount = Settings::BackBufferCount;
swapChainDesc.Width = Settings::Width;
swapChainDesc.Height = Settings::Height;
swapChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.Flags = m_tearingSupport ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0;
ComPtr<IDXGISwapChain1> swapChain;
ThrowIfFailed(factory->CreateSwapChainForCoreWindow(
m_graphicsQueue->GetChildObject(0), // Swap chain needs the queue so that it can force a flush on it.
reinterpret_cast<IUnknown*>(Windows::UI::Core::CoreWindow::GetForCurrentThread()),
&swapChainDesc,
nullptr,
&swapChain
));
DXGIXAffinityCreateLDASwapChain(swapChain.Get(), m_graphicsQueue.Get(), m_device.Get(), &m_swapChain);
// Scene descriptor heaps.
{
// Describe and create a render target view (RTV) descriptor heap.
D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = {};
rtvHeapDesc.NumDescriptors = Settings::SceneHistoryCount;
rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&m_sceneRtvHeap)));
// Describe and create a depth stencil view (DSV) descriptor heap.
D3D12_DESCRIPTOR_HEAP_DESC dsvHeapDesc = {};
dsvHeapDesc.NumDescriptors = 1;
dsvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
dsvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&dsvHeapDesc, IID_PPV_ARGS(&m_sceneDsvHeap)));
// Describe and create a constant buffer view (CBV) descriptor heap.
D3D12_DESCRIPTOR_HEAP_DESC cbvHeapDesc = {};
cbvHeapDesc.NumDescriptors = Settings::TriangleCount * Settings::SceneConstantBufferFrames;
cbvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
cbvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&cbvHeapDesc, IID_PPV_ARGS(&m_sceneCbvHeap)));
}
// Post-process descriptor heaps.
{
// Describe and create a render target view (RTV) descriptor heap for
// the final output.
D3D12_DESCRIPTOR_HEAP_DESC postRtvHeapDesc = {};
postRtvHeapDesc.NumDescriptors = Settings::BackBufferCount;
postRtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
postRtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&postRtvHeapDesc, IID_PPV_ARGS(&m_postRtvHeap)));
// Describe and create a shader resource view (SRV) descriptor heap.
D3D12_DESCRIPTOR_HEAP_DESC srvHeapDesc = {};
srvHeapDesc.NumDescriptors = Settings::SceneHistoryCount;
srvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
srvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&srvHeapDesc, IID_PPV_ARGS(&m_postSrvHeap)));
// Describe and create a sampler descriptor heap.
D3D12_DESCRIPTOR_HEAP_DESC samplerHeapDesc = {};
samplerHeapDesc.NumDescriptors = 1;
samplerHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER;
samplerHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&samplerHeapDesc, IID_PPV_ARGS(&m_postSamplerHeap)));
}
// Create command allocators for each buffered frame.
for (UINT n = 0; n < Settings::FrameCount; n++)
{
ThrowIfFailed(m_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_sceneCommandAllocators[n])));
ThrowIfFailed(m_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_postCommandAllocators[n])));
}
}
// Generate data for the scene triangles.
void D3D12LinkedGpusAffinity::LoadAssets()
{
// Create the root signatures.
{
D3D12_FEATURE_DATA_ROOT_SIGNATURE featureData = {};
// This is the highest version the sample supports. If CheckFeatureSupport succeeds, the HighestVersion returned will not be greater than this.
featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_1;
if (FAILED(m_device->CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE, &featureData, sizeof(featureData))))
{
featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_0;
}
// Create a root signature for rendering the triangle scene.
{
CD3DX12_DESCRIPTOR_RANGE1 sceneRanges[1];
sceneRanges[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_CBV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC);
CD3DX12_ROOT_PARAMETER1 sceneRootParameters[2];
sceneRootParameters[0].InitAsDescriptorTable(1, &sceneRanges[0], D3D12_SHADER_VISIBILITY_VERTEX);
sceneRootParameters[1].InitAsConstants(1, 1, 0, D3D12_SHADER_VISIBILITY_VERTEX);
CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC sceneRootSignatureDesc;
sceneRootSignatureDesc.Init_1_1(_countof(sceneRootParameters), sceneRootParameters, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
ComPtr<ID3DBlob> signature;
ComPtr<ID3DBlob> error;
ThrowIfFailed(D3DX12SerializeVersionedRootSignature(&sceneRootSignatureDesc, featureData.HighestVersion, &signature, &error));
ThrowIfFailed(m_device->CreateRootSignature(Settings::SharedNodeMask, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&m_sceneRootSignature)));
}
// Create a root signature for the post-process pass.
{
// We don't modify the SRV in the post-processing command list after
// SetGraphicsRootDescriptorTable is executed on the GPU so we can use the default
// range behavior: D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE
CD3DX12_DESCRIPTOR_RANGE1 postRanges[2];
postRanges[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, Settings::SceneHistoryCount, 0);
postRanges[1].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 1, 0);
CD3DX12_ROOT_PARAMETER1 postRootParameters[3];
postRootParameters[0].InitAsDescriptorTable(1, &postRanges[0], D3D12_SHADER_VISIBILITY_PIXEL);
postRootParameters[1].InitAsDescriptorTable(1, &postRanges[1], D3D12_SHADER_VISIBILITY_PIXEL);
postRootParameters[2].InitAsConstants(2, 0, 0, D3D12_SHADER_VISIBILITY_PIXEL);
CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC postRootSignatureDesc;
postRootSignatureDesc.Init_1_1(_countof(postRootParameters), postRootParameters, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
ComPtr<ID3DBlob> signature;
ComPtr<ID3DBlob> error;
ThrowIfFailed(D3DX12SerializeVersionedRootSignature(&postRootSignatureDesc, featureData.HighestVersion, &signature, &error));
ThrowIfFailed(m_device->CreateRootSignature(Settings::SharedNodeMask, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&m_postRootSignature)));
}
}
// Create the pipeline state, which includes compiling and loading shaders.
{
// Define the vertex input layout for the triangle scene.
D3D12_INPUT_ELEMENT_DESC inputElementDescs[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
};
// Describe and create the graphics pipeline state objects (PSO).
D3DX12_AFFINITY_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
psoDesc.InputLayout = { inputElementDescs, _countof(inputElementDescs) };
psoDesc.pRootSignature = m_sceneRootSignature.Get();
psoDesc.VS = CD3DX12_SHADER_BYTECODE(g_SceneVS, sizeof(g_SceneVS));
psoDesc.PS = CD3DX12_SHADER_BYTECODE(g_ScenePS, sizeof(g_ScenePS));
psoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
psoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
psoDesc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT);
psoDesc.SampleMask = UINT_MAX;
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
psoDesc.NumRenderTargets = 1;
psoDesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
psoDesc.DSVFormat = DXGI_FORMAT_D32_FLOAT;
psoDesc.SampleDesc.Count = 1;
ThrowIfFailed(m_device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&m_scenePipelineState)));
// Define the vertex input layout for the post-process fullscreen quad.
D3D12_INPUT_ELEMENT_DESC postInputElementDescs[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
};
// Describe and create the PSO for the post-process pass.
D3DX12_AFFINITY_GRAPHICS_PIPELINE_STATE_DESC postPsoDesc = {};
postPsoDesc.InputLayout = { postInputElementDescs, _countof(postInputElementDescs) };
postPsoDesc.pRootSignature = m_postRootSignature.Get();
postPsoDesc.VS = CD3DX12_SHADER_BYTECODE(g_PostVS, sizeof(g_PostVS));
postPsoDesc.PS = CD3DX12_SHADER_BYTECODE(g_PostPS, sizeof(g_PostPS));
postPsoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
postPsoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
postPsoDesc.DepthStencilState.DepthEnable = FALSE;
postPsoDesc.DepthStencilState.StencilEnable = FALSE;
postPsoDesc.SampleMask = UINT_MAX;
postPsoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
postPsoDesc.NumRenderTargets = 1;
postPsoDesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
postPsoDesc.SampleDesc.Count = 1;
ThrowIfFailed(m_device->CreateGraphicsPipelineState(&postPsoDesc, IID_PPV_ARGS(&m_postPipelineState)));
}
// Single-use command allocator/list for resource initialization.
ComPtr<CD3DX12AffinityCommandAllocator> commandAllocator;
ComPtr<CD3DX12AffinityGraphicsCommandList> commandList;
// Set the AffinityMask to Settings::SharedNodeMask to make the Affinity layer
// create n allocators and n command lists and execute the following setup commands
// on all GPU nodes.
ThrowIfFailed(m_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&commandAllocator), Settings::SharedNodeMask));
ThrowIfFailed(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAllocator.Get(), nullptr, IID_PPV_ARGS(&commandList), Settings::SharedNodeMask));
// Create command lists for the scene and post-processing passes.
{
ThrowIfFailed(m_device->CreateCommandList(
0,
D3D12_COMMAND_LIST_TYPE_DIRECT,
m_sceneCommandAllocators[m_frameIndex].Get(),
m_scenePipelineState.Get(),
IID_PPV_ARGS(&m_sceneCommandList)));
ThrowIfFailed(m_device->CreateCommandList(
0,
D3D12_COMMAND_LIST_TYPE_DIRECT,
m_postCommandAllocators[m_frameIndex].Get(),
m_postPipelineState.Get(),
IID_PPV_ARGS(&m_postCommandList)));
// Command lists are created in the 'recording' state. We always call Reset
// as the first thing when populating command lists, so we need to close
// these here for the first frame.
ThrowIfFailed(m_sceneCommandList->Close());
ThrowIfFailed(m_postCommandList->Close());
}
ComPtr<CD3DX12AffinityResource> triangleVertexBufferUpload;
ComPtr<CD3DX12AffinityResource> quadVertexBufferUpload;
// Create the triangle vertex buffer.
{
// Define the geometry for a triangle.
SceneVertex vertices[] =
{
{ { 0.0f, Settings::TriangleHalfWidth, Settings::TriangleDepth } },
{ { Settings::TriangleHalfWidth, -Settings::TriangleHalfWidth, Settings::TriangleDepth } },
{ { -Settings::TriangleHalfWidth, -Settings::TriangleHalfWidth, Settings::TriangleDepth } }
};
const UINT vertexBufferSize = sizeof(vertices);
ThrowIfFailed(m_device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(vertexBufferSize),
D3D12_RESOURCE_STATE_COPY_DEST,
nullptr,
IID_PPV_ARGS(&m_sceneVertexBuffer)));
ThrowIfFailed(m_device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(vertexBufferSize),
D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr,
IID_PPV_ARGS(&triangleVertexBufferUpload)));
// Copy data to the intermediate upload heap and then schedule a copy
// from the upload heap to the vertex buffer.
D3D12_SUBRESOURCE_DATA vertexData = {};
vertexData.pData = reinterpret_cast<UINT8*>(vertices);
vertexData.RowPitch = vertexBufferSize;
vertexData.SlicePitch = vertexData.RowPitch;
UpdateSubresources<1>(commandList.Get(), m_sceneVertexBuffer.Get(), triangleVertexBufferUpload.Get(), 0, 0, 1, &vertexData);
commandList->ResourceBarrier(1, &CD3DX12_AFFINITY_RESOURCE_BARRIER::Transition(m_sceneVertexBuffer.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER));
// Initialize the vertex buffer view.
m_sceneVertexBufferView.BufferLocation = m_sceneVertexBuffer->GetGPUVirtualAddress();
m_sceneVertexBufferView.StrideInBytes = sizeof(SceneVertex);
m_sceneVertexBufferView.SizeInBytes = sizeof(vertices);
}
// Create the quad vertex buffer.
{
// Define the geometry for a quad.
PostVertex vertices[] =
{
{ { -1.0f, -1.0f, 0.0f }, { 0.0f, 1.0f } }, // Bottom Left
{ { -1.0f, 1.0f, 0.0f }, { 0.0f, 0.0f } }, // Top Left
{ { 1.0f, -1.0f, 0.0f }, { 1.0f, 1.0f } }, // Bottom Right
{ { 1.0f, 1.0f, 0.0f }, { 1.0f, 0.0f } }, // Top Right
};
const UINT vertexBufferSize = sizeof(vertices);
ThrowIfFailed(m_device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(vertexBufferSize),
D3D12_RESOURCE_STATE_COPY_DEST,
nullptr,
IID_PPV_ARGS(&m_postVertexBuffer)));
ThrowIfFailed(m_device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(vertexBufferSize),
D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr,
IID_PPV_ARGS(&quadVertexBufferUpload)));
// Copy data to the intermediate upload heap and then schedule a copy
// from the upload heap to the vertex buffer.
D3D12_SUBRESOURCE_DATA vertexData = {};
vertexData.pData = reinterpret_cast<UINT8*>(vertices);
vertexData.RowPitch = vertexBufferSize;
vertexData.SlicePitch = vertexData.RowPitch;
UpdateSubresources<1>(commandList.Get(), m_postVertexBuffer.Get(), quadVertexBufferUpload.Get(), 0, 0, 1, &vertexData);
commandList->ResourceBarrier(1, &CD3DX12_AFFINITY_RESOURCE_BARRIER::Transition(m_postVertexBuffer.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER));
// Initialize the vertex buffer view.
m_postVertexBufferView.BufferLocation = m_postVertexBuffer->GetGPUVirtualAddress();
m_postVertexBufferView.StrideInBytes = sizeof(PostVertex);
m_postVertexBufferView.SizeInBytes = sizeof(vertices);
}
// Create and map the constant buffers.
{
// UPLOAD heaps are not duplicated by the Affinity layer because:
// 1. they live in system memory
// 2. they are expected to contain data that will be read by all GPUs.
// All of our constant buffers change each frame, so the state of any one frame
// is only ever read by a single GPU. Therefore, we must ensure that a large
// enough resource is created to persist frame data for all GPUs to read from.
const UINT constantBufferDataSize = Settings::TriangleCount * Settings::SceneConstantBufferFrames * sizeof(SceneConstantBuffer);
ThrowIfFailed(m_device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(constantBufferDataSize),
D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr,
IID_PPV_ARGS(&m_sceneConstantBuffer)));
// Map and initialize the constant buffer. We don't unmap this until the
// app closes. Keeping things mapped for the lifetime of the resource is okay.
CD3DX12_RANGE readRange(0, 0); // We do not intend to read from this resource on the CPU.
ThrowIfFailed(m_sceneConstantBuffer->Map(0, &readRange, reinterpret_cast<void**>(&m_mappedConstantBuffer)));
ZeroMemory(m_mappedConstantBuffer, constantBufferDataSize);
// Create constant buffer views. Because the Affinity layer does not duplicate
// UPLOAD heaps across nodes, the CBVs on each node will all point to the same
// range of system memory.
CD3DX12_CPU_DESCRIPTOR_HANDLE cpuHandle(m_sceneCbvHeap->GetCPUDescriptorHandleForHeapStart());
D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc = {};
cbvDesc.SizeInBytes = sizeof(SceneConstantBuffer);
cbvDesc.BufferLocation = m_sceneConstantBuffer->GetGPUVirtualAddress();
for (UINT frame = 0; frame < Settings::SceneConstantBufferFrames; frame++)
{
for (UINT n = 0; n < Settings::TriangleCount; n++)
{
m_device->CreateConstantBufferView(&cbvDesc, cpuHandle);
cpuHandle.Offset(Settings::CbvSrvDescriptorSize);
cbvDesc.BufferLocation += cbvDesc.SizeInBytes;
}
}
}
for (UINT n = 0; n < Settings::TriangleCount; n++)
{
m_sceneData[n].velocity = XMFLOAT4(GetRandomFloat(0.005f, 0.01f), 0.0f, 0.0f, 0.0f);
m_sceneData[n].offset = XMFLOAT4(GetRandomFloat(-6.0f, -1.5f), GetRandomFloat(-1.0f, 1.0f), GetRandomFloat(0.0f, 2.0f), 0.0f);
m_sceneData[n].color = XMFLOAT4(GetRandomFloat(0.4f, 0.9f), GetRandomFloat(0.4f, 0.9f), GetRandomFloat(0.4f, 0.9f), 1.0f);
m_sceneData[n].projection = XMMatrixTranspose(XMMatrixPerspectiveFovLH(XM_PIDIV4, m_aspectRatio, 0.01f, 20.0f));
}
// Describe and create a sampler.
{
D3D12_SAMPLER_DESC samplerDesc = {};
samplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
samplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
samplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D12_FLOAT32_MAX;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
m_device->CreateSampler(&samplerDesc, m_postSamplerHeap->GetCPUDescriptorHandleForHeapStart());
}
m_sceneFence = std::make_shared<LinearFence>(m_graphicsQueue.Get(), Settings::FrameCount);
m_postFence = std::make_shared<LinearFence>(m_graphicsQueue.Get(), Settings::FrameCount);
ThrowIfFailed(commandList->Close());
// Submit the initialization work to the GPU.
CD3DX12AffinityCommandList* ppCommandLists[] = { commandList.Get() };
m_graphicsQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists);
// Wait for the graphics queue to finish executing the commands.
Fence fence(m_graphicsQueue.Get());
fence.FlushGpuQueue();
LoadSizeDependentResources();
}
void D3D12LinkedGpusAffinity::LoadSizeDependentResources()
{
// Single-use command allocator/list for resource initialization.
ComPtr<CD3DX12AffinityCommandAllocator> commandAllocator;
ComPtr<CD3DX12AffinityGraphicsCommandList> commandList;
// Set the AffinityMask to Settings::SharedNodeMask to make the Affinity layer
// create n allocators and n command lists and execute the following setup commands
// on all GPU nodes.
ThrowIfFailed(m_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&commandAllocator), Settings::SharedNodeMask));
ThrowIfFailed(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAllocator.Get(), nullptr, IID_PPV_ARGS(&commandList), Settings::SharedNodeMask));
// Create RTVs for swap chain back buffers.
CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_postRtvHeap->GetCPUDescriptorHandleForHeapStart());
for (UINT n = 0; n < Settings::BackBufferCount; n++)
{
ThrowIfFailed(m_swapChain->GetBuffer(n, IID_PPV_ARGS(&m_postRenderTargets[n])));
m_device->CreateRenderTargetView(m_postRenderTargets[n].Get(), nullptr, rtvHandle);
rtvHandle.Offset(Settings::RtvDescriptorSize);
}
m_frameIndex = 0;
m_sceneRenderTargetIndex = 0;
m_nodeIndex = 0;
// Create the render targets used to draw the scene.
// These will be sampled from during the post-processing step.
{
D3D12_RESOURCE_DESC renderTargetDesc = m_postRenderTargets[0]->GetDesc();
D3D12_RESOURCE_ALLOCATION_INFO info = m_device->GetResourceAllocationInfo(Settings::SharedNodeMask, 1, &renderTargetDesc);
const UINT64 alignedRenderTargetSize = AlignResource(info.SizeInBytes, info.Alignment);
D3D12_HEAP_DESC heapDesc = {};
heapDesc.SizeInBytes = alignedRenderTargetSize * Settings::SceneHistoryCount;
heapDesc.Alignment = info.Alignment;
heapDesc.Properties = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT);
heapDesc.Flags = D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES | D3D12_HEAP_FLAG_DENY_BUFFERS;
ThrowIfFailed(m_device->CreateHeap(&heapDesc, IID_PPV_ARGS(&m_sceneRenderTargetHeap)));
CD3DX12_CLEAR_VALUE clearValue(DXGI_FORMAT_R8G8B8A8_UNORM, Settings::ClearColor);
CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_sceneRtvHeap->GetCPUDescriptorHandleForHeapStart());
CD3DX12_CPU_DESCRIPTOR_HANDLE srvHandle(m_postSrvHeap->GetCPUDescriptorHandleForHeapStart());
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = 1;
D3DX12_AFFINITY_RESOURCE_BARRIER barriers[Settings::SceneHistoryCount];
for (UINT sceneIndex = 0; sceneIndex < Settings::SceneHistoryCount; sceneIndex++)
{
ThrowIfFailed(m_device->CreatePlacedResource(
m_sceneRenderTargetHeap.Get(),
alignedRenderTargetSize * sceneIndex,
&renderTargetDesc,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
&clearValue,
IID_PPV_ARGS(&m_sceneRenderTargets[sceneIndex])));
barriers[sceneIndex] = CD3DX12_AFFINITY_RESOURCE_BARRIER::Aliasing(nullptr, m_sceneRenderTargets[sceneIndex].Get());
m_device->CreateRenderTargetView(m_sceneRenderTargets[sceneIndex].Get(), nullptr, rtvHandle);
rtvHandle.Offset(Settings::RtvDescriptorSize);
m_device->CreateShaderResourceView(m_sceneRenderTargets[sceneIndex].Get(), &srvDesc, srvHandle);
srvHandle.Offset(Settings::CbvSrvDescriptorSize);
}
commandList->ResourceBarrier(_countof(barriers), barriers);
if (m_syncSceneRenderTargets)
{
// The post-processing pass expects that a previous post-processing pass has
// transitioned the next frame's dependencies into the COPY_DEST state.
// Since these resources were created with the PIXEL_SHADER_RESOURCE state,
// we need to transition them to COPY_DEST.
for (UINT nodeIndex = 0; nodeIndex < Settings::NodeCount; nodeIndex++)
{
D3DX12_AFFINITY_RESOURCE_BARRIER copyBarriers[Settings::MaxNodeCount];
UINT barrierIndex = 0;
// The next commands added to the command list will only apply to the
// node selected.
commandList->SetAffinity(1 << nodeIndex);
for (UINT index = 0; index < Settings::NodeCount - 1; index++)
{
UINT offset = Settings::SceneHistoryCount - (Settings::NodeCount - 1) + index;
UINT renderTargetIndex = (nodeIndex + offset) % Settings::SceneHistoryCount;
copyBarriers[index] = CD3DX12_AFFINITY_RESOURCE_BARRIER::Transition(
m_sceneRenderTargets[renderTargetIndex].Get(),
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
D3D12_RESOURCE_STATE_COPY_DEST);
}
commandList->ResourceBarrier(Settings::NodeCount - 1, copyBarriers);
}
// The next commands added to the command list will apply to all nodes.
commandList->SetAffinity(Settings::SharedNodeMask);
}
}
// Create the depth stencil and its view.
{
CD3DX12_HEAP_PROPERTIES heapProps(D3D12_HEAP_TYPE_DEFAULT);
CD3DX12_CLEAR_VALUE depthOptimizedClearValue(DXGI_FORMAT_D32_FLOAT, 1.0f, 0);
ThrowIfFailed(m_device->CreateCommittedResource(
&heapProps,
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Tex2D(DXGI_FORMAT_D32_FLOAT, Settings::Width, Settings::Height, 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL),
D3D12_RESOURCE_STATE_DEPTH_WRITE,
&depthOptimizedClearValue,
IID_PPV_ARGS(&m_sceneDepthStencil)
));
D3D12_DEPTH_STENCIL_VIEW_DESC depthStencilDesc = {};
depthStencilDesc.Format = DXGI_FORMAT_D32_FLOAT;
depthStencilDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
m_device->CreateDepthStencilView(m_sceneDepthStencil.Get(), &depthStencilDesc, m_sceneDsvHeap->GetCPUDescriptorHandleForHeapStart());
}
ThrowIfFailed(commandList->Close());
// Submit the resource barrier changes to the GPU.
CD3DX12AffinityCommandList* ppCommandLists[] = { commandList.Get() };
m_graphicsQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists);
// Wait for the graphics queue to finish executing the commands.
Fence fence(m_graphicsQueue.Get());
fence.FlushGpuQueue();
}
// Get a random float value between min and max.
float D3D12LinkedGpusAffinity::GetRandomFloat(float min, float max)
{
float scale = static_cast<float>(rand()) / RAND_MAX;
float range = max - min;
return scale * range + min;
}
void D3D12LinkedGpusAffinity::UpdateWindowTitle()
{
WCHAR nodeText[100];
if (Settings::NodeCount == 1)
{
swprintf_s(nodeText, L"Node Count = 1 | SyncInterval = %u | SimulatedLoad = %u", m_syncInterval, m_simulatedGpuLoad);
}
else
{
swprintf_s(
nodeText,
L"Node Count = %u | Cross Node Sharing Tier = %d | SyncInterval = %u | SimulatedLoad = %u",
Settings::NodeCount,
Settings::Tier2Support ? 2 : 1,
m_syncInterval,
m_simulatedGpuLoad);
}
SetCustomWindowText(nodeText);
}
// Update frame-based values.
void D3D12LinkedGpusAffinity::OnUpdate()
{
for (UINT n = 0; n < Settings::TriangleCount; n++)
{
const float offsetBounds = 1.5f * m_aspectRatio;
// Animate the triangles.
m_sceneData[n].offset.x += m_sceneData[n].velocity.x;
if (m_sceneData[n].offset.x > offsetBounds)
{
m_sceneData[n].velocity.x = GetRandomFloat(0.005f, 0.01f);
m_sceneData[n].offset.x = -offsetBounds;
}
}
UINT index = m_frameId % Settings::SceneConstantBufferFrames;
UINT offset = Settings::TriangleCount * index * sizeof(SceneConstantBuffer);
memcpy(m_mappedConstantBuffer + offset, m_sceneData.data(), Settings::TriangleCount * sizeof(SceneConstantBuffer));
}
// Render the scene.
void D3D12LinkedGpusAffinity::OnRender()
{
if (m_windowVisible)
{
// Render and present the current frame.
RenderScene();
RenderPost();
// When using sync interval 0, it is recommended to always pass the tearing
// flag when it is supported, even if not presenting to a fullscreen window.
// This flag cannot be used if the app is in "exclusive" fullscreen mode as
// a result of calling SetFullscreenState.
UINT presentFlags = (m_syncInterval == 0 && m_tearingSupport && m_windowedMode) ? DXGI_PRESENT_ALLOW_TEARING : 0;
ThrowIfFailed(m_swapChain->Present(m_syncInterval, presentFlags));
MoveToNextFrame();
}
}
// Fill the command list with all the render commands and dependent state.
void D3D12LinkedGpusAffinity::RenderScene()
{
UINT cbvDescriptorTableOffset = Settings::TriangleCount * (m_frameId % Settings::SceneConstantBufferFrames);
CD3DX12_GPU_DESCRIPTOR_HANDLE cbvHandle(m_sceneCbvHeap->GetGPUDescriptorHandleForHeapStart(), cbvDescriptorTableOffset, Settings::CbvSrvDescriptorSize);
CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_sceneRtvHeap->GetCPUDescriptorHandleForHeapStart(), m_sceneRenderTargetIndex, Settings::RtvDescriptorSize);
CD3DX12_CPU_DESCRIPTOR_HANDLE dsvHandle(m_sceneDsvHeap->GetCPUDescriptorHandleForHeapStart());
m_sceneFence->Next();
// Record the rendering commands.
ThrowIfFailed(m_sceneCommandAllocators[m_frameIndex]->Reset());
ThrowIfFailed(m_sceneCommandList->Reset(m_sceneCommandAllocators[m_frameIndex].Get(), m_scenePipelineState.Get()));
// Set necessary state.
m_sceneCommandList->SetGraphicsRootSignature(m_sceneRootSignature.Get());
m_sceneCommandList->SetGraphicsRoot32BitConstant(1, m_simulatedGpuLoad, 0);
CD3DX12AffinityDescriptorHeap* ppHeaps[] = { m_sceneCbvHeap.Get() };
m_sceneCommandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps);
m_sceneCommandList->RSSetViewports(1, &Settings::Viewport);
m_sceneCommandList->RSSetScissorRects(1, &Settings::ScissorRect);
m_sceneCommandList->OMSetRenderTargets(1, &rtvHandle, FALSE, &dsvHandle);
// Record commands.
D3DX12_AFFINITY_RESOURCE_BARRIER barrier = CD3DX12_AFFINITY_RESOURCE_BARRIER::Transition(
m_sceneRenderTargets[m_sceneRenderTargetIndex].Get(),
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
D3D12_RESOURCE_STATE_RENDER_TARGET);
m_sceneCommandList->ResourceBarrier(1, &barrier);
m_sceneCommandList->ClearRenderTargetView(rtvHandle, Settings::ClearColor, 0, nullptr);
m_sceneCommandList->ClearDepthStencilView(dsvHandle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);
m_sceneCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
m_sceneCommandList->IASetVertexBuffers(0, 1, &m_sceneVertexBufferView);
for (UINT triangle = 0; triangle < Settings::TriangleCount; triangle++)
{
m_sceneCommandList->SetGraphicsRootDescriptorTable(0, cbvHandle);
m_sceneCommandList->DrawInstanced(3, 1, 0, 0);
cbvHandle.Offset(Settings::CbvSrvDescriptorSize);
}
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
barrier.Transition.StateAfter = m_syncSceneRenderTargets ? D3D12_RESOURCE_STATE_COPY_SOURCE : D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
m_sceneCommandList->ResourceBarrier(1, &barrier);
ThrowIfFailed(m_sceneCommandList->Close());
CD3DX12AffinityCommandList* ppSceneCommandLists[] = { m_sceneCommandList.Get() };
m_graphicsQueue->ExecuteCommandLists(_countof(ppSceneCommandLists), ppSceneCommandLists);
m_sceneFence->Signal();
}
void D3D12LinkedGpusAffinity::RenderPost()
{
UINT backBufferIndex = m_swapChain->GetCurrentBackBufferIndex();
CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_postRtvHeap->GetCPUDescriptorHandleForHeapStart(), backBufferIndex, Settings::RtvDescriptorSize);
m_postFence->Next();
ThrowIfFailed(m_postCommandAllocators[m_frameIndex]->Reset());
ThrowIfFailed(m_postCommandList->Reset(m_postCommandAllocators[m_frameIndex].Get(), m_postPipelineState.Get()));
if (m_syncSceneRenderTargets)
{
// If the rendered scenes need to be copied across nodes, we need to wait
// until the other nodes are done with their post-processing passes (which
// includes transitioning the state of the next render targets in the
// history to the COPY_DEST state).
if (m_frameId > 0)
{
Fence::GpuWait(m_graphicsQueue.Get(), m_postFence.get());
}
// Copy the render target from the scene pass to all other nodes.
m_postCommandList->BroadcastResource(m_sceneRenderTargets[m_sceneRenderTargetIndex].Get(), m_nodeIndex, Settings::SharedNodeMask);
// Transition all render target resources into the PIXEL_SHADER_RESOURCE
// state to prepare for rendering the motion blur effect.
D3DX12_AFFINITY_RESOURCE_BARRIER barriers[Settings::MaxNodeCount];
for (UINT index = 0; index < Settings::NodeCount - 1; index++)
{
UINT offset = Settings::SceneHistoryCount - Settings::NodeCount + 1 + index;
UINT renderTargetIndex = (m_sceneRenderTargetIndex + offset) % Settings::SceneHistoryCount;
barriers[index] = CD3DX12_AFFINITY_RESOURCE_BARRIER::Transition(
m_sceneRenderTargets[renderTargetIndex].Get(),
D3D12_RESOURCE_STATE_COPY_DEST,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
}
barriers[Settings::NodeCount - 1] = CD3DX12_AFFINITY_RESOURCE_BARRIER::Transition(
m_sceneRenderTargets[m_sceneRenderTargetIndex].Get(),
D3D12_RESOURCE_STATE_COPY_SOURCE,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
m_postCommandList->ResourceBarrier(Settings::NodeCount, barriers);
}
m_postCommandList->SetGraphicsRootSignature(m_postRootSignature.Get());
CD3DX12AffinityDescriptorHeap* ppPostHeaps[] = { m_postSrvHeap.Get(), m_postSamplerHeap.Get() };
m_postCommandList->SetDescriptorHeaps(_countof(ppPostHeaps), ppPostHeaps);
m_postCommandList->RSSetViewports(1, &Settings::Viewport);
m_postCommandList->RSSetScissorRects(1, &Settings::ScissorRect);
D3DX12_AFFINITY_RESOURCE_BARRIER barrier = CD3DX12_AFFINITY_RESOURCE_BARRIER::Transition(
m_postRenderTargets[backBufferIndex].Get(),
D3D12_RESOURCE_STATE_PRESENT,
D3D12_RESOURCE_STATE_RENDER_TARGET);
m_postCommandList->ResourceBarrier(1, &barrier);
m_postCommandList->OMSetRenderTargets(1, &rtvHandle, false, nullptr);
m_postCommandList->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
m_postCommandList->IASetVertexBuffers(0, 1, &m_postVertexBufferView);
m_postCommandList->SetGraphicsRootDescriptorTable(0, m_postSrvHeap->GetGPUDescriptorHandleForHeapStart());
m_postCommandList->SetGraphicsRootDescriptorTable(1, m_postSamplerHeap->GetGPUDescriptorHandleForHeapStart());
m_postCommandList->SetGraphicsRoot32BitConstant(2, m_frameId % Settings::SceneHistoryCount, 0);
m_postCommandList->SetGraphicsRoot32BitConstant(2, static_cast<UINT>(min(m_frameId + 1, Settings::SceneHistoryCount)), 1);
m_postCommandList->DrawInstanced(4, 1, 0, 0);
// Indicate that the back buffer will now be used to present.
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
D3DX12_AFFINITY_RESOURCE_BARRIER barriers[Settings::MaxNodeCount];
barriers[0] = barrier;
if (m_syncSceneRenderTargets)
{
// Transition render target resources rendered by the next nodes into the
// COPY_DEST state to prepare them to be copied to during those nodes'
// post-process passes.
for (UINT offset = 1; offset < Settings::NodeCount; offset++)
{
UINT renderTargetIndex = (m_sceneRenderTargetIndex + offset) % Settings::SceneHistoryCount;
barriers[offset] = CD3DX12_AFFINITY_RESOURCE_BARRIER::Transition(
m_sceneRenderTargets[renderTargetIndex].Get(),
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
D3D12_RESOURCE_STATE_COPY_DEST);
}
}
m_postCommandList->ResourceBarrier(Settings::NodeCount, barriers);
ThrowIfFailed(m_postCommandList->Close());
CD3DX12AffinityCommandList* ppPostCommandLists[] = { m_postCommandList.Get() };
m_graphicsQueue->ExecuteCommandLists(_countof(ppPostCommandLists), ppPostCommandLists);
}
void D3D12LinkedGpusAffinity::OnSizeChanged(UINT width, UINT height, bool minimized)
{
// Determine if the swap buffers and other resources need to be resized or not.
if ((width != m_width || height != m_height) && !minimized)
{
// Flush all current GPU commands.
WaitForGpus();
// Release buffers tied to the swap chain and update the global Settings
// for the new size.
for (UINT n = 0; n < Settings::BackBufferCount; n++)
{
m_postRenderTargets[n].Reset();
}
Settings::OnSizeChanged(width, height);
// Resize the swap chain to the desired dimensions.
DXGI_SWAP_CHAIN_DESC1 swapChainDesc;
ThrowIfFailed(m_swapChain->GetDesc1(&swapChainDesc));
ThrowIfFailed(m_swapChain->ResizeBuffers(Settings::BackBufferCount, width, height, swapChainDesc.Format, swapChainDesc.Flags));
// Re-create render targets.
LoadSizeDependentResources();
// Reset the node index and align the frameId so that assumptions in post-processing hold.
m_nodeIndex = m_swapChain->GetCurrentBackBufferIndex() % Settings::NodeCount;
m_frameId += (Settings::SceneHistoryCount - (m_frameId % Settings::SceneHistoryCount));
// Update the m_width, m_height, and m_aspectRatio member variables.
UpdateForSizeChange(width, height);
// Update the scene projection matrix.
for (UINT n = 0; n < Settings::TriangleCount; n++)
{
m_sceneData[n].projection = XMMatrixTranspose(XMMatrixPerspectiveFovLH(XM_PIDIV4, m_aspectRatio, 0.01f, 20.0f));
}
}
m_windowVisible = !minimized;
}
void D3D12LinkedGpusAffinity::OnKeyDown(UINT8 key)
{
switch (key)
{
// Instrument the Space Bar to toggle between fullscreen states.
// The CoreWindow will fire a SizeChanged event once the window is in the
// fullscreen state. At that point, the IDXGISwapChain should be resized
// to match the new window size.
case VK_SPACE:
{
auto applicationView = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
if (applicationView->IsFullScreenMode)
{
applicationView->ExitFullScreenMode();
}
else
{
applicationView->TryEnterFullScreenMode();
}
break;
}
case VK_LEFT:
case VK_RIGHT:
m_syncInterval = (m_syncInterval > 0) ? 0 : 1;
UpdateWindowTitle();
break;
case VK_UP:
if (m_simulatedGpuLoad > 0)
{
if (m_simulatedGpuLoad < 0x80000)
{
m_simulatedGpuLoad <<= 1;
}
}
else
{
m_simulatedGpuLoad = 1;
}
UpdateWindowTitle();
break;
case VK_DOWN:
if (m_simulatedGpuLoad != 0)
{
m_simulatedGpuLoad >>= 1;
}
UpdateWindowTitle();
break;
}
}
void D3D12LinkedGpusAffinity::OnDestroy()
{
// Wait for the GPUs to be done with all their resources.
WaitForGpus();
}
// Wait for pending GPU work to complete.
void D3D12LinkedGpusAffinity::WaitForGpus()
{
m_postFence->FlushGpuQueue();
}
// Prepare to render the next frame.
void D3D12LinkedGpusAffinity::MoveToNextFrame()
{
UINT nextNode = m_swapChain->GetCurrentBackBufferIndex() % Settings::NodeCount;
if (Settings::NodeCount > 1 && nextNode == m_nodeIndex)
{
// If a WM_SIZE event was processed during Present, we will already be in the
// correct state. Do not update any indices.
}
else
{
m_postFence->Signal();
// Advance to the next node.
m_device->SwitchToNextNode();
m_nodeIndex = m_device->GetActiveNodeIndex();
if (m_nodeIndex == 0)
{
m_frameIndex = (m_frameIndex + 1) % Settings::FrameCount;
}
m_sceneRenderTargetIndex = (m_sceneRenderTargetIndex + 1) % Settings::SceneHistoryCount;
m_frameId++;
}
}
| 45.379447
| 197
| 0.688703
|
HanmingZhang
|
b40833c9efb374d0e1d3b5e317c0f03d8422a365
| 975
|
cpp
|
C++
|
src/commands/MessageCommand.cpp
|
Evropa1/audacity
|
3be57fce49d293bd64cb0904b3883c885503ab2e
|
[
"CC-BY-3.0"
] | 21
|
2015-08-02T20:43:37.000Z
|
2022-02-06T04:19:16.000Z
|
src/commands/MessageCommand.cpp
|
Evropa1/audacity
|
3be57fce49d293bd64cb0904b3883c885503ab2e
|
[
"CC-BY-3.0"
] | null | null | null |
src/commands/MessageCommand.cpp
|
Evropa1/audacity
|
3be57fce49d293bd64cb0904b3883c885503ab2e
|
[
"CC-BY-3.0"
] | 3
|
2016-05-15T05:35:57.000Z
|
2018-09-21T20:50:11.000Z
|
/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2018 Audacity Team
License: wxwidgets
Dan Horgan
******************************************************************//**
\file MessageCommand.cpp
\brief Definitions for MessageCommand class
*//*******************************************************************/
#include "../Audacity.h"
#include "MessageCommand.h"
#include "CommandType.h"
#include "CommandContext.h"
#include "../ShuttleGui.h"
bool MessageCommand::DefineParams( ShuttleParams & S ){
S.Define( mMessage, wxT("Text"), "Some message" );
return true;
}
void MessageCommand::PopulateOrExchange(ShuttleGui & S)
{
S.AddSpace(0, 5);
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieTextBox(_("Text:"),mMessage,60);
}
S.EndMultiColumn();
}
bool MessageCommand::Apply(const CommandContext & context){
context.Status( mMessage );
return true;
}
| 23.214286
| 71
| 0.548718
|
Evropa1
|
b40b40825f551de9c6d7ba5c4c084089eda66f39
| 857
|
hpp
|
C++
|
glfw3_app/doom/doomdef.hpp
|
hirakuni45/glfw3_app
|
d9ceeef6d398229fda4849afe27f8b48d1597fcf
|
[
"BSD-3-Clause"
] | 9
|
2015-09-22T21:36:57.000Z
|
2021-04-01T09:16:53.000Z
|
glfw3_app/doom/doomdef.hpp
|
hirakuni45/glfw3_app
|
d9ceeef6d398229fda4849afe27f8b48d1597fcf
|
[
"BSD-3-Clause"
] | null | null | null |
glfw3_app/doom/doomdef.hpp
|
hirakuni45/glfw3_app
|
d9ceeef6d398229fda4849afe27f8b48d1597fcf
|
[
"BSD-3-Clause"
] | 2
|
2019-02-21T04:22:13.000Z
|
2021-03-02T17:24:32.000Z
|
#pragma once
//=====================================================================//
/*! @file
@brief DOOM インターフェース・定義 @n
Copyright 2019 Kunihito Hiramatsu
@author 平松邦仁 (hira@rvf-rc45.net)
*/
//=====================================================================//
#ifdef __cplusplus
extern "C" {
int doom_main(int argc, char* argv[]);
void doom_keybits(uint32_t bits);
void doom_frame(int width, int height, uint8_t* rgba);
}
#endif
static const uint32_t KEY_BITS_UP = 0x00000001;
static const uint32_t KEY_BITS_DOWN = 0x00000002;
static const uint32_t KEY_BITS_RIGHT = 0x00000004;
static const uint32_t KEY_BITS_LEFT = 0x00000008;
static const uint32_t KEY_BITS_ENTER = 0x00000010;
static const uint32_t KEY_BITS_ESC = 0x00000020;
static const uint32_t KEY_BITS_DEL = 0x00000040;
static const uint32_t KEY_BITS_TAB = 0x00000080;
| 31.740741
| 73
| 0.637106
|
hirakuni45
|
b410f0da115884f9b5256af683261c4b0328c4cc
| 1,218
|
cpp
|
C++
|
BOJ_solve/19857.cpp
|
python-programmer1512/Code_of_gunwookim
|
e72e6724fb9ee6ccf2e1064583956fa954ba0282
|
[
"MIT"
] | 4
|
2021-01-27T11:51:30.000Z
|
2021-01-30T17:02:55.000Z
|
BOJ_solve/19857.cpp
|
python-programmer1512/Code_of_gunwookim
|
e72e6724fb9ee6ccf2e1064583956fa954ba0282
|
[
"MIT"
] | null | null | null |
BOJ_solve/19857.cpp
|
python-programmer1512/Code_of_gunwookim
|
e72e6724fb9ee6ccf2e1064583956fa954ba0282
|
[
"MIT"
] | 5
|
2021-01-27T11:46:12.000Z
|
2021-05-06T05:37:47.000Z
|
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 1e18;
const long long mod = 998244353;
const long long hashmod = 100003;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
int n;
ll a[200000],b[200000];
bool isok(int mid) {
for(int i = 0;i < n;i++) b[i] = a[i];
for(int i = mid;i < n;i++) b[0] += b[i];
ll nec = 1;
for(int i = mid-1;i >= 0;i--) {
if(nec > b[i]) {
if(!i) return false;
nec += nec-b[i];
}
else b[0] += b[i]-nec;
nec = min(nec,llINF);
}
return true;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
ll sum = 0, wi = 0;
for(int i = 0;i < n;i++) {
cin >> a[i];
sum += a[i];
if(a[i]) wi = i;
}
if(sum == 1) {
cout << (!wi ? 1 : wi);
return 0;
}
int l = 0,r = 150000;
while(l < r) {
int mid = (l + r + 1) >> 1;
if(isok(mid)) l = mid;
else r = mid-1;
}
cout << l;
}
| 20.3
| 47
| 0.577997
|
python-programmer1512
|
b4117b64e3691f451f8a1883e332f6f1f47af419
| 3,053
|
cpp
|
C++
|
spot_test/test_functions.cpp
|
tgeijten/spot
|
2faca07d6ebc8d4a405001b254d78f1bc97ca50a
|
[
"Apache-2.0"
] | 5
|
2017-12-18T10:37:26.000Z
|
2021-12-20T07:00:44.000Z
|
spot_test/test_functions.cpp
|
tgeijten/spot
|
2faca07d6ebc8d4a405001b254d78f1bc97ca50a
|
[
"Apache-2.0"
] | 6
|
2018-11-05T10:08:09.000Z
|
2021-02-11T07:50:54.000Z
|
spot_test/test_functions.cpp
|
tgeijten/spot
|
2faca07d6ebc8d4a405001b254d78f1bc97ca50a
|
[
"Apache-2.0"
] | 4
|
2018-11-03T17:11:12.000Z
|
2020-09-22T13:10:01.000Z
|
#include "test_functions.h"
#include "xo/string/string_tools.h"
namespace spot
{
using xo::squared;
double cigtab_c( double const* x, int N )
{
double sum = 1e4 * x[ 0 ] * x[ 0 ] + 1e-4 * x[ 1 ] * x[ 1 ];
for ( int i = 2; i < N; ++i )
sum += x[ i ] * x[ i ];
return sum;
}
double cigtab( const par_vec& x )
{
double sum = 1e4 * x[ 0 ] * x[ 0 ] + 1e-4 * x[ 1 ] * x[ 1 ];
for ( int i = 2; i < x.size(); ++i )
sum += x[ i ] * x[ i ];
return sum;
}
double sphere( const par_vec& v )
{
double sum = 0.0;
for ( unsigned int i = 0; i < v.size(); ++i )
sum += squared( v[ i ] );
return sum;
}
function_objective make_sphere_objective( size_t d )
{
return function_objective( sphere, d, 0.0, 1.0, -1e9, 1e9, xo::stringf( "sphere-%d", d ) );
}
double himmelblau( const par_vec& v )
{
return squared( squared( v[ 0 ] ) + v[ 1 ] - 11 ) + squared( v[ 0 ] + squared( v[ 1 ] ) - 7 );
}
function_objective make_himmelblau_objective()
{
return function_objective( himmelblau, 2, 0, 2.5, -5, 5, "himmelblau" );
}
double rosenbrock( const par_vec& v )
{
double sum = 0.0;
for ( unsigned int i = 0; i < v.size() - 1; i++ )
sum += 100 * squared( v[ i + 1 ] - squared( v[ i ] ) ) + squared( 1. - v[ i ] );
return sum;
}
function_objective make_rosenbrock_objective( size_t d )
{
return function_objective( rosenbrock, d, 2.5, 1.0, -5, 10, xo::stringf( "rosenbrock-%d", d ) );
}
double schwefel( const par_vec& v )
{
double sum = 0.0;
for ( index_t i = 0; i < v.size(); ++i )
sum += v[ i ] * sin( sqrt( fabs( v[ i ] ) ) );
return 418.9829 * v.size() - sum;
}
function_objective make_schwefel_objective( size_t d )
{
return function_objective( schwefel, d, 0, 100, -500, 500, xo::stringf( "schwefel-%d", d ) );
}
double slow_schwefel( const par_vec& v )
{
double result = 0;
auto dim = v.size();
size_t evals = 1ULL << dim;
for ( size_t i = 0; i < evals; ++i )
{
par_vec v2 = v;
for ( size_t d = 0; d < dim; ++d )
if ( ( 1ULL << d ) & i )
v2[ d ] *= 1.0001;
auto f = schwefel( v2 );
result += f / evals;
}
return result;
}
function_objective make_slow_schwefel_objective( size_t d )
{
return function_objective( slow_schwefel, d, 0, 100, -500, 500 );
}
double rastrigin( const par_vec& v )
{
double sum = 10.0 * v.size();
for ( index_t i = 0; i < v.size(); ++i )
sum += xo::squared( v[ i ] ) - 10.0 * cos( 2 * xo::constantsd::pi() * v[ i ] );
return sum;
}
function_objective make_rastrigin_objective( size_t d )
{
return function_objective( rastrigin, d, 0, 1.0, -5.12, 5.12, xo::stringf( "rastrigin-%d", d ) );
}
std::vector<function_objective> make_objectives( std::initializer_list<size_t> dims )
{
std::vector<function_objective> objs;
for ( auto& d : dims )
{
objs.emplace_back( make_sphere_objective( d ) );
objs.emplace_back( make_rosenbrock_objective( d ) );
objs.emplace_back( make_rastrigin_objective( d ) );
objs.emplace_back( make_schwefel_objective( d ) );
}
return objs;
}
}
| 25.231405
| 99
| 0.588274
|
tgeijten
|
b413de08aab7b03d2d367f1aa0766ce762535a79
| 10,617
|
cpp
|
C++
|
src/creator/variables.cpp
|
Tatrabbit/trance
|
9f0a9c21a079da2e376857138591593a9cff5a21
|
[
"WTFPL"
] | 37
|
2015-02-19T02:36:26.000Z
|
2021-10-05T22:06:17.000Z
|
src/creator/variables.cpp
|
Tatrabbit/trance
|
9f0a9c21a079da2e376857138591593a9cff5a21
|
[
"WTFPL"
] | 21
|
2015-07-14T13:07:14.000Z
|
2019-10-17T15:30:32.000Z
|
src/creator/variables.cpp
|
Tatrabbit/trance
|
9f0a9c21a079da2e376857138591593a9cff5a21
|
[
"WTFPL"
] | 20
|
2016-08-18T11:11:47.000Z
|
2022-03-05T20:58:00.000Z
|
#include <creator/variables.h>
#include <common/common.h>
#include <common/session.h>
#include <creator/item_list.h>
#include <creator/main.h>
#include <algorithm>
#pragma warning(push, 0)
#include <common/trance.pb.h>
#include <wx/button.h>
#include <wx/choice.h>
#include <wx/listctrl.h>
#include <wx/sizer.h>
#include <wx/splitter.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#pragma warning(pop)
namespace
{
const std::string DEFAULT_VALUE_TOOLTIP = "The value to use by default.";
const std::string DESCRIPTION_TOOLTIP =
"Description of what this variable controls. Displayed when choosing "
"a value for this variable on session launch.";
}
VariablePage::VariablePage(wxNotebook* parent, CreatorFrame& creator_frame,
trance_pb::Session& session)
: wxNotebookPage{parent, wxID_ANY}, _creator_frame{creator_frame}, _session(session)
{
auto sizer = new wxBoxSizer{wxVERTICAL};
auto splitter = new wxSplitterWindow{this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxSP_THIN_SASH | wxSP_LIVE_UPDATE};
splitter->SetSashGravity(0);
splitter->SetMinimumPaneSize(128);
auto bottom_panel = new wxPanel{splitter, wxID_ANY};
auto bottom = new wxBoxSizer{wxHORIZONTAL};
auto bottom_splitter = new wxSplitterWindow{bottom_panel, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxSP_THIN_SASH | wxSP_LIVE_UPDATE};
bottom_splitter->SetSashGravity(0.5);
bottom_splitter->SetMinimumPaneSize(128);
auto left_panel = new wxPanel{bottom_splitter, wxID_ANY};
auto left = new wxStaticBoxSizer{wxVERTICAL, left_panel, "Variable values"};
auto right_panel = new wxPanel{bottom_splitter, wxID_ANY};
auto right = new wxStaticBoxSizer{wxVERTICAL, right_panel, "Variable information"};
auto left_buttons = new wxBoxSizer{wxVERTICAL};
_item_list = new ItemList<trance_pb::Variable>{
splitter,
*session.mutable_variable_map(),
"variable",
[&](const std::string& s) {
_item_selected = s;
RefreshOurData();
},
std::bind(&CreatorFrame::VariableCreated, &_creator_frame, std::placeholders::_1),
std::bind(&CreatorFrame::VariableDeleted, &_creator_frame, std::placeholders::_1),
std::bind(&CreatorFrame::VariableRenamed, &_creator_frame, std::placeholders::_1,
std::placeholders::_2),
true};
_value_list = new wxListCtrl{left_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL | wxLC_EDIT_LABELS};
_value_list->InsertColumn(0, "Value", wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE_USEHEADER);
_value_list->SetToolTip(
"Potential values that this variable can be set to "
"when the session is launched.");
_button_new = new wxButton{left_panel, wxID_ANY, "New"};
_button_rename = new wxButton{left_panel, wxID_ANY, "Rename"};
_button_delete = new wxButton{left_panel, wxID_ANY, "Delete"};
_button_new->SetToolTip("Create a new variable value.");
_button_rename->SetToolTip("Rename the selected variable value.");
_button_delete->SetToolTip("Delete the selected variable value.");
left->Add(_value_list, 1, wxEXPAND | wxALL, DEFAULT_BORDER);
left->Add(left_buttons, 0, wxEXPAND, 0);
left_buttons->Add(_button_new, 0, wxEXPAND | wxALL, DEFAULT_BORDER);
left_buttons->Add(_button_rename, 0, wxEXPAND | wxALL, DEFAULT_BORDER);
left_buttons->Add(_button_delete, 0, wxEXPAND | wxALL, DEFAULT_BORDER);
left_panel->SetSizer(left);
wxStaticText* label = nullptr;
label = new wxStaticText{right_panel, wxID_ANY, "Default value:"};
label->SetToolTip(DEFAULT_VALUE_TOOLTIP);
right->Add(label, 0, wxALL, DEFAULT_BORDER);
_default_value = new wxChoice{right_panel, wxID_ANY};
_default_value->SetToolTip(DEFAULT_VALUE_TOOLTIP);
right->Add(_default_value, 0, wxALL | wxEXPAND, DEFAULT_BORDER);
label = new wxStaticText{right_panel, wxID_ANY, "Description:"};
label->SetToolTip(DESCRIPTION_TOOLTIP);
right->Add(label, 0, wxALL, DEFAULT_BORDER);
_description =
new wxTextCtrl{right_panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE};
_description->SetToolTip(DESCRIPTION_TOOLTIP);
right->Add(_description, 1, wxALL | wxEXPAND, DEFAULT_BORDER);
right_panel->SetSizer(right);
bottom->Add(bottom_splitter, 1, wxEXPAND, 0);
bottom_splitter->SplitVertically(left_panel, right_panel);
bottom_panel->SetSizer(bottom);
sizer->Add(splitter, 1, wxEXPAND, 0);
splitter->SplitHorizontally(_item_list, bottom_panel);
SetSizer(sizer);
_value_list->Bind(
wxEVT_SIZE, [&](wxSizeEvent&) { _value_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); },
wxID_ANY);
_value_list->Bind(
wxEVT_LIST_ITEM_SELECTED,
[&](wxListEvent& e) { _current_value = _value_list->GetItemText(e.GetIndex()); }, wxID_ANY);
_value_list->Bind(wxEVT_LIST_END_LABEL_EDIT,
[&](wxListEvent& e) {
if (e.IsEditCancelled()) {
return;
}
e.Veto();
std::string old_name = _current_value;
std::string new_name = e.GetLabel();
if (new_name.empty()) {
return;
}
for (int i = 0; i < _value_list->GetItemCount(); ++i) {
if (_value_list->GetItemText(i) == new_name && i != e.GetIndex()) {
return;
}
}
auto& data = (*_session.mutable_variable_map())[_item_selected];
for (auto& value : *data.mutable_value()) {
if (value == old_name) {
value = new_name;
}
}
if (data.default_value() == old_name) {
data.set_default_value(new_name);
}
_current_value = new_name;
_creator_frame.VariableValueRenamed(_item_selected, old_name, new_name);
RefreshData();
},
wxID_ANY);
_button_new->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [&](wxCommandEvent&) {
static const std::string new_name = "New value";
auto name = new_name;
int number = 0;
auto& data = (*_session.mutable_variable_map())[_item_selected];
while (std::find(data.value().begin(), data.value().end(), name) != data.value().end()) {
name = new_name + " (" + std::to_string(number) + ")";
++number;
}
data.add_value(name);
_current_value = name;
RefreshOurData();
_creator_frame.VariableValueCreated(_item_selected, name);
_creator_frame.MakeDirty(true);
});
_button_rename->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [&](wxCommandEvent&) {
for (int i = 0; i < _value_list->GetItemCount(); ++i) {
if (_value_list->GetItemState(i, wxLIST_STATE_SELECTED)) {
_value_list->EditLabel(i);
return;
}
}
});
_button_delete->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [&](wxCommandEvent&) {
auto& data = (*_session.mutable_variable_map())[_item_selected];
int removed = -1;
for (int i = 0; i < _value_list->GetItemCount(); ++i) {
if (_value_list->GetItemState(i, wxLIST_STATE_SELECTED)) {
removed = i;
break;
}
}
if (removed >= 0) {
for (auto it = data.mutable_value()->begin(); it != data.mutable_value()->end();) {
if (*it == _current_value) {
it = data.mutable_value()->erase(it);
} else {
++it;
}
}
if (data.default_value() == _current_value) {
data.set_default_value(data.value(0));
}
_creator_frame.VariableValueDeleted(_item_selected, _current_value);
_current_value.clear();
}
RefreshOurData();
if (removed >= 0) {
auto index = std::min(_value_list->GetItemCount() - 1, removed);
_current_value = _value_list->GetItemText(index);
_value_list->SetItemState(index, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
_creator_frame.MakeDirty(true);
});
_default_value->Bind(wxEVT_CHOICE, [&](wxCommandEvent&) {
auto it = _session.mutable_variable_map()->find(_item_selected);
if (it == _session.mutable_variable_map()->end()) {
return;
}
it->second.set_default_value(_default_value->GetString(_default_value->GetSelection()));
_creator_frame.MakeDirty(true);
});
_description->Bind(wxEVT_TEXT, [&](wxCommandEvent&) {
auto it = _session.mutable_variable_map()->find(_item_selected);
if (it == _session.mutable_variable_map()->end()) {
return;
}
it->second.set_description(_description->GetValue());
_creator_frame.MakeDirty(true);
});
}
VariablePage::~VariablePage()
{
}
void VariablePage::RefreshOurData()
{
_default_value->Clear();
_description->ChangeValue("");
auto it = _session.variable_map().find(_item_selected);
if (it != _session.variable_map().end()) {
std::vector<std::string> values{it->second.value().begin(), it->second.value().end()};
std::sort(values.begin(), values.end());
if (_current_value.empty() && !values.empty()) {
_current_value = values.front();
}
while (std::size_t(_value_list->GetItemCount()) < values.size()) {
_value_list->InsertItem(_value_list->GetItemCount(), "");
}
while (std::size_t(_value_list->GetItemCount()) > values.size()) {
_value_list->DeleteItem(_value_list->GetItemCount() - 1);
}
long i = 0;
for (const auto& value : values) {
_value_list->SetItemText(i, value);
if (value == _current_value) {
_value_list->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
_default_value->Append(value);
if (value == it->second.default_value()) {
_default_value->SetSelection(i);
}
++i;
}
_description->ChangeValue(it->second.description());
_button_new->Enable(true);
_button_rename->Enable(!values.empty());
_button_delete->Enable(values.size() > 1);
_default_value->Enable(!values.empty());
_description->Enable(true);
} else {
_value_list->DeleteAllItems();
_button_new->Enable(false);
_button_rename->Enable(false);
_button_delete->Enable(false);
_default_value->Enable(false);
_description->Enable(false);
}
}
void VariablePage::RefreshData()
{
_item_list->RefreshData();
RefreshOurData();
}
| 37.515901
| 99
| 0.643685
|
Tatrabbit
|
b413e6a1c49c16896c68833fed3322524c79f3a0
| 5,741
|
hpp
|
C++
|
src/rynx/tech/serialization.hpp
|
Apodus/rynx
|
3e1babc2f2957702ba2b09d78be3a959f2f4ea18
|
[
"MIT"
] | 11
|
2019-08-19T08:44:14.000Z
|
2020-09-22T20:04:46.000Z
|
src/rynx/tech/serialization.hpp
|
Apodus/rynx
|
3e1babc2f2957702ba2b09d78be3a959f2f4ea18
|
[
"MIT"
] | null | null | null |
src/rynx/tech/serialization.hpp
|
Apodus/rynx
|
3e1babc2f2957702ba2b09d78be3a959f2f4ea18
|
[
"MIT"
] | null | null | null |
#pragma once
#include <rynx/tech/ecs/id.hpp>
#include <rynx/system/assert.hpp>
#include <type_traits>
#include <vector>
#include <string>
namespace rynx {
template<typename T, typename IOStream> void serialize(const T& t, IOStream& io);
template<typename T, typename IOStream> void deserialize(T& t, IOStream& io);
template<typename T, typename IOStream> T deserialize(IOStream& io);
namespace serialization {
template<typename T> struct Serialize {
template<typename IOStream>
void serialize(const T& t, IOStream& writer) {
static_assert(std::is_trivially_constructible_v<T> && std::is_trivially_copyable_v<T>, "no serialization defined for type");
if constexpr (std::is_trivially_constructible_v<T> && std::is_trivially_copyable_v<T>) {
writer(&t, sizeof(t));
}
}
template<typename IOStream>
void deserialize(T& t, IOStream& reader) {
if constexpr (std::is_trivially_constructible_v<T> && std::is_trivially_copyable_v<T>) {
reader(&t, sizeof(t));
}
}
};
template<> struct Serialize<rynx::ecs_internal::id> {
template<typename IOStream>
void serialize(const rynx::ecs_internal::id& id, IOStream& writer) {
rynx::serialize(id.value, writer);
}
template<typename IOStream>
void deserialize(rynx::ecs_internal::id& id, IOStream& reader) {
rynx::deserialize(id.value, reader);
}
};
template<> struct Serialize<std::string> {
template<typename IOStream>
void serialize(const std::string& s, IOStream& writer) {
writer(s.size());
writer(s.data(), s.size());
}
template<typename IOStream>
void deserialize(std::string& s, IOStream& reader) {
size_t numElements = 0;
reader(numElements);
s.resize(numElements);
reader(s.data(), numElements);
}
};
template<typename T> struct Serialize<std::vector<T>> {
template<typename IOStream>
void serialize(const std::vector<T>& vec_t, IOStream& writer) {
writer(vec_t.size());
if constexpr (
(sizeof(T) >= alignof(T)) &&
(sizeof(T) % alignof(T) == 0) &&
(std::is_integral_v<T> || std::is_floating_point_v<T>))
{
// fast path for clear cases
// NOTE: Do not serialize non-pods with fast-path, because
// if for some reason T is changed later to not follow alignment rules,
// loading previously written data will fail.
writer(vec_t.data(), sizeof(T) * vec_t.size());
}
else {
for (auto&& t : vec_t)
rynx::serialize(t, writer);
}
}
template<typename IOStream>
void deserialize(std::vector<T>& vec_t, IOStream& reader) {
size_t numElements = 0;
reader(numElements);
size_t originalSize = vec_t.size();
if constexpr (
(sizeof(T) >= alignof(T)) &&
(sizeof(T) % alignof(T) == 0) &&
(std::is_integral_v<T> || std::is_floating_point_v<T>))
{
// fast path for clear cases
// NOTE: Do not serialize non-pods with fast-path, because
// if for some reason T is changed later to not follow alignment rules,
// loading previously written data will fail.
vec_t.resize(originalSize + numElements);
reader(vec_t.data() + originalSize, sizeof(T) * numElements);
}
else
{
vec_t.reserve(originalSize + numElements);
for (size_t i = 0; i < numElements; ++i) {
T t;
rynx::deserialize(t, reader);
vec_t.emplace_back(std::move(t));
}
}
}
};
class vector_reader {
public:
vector_reader(std::vector<char> data) : m_data(std::move(data)) {}
void operator()(void* dst, size_t size) {
rynx_assert(m_head + size <= m_data.size(), "reading out of bounds");
std::memcpy(dst, m_data.data() + m_head, size);
m_head += size;
}
template<typename T> void operator()(T& t) { operator()(&t, sizeof(t)); }
template<typename T> T read() { T t; operator()(&t, sizeof(t)); return t; }
private:
std::vector<char> m_data;
size_t m_head = 0;
};
class vector_writer {
public:
vector_writer() {}
// vector_writer(std::vector<char> data) : m_data(std::move(data)) { m_head = m_data.size(); }
vector_writer(std::vector<char>&& data) : m_data(std::move(data)) { m_head = m_data.size(); }
void operator()(const void* src, size_t size) {
if (m_head + size > m_data.size()) {
m_data.resize((m_head + size) * 2);
}
std::memcpy(m_data.data() + m_head, src, size);
m_head += size;
}
std::vector<char>& data() { return m_data; }
const std::vector<char>& data() const { return m_data; }
template<typename T> void operator()(const T& t) { operator()(&t, sizeof(t)); }
private:
std::vector<char> m_data;
size_t m_head = 0;
};
template<typename T> struct for_each_id_field_t {
template<typename Op> void execute(T&, Op&&) {}
};
template<> struct for_each_id_field_t<rynx::id> {
template<typename Op> void execute(rynx::id& id_value, Op&& op) { op(id_value); }
};
}
template<typename T, typename IOStream> void serialize(const T& t, IOStream& io) {
rynx::serialization::Serialize<T>().serialize(t, io);
}
template<typename T, typename IOStream> void deserialize(T& t, IOStream& io) {
rynx::serialization::Serialize<T>().deserialize(t, io);
}
template<typename T, typename IOStream> T deserialize(IOStream& io) {
T t;
rynx::deserialize(t, io);
return t;
}
template<typename T> rynx::serialization::vector_writer serialize_to_memory(const T& t) {
rynx::serialization::vector_writer writer;
rynx::serialization::Serialize<T>().serialize(t, writer);
return writer;
}
template<typename T, typename Op> void for_each_id_field(T& t, Op&& op) {
rynx::serialization::for_each_id_field_t<T>().execute(t, std::forward<Op>(op));
}
}
| 29.901042
| 128
| 0.649538
|
Apodus
|
b415229805d415481342314e4dca6fb5d6248742
| 852
|
hpp
|
C++
|
src/parser/__ast/DoStmt.hpp
|
shockazoid/HydroLanguage
|
25071995477406245911989584cb3e6f036229c0
|
[
"Apache-2.0"
] | null | null | null |
src/parser/__ast/DoStmt.hpp
|
shockazoid/HydroLanguage
|
25071995477406245911989584cb3e6f036229c0
|
[
"Apache-2.0"
] | null | null | null |
src/parser/__ast/DoStmt.hpp
|
shockazoid/HydroLanguage
|
25071995477406245911989584cb3e6f036229c0
|
[
"Apache-2.0"
] | null | null | null |
//
// __ __ __
// / / / /__ __ ____/ /_____ ____
// / /_/ // / / // __ // ___// __ \
// / __ // /_/ // /_/ // / / /_/ /
// /_/ /_/ \__, / \__,_//_/ \____/
// /____/
//
// The Hydro Programming Language
//
// © 2020 Shockazoid, Inc. All Rights Reserved.
//
#ifndef __h3o_DoStmt_hpp
#define __h3o_DoStmt_hpp
#include "Stmt.hpp"
#include "Expr.hpp"
namespace hydro
{
class DoStmt : public Stmt
{
private:
ast_stmt _body;
ast_expr _cond;
public:
DoStmt(lex_token token, ast_stmt body, ast_expr cond);
virtual ~DoStmt();
ast_stmt body() const { return _body; }
ast_expr cond() const { return _cond; }
};
typedef DoStmt *ast_do;
} // namespace hydro
#endif /* __h3o_DoStmt_hpp */
| 20.780488
| 55
| 0.5
|
shockazoid
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.