Ejemplo n.º 1
0
static struct DevUnit *CreatePCIUnit(ULONG index, struct DevBase *base)
{
   BOOL success = TRUE;
   struct BusContext *context;
   struct DevUnit *unit = NULL;

   context = AllocCard(index, base);
   if(context == NULL)
      success = FALSE;

   if(success)
   {
      if(context->unit_tags == NULL)
      {
         if(context->bus_type == PCI_BUS)
            context->unit_tags = unit_tags;
         else
            context->unit_tags = bridge_unit_tags;
      }

      context->unit = unit =
         CreateUnit(index, context, context->unit_tags, context->bus_type,
            base);
      if(unit == NULL)
         success = FALSE;
   }

   /* Add interrupt */

   if(success)
   {
      if(!(WrapInt(&unit->status_int, base)
         && WrapInt(&unit->rx_int, base)
         && WrapInt(&unit->tx_int, base)
         && WrapInt(&unit->info_int, base)))
         success = FALSE;
      success = AddPCIIntServer(context->card, &unit->status_int, base);
   }

   if(!success)
   {
      if(context != NULL)
      {
         DeleteUnit(context->unit, base);
         FreeCard(context, base);
      }
      unit = NULL;
   }

   return unit;
}
Ejemplo n.º 2
0
void cTexture::CreateMipMaps()
{
	int prevW = width;
	int prevH = height;
	int w = width / 2;
	int h = height / 2;
	sRGB8 *prevBitmap = bitmap;
	while(w > 0 && h > 0)
	{
		QVector<sRGB8> newMipmapV(w * h);
		sRGB8 *newMipmap = newMipmapV.data();

		for(int y = 0; y < h; y++)
		{
			for (int x = 0; x < w; x++)
			{
				sRGB8 newPixel;
				sRGB8 p1 = prevBitmap[WrapInt(x * 2, prevW) + WrapInt(y * 2, prevH) * prevW];
				sRGB8 p2 = prevBitmap[WrapInt(x * 2 + 1, prevW) + WrapInt(y * 2, prevH) * prevW];
				sRGB8 p3 = prevBitmap[WrapInt(x * 2, prevW) + WrapInt(y * 2 + 1, prevH) * prevW];
				sRGB8 p4 = prevBitmap[WrapInt(x * 2 + 1, prevW) + WrapInt(y * 2 + 1, prevH) * prevW];
				newPixel.R = ((int)p1.R + p2.R + p3.R + p4.R)/4;
				newPixel.G = ((int)p1.G + p2.G + p3.G + p4.G)/4;
				newPixel.B = ((int)p1.B + p2.B + p3.B + p4.B)/4;
				newMipmap[x + y * w] = newPixel;
			}
		}
		mipmapSizes.append(CVector2<int>(w, h));
		mipmaps.append(newMipmapV);
		prevH = h;
		prevW = w;
		w /= 2;
		h /= 2;
		prevBitmap = mipmaps.last().data();
	}
}