示例#1
0
//
//	Writer
//
M4Err WriteOD(BitStream *bs, ObjectDescriptor *od)
{
	M4Err e;
	u32 size;
	if (! od) return M4BadParam;

	e = CalcSize((Descriptor *)od, &size);
	if (e) return e;
	e = writeBaseDescriptor(bs, od->tag, size);
	if (e) return e;
	
	BS_WriteInt(bs, od->objectDescriptorID, 10);
	BS_WriteInt(bs, od->URLString != NULL ? 1 : 0, 1);
	BS_WriteInt(bs, 31, 5);		//reserved: 0b1111.1 == 31

	if (od->URLString) {
		OD_WriteString(bs, od->URLString, 1);
	} else {
		e = writeDescList(bs, od->ESDescriptors);
		if (e) return e;
		e = writeDescList(bs, od->OCIDescriptors);
		if (e) return e;
		e = writeDescList(bs, od->IPMPDescriptorPointers);
		if (e) return e;
	}
	e = writeDescList(bs, od->extensionDescriptors);
	return M4OK;
}
//
//	Writer
//
M4Err WriteIOD(BitStream *bs, InitialObjectDescriptor *iod)
{
    M4Err e;
    u32 size;
    if (! iod) return M4BadParam;

    e = CalcSize((Descriptor *)iod, &size);
    if (e) return e;
    e = writeBaseDescriptor(bs, iod->tag, size);
    if (e) return e;

    BS_WriteInt(bs, iod->objectDescriptorID, 10);
    BS_WriteInt(bs, iod->URLString != NULL ? 1 : 0, 1);
    BS_WriteInt(bs, iod->inlineProfileFlag, 1);
    BS_WriteInt(bs, 15, 4);		//reserved: 0b1111 == 15

    if (iod->URLString) {
        OD_WriteString(bs, iod->URLString, 1);
    } else {
        BS_WriteInt(bs, iod->OD_profileAndLevel, 8);
        BS_WriteInt(bs, iod->scene_profileAndLevel, 8);
        BS_WriteInt(bs, iod->audio_profileAndLevel, 8);
        BS_WriteInt(bs, iod->visual_profileAndLevel, 8);
        BS_WriteInt(bs, iod->graphics_profileAndLevel, 8);
        e = writeDescList(bs, iod->ESDescriptors);
        if (e) return e;
        e = writeDescList(bs, iod->OCIDescriptors);
        if (e) return e;
        e = writeDescList(bs, iod->IPMPDescriptorPointers);
        if (e) return e;
    }
    e = writeDescList(bs, iod->extensionDescriptors);
    return M4OK;
}
示例#3
0
bool CDisAssm::GetInstructionInfo(const BYTE* pInstruction, InstrInfo& rInfo, int& riLen)
{
	_ASSERTE(pInstruction);
	_ASSERTE(m_aInstructions[*pInstruction].iOpCode == *pInstruction);

	rInfo = m_aInstructions[*pInstruction];

	// check the special ones
	if (0xff == *pInstruction)
	{
		if (!GetInstructionInfoFF(rInfo, pInstruction))
			return false;
	}
/*else if (0x66 == *pInstruction)
	{
		m_b16BitOperand = true;
	}
	else if (0x67 == *pInstruction)
	{
		m_b16BitAddress = true;
	}*/

	_ASSERTE(rInfo.iOpSize);  // undefined?

	if (!rInfo.iOpSize)
		return false;

  riLen = CalcSize(rInfo, pInstruction);

	return true;
}
示例#4
0
void ToolTip::SetText(const char *text)
{
	m_text = text;
	if (m_layout) delete m_layout;
	m_layout = new TextLayout(text);
	CalcSize();
}
示例#5
0
void Box::Layout()
{
	if (m_children.size() == 0) return;

	PreferredSize();

	const Point boxSize = GetSize();

	Point::Component vc, fc;
	GetComponentsForOrient(m_orient == BOX_HORIZONTAL, vc, fc);

	// fast path. we know the exact size that everything wants, so just
	// loop and hand it out
	if (m_numVariable == 0) {
		Point childPos(0), childSize(0);
		for (std::list<Child>::iterator i = m_children.begin(); i != m_children.end(); ++i) {
			childSize[fc] = boxSize[fc];
			childSize[vc] = (*i).contribSize[vc];
			const Point actualSize(CalcSize((*i).widget, childSize));
			SetWidgetDimensions((*i).widget, childPos, actualSize);
			childPos[vc] += actualSize[vc] + m_spacing;
		}
	}

	// we have one or more children that have requested the maximum size
	// possible. each with a known size gets it, and any remaining space is
	// distributed evenly among the max-sized children. if there is no
	// remaining space, then we're already outside the bounds, so just give
	// them something
	else {
		const int sizeAvail = boxSize[vc];
		const int sizeMin = sizeAvail/10; // 10%, as good as anything

		const int amount = m_minAllocation < sizeAvail ? std::max((sizeAvail-m_minAllocation-m_spacing*(int(m_children.size())-1))/m_numVariable, sizeMin) : sizeMin;

		Point childPos(0), childSize(0);
		for (std::list<Child>::iterator i = m_children.begin(); i != m_children.end(); ++i) {
			childSize[fc] = boxSize[fc];
			childSize[vc] = (*i).contribSize[vc] == SIZE_EXPAND ? amount : (*i).contribSize[vc];
			const Point actualSize(CalcSize((*i).widget, childSize));
			SetWidgetDimensions((*i).widget, childPos, actualSize);
			childPos[vc] += actualSize[vc] + m_spacing;
		}
	}

	LayoutChildren();
}
示例#6
0
void ToolTip::SetText(const char *text)
{
	if (m_text != text) {
		m_text = text;
		m_layout.reset(new TextLayout(text));
		CalcSize();
	}
}
示例#7
0
///---------------------------------------------------------------------------------
/// fast
///---------------------------------------------------------------------------------
inline const Vector2 AABB2D::GetPointAtNormalizedPositionWithinBox( const Vector2& normalizedPosition ) const
{
	Vector2 boxSize = CalcSize();
	float xPos = m_mins.x + ( boxSize.x * normalizedPosition.x );
	float yPos = m_mins.y + ( boxSize.y * normalizedPosition.y );
	Vector2 positionAtNormalizedPoint( xPos, yPos );
	return positionAtNormalizedPoint;
}
void CPDF_ImageCacheEntry::Reset(const CFX_DIBitmap* pBitmap) {
  delete m_pCachedBitmap;
  m_pCachedBitmap = nullptr;
  if (pBitmap) {
    m_pCachedBitmap = pBitmap->Clone();
  }
  CalcSize();
}
示例#9
0
void CPDF_ImageCache::Reset(const CFX_DIBitmap* pBitmap) {
  delete m_pCachedBitmap;
  m_pCachedBitmap = NULL;
  if (pBitmap) {
    m_pCachedBitmap = pBitmap->Clone();
  }
  CalcSize();
}
示例#10
0
CommonHeader::CommonHeader()
{
	_elements.push_back(&_startByte);
	_elements.push_back(&_payloadType);
	_elements.push_back(&_sequenceNumber);
	_elements.push_back(&_timeStamp);

	CalcSize();
}
示例#11
0
FX_BOOL CPDF_ImageCache::GetCachedBitmap(CFX_DIBSource*& pBitmap, CFX_DIBSource*& pMask, FX_DWORD& MatteColor, CPDF_Dictionary* pPageResources,
        FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus,
        FX_INT32 downsampleWidth, FX_INT32 downsampleHeight)
{
    if (m_pCachedBitmap) {
        pBitmap = m_pCachedBitmap;
        pMask = m_pCachedMask;
        MatteColor = m_MatteColor;
        return TRUE;
    }
    if (!pRenderStatus) {
        return FALSE;
    }
    CPDF_RenderContext*pContext = pRenderStatus->GetContext();
    CPDF_PageRenderCache* pPageRenderCache = pContext->m_pPageCache;
    m_dwTimeCount = pPageRenderCache->GetTimeCount();
    CPDF_DIBSource* pSrc = FX_NEW CPDF_DIBSource;
    CPDF_DIBSource* pMaskSrc = NULL;
    if (!pSrc->Load(m_pDocument, m_pStream, &pMaskSrc, &MatteColor, pRenderStatus->m_pFormResource, pPageResources, bStdCS, GroupFamily, bLoadMask)) {
        delete pSrc;
        pBitmap = NULL;
        return FALSE;
    }
    m_MatteColor = MatteColor;
#if !defined(_FPDFAPI_MINI_)
    if (pSrc->GetPitch() * pSrc->GetHeight() < FPDF_HUGE_IMAGE_SIZE) {
        m_pCachedBitmap = pSrc->Clone();
        delete pSrc;
    } else {
        m_pCachedBitmap = pSrc;
    }
    if (pMaskSrc) {
        m_pCachedMask = pMaskSrc->Clone();
        delete pMaskSrc;
    }
#else
    if (pSrc->GetFormat() == FXDIB_8bppRgb && pSrc->GetPalette() &&
            pSrc->GetHeight() * pSrc->GetWidth() * 3 < 1024) {
#if _FXM_PLATFORM_  == _FXM_PLATFORM_APPLE_
        m_pCachedBitmap = pSrc->CloneConvert(FXDIB_Rgb32);
#else
        m_pCachedBitmap = pSrc->CloneConvert(FXDIB_Rgb);
#endif
        delete pSrc;
    } else if (pSrc->GetPitch() * pSrc->GetHeight() < 102400) {
        m_pCachedBitmap = pSrc->Clone();
        delete pSrc;
    } else {
        m_pCachedBitmap = pSrc;
    }
    m_pCachedMask = pMaskSrc;
#endif
    pBitmap = m_pCachedBitmap;
    pMask = m_pCachedMask;
    CalcSize();
    return FALSE;
}
示例#12
0
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
                            int32_t iLength,
                            CFX_SizeF& size) {
  CFX_RectF rtText;
  rtText.Set(0.0f, 0.0f, size.x, size.y);
  CalcSize(pwsStr, iLength, rtText);
  size.x = rtText.Width();
  size.y = rtText.Height();
}
示例#13
0
void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr,
                            int32_t iLength,
                            CFX_Rect& rect) {
  CFX_RectF rtText;
  rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.Width(),
             (FX_FLOAT)rect.Height());
  CalcSize(pwsStr, iLength, rtText);
  rect.Set((int32_t)rtText.left, (int32_t)rtText.top, (int32_t)rtText.Width(),
           (int32_t)rtText.Height());
}
示例#14
0
M4Err SizeIPMPDUpdate(IPMPDescriptorUpdate *ipmpUp, u32 *outSize)
{
	u32 i, tmpSize;
	if (!ipmpUp) return M4BadParam;

	*outSize = 0;
	for (i = 0; i < ChainGetCount(ipmpUp->IPMPDescList); i++) {
		Descriptor *tmp = (Descriptor*)ChainGetEntry(ipmpUp->IPMPDescList, i);
		CalcSize(tmp, &tmpSize);
		*outSize += tmpSize + GetSizeFieldSize(tmpSize);
	}
	return M4OK;
}
示例#15
0
M4Err SizeODUpdate(ObjectDescriptorUpdate *odUp, u32 *outSize)
{
	Descriptor *tmp;
	u32 i, tmpSize;
	if (!odUp) return M4BadParam;

	*outSize = 0;
	for (i = 0; i < ChainGetCount(odUp->objectDescriptors); i++) {
		tmp = (Descriptor*)ChainGetEntry(odUp->objectDescriptors, i);
		CalcSize(tmp, &tmpSize);
		*outSize += tmpSize + GetSizeFieldSize(tmpSize);
	}
	return M4OK;
}
示例#16
0
bool CPDF_ImageCacheEntry::GetCachedBitmap(CFX_DIBSource*& pBitmap,
                                           CFX_DIBSource*& pMask,
                                           uint32_t& MatteColor,
                                           CPDF_Dictionary* pPageResources,
                                           bool bStdCS,
                                           uint32_t GroupFamily,
                                           bool bLoadMask,
                                           CPDF_RenderStatus* pRenderStatus,
                                           int32_t downsampleWidth,
                                           int32_t downsampleHeight) {
  if (m_pCachedBitmap) {
    pBitmap = m_pCachedBitmap;
    pMask = m_pCachedMask;
    MatteColor = m_MatteColor;
    return true;
  }
  if (!pRenderStatus) {
    return false;
  }
  CPDF_RenderContext* pContext = pRenderStatus->GetContext();
  CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache();
  m_dwTimeCount = pPageRenderCache->GetTimeCount();
  CPDF_DIBSource* pSrc = new CPDF_DIBSource;
  CPDF_DIBSource* pMaskSrc = nullptr;
  if (!pSrc->Load(m_pDocument, m_pStream, &pMaskSrc, &MatteColor,
                  pRenderStatus->m_pFormResource, pPageResources, bStdCS,
                  GroupFamily, bLoadMask)) {
    delete pSrc;
    pBitmap = nullptr;
    return false;
  }
  m_MatteColor = MatteColor;
  if (pSrc->GetPitch() * pSrc->GetHeight() < FPDF_HUGE_IMAGE_SIZE) {
    m_pCachedBitmap = pSrc->Clone();
    delete pSrc;
  } else {
    m_pCachedBitmap = pSrc;
  }
  if (pMaskSrc) {
    m_pCachedMask = pMaskSrc->Clone();
    delete pMaskSrc;
  }

  pBitmap = m_pCachedBitmap;
  pMask = m_pCachedMask;
  CalcSize();
  return false;
}
示例#17
0
	HexRowView(HexView *hexView,
		wxWindowID winid = wxID_ANY,
		const wxPoint& pos = wxDefaultPosition,
		const wxSize& size = wxDefaultSize)
	{
		Create(hexView, winid, pos, size);
		m_view = hexView;

		Bind(wxEVT_LEFT_DOWN, &HexRowView::OnLeftDown, this);
		Bind(wxEVT_LEFT_UP, &HexRowView::OnLeftUp, this);

		SetBackgroundStyle(wxBG_STYLE_PAINT);
		SetCursor(wxCURSOR_IBEAM);

		CalcSize();
	}
示例#18
0
int Subgraph::CalcSize(const Node *n) const
{
  if (n->GetType() != TREE || n->IsPreterminal()) {
    return 0;
  }
  if (IsTrivial()) {
    return 1;
  }
  int count = 1;
  const std::vector<Node*> &children = n->GetChildren();
  for (std::vector<Node *>::const_iterator p = children.begin();
       p != children.end(); ++p) {
    if (m_leaves.find(*p) == m_leaves.end()) {
      count += CalcSize(*p);
    }
  }
  return count;
}
示例#19
0
M4Err SizeESDUpdate(ESDescriptorUpdate *esdUp, u32 *outSize)
{
	u32 i, BitSize, tmpSize;
	if (!esdUp) return M4BadParam;

	*outSize = 0;
	BitSize = 10;
	for (i = 0; i < ChainGetCount(esdUp->ESDescriptors); i++) {
		Descriptor *tmp = (Descriptor*)ChainGetEntry(esdUp->ESDescriptors, i);
		CalcSize(tmp, &tmpSize);
		BitSize += ( tmpSize + GetSizeFieldSize(tmpSize) ) * 8;
	}
	while ((s32) BitSize > 0) {
		BitSize -= 8;
		*outSize += 1;
	}
	return M4OK;
}
示例#20
0
TextEdit::TextEdit(const QString & str, QWidget *parent) : QTextEdit(parent)
{
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    //setFrameShape(QFrame::NoFrame);
    setFrameShadow(QFrame::Plain);
    setLineWrapMode(QTextEdit::NoWrap);
    setAcceptRichText(false);
    setAutoFormatting(QTextEdit::AutoNone);
    setTabChangesFocus(true);
    setPlainText(str);
    CalcSize();
    connect( this, SIGNAL( textChanged() ), this, SLOT( sltTextChanged() ) );

    QTextCursor cursor = this->textCursor();
    cursor.select(QTextCursor::LineUnderCursor);
    setTextCursor( cursor );
}
示例#21
0
int CPDF_ImageCache::ContinueGetCachedBitmap()
{
    m_MatteColor = ((CPDF_DIBSource*)m_pCurBitmap)->m_MatteColor;
    m_pCurMask = ((CPDF_DIBSource*)m_pCurBitmap)->DetachMask();
    CPDF_RenderContext*pContext = m_pRenderStatus->GetContext();
    CPDF_PageRenderCache* pPageRenderCache = pContext->m_pPageCache;
    m_dwTimeCount = pPageRenderCache->GetTimeCount();
#if !defined(_FPDFAPI_MINI_)
    if (m_pCurBitmap->GetPitch() * m_pCurBitmap->GetHeight() < FPDF_HUGE_IMAGE_SIZE) {
        m_pCachedBitmap = m_pCurBitmap->Clone();
        delete m_pCurBitmap;
        m_pCurBitmap = NULL;
    } else {
        m_pCachedBitmap = m_pCurBitmap;
    }
    if (m_pCurMask) {
        m_pCachedMask = m_pCurMask->Clone();
        delete m_pCurMask;
        m_pCurMask = NULL;
    }
#else
    if (m_pCurBitmap->GetFormat() == FXDIB_8bppRgb && m_pCurBitmap->GetPalette() &&
            m_pCurBitmap->GetHeight() * m_pCurBitmap->GetWidth() * 3 < 1024) {
        m_pCachedBitmap = m_pCurBitmap->CloneConvert(FXDIB_Rgb32);
        m_pCachedBitmap = m_pCurBitmap->CloneConvert(FXDIB_Rgb);
        delete m_pCurBitmap;
        m_pCurBitmap = NULL;
    } else if (m_pCurBitmap->GetPitch() * m_pCurBitmap->GetHeight() < 102400) {
        m_pCachedBitmap = m_pCurBitmap->Clone();
        delete m_pCurBitmap;
        m_pCurBitmap = NULL;
    } else {
        m_pCachedBitmap = m_pCurBitmap;
    }
    m_pCachedMask = m_pCurMask;
#endif
    m_pCurBitmap = m_pCachedBitmap;
    m_pCurMask = m_pCachedMask;
    CalcSize();
    return 0;
}
示例#22
0
int main(void)
{
	unsigned long long total = 0;
	unsigned int dim[3], temp;
	char c;
	unsigned char i;
	temp = dim[0] = dim[1] = dim[2] = 0;
	while ((c = fgetc(stdin)) != EOF) {
		switch (c) {
		case '9':
		case '8':
		case '7':
		case '6':
		case '5':
		case '4':
		case '3':
		case '2':
		case '1':
		case '0':
			temp *= 10;
			temp += c-'0';
			break;
		case 'x':
		case '\n':
			for (i = 0; dim[i] != 0; i++) { ; }
			dim[i] = temp;
			temp = 0;
			break;
		default:
			printf("Unknown character: %d\n", c);
			break;
		}
		if (c == '\n') {
			total += CalcSize(dim[0], dim[1], dim[2]);
			temp = dim[0] = dim[1] = dim[2] = 0;
		}
	}
	printf("Total size: %llu\n", total);
	return 0;
}
示例#23
0
/*
	Usado para leer Meshes de un recurso
*/
DWORD C3DMesh::ReadFromMemory(void *lpPointer)
{
	BYTE*	m_lppos;
	DWORD	i;
	m_onstatic=true;
	m_lpdata = (S_3DMESH*)lpPointer;
	m_lppos = (BYTE*)m_lpdata+sizeof(S_3DMESH);
	if (m_lpdata ->m_version != sizeof (m_data))
		return 1;
	// Leer toda la informacion de la malla

	// Leer todos los vertices
	m_vertex = (S_3DSPOINT*)m_lppos;
	m_lppos+= sizeof(S_3DSPOINT)*m_lpdata->m_nvertex;

	// Leer todas las caras
	m_faces = (S_3DSFACE*)m_lppos;
	m_lppos+= sizeof(S_3DSFACE)*m_lpdata->m_nfaces;

	// Reservar espacio para los materiales
	m_materials=new S_3DMESHMAT[m_lpdata->m_nmat];
	S_3DMESHMATDAT*	m_mat_dat;

	// Leer todos los materiales
	for (i=0;i<m_lpdata->m_nmat;i++)
	{
		m_mat_dat = (S_3DMESHMATDAT*)m_lppos;		
		m_lppos+=sizeof(S_3DMESHMATDAT);
		m_materials[i].m_data=*m_mat_dat;
		m_materials[i].m_faces=(DWORD*)m_lppos;
		if (m_3descene)
			m_materials[i].m_material=m_3descene->GetMaterial(m_materials[i].m_data.m_mat_index);
		else
			m_materials[i].m_material=NULL;
		m_lppos+=sizeof(DWORD)*m_mat_dat->m_faces_cant;
	}
	CalcSize();
	return 0;
}
示例#24
0
void CPDF_ImageCacheEntry::ContinueGetCachedBitmap() {
  m_MatteColor = ((CPDF_DIBSource*)m_pCurBitmap)->GetMatteColor();
  m_pCurMask = ((CPDF_DIBSource*)m_pCurBitmap)->DetachMask();
  CPDF_RenderContext* pContext = m_pRenderStatus->GetContext();
  CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache();
  m_dwTimeCount = pPageRenderCache->GetTimeCount();
  if (m_pCurBitmap->GetPitch() * m_pCurBitmap->GetHeight() <
      FPDF_HUGE_IMAGE_SIZE) {
    m_pCachedBitmap = m_pCurBitmap->Clone();
    delete m_pCurBitmap;
    m_pCurBitmap = nullptr;
  } else {
    m_pCachedBitmap = m_pCurBitmap;
  }
  if (m_pCurMask) {
    m_pCachedMask = m_pCurMask->Clone();
    delete m_pCurMask;
    m_pCurMask = nullptr;
  }
  m_pCurBitmap = m_pCachedBitmap;
  m_pCurMask = m_pCachedMask;
  CalcSize();
}
示例#25
0
void Grid::Layout()
{
	const Point size = GetSize();

	Point childPos, childSize;
	for (unsigned int rowNum = 0; rowNum < m_numRows; rowNum++) {
		childSize.y = m_colSpec.cellPercent[rowNum]*size.y;

		childPos.x = 0;
		for (unsigned int colNum = 0; colNum < m_numCols; colNum++) {
			childSize.x = m_rowSpec.cellPercent[colNum]*size.x;

			const unsigned int n = rowNum*m_numCols+colNum;
			if (m_widgets[n])
				SetWidgetDimensions(m_widgets[n], childPos, CalcSize(m_widgets[n], childSize));

			childPos.x += childSize.x;
		}

		childPos.y += childSize.y;
	}

	LayoutChildren();
}
示例#26
0
void FileReader::LoadFile(const std::string &filename)
{
	std::map<std::string, file_cache>::iterator file = ServerInstance->Config->Files.find(filename);
	if (file != ServerInstance->Config->Files.end())
	{
		this->fc = file->second;
	}
	else
	{
		fc.clear();
		FILE* f = fopen(filename.c_str(), "r");
		if (!f)
			return;
		char linebuf[MAXBUF*10];
		while (fgets(linebuf, sizeof(linebuf), f))
		{
			int len = strlen(linebuf);
			if (len)
				fc.push_back(std::string(linebuf, len - 1));
		}
		fclose(f);
	}
	CalcSize();
}
示例#27
0
CTextureQuad::CTextureQuad(const char *srcImg,double maxW,double maxH)
{
	Texture=CTexture::LoadTexture(srcImg);
	HasAllocatedTex=true;
	CalcSize(maxW,maxH);
}
示例#28
0
///---------------------------------------------------------------------------------
/// fast
///---------------------------------------------------------------------------------
inline const Vector2 AABB2D::CalcCenter() const
{
	Vector2 boxSize = CalcSize();
	Vector2 center( boxSize.x * 0.5f, boxSize.y * 0.5f );
	return center;
}
示例#29
0
CTextureQuad::CTextureQuad(CTexture *tex,double maxW,double maxH) :
	HasAllocatedTex(false),
	Texture(tex)
{
	CalcSize(maxW,maxH);
}
示例#30
0
void TextEdit::sltTextChanged()
{
    CalcSize();
}