Example #1
0
static void move(DitherImage& dither, int direction)
{
    const Image16Bpp& image = dither.inImage;
    Image8Bpp& indexedImage = dither.outImage;
    int x = dither.x;
    int y = dither.y;
    int width = indexedImage.width;
    int height = indexedImage.height;
    /* dither the current pixel */
    if (x >= 0 && x < width && y >= 0 && y < height)
    {
        int index = Dither(image.pixels[x + y * width], dither.outImage.palette, dither.transparent, dither.dither, dither.ditherlevel);
        indexedImage.pixels[x + y * width] = index;
    }

    /* move to the next pixel */
    switch (direction)
    {
        case LEFT:
            dither.x -= 1;
            break;
        case RIGHT:
            dither.x += 1;
            break;
        case UP:
            dither.y -= 1;
            break;
        case DOWN:
            dither.y += 1;
            break;
    }
}
Example #2
0
void
Scaler::Run(int32 i, int32 n)
{
	int32 from, to, height, imageHeight;
	imageHeight = GetDestImage()->Bounds().IntegerHeight() + 1;
	height = imageHeight / n;
	from = i * height;
	if (i+1 == n) {
		to = imageHeight - 1;
	} else {
		to = from + height - 1;
	}
	if (GetDestImage()->Bounds().Width() >= GetSrcImage()->Bounds().Width()) {
		ScaleBilinearFP(from, to);
	} else {
		DownScaleBilinear(from, to);
	}
	if (fDither) {
		Dither(from, to);
	}
}
Example #3
0
void render::RenderImage(void)
{
    ULONG index;
    UBYTE palIndex;
    ULONG memIndex;

    if((Type == RGB) || (Type == RGBW))
    {
        if(DitherFlag == True)
        {
            Dither();
        }

        // Note that we are assured that all colors in the image are
        // in the LookupTable since for each image, we add its colors to
        // the lookup table before we get here.
        else
        {
            for(index = 0;index < ImageSize;index++)
            {
                memIndex=(((ULONG)(pData24[index].peGreen)>>1)<<14)+(((ULONG)(pData24[index].peRed)>>1)<<7)+
                          ((ULONG)(pData24[index].peBlue)>>1);

                if(IsZeroColor(&pData24[index]) == True)
                {
                    pData8[index] = 0;
                }
                else
                {
                    palIndex      = (UBYTE) LookupTable[memIndex];
                    pData8[index] = palIndex;
                }
            }
        }
    }
    else

    if(Type == LUV)
Example #4
0
void RT_RayTracer::renderFrameETC() {
  uint32_t* fb1 = (uint32_t*)frameBuffer->getFrameBuffer();
  uint32_t* fb2 = (uint32_t*)blockFB->getFrameBuffer();

  const int widthFB1 = frameBuffer->getSizeX(); // width of full frame buffer, e.g. 1280 for 1280x720
  int widthFB2 = widthFB1;
  if (Engine::rectMode) {
    widthFB2 = Engine::rectSizeX;   // width of rect, e.g. 640 if only one half of the full frame buffer should be rendered
  }

  look();
  taskManager.deleteAllTasks();
  createRenderingTasks();

  if (Engine::server) {
    auto etc1_fun = [&] (size_t i) {
      // render the tile to get RGBA data into the framebuffer
      taskManager.tasks[i]->run();

      auto src = fb1 + widthFB1 * Engine::RENDERLINE_SIZE * i;
      if (Engine::rectMode) {
        src += Engine::rectBottom * widthFB1 + Engine::rectLeft;  // offset the RGBA access until the bottom (lower part) of the rect starts and on the left side
      }
      auto dst = fb2 + widthFB2 * Engine::RENDERLINE_SIZE * i;

      // copy RGBA data from fb1 into the blockwise-oriented fb2
      for (int blockY = 0; blockY < Engine::RENDERLINE_SIZE/4; blockY++) {  // if RENDERLINE_SIZE=4 then this loop will only be executed once
        for (int blockX = 0; blockX < widthFB2 / 4; blockX++) {
          for (int x = 0; x < 4; x++) {
            for (int y = 0; y < 4; y++) {
              *dst++ = *src;
              src += widthFB1;
            }
            src -= widthFB1 * 4 - 1;
          }
        }
        src += widthFB1 * 3; // if RENDERLINE_SIZE=4 then this is irrelevant as src will not be used later
      }

      auto etc = ((uint64_t*)etcdata) + i * widthFB2 / 4;
      auto etcsrc = ((uint8_t*)fb2) + widthFB2 * Engine::RENDERLINE_SIZE * i * 4;

      // loop through the blockwise-oriented fb2 and compress RGBA into ETC1 and store this in etc/etcdata.
      for (size_t i = 0; i < widthFB2*Engine::RENDERLINE_SIZE / 16; ++i) {
        #if 0
        Dither( etcsrc );
        #endif
        *etc++ = ProcessRGB( etcsrc );
        etcsrc += 4*4*4;
      }
    };

    auto ompf_dispatch = [&] () {
      size_t e = taskManager.tasks.size();
      #pragma omp parallel for
      for (size_t i = 0; i < e; ++i) {
        etc1_fun(i);
      }
    };
    auto ompt_dispatch = [&] () {
      #pragma omp parallel
      #pragma omp single
      for (size_t i = 0, e = taskManager.tasks.size(); i < e; ++i) {
        #pragma omp task
        etc1_fun(i);
      }
    };
    auto cilk_dispatch = [&] () {
      for (size_t i = 0, e = taskManager.tasks.size(); i < e; ++i) {
        #ifdef __cilk
        cilk_spawn(etc1_fun(i));
        #else
        etc1_fun(i);
        #endif
      }
      #ifdef __cilk
      cilk_sync;
      #endif
    };
    auto task_dispatch = [&] () {
      for (size_t i = 0, e = taskManager.tasks.size(); i < e; ++i) {
        TaskDispatch::Queue([&etc1_fun, i] { etc1_fun(i); });
      }
      TaskDispatch::Sync();
    };

    switch (Engine::methodToMultiThread) {
      case MultiThreadMethods::TASKDISPATCH: task_dispatch(); break;
      case MultiThreadMethods::OPENMP:       ompf_dispatch(); break;
      case MultiThreadMethods::OPENMPT:      ompt_dispatch(); break;
      case MultiThreadMethods::CILK:         cilk_dispatch(); break;
    }
  } else {
    renderScene();
  }
}
void GPUDrawScanlineCodeGenerator::Generate()
{
	push(esi);
	push(edi);

	Init();

	align(16);

L("loop");

	// GSVector4i test = m_test[7 + (steps & (steps >> 31))];

	mov(edx, ecx);
	sar(edx, 31);
	and(edx, ecx);
	shl(edx, 4);

	movdqa(xmm7, ptr[edx + (size_t)&m_test[7]]);

	// movdqu(xmm1, ptr[edi]);

	movq(xmm1, qword[edi]);
	movhps(xmm1, qword[edi + 8]);

	// ecx = steps
	// esi = tex (tme)
	// edi = fb
	// xmm1 = fd
	// xmm2 = s
	// xmm3 = t
	// xmm4 = r
	// xmm5 = g
	// xmm6 = b
	// xmm7 = test

	TestMask();

	SampleTexture();

	// xmm1 = fd
	// xmm3 = a
	// xmm4 = r
	// xmm5 = g
	// xmm6 = b
	// xmm7 = test
	// xmm0, xmm2 = free

	ColorTFX();

	AlphaBlend();

	Dither();

	WriteFrame();

L("step");

	// if(steps <= 0) break;

	test(ecx, ecx);
	jle("exit", T_NEAR);

	Step();

	jmp("loop", T_NEAR);

L("exit");

	pop(edi);
	pop(esi);

	ret(8);
}