Esempio n. 1
0
void FlatShader::CreateEffectFromFile( wchar_t* FXFileName )
{
	_Assert(NULL != UtilityShader::pool);
	D3DXCreateEffectFromFile(gEngine->GetDriver()->GetD3DDevice(), FXFileName, NULL, NULL, D3DXSHADER_DEBUG, UtilityShader::pool, &mEffect, NULL);

	_Assert(NULL != mEffect);
}
Esempio n. 2
0
void ShadowMapRenderer::DrawMeshShadowTexPass(const D3DXMATRIX& matWorld, Geometry* geo, Camera* camera)
{
	_Assert(NULL != geo);

	geo->SetVertexStream();
	geo->SetVertexDeclaration();

	mShadowTexEffect->SetTechnique("Shadow");

	mShadowTexEffect->SetMatrix("matWVP", &(matWorld * camera->ViewMatrix() * camera->ProjMatrix()));
	mShadowTexEffect->SetMatrix("matWorld", &matWorld);

	_Assert(CASCADE_COUNTS >= 3);
	mShadowTexEffect->SetMatrix("matLightVP0", &mVirtualCamera[0].matVP);
	mShadowTexEffect->SetMatrix("matLightVP1", &mVirtualCamera[1].matVP);
	mShadowTexEffect->SetMatrix("matLightVP2", &mVirtualCamera[2].matVP);

	mShadowTexEffect->SetRawValue("lightPos0", &(mVirtualCamera[0].pos), 0, sizeof(Vector3));
	mShadowTexEffect->SetRawValue("lightPos1", &(mVirtualCamera[1].pos), 0, sizeof(Vector3));
	mShadowTexEffect->SetRawValue("lightPos2", &(mVirtualCamera[2].pos), 0, sizeof(Vector3));

	mShadowTexEffect->SetTexture("shadowMapTex0", mShadowMapBluredTex[0]->GetD3DTexture());
	mShadowTexEffect->SetTexture("shadowMapTex1", mShadowMapBluredTex[1]->GetD3DTexture());
	mShadowTexEffect->SetTexture("shadowMapTex2", mShadowMapBluredTex[2]->GetD3DTexture());

	float farZ = 0;
	camera->GetCameraParams(NULL, &farZ, NULL, NULL);
	mShadowTexEffect->SetFloat("farZ", farZ);

	mShadowTexEffect->CommitChanges();

	geo->Draw();
}
Esempio n. 3
0
void ShadowMapRenderer::createTextures()
{
	SAFE_DELETE(mShadowMapTex);
	SAFE_DELETE(mShadowMapBluredTexH);
	SAFE_DELETE(mShadowTex);
	for(int i = 0; i < CASCADE_COUNTS; ++i)
		SAFE_DELETE(mShadowMapBluredTex[i]);

	mShadowMapTex = New Texture;
	mShadowMapTex->Create(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, D3DFMT_G32R32F, D3DUSAGE_RENDERTARGET);

	mShadowMapBluredTexH = New Texture;
	mShadowMapBluredTexH->Create(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, D3DFMT_G32R32F, D3DUSAGE_RENDERTARGET);

	for(int i = 0; i < CASCADE_COUNTS; ++i)
	{
		mShadowMapBluredTex[i] = New Texture;
		mShadowMapBluredTex[i]->Create(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, D3DFMT_G32R32F, D3DUSAGE_RENDERTARGET);

		_Assert(mShadowMapBluredTex[i] != NULL);
	}

	mShadowTex = New Texture;
	mShadowTex->Create(SHADOW_TEX_SIZE, SHADOW_TEX_SIZE, D3DFMT_A8R8G8B8, D3DUSAGE_RENDERTARGET);

	_Assert(mShadowMapTex != NULL);
	_Assert(mShadowTex != NULL);
}
Esempio n. 4
0
static Thread_queue_Heads *_Thread_queue_Queue_enqueue(
  Thread_queue_Queue *queue,
  Thread_Control     *the_thread,
  void             ( *initialize )( Thread_queue_Heads *, Thread_Control * ),
  void             ( *enqueue )( Thread_queue_Heads *, Thread_Control * )
)
{
  Thread_queue_Heads *heads;
  Thread_queue_Heads *spare_heads;

  heads = queue->heads;
  spare_heads = the_thread->Wait.spare_heads;
  the_thread->Wait.spare_heads = NULL;

  if ( heads == NULL ) {
    _Assert( spare_heads != NULL );
    _Assert( _Chain_Is_empty( &spare_heads->Free_chain ) );

    heads = spare_heads;
    queue->heads = heads;
    _Chain_Prepend_unprotected( &heads->Free_chain, &spare_heads->Free_node );
    ( *initialize )( heads, the_thread );
  } else {
    _Chain_Prepend_unprotected( &heads->Free_chain, &spare_heads->Free_node );
    ( *enqueue )( heads, the_thread );
  }

  return heads;
}
Esempio n. 5
0
/// Game
BZGame::BZGame(CAStageLayer* player) : BZBoard(player)
{
	GUARD_FUNCTION();

	_name = "na";

	_nCounter = 0;

	_nScore = 0;
	_typesCount = 0;
	if (_typesCount < BLOCK_TYPES) _types[_typesCount++] = "bubble_a";	else _Assert(false);
	if (_typesCount < BLOCK_TYPES) _types[_typesCount++] = "bubble_b";	else _Assert(false);
	if (_typesCount < BLOCK_TYPES) _types[_typesCount++] = "bubble_c";	else _Assert(false);
	if (_typesCount < BLOCK_TYPES) _types[_typesCount++] = "bubble_d";	else _Assert(false);
	if (_typesCount < BLOCK_TYPES) _types[_typesCount++] = "bubble_e";	else _Assert(false);

	//_types[_typesCount++] = "bird";
	_nGameStatesCount = 0;
	memset(_oldGameStates, 0, sizeof(_oldGameStates));

	setState(GS_Idle);

	_timeLastBorn = 0;

	//_VerifyClass(this);
}
Esempio n. 6
0
void ModelPreviewCanvas::AddjustCameraPos()
{
	_Assert(mCamera != NULL);
	_Assert(mModel != NULL);

	AABBox bound;
	mModel->CalcDynamicAABBox(IDENTITY_MATRIX, &bound);

	float width = bound.GetSize().x;
	float height = bound.GetSize().y;
	float length = bound.GetSize().z;

	float aspect = 0;
	float fov = 0;
	mCamera->GetCameraParams(NULL, NULL, &fov, &aspect);

	float distY = (height / 2.0f) / tan(fov / 2.0f);
	float distX = (height / 2.0f) / (aspect * tan(fov / 2.0f));

	float dist = Max(distX, distY);

	mCamera->SetWorldPosition(bound.GetCenter());
	mCamera->Translate(0, 0, -dist - length);
	mCamera->LookAt(bound.GetCenter());

	HoverCameraController* hoverCameraController = New HoverCameraController(5.0f, 20.0f, -4*PI/9, 4*PI/9, 
		2.0f, 1000.0f, bound.GetCenter(), dist + length);

	mCamera->SetCameraController(hoverCameraController);
}
void _Thread_Exit(
  Thread_Control    *executing,
  Thread_Life_state  set,
  void              *exit_value
)
{
  ISR_lock_Context lock_context;

  _Assert(
    _Watchdog_Get_state( &executing->Timer.Watchdog ) == WATCHDOG_INACTIVE
  );
  _Assert(
    executing->current_state == STATES_READY
      || executing->current_state == STATES_SUSPENDED
  );

  _Thread_State_acquire( executing, &lock_context );
  _Thread_Set_exit_value( executing, exit_value );
  _Thread_Change_life_locked(
    executing,
    0,
    set,
    THREAD_LIFE_PROTECTED | THREAD_LIFE_CHANGE_DEFERRED
  );
  _Thread_State_release( executing, &lock_context );
}
Esempio n. 8
0
int          clsDump::DumpScope(clsScope * pScope, int onlyCalculateSize)
{
  int          iSize = 0;
  unsigned int iIndex;

  iSize += DumpLine("----- SCOPE BEG -----\n", onlyCalculateSize);
  iSize += DumpLine("\tUID %u\n", pScope->m_UID, onlyCalculateSize);
  iSize += DumpLocation(pScope->m_Location, onlyCalculateSize);
  _Assert(pScope->m_pParentScope && "Frontend Error: All scopes should have a parent.");
  iSize += DumpLine("\tParent Scope UID %u\n", pScope->m_pParentScope->m_UID, onlyCalculateSize);
  _Assert(pScope->m_pRootScope && "Frontend Error: All scopes should have a root.");
  iSize += DumpLine("\tRoot Scope UID %u\n", pScope->m_pRootScope->m_UID, onlyCalculateSize);
  iSize += DumpLine("\tNumber of Children Scopes %u\n", pScope->m_pChildrenScopes.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pChildrenScopes.size(); ++iIndex)
  {
    iSize += DumpLine("\tChild Scope UID %u\n", pScope->m_pChildrenScopes[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Signals %u\n", pScope->m_pSignals.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pSignals.size(); ++iIndex)
  {
    iSize += DumpLine("\tSignal UID %u\n", pScope->m_pSignals[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Arguments %u\n", pScope->m_pArguments.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pArguments.size(); ++iIndex)
  {
    iSize += DumpLine("\tArgument UID %u\n", pScope->m_pArguments[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Parameters %u\n", pScope->m_pParameters.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pParameters.size(); ++iIndex)
  {
    iSize += DumpLine("\tParameter UID %u\n", pScope->m_pParameters[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Conditions %u\n", pScope->m_pConditions.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pConditions.size(); ++iIndex)
  {
    iSize += DumpLine("\tCondition UID %u\n", pScope->m_pConditions[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Events %u\n", pScope->m_pEvents.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pEvents.size(); ++iIndex)
  {
    iSize += DumpLine("\tEvent UID %u\n", pScope->m_pEvents[iIndex]->m_UID, onlyCalculateSize);
  }
  if (pScope->m_pBasicBlock)
  {
    iSize += DumpLine("\tHas Basicblock %u\n", true, onlyCalculateSize);
    iSize += DumpLine("\tBasicblock UID %u\n", pScope->m_pBasicBlock->m_UID, onlyCalculateSize);
  }
  else
  {
    iSize += DumpLine("\tHas No Basicblock %u\n", false, onlyCalculateSize);
  }
  iSize += DumpString("\tScope Name\n", pScope->m_sScopeName, onlyCalculateSize);
  iSize += DumpLine("\tScope Type UID %u\n", pScope->m_pScopeType->m_UID, onlyCalculateSize);
  iSize += DumpLine("\tScope is Root = %u\n", pScope->m_IsRoot, onlyCalculateSize);
  iSize += DumpLine("\tScope is Automatic = %u\n", pScope->m_IsAutomatic, onlyCalculateSize);
  iSize += DumpLine("----- SCOPE END -----\n", onlyCalculateSize);

  return iSize;
}
Esempio n. 9
0
void BumpSpecularShader::Render(const D3DXMATRIX& matWorld, Geometry* geo, Camera* camera, bool isStandAlone)
{
	_Assert(NULL != geo);
	_Assert(NULL != camera);

	geo->SetVertexStream();
	geo->SetVertexDeclaration();

	BumpSpecularShader::mEffect->SetTechnique("BumpSpecular");

	BumpSpecularShader::mEffect->SetMatrix("matWVP", &(matWorld * camera->ViewMatrix() * camera->ProjMatrix()));
	BumpSpecularShader::mEffect->SetMatrix("matWorld", &matWorld);
	BumpSpecularShader::mEffect->SetMatrix("matUVTransform", &(mMaterial->UVTransformMatrix()));

	BumpSpecularShader::mEffect->SetRawValue("eyePos", &(camera->GetRelativePosition()), 0, sizeof(Vector3));

	if(NULL == mMaterial->GetTexture(0))
	{
		BumpSpecularShader::mEffect->SetBool("useColorTex", false);
	}
	else
	{
		BumpSpecularShader::mEffect->SetBool("useColorTex", true);	
		BumpSpecularShader::mEffect->SetTexture("colorTex", mMaterial->GetTexture(0)->GetD3DTexture());
	}

	if(gEngine->GetSceneManager()->NeedDirLightShadow())
	{
		BumpSpecularShader::mEffect->SetBool("calcShadow", true);
		BumpSpecularShader::mEffect->SetTexture("shadowTex", ShadowMapRenderer::GetShadowTex()->GetD3DTexture());
	}
	else
	{
		BumpSpecularShader::mEffect->SetBool("calcShadow", false);
	}

	BumpSpecularShader::mEffect->SetTexture("normalTex", mMaterial->GetTexture(1)->GetD3DTexture());

	BumpSpecularShader::mEffect->SetRawValue("mtlAmbient", &(mMaterial->GetAmbientColor()), 0, sizeof(D3DXCOLOR));
	BumpSpecularShader::mEffect->SetRawValue("mtlDiffuse", &(mMaterial->GetDiffuseColor()), 0, sizeof(D3DXCOLOR));
	BumpSpecularShader::mEffect->SetRawValue("mtlSpec", &(mMaterial->GetFinalSpecularColor()), 0, sizeof(D3DXCOLOR));
	BumpSpecularShader::mEffect->SetFloat("gloss", mMaterial->GetSpecGloss());

	BumpSpecularShader::mEffect->CommitChanges();

	if(isStandAlone)
	{
		BumpSpecularShader::mEffect->Begin(0, 0);
		BumpSpecularShader::mEffect->BeginPass(0);
	}

	geo->Draw();

	if(isStandAlone)
	{
		BumpSpecularShader::mEffect->EndPass();
		BumpSpecularShader::mEffect->End();
	}
}
Esempio n. 10
0
bool BZStagePlayLayerGamePlay::checkCondition(CAState* from, const CATransition& trans)
{
	//root.idle:	inner condition
	//root.running:	button event
	if (CAMachine::checkCondition(from, trans))
		return true;

	bool result = false;
	float timeout = trans.timeout;
	if (timeout > 0 && this->getTimeNow() - from->getTimeEnter() > timeout)
	{
		return true;
	}

	string fname = from->getFullName();
	if (CAString::startWith(fname, "root.fade"))
	{
		const char* pszPose = "fadein";
		if (fname == "root.fadein")
		{
		}
		else if (fname == "root.fadeout")
		{
			pszPose = "fadeout";
		}
		else
		{
			_Assert(false);
		}
		if (result)
		{
			string result = "";
			result += from->getFullName();
			result += "@";
			result += trans.condition;
			this->setConditionResult(result.c_str(), true);
		}
	}
	else if (fname == "root.diving")
	{
	}
	else if (fname == "root.resume" || fname == "root.restart")
	{
		CAStageLayer* pl = this->getSubLayer("game.play.pause");
		_Assert(pl);
		_Assert(trans.condition == "pause.isidle" || trans.condition == "over.isidle");
		if (pl->getCurrentState()->getFullName() == "root.idle")
		{
			return true;
		}
	}

	if (CAMachine::checkCondition(from, trans))
		return true;

	return false;
}
Esempio n. 11
0
static void _Thread_Start_life_change_for_executing(
  Thread_Control *executing
)
{
  _Assert( executing->Timer.state == WATCHDOG_INACTIVE );
  _Assert(
    executing->current_state == STATES_READY
      || executing->current_state == STATES_SUSPENDED
  );

  _Thread_Add_life_change_action( executing );
}
Esempio n. 12
0
void ShadowMapRenderer::createRendertargetDepthStencil()
{
	SAFE_RELEASE(mShadowMapRTSurface);
	SAFE_RELEASE(mDepthStencilSurface);

	gEngine->GetDriver()->GetD3DDevice()->CreateRenderTarget(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, D3DFMT_G32R32F, 
		D3DMULTISAMPLE_8_SAMPLES, 0, false, &mShadowMapRTSurface, NULL);

	gEngine->GetDriver()->GetD3DDevice()->CreateDepthStencilSurface(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, D3DFMT_D24X8, 
		D3DMULTISAMPLE_8_SAMPLES, 0, true, &mDepthStencilSurface, NULL);

	_Assert(mShadowMapRTSurface != NULL);
	_Assert(mDepthStencilSurface != NULL);
}
Esempio n. 13
0
Objects_Control *_Objects_Get_by_name(
  const Objects_Information *information,
  const char                *name,
  size_t                    *name_length_p,
  Objects_Get_by_name_error *error
)
{
  size_t   name_length;
  size_t   max_name_length;
  uint32_t index;

  _Assert( information->is_string );
  _Assert( _Objects_Allocator_is_owner() );

  if ( name == NULL ) {
    *error = OBJECTS_GET_BY_NAME_INVALID_NAME;
    return NULL;
  }

  name_length = strnlen( name, information->name_length + 1 );
  max_name_length = information->name_length;
  if ( name_length > max_name_length ) {
    *error = OBJECTS_GET_BY_NAME_NAME_TOO_LONG;
    return NULL;
  }

  if ( name_length_p != NULL ) {
    *name_length_p = name_length;
  }

  for ( index = 1; index <= information->maximum; index++ ) {
    Objects_Control *the_object;

    the_object = information->local_table[ index ];

    if ( the_object == NULL )
      continue;

    if ( the_object->name.name_p == NULL )
      continue;

    if ( strncmp( name, the_object->name.name_p, max_name_length ) == 0 ) {
      return the_object;
    }
  }

  *error = OBJECTS_GET_BY_NAME_NO_OBJECT;
  return NULL;
}
Esempio n. 14
0
bool _Thread_queue_Do_extract_locked(
  Thread_queue_Queue            *queue,
  const Thread_queue_Operations *operations,
  Thread_Control                *the_thread
#if defined(RTEMS_MULTIPROCESSING)
  ,
  const Thread_queue_Context    *queue_context
#endif
)
{
  bool success;
  bool unblock;

#if defined(RTEMS_MULTIPROCESSING)
  if ( !_Objects_Is_local_id( the_thread->Object.id ) ) {
    Thread_Proxy_control    *the_proxy;
    Thread_queue_MP_callout  mp_callout;

    the_proxy = (Thread_Proxy_control *) the_thread;
    mp_callout = queue_context->mp_callout;
    _Assert( mp_callout != NULL );
    the_proxy->thread_queue_callout = queue_context->mp_callout;
  }
#endif

  ( *operations->extract )( queue, the_thread );

  /*
   * We must update the wait flags under protection of the current thread lock,
   * otherwise a _Thread_Timeout() running on another processor may interfere.
   */
  success = _Thread_Wait_flags_try_change_release(
    the_thread,
    THREAD_QUEUE_INTEND_TO_BLOCK,
    THREAD_QUEUE_READY_AGAIN
  );
  if ( success ) {
    unblock = false;
  } else {
    _Assert( _Thread_Wait_flags_get( the_thread ) == THREAD_QUEUE_BLOCKED );
    _Thread_Wait_flags_set( the_thread, THREAD_QUEUE_READY_AGAIN );
    unblock = true;
  }

  _Thread_Wait_restore_default( the_thread );

  return unblock;
}
Esempio n. 15
0
void _Timer_Cancel( Per_CPU_Control *cpu, Timer_Control *the_timer )
{
  Timer_Classes the_class;

  the_class = the_timer->the_class;

  if ( _Watchdog_Is_scheduled( &the_timer->Ticker ) ) {
    the_timer->stop_time = _Timer_Get_CPU_ticks( cpu );
    _Watchdog_Remove(
      &cpu->Watchdog.Header[ _Timer_Watchdog_header_index( the_class ) ],
      &the_timer->Ticker
    );
  } else if ( _Timer_Is_on_task_class( the_class ) ) {
    Timer_server_Control *timer_server;
    ISR_lock_Context      lock_context;

    timer_server = _Timer_server;
    _Assert( timer_server != NULL );
    _Timer_server_Acquire_critical( timer_server, &lock_context );

    if ( _Watchdog_Get_state( &the_timer->Ticker ) == WATCHDOG_PENDING ) {
      _Watchdog_Set_state( &the_timer->Ticker, WATCHDOG_INACTIVE );
      _Chain_Extract_unprotected( &the_timer->Ticker.Node.Chain );
    }

    _Timer_server_Release_critical( timer_server, &lock_context );
  }
}
Esempio n. 16
0
static void _Thread_queue_Priority_priority_change(
  Thread_queue_Queue *queue,
  Thread_Control     *the_thread,
  Priority_Control    new_priority
)
{
  Thread_queue_Heads          *heads;
  Thread_queue_Priority_queue *priority_queue;
  Scheduler_Node              *scheduler_node;

  heads = queue->heads;
  _Assert( heads != NULL );

  priority_queue = _Thread_queue_Priority_queue( heads, the_thread );
  scheduler_node = _Scheduler_Thread_get_own_node( the_thread );

  _RBTree_Extract(
    &priority_queue->Queue,
    &scheduler_node->Wait.Node.RBTree
  );
  _RBTree_Insert_inline(
    &priority_queue->Queue,
    &scheduler_node->Wait.Node.RBTree,
    &new_priority,
    _Thread_queue_Priority_less
  );
}
Esempio n. 17
0
void *_Freechain_Get(
  Freechain_Control   *freechain,
  Freechain_Allocator  allocator,
  size_t               number_nodes_to_extend,
  size_t               node_size
)
{
  _Assert( node_size >= sizeof( Chain_Node ) );

  if ( _Chain_Is_empty( &freechain->Free ) && number_nodes_to_extend > 0 ) {
    void *starting_address;

    starting_address = ( *allocator )( number_nodes_to_extend * node_size );
    number_nodes_to_extend *= ( starting_address != NULL );

    _Chain_Initialize(
      &freechain->Free,
      starting_address,
      number_nodes_to_extend,
      node_size
    );
  }

  return _Chain_Get_unprotected( &freechain->Free );
}
Esempio n. 18
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 缩放所有窗口
VOID CClientWnd::OnPlayZoom(UINT uCmd)
{
	RECT rtMain;
	RECT rtClient;
	RECT rtChild;

	SendMessage(m_hWnd, WM_MDICASCADE, 0, 0);
	HWND hWnd = GetWindow(m_hWnd, GW_CHILD);
	for (hWnd = GetWindow(hWnd, GW_HWNDFIRST); hWnd; )
	{
		_Assert(GetChildWnd(hWnd));
		GetChildWnd(hWnd)->OnPlayZoom(uCmd, FALSE);
		hWnd = GetWindow(hWnd, GW_HWNDNEXT);
	}

	if (m_bScrabble)
	{
		GetWindowRect(CMainWnd::m_hWnd, &rtMain);
		GetClientRect(m_hWnd, &rtClient);
		hWnd = GetWindow(GetWindow(m_hWnd, GW_CHILD), GW_HWNDFIRST);
		GetWindowRect(hWnd, &rtChild);

		MoveWindow(CMainWnd::m_hWnd, rtMain.left, rtMain.top, 
			_RectWidth(rtMain) - _RectWidth(rtClient) + _RectWidth(rtChild),
			_RectHeight(rtMain) - _RectHeight(rtClient) + _RectHeight(rtChild), TRUE);
	}
}
Esempio n. 19
0
void TreeGeneratorFrame::getValueGeneralParams(TreeGeneralParams* generalParams)
{
	_Assert(NULL != generalParams);

	double scale = 0;
	double scaleV = 0;
	double baseSize = 0;
	double radiusRatio = 0;
	double ratioPower = 0;

	mTextScale->GetValue().ToDouble(&scale);
	mTextScaleV->GetValue().ToDouble(&scaleV);
	mTextBaseSize->GetValue().ToDouble(&baseSize);
	mTextRadiusRatio->GetValue().ToDouble(&radiusRatio);
	mTextRatioPower->GetValue().ToDouble(&ratioPower);

	generalParams->scale = scale;
	generalParams->scaleV = scaleV;
	generalParams->baseSize = baseSize;
	generalParams->radiusRatio = radiusRatio;
	generalParams->ratioPower = ratioPower;

	generalParams->levels = mSpinLevels->GetValue();
	generalParams->shape = mSpinShape->GetValue();
	generalParams->baseSplits = mSpinBaseSplits->GetValue();
}
Esempio n. 20
0
RTEMS_INLINE_ROUTINE bool _Scheduler_Set_root_visitor(
  Resource_Node *resource_node,
  void          *arg
)
{
  Scheduler_Set_root_context *ctx = arg;
  Thread_Control *root = ctx->root;
  Thread_Control *needs_help = root;
  Thread_Control *offers_help =
    THREAD_RESOURCE_NODE_TO_THREAD( resource_node );
  const Scheduler_Control *scheduler = _Scheduler_Get_own( offers_help );
  Thread_Control *needs_help_too;

  _Resource_Node_set_root( resource_node, &root->Resource_node );

  needs_help_too = ( *scheduler->Operations.ask_for_help )(
    scheduler,
    offers_help,
    needs_help
  );

  if ( needs_help_too != needs_help && needs_help_too != NULL ) {
    _Assert( ctx->needs_help == NULL );
    ctx->needs_help = needs_help_too;
  }

  return false;
}
Esempio n. 21
0
void _Scheduler_Thread_change_resource_root(
  Thread_Control *top,
  Thread_Control *root
)
{
  Scheduler_Set_root_context ctx = { root, NULL };
  Thread_Control *offers_help = top;
  Scheduler_Node *offers_help_node;
  Thread_Control *offers_help_too;

  offers_help_node = _Scheduler_Thread_get_node( offers_help );
  offers_help_too = _Scheduler_Node_get_owner( offers_help_node );

  if ( offers_help != offers_help_too ) {
    _Scheduler_Set_root_visitor( &offers_help_too->Resource_node, &ctx );
    _Assert( ctx.needs_help == offers_help );
    ctx.needs_help = NULL;
  }

  _Scheduler_Set_root_visitor( &top->Resource_node, &ctx );
  _Resource_Iterate( &top->Resource_node, _Scheduler_Set_root_visitor, &ctx );

  if ( ctx.needs_help != NULL ) {
    _Scheduler_Ask_for_help( ctx.needs_help );
  }
}
Esempio n. 22
0
// 添加新session
void TcpListener::event_new_session(tcp::socket& sk)
{
	TcpSession::TcpSessionSptr session = std::make_shared<TcpSession>(m_loop, next_session_id(),
		std::bind(&TcpListener::event_session_error, this, std::placeholders::_1, std::placeholders::_2),
		nullptr,
		std::bind(&TcpListener::event_session_disconnect, this, std::placeholders::_1),
		std::bind(&TcpListener::event_readable, this, std::placeholders::_1));

	// 添加到列表
	bool succ = m_map_session.insert(std::make_pair(session->sid(), session)).second;
	if (succ == false)
	{
		session->stop();
		_Assert(false, "添加新session失败");
		return;
	}

	// 开启session
	session->start();

	// 添加到事件列表
	std::unique_lock<std::mutex> ul(m_mtx_ev);
	m_events.push_back(std::bind(&TcpListener::fun_session_new, this, session));
	ul.unlock();
}
Esempio n. 23
0
void _Semaphore_Post( struct _Semaphore_Control *_sem )
{
  Semaphore_Control    *sem;
  Thread_queue_Context  queue_context;
  Thread_queue_Heads   *heads;

  sem = _Semaphore_Get( _sem );
  _Thread_queue_Context_initialize( &queue_context );
  _Semaphore_Queue_acquire( sem, &queue_context );

  heads = sem->Queue.Queue.heads;
  if ( heads == NULL ) {
    _Assert( sem->count < UINT_MAX );
    ++sem->count;
    _Semaphore_Queue_release( sem, &queue_context );
  } else {
    const Thread_queue_Operations *operations;
    Thread_Control *first;

    operations = SEMAPHORE_TQ_OPERATIONS;
    first = ( *operations->first )( heads );

    _Thread_queue_Extract_critical(
      &sem->Queue.Queue,
      operations,
      first,
      &queue_context
    );
  }
}
Esempio n. 24
0
static bool _Thread_queue_Make_ready_again( Thread_Control *the_thread )
{
    bool success;
    bool unblock;

    /*
     * We must update the wait flags under protection of the current thread lock,
     * otherwise a _Thread_Timeout() running on another processor may interfere.
     */
    success = _Thread_Wait_flags_try_change_release(
                  the_thread,
                  THREAD_QUEUE_INTEND_TO_BLOCK,
                  THREAD_QUEUE_READY_AGAIN
              );
    if ( success ) {
        unblock = false;
    } else {
        _Assert( _Thread_Wait_flags_get( the_thread ) == THREAD_QUEUE_BLOCKED );
        _Thread_Wait_flags_set( the_thread, THREAD_QUEUE_READY_AGAIN );
        unblock = true;
    }

    _Thread_Wait_restore_default( the_thread );
    return unblock;
}
Esempio n. 25
0
void _Thread_queue_Surrender_sticky(
    Thread_queue_Queue            *queue,
    Thread_queue_Heads            *heads,
    Thread_Control                *previous_owner,
    Thread_queue_Context          *queue_context,
    const Thread_queue_Operations *operations
)
{
    Thread_Control  *new_owner;
    Per_CPU_Control *cpu_self;

    _Assert( heads != NULL );

    _Thread_queue_Context_clear_priority_updates( queue_context );
    new_owner = ( *operations->surrender )(
                    queue,
                    heads,
                    previous_owner,
                    queue_context
                );
    queue->owner = new_owner;
    _Thread_queue_Make_ready_again( new_owner );

    cpu_self = _Thread_Dispatch_disable_critical(
                   &queue_context->Lock_context.Lock_context
               );
    _Thread_queue_Queue_release(
        queue,
        &queue_context->Lock_context.Lock_context
    );
    _Thread_Priority_and_sticky_update( previous_owner, -1 );
    _Thread_Priority_and_sticky_update( new_owner, 0 );
    _Thread_Dispatch_enable( cpu_self );
}
Esempio n. 26
0
void BZSpriteButton::_onClick()
{
	_Assert(_bEnabled);
	_setAnimateState(BS_Idle);
	_Debug("button %s clicked", this->getModName().c_str());
	_pLayer->onEvent(new CAEventCommand(this, "onClick"));
}
Esempio n. 27
0
void _TOD_Set(
  const Timestamp_Control *tod_as_timestamp,
  ISR_lock_Context        *lock_context
)
{
  struct timespec tod_as_timespec;
  uint64_t        tod_as_ticks;
  uint32_t        cpu_count;
  uint32_t        cpu_index;

  _Assert( _API_Mutex_Is_owner( _Once_Mutex ) );

  _Timecounter_Set_clock( tod_as_timestamp, lock_context );

  _Timestamp_To_timespec( tod_as_timestamp, &tod_as_timespec );
  tod_as_ticks = _Watchdog_Ticks_from_timespec( &tod_as_timespec );
  cpu_count = _SMP_Get_processor_count();

  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
    Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );

    _Watchdog_Per_CPU_tickle_absolute( cpu, tod_as_ticks );
  }

  _TOD.is_set = true;
}
Esempio n. 28
0
void _Mutex_recursive_Release( struct _Mutex_recursive_Control *_mutex )
{
  Mutex_recursive_Control *mutex;
  Thread_queue_Context     queue_context;
  ISR_Level                level;
  Thread_Control          *executing;
  unsigned int             nest_level;

  mutex = _Mutex_recursive_Get( _mutex );
  _Thread_queue_Context_initialize( &queue_context );
  _Thread_queue_Context_ISR_disable( &queue_context, level );
  executing = _Mutex_Queue_acquire_critical( &mutex->Mutex, &queue_context );

  _Assert( mutex->Mutex.Queue.Queue.owner == executing );

  nest_level = mutex->nest_level;

  if ( __predict_true( nest_level == 0 ) ) {
    _Mutex_Release_critical( &mutex->Mutex, executing, level, &queue_context );
  } else {
    mutex->nest_level = nest_level - 1;

    _Mutex_Queue_release( &mutex->Mutex, level, &queue_context );
  }
}
Esempio n. 29
0
Box::Box(const Box &old_box)
{
	_Init(old_box._xsize, old_box._ysize, old_box._xpos, old_box._ypos, old_box._border,
		old_box._outer_colour, old_box._inner_colour);
	if (!_Assert())
		throw std::invalid_argument("Box [WARNING]: constructor recieved an invalid input.");
}
Esempio n. 30
0
void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing )
{
  _Assert( _Thread_Is_life_protected( executing->Life.state ) );

  if ( _States_Is_dormant( the_thread->current_state ) ) {
    _Thread_Make_zombie( the_thread );
  } else {
    if (
      the_thread != executing
        && !_Thread_Is_life_terminating( executing->Life.state )
    ) {
      /*
       * Wait for termination of victim thread.  If the executing thread is
       * also terminated, then do not wait.  This avoids potential cyclic
       * dependencies and thus dead lock.
       */
       the_thread->Life.terminator = executing;
       _Thread_Set_state( executing, STATES_WAITING_FOR_TERMINATION );
    }

    _Thread_Request_life_change(
      the_thread,
      executing,
      executing->current_priority,
      THREAD_LIFE_TERMINATING
    );
  }
}