📄 dtbase.cpp
字号:
WI.pvThis = this;
long Start = lStartAtRow;
ULONG Count = RowsPerBand;
long OutputYDelta = WI.OutputBnds[DXB_Y].Min - WI.DoBnds[DXB_Y].Min;
for( ulBand = 0; ulBand < ulNumBandsToDo; ++ulBand )
{
memcpy( &WIArray[ulBand], &WI, sizeof( WI ) );
WIArray[ulBand].DoBnds[DXB_Y].Min = Start;
WIArray[ulBand].OutputBnds[DXB_Y].Min = Start + OutputYDelta;
WIArray[ulBand].DoBnds[DXB_Y].Max = Start + Count;
WIArray[ulBand].OutputBnds[DXB_Y].Max = Start + Count + OutputYDelta;
TaskInfo[ulBand].pfnTaskProc = _TaskProc;
TaskInfo[ulBand].pTaskData = &WIArray[ulBand];
TaskInfo[ulBand].pfnCompletionAPC = NULL;
TaskInfo[ulBand].dwCompletionData = 0;
TaskInfo[ulBand].pRequestID = pRequestID;
//--- Advance
Start += Count;
//--- Check for a remainder and add on to the last band.
if( ( ulRowCount - ( Start + Count ) ) < Count )
{
Count = ulRowCount - Start;
}
}
//
// Procedural surfaces (and perhaps some transforms) need to "know" that
// they are in a multi-threaded work procedure to avoid deadlocks. Procedural
// surfaces need to allow LockSurface to work WITHOUT taking the object
// critical section. Other transforms may also want to know this information
// to avoid deadlocks.
//
m_bInMultiThreadWorkProc = TRUE;
//--- Schedule the work and wait for it to complete
hr = m_cpTaskMgr->ScheduleTasks( TaskInfo, m_aEvent,
TaskIDs, ulNumBandsToDo, m_ulLockTimeOut );
m_bInMultiThreadWorkProc = FALSE;
//--- Check return codes from work info structures
// return the first bad hr if any
for( ulBand = 0; SUCCEEDED( hr ) && ( ulBand < ulNumBandsToDo ); ++ulBand )
{
hr = WIArray[ulBand].hr;
if( hr != S_OK ) break;
}
}
OnFreeInstData( WI );
}
#ifdef _DEBUG
if( FAILED( hr ) ) DXTDBG_MSG1( _CRT_ERROR, "\nExecute failed. HR = %X", hr );
#endif
return hr;
} /* CDXBaseNTo1::Execute */
/*****************************************************************************
* CDXBaseNTo1::_ImageMapIn2Out *
*------------------------------*
* Description:
*-----------------------------------------------------------------------------
* Created By: RAL Date: 07/28/97
*****************************************************************************/
HRESULT CDXBaseNTo1::_ImageMapIn2Out( CDXDBnds & bnds, ULONG ulNumInBnds,
const CDXDBnds * pInBounds )
{
HRESULT hr = S_OK;
if(ulNumInBnds)
{
for(ULONG i = 0; i < ulNumInBnds; ++i )
{
bnds |= pInBounds[i];
}
}
else
{
for( ULONG i = 0; SUCCEEDED(hr) && i < m_ulNumInputs; ++i )
{
if (InputSurface(i))
{
CDXDBnds SurfBnds(InputSurface(i), hr);
bnds |= SurfBnds;
}
}
}
if (SUCCEEDED(hr))
{
hr = DetermineBnds(bnds);
}
return hr;
} /* CDXBaseNTo1::_ImageMapIn2Out */
/*****************************************************************************
* CDXBaseNTo1::_MeshMapIn2Out *
*-----------------------------*
* Description:
*-----------------------------------------------------------------------------
* Created By: RAL Date: 07/28/97
*****************************************************************************/
HRESULT CDXBaseNTo1::_MeshMapIn2Out(CDXCBnds & bnds, ULONG ulNumInBnds, CDXCBnds * pInBounds)
{
HRESULT hr = S_OK;
if (m_dwOptionFlags & DXBOF_INPUTS_MESHBUILDER)
{
if(ulNumInBnds)
{
for(ULONG i = 0; i < ulNumInBnds; ++i )
{
bnds |= pInBounds[i];
}
}
else
{
for(ULONG i = 0; SUCCEEDED(hr) && i < m_ulNumInputs; ++i )
{
if (InputMeshBuilder(i))
{
CDXCBnds MeshBnds(InputMeshBuilder(i), hr);
bnds |= MeshBnds;
}
}
}
}
else
{
// Already done -> bnds[DXB_T].Min = 0.0f;
bnds[DXB_X].Min = bnds[DXB_Y].Min = bnds[DXB_Z].Min = -1.0f;
bnds[DXB_X].Max = bnds[DXB_Y].Max = bnds[DXB_Z].Max = bnds[DXB_T].Max = 1.0f;
}
//
// Call the derived class to get the scale values.
//
if (SUCCEEDED(hr))
{
// Increase the size just a bit so we won't have rounding errors
// result in bounds that don't actually contain the result.
const float fBndsIncrease = 0.0001F;
float fTemp = bnds.Width() * fBndsIncrease;
bnds[DXB_X].Min -= fTemp;
bnds[DXB_X].Max += fTemp;
fTemp = fBndsIncrease * bnds.Height();
bnds[DXB_Y].Min -= fTemp;
bnds[DXB_Y].Max += fTemp;
fTemp = fBndsIncrease * bnds.Depth();
bnds[DXB_Z].Min -= fTemp;
bnds[DXB_Z].Max += fTemp;
hr = DetermineBnds(bnds);
}
return hr;
} /* CDXBaseNTo1::_MeshMapIn2Out */
/*****************************************************************************
* CDXBaseNTo1::MapBoundsIn2Out *
*------------------------------*
* Description:
* The MapBoundsIn2Out method is used to perform coordinate transformation
* from the input to the output coordinate space.
*-----------------------------------------------------------------------------
* Created By: Ed Connell Date: 07/28/97
*-----------------------------------------------------------------------------
* Parameters:
*****************************************************************************/
STDMETHODIMP CDXBaseNTo1::MapBoundsIn2Out( const DXBNDS *pInBounds, ULONG ulNumInBnds,
ULONG ulOutIndex, DXBNDS *pOutBounds )
{
DXTDBG_FUNC( "CDXBaseNTo1::MapBoundsIn2Out" );
if((ulNumInBnds && DXIsBadReadPtr( pInBounds, ulNumInBnds * sizeof( *pInBounds ) )) ||
ulOutIndex)
{
return E_INVALIDARG;
}
if( DXIsBadWritePtr( pOutBounds, sizeof( *pOutBounds ) ) )
{
return E_POINTER;
}
//
// Set the bounds to empty and the appropriate type.
//
memset(pOutBounds, 0, sizeof(*pOutBounds));
_ASSERT(DXBT_DISCRETE == 0);
if (m_dwOptionFlags & DXBOF_OUTPUT_MESHBUILDER)
{
pOutBounds->eType = DXBT_CONTINUOUS;
}
//
// Make sure all input bounds are of the correct type.
//
if( ulNumInBnds )
{
DXBNDTYPE eType = (m_dwOptionFlags & DXBOF_INPUTS_MESHBUILDER) ? DXBT_CONTINUOUS : DXBT_DISCRETE;
for (ULONG i = 0; i < ulNumInBnds; i++)
{
if (pInBounds[i].eType != eType)
{
return E_INVALIDARG;
}
}
}
//
// Now do the appropriate mapping
//
if (m_dwOptionFlags & DXBOF_OUTPUT_MESHBUILDER)
{
//
// NOTE: In the case of non-mesh inputs, the inputs are discrete, but they will
// be completely ignored by the function so it's OK to cast them to CDXCBnds
//
return _MeshMapIn2Out(*((CDXCBnds *)pOutBounds), ulNumInBnds, (CDXCBnds *)pInBounds);
}
else
{
return _ImageMapIn2Out(*(CDXDBnds *)pOutBounds, ulNumInBnds, (CDXDBnds *)pInBounds);
}
} /* CDXBaseNTo1::MapBoundsIn2Out */
/*****************************************************************************
* CDXBaseNTo1::MapBoundsOut2In *
*------------------------------*
* Description:
* The MapBoundsOut2In method is used to perform coordinate transformation
* from the input to the output coordinate space.
*-----------------------------------------------------------------------------
* Created By: Ed Connell Date: 07/28/97
*-----------------------------------------------------------------------------
* Parameters:
*****************************************************************************/
STDMETHODIMP CDXBaseNTo1::
MapBoundsOut2In( ULONG ulOutIndex, const DXBNDS *pOutBounds, ULONG ulInIndex, DXBNDS *pInBounds )
{
DXTDBG_FUNC( "CDXBaseNTo1::MapBoundsOut2In" );
HRESULT hr = S_OK;
if (m_dwOptionFlags & DXBOF_OUTPUT_MESHBUILDER)
{
hr = E_NOTIMPL; // This is pointless for meshes.
}
else if(ulInIndex >= m_ulMaxInputs || ulOutIndex || DXIsBadReadPtr( pOutBounds, sizeof( *pOutBounds ) ) )
{
hr = E_INVALIDARG;
}
else if( DXIsBadWritePtr( pInBounds, sizeof( *pInBounds ) ) )
{
hr = E_POINTER;
}
else
{
*pInBounds = *pOutBounds;
}
return hr;
} /* CDXBaseNTo1::MapBoundsOut2In */
/*****************************************************************************
* CDXBaseNTo1::SetMiscFlags *
*---------------------------*
* Description:
*-----------------------------------------------------------------------------
* Created By: RAL Date: 10/30.97
*-----------------------------------------------------------------------------
* Parameters:
* bMiscFlags - New value to set
*****************************************************************************/
STDMETHODIMP CDXBaseNTo1::SetMiscFlags( DWORD dwMiscFlags )
{
DXTDBG_FUNC( "CDXBaseNTo1::SetMiscFlags" );
HRESULT hr = S_OK;
Lock();
WORD wOpts = (WORD)dwMiscFlags; // Ignore high word. Only set low word.
if (((WORD)m_dwMiscFlags) != wOpts)
{
if ((wOpts & (~DXTMF_VALID_OPTIONS)) ||
((wOpts & DXTMF_BLEND_WITH_OUTPUT) && (m_dwMiscFlags & DXTMF_BLEND_SUPPORTED) == 0) ||
((wOpts & DXTMF_DITHER_OUTPUT) && (m_dwMiscFlags & DXTMF_DITHER_SUPPORTED) == 0))
{
hr = E_INVALIDARG;
}
else
{
m_dwMiscFlags &= 0xFFFF0000;
m_dwMiscFlags |= wOpts;
_UpdateBltFlags();
m_dwGenerationId++;
}
}
Unlock();
return hr;
} /* CDXBaseNTo1::SetMiscFlags */
/*****************************************************************************
* CDXBaseNTo1::GetMiscFlags *
*----------------------------*
* Description:
*-----------------------------------------------------------------------------
* Created By: RAL Date: 10/30/97
*-----------------------------------------------------------------------------
* Parameters:
*****************************************************************************/
STDMETHODIMP CDXBaseNTo1::GetMiscFlags( DWORD* pdwMiscFlags )
{
if( DXIsBadWritePtr( pdwMiscFlags, sizeof( *pdwMiscFlags ) ) )
{
return E_POINTER;
}
*pdwMiscFlags = m_dwMiscFlags;
return S_OK;
} /* CDXBaseNTo1::GetMiscFlags */
/*****************************************************************************
* CDXBaseNTo1::SetQuality *
*----------------------------*
* Description:
*-----------------------------------------------------------------------------
* Created By: RAL Date: 10/30/97
*-----------------------------------------------------------------------------
* Parameters:
*****************************************************************************/
STDMETHODIMP CDXBaseNTo1::SetQuality(float fQuality)
{
if ((m_dwMiscFlags & DXTMF_QUALITY_SUPPORTED) == 0)
{
return E_NOTIMPL;
}
if (fQuality < 0.0f || fQuality > 1.0f)
{
return E_INVALIDARG;
}
Lock();
if (m_fQuality != fQuality)
{
m_fQuality = fQuality;
m_dwGenerationId++;
}
Unlock();
return S_OK;
}
/*****************************************************************************
* CDXBaseNTo1::GetQuality *
*-------------------------*
* Description:
*-----------------------------------------------------------------------------
* Created By: RAL Date: 10/30/97
*-----------------------------------------------------------------------------
* Parameters:
*****************************************************************************/
STDMETHODIMP CDXBaseNTo1::GetQuality(float *pfQuality)
{
HRESULT hr = S_OK;
if ((m_dwMiscFlags & DXTMF_QUALITY_SUPPORTED) == 0)
{
hr = E_NOTIMPL;
}
else
{
if( DXIsBadWritePtr( pfQuality, sizeof( *pfQuality ) ) )
{
hr = E_POINTER;
}
else
{
*pfQuality = m_fQuality;
}
}
return hr;
}
/*****************************************************************************
* GetInOutInfo
*-----------------------------------------------------------------------------
* Description:
*-----------------------------------------------------------------------------
* Created By: RAL Date: 12/10/97
*-----------------------------------------------------------------------------
* Parameters:
*****************************************************************************/
STDMETHODIMP CDXBaseNTo1::GetInOutInfo( BOOL bOutput, ULONG ulIndex, DWORD *pdwFlags,
GUID * pIDs, ULONG *pcIDs, IUnknown **ppUnkCurObj )
{
DXTDBG_FUNC( "CDXBaseNTo1::GetInOutInfo" );
HRESULT hr = S_FALSE;
DWORD dwFlags = 0;
BOOL bImage;
if( bOutput )
{
bImage = !(m_dwOptionFlags & DXBOF_OUTPUT_MESHBUILDER);
if (ulIndex == 0)
{
hr = S_OK;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -