Exemple #1
0
void DashEdit::Dash()
{
	RichTxt::FormatInfo f = GetFormatInfo();
	f.charvalid = RichText::DASHED;
	f.dashed = !f.dashed;
	ApplyFormatInfo(f);
}
 std::string FileFormat::getName() const
 {
     FormatInfoVec infoVec;
     GetFormatInfo(infoVec);
     if(infoVec.size()>0)
     {
         return infoVec[0].name;
     }
     return "Unknown Format";
 }
Exemple #3
0
BOOL SGDisplayDATATYPE::HandleEvent(SGEventType EventType, void *EventInfo,
								  SGMiscInfo *MiscInfo)
{
	switch (EventType)
	{
		case SGEVENT_FORMAT:
			{
				SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
				CalculateMyRect(FormatInfo, MiscInfo);		// Cache our FormatRect for later use
			}
			break;


		case SGEVENT_REDRAW:
			{
				DocRect MyRect(FormatRect);		// Rely on FormatRect being cached from above
				SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);

				if (IMustRedraw(RedrawInfo))	// only redraw if we intersect the clip rect
					HandleRedraw(RedrawInfo, MiscInfo);
			}
			break;		// exit and return FALSE to pass the redraw event on


		case SGEVENT_MOUSECLICK:
			{
				SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);

				if (FormatRect.ContainsCoord(Mouse->Position))
				{
					// Test for drag...		**** !!!! ToDo !!!! ****
					// DefaultDragHandler(Mouse, MiscInfo);

					// No drag, so move on to normal selection click handling
					DefaultClickHandler(Mouse, MiscInfo);

					return(TRUE);		// Claim this event - nobody else can own this click
				}
			}
			break;

		default:
			// Let the base class handle any events we don't know about.
			// This includes things like hit testing (CLAIMPOINT) etc
			return(SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
	}

	// Default return value: We do not claim this event, so it will be passed on to others
	return(FALSE);
}
Exemple #4
0
SWR_FORMAT
mesa_to_swr_format(enum pipe_format format)
{
   const struct util_format_description *format_desc =
      util_format_description(format);
   if (!format_desc)
      return (SWR_FORMAT)-1;

   // more robust check would be comparing all attributes of the formats
   // luckily format names are mostly standardized
   for (int i = 0; i < NUM_SWR_FORMATS; i++) {
      const SWR_FORMAT_INFO &swr_desc = GetFormatInfo((SWR_FORMAT)i);

      if (!strcasecmp(format_desc->short_name, swr_desc.name))
         return (SWR_FORMAT)i;
   }

   // ... with some exceptions
   switch (format) {
   case PIPE_FORMAT_R8G8B8A8_SRGB:
      return R8G8B8A8_UNORM_SRGB;
   case PIPE_FORMAT_B8G8R8A8_SRGB:
      return B8G8R8A8_UNORM_SRGB;
   case PIPE_FORMAT_I8_UNORM:
      return R8_UNORM;
   case PIPE_FORMAT_Z16_UNORM:
      return R16_UNORM;
   case PIPE_FORMAT_Z24X8_UNORM:
   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
      return R24_UNORM_X8_TYPELESS;
   case PIPE_FORMAT_Z32_FLOAT:
      return R32_FLOAT;
   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
      return R32_FLOAT_X8X24_TYPELESS;
   case PIPE_FORMAT_L8A8_UNORM:
      return R8G8_UNORM;
   default:
      break;
   }

   debug_printf("asked to convert unsupported format %s\n",
                format_desc->name);
   return (SWR_FORMAT)-1;
}
Exemple #5
0
static boolean
swr_texture_layout(struct swr_screen *screen,
                   struct swr_resource *res,
                   boolean allocate)
{
   struct pipe_resource *pt = &res->base;

   pipe_format fmt = pt->format;
   const struct util_format_description *desc = util_format_description(fmt);

   res->has_depth = util_format_has_depth(desc);
   res->has_stencil = util_format_has_stencil(desc);

   if (res->has_stencil && !res->has_depth)
      fmt = PIPE_FORMAT_R8_UINT;

   res->swr.width = pt->width0;
   res->swr.height = pt->height0;
   res->swr.depth = pt->depth0;
   res->swr.type = swr_convert_target_type(pt->target);
   res->swr.tileMode = SWR_TILE_NONE;
   res->swr.format = mesa_to_swr_format(fmt);
   res->swr.numSamples = (1 << pt->nr_samples);

   SWR_FORMAT_INFO finfo = GetFormatInfo(res->swr.format);

   unsigned total_size = 0;
   unsigned width = pt->width0;
   unsigned height = pt->height0;
   unsigned depth = pt->depth0;
   unsigned layers = pt->array_size;

   for (int level = 0; level <= pt->last_level; level++) {
      unsigned alignedWidth, alignedHeight;
      unsigned num_slices;

      if (pt->bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL)) {
         alignedWidth = align(width, KNOB_MACROTILE_X_DIM);
         alignedHeight = align(height, KNOB_MACROTILE_Y_DIM);
      } else {
         alignedWidth = width;
         alignedHeight = height;
      }

      if (level == 0) {
         res->alignedWidth = alignedWidth;
         res->alignedHeight = alignedHeight;
      }

      res->row_stride[level] = alignedWidth * finfo.Bpp;
      res->img_stride[level] = res->row_stride[level] * alignedHeight;
      res->mip_offsets[level] = total_size;

      if (pt->target == PIPE_TEXTURE_3D)
         num_slices = depth;
      else if (pt->target == PIPE_TEXTURE_1D_ARRAY
               || pt->target == PIPE_TEXTURE_2D_ARRAY
               || pt->target == PIPE_TEXTURE_CUBE
               || pt->target == PIPE_TEXTURE_CUBE_ARRAY)
         num_slices = layers;
      else
         num_slices = 1;

      total_size += res->img_stride[level] * num_slices;
      if (total_size > SWR_MAX_TEXTURE_SIZE)
         return FALSE;

      width = u_minify(width, 1);
      height = u_minify(height, 1);
      depth = u_minify(depth, 1);
   }

   res->swr.halign = res->alignedWidth;
   res->swr.valign = res->alignedHeight;
   res->swr.pitch = res->row_stride[0];

   if (allocate) {
      res->swr.pBaseAddress = (uint8_t *)AlignedMalloc(total_size, 64);

      if (res->has_depth && res->has_stencil) {
         SWR_FORMAT_INFO finfo = GetFormatInfo(res->secondary.format);
         res->secondary.width = pt->width0;
         res->secondary.height = pt->height0;
         res->secondary.depth = pt->depth0;
         res->secondary.type = SURFACE_2D;
         res->secondary.tileMode = SWR_TILE_NONE;
         res->secondary.format = R8_UINT;
         res->secondary.numSamples = (1 << pt->nr_samples);
         res->secondary.pitch = res->alignedWidth * finfo.Bpp;

         res->secondary.pBaseAddress = (uint8_t *)AlignedMalloc(
            res->alignedHeight * res->secondary.pitch, 64);
      }
   }

   return TRUE;
}
bool ContentDecoder::DecodeData(int nCodeSize,int nVersion,unsigned char CodeData[MAX_MODULESIZE][MAX_MODULESIZE])
{
	int i,j;

	m_nCodeSize=nCodeSize;
	m_nVersion=nVersion;
	for(i=0;i<nCodeSize;i++)
		for(j=0;j<nCodeSize;j++)
			m_CodeData[i][j]=CodeData[i][j];

	//获取版本信息(7~40有版本信息)
	//if(m_nVersion>=7)
	//{
	//	m_nVersion=GetVersionInfo();
	//}

	//获取格式信息
	int nFormatData=GetFormatInfo();

	m_nLevel=((nFormatData & 0x18) >> 3);//纠错级别,前两位
	switch(m_nLevel)
	{
	case 1: m_nLevel=QR_LEVEL_L;break;
	case 0: m_nLevel=QR_LEVEL_M;break;
	case 3: m_nLevel=QR_LEVEL_Q;break;
	case 2: m_nLevel=QR_LEVEL_H;break;
	}
	m_nMaskingNo=(nFormatData & 0x07);//掩膜图形参考,后三位

	//去除掩膜图形
	for(i=0;i<m_nCodeSize;++i)
	{
		for(j=0;j<m_nCodeSize;++j)
		{
			bool bMask;
			switch (m_nMaskingNo)
			{
			case 0:
				bMask=((i+j)%2==0);break;
			case 1:
				bMask=(i%2==0);break;
			case 2:
				bMask=(j%3==0);break;
			case 3:
				bMask=((i+j) % 3 == 0);break;
			case 4:
				bMask=(((i/2)+(j/3))%2==0);break;
			case 5:
				bMask=(((i*j)%2)+((i*j)%3)==0);break;
			case 6:
				bMask=((((i*j)%2)+((i* j)%3))%2==0);break;
			default: // case 7:
				bMask=((((i*j)%3)+((i+j)%2))%2==0);break;
			}
			m_CodeData[j][i] = (unsigned char)(m_CodeData[j][i] ^ bMask);
		}
	}

	//标记非数据位置
	SetFinderPattern();
	if(m_nVersion>1)
		SetAlignmentPattern();
	SetFormatPattern();
	SetVersionPattern();

	//读取数据位置,得到数据位流
	GetCodeWord();

	//纠错
	CorrectDataBlocks();

	//解析数据码字,得到字符串
	ParseDataCodeWord();

	return true;
}