blending.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "blending.h"
  2. #if !defined(WIN32) && !defined(LINUX)
  3. #error port me!
  4. #endif
  5. class BlenderInit
  6. {
  7. public:
  8. BlenderInit() { Blenders::init(); }
  9. };
  10. static BlenderInit blender_init;
  11. void Blenders::init()
  12. {
  13. if (!alphatable[127][127])
  14. {
  15. int i, j;
  16. for (j = 0;j < 256;j++)
  17. for (i = 0;i < 256;i++)
  18. alphatable[i][j] = (i * (j + 1)) >> 8;
  19. #ifndef NO_MMX
  20. DWORD retval1, retval2;
  21. #ifdef WIN32
  22. __try {
  23. _asm {
  24. mov eax, 1 // set up CPUID to return processor version and features
  25. // 0 = vendor string, 1 = version info, 2 = cache info
  26. _emit 0x0f // code bytes = 0fh, 0a2h
  27. _emit 0xa2
  28. mov retval1, eax
  29. mov retval2, edx
  30. }
  31. } __except(EXCEPTION_EXECUTE_HANDLER) { retval1 = retval2 = 0;}
  32. #else
  33. __asm__ volatile ( "movl $1, %%eax\n"
  34. ".byte 15, 162\n"
  35. "movl %%eax, %0\n"
  36. "movl %%edx, %1\n"
  37. : "=m" (retval1), "=m" (retval2)
  38. : // No inputs...
  39. : "%eax", "%edx" );
  40. #endif
  41. mmx_available = retval1 && (retval2 & 0x800000);
  42. #endif //ndef NO_MMX
  43. }
  44. }
  45. #ifndef NO_MMX
  46. int Blenders::mmx_available = 0;
  47. #endif
  48. unsigned char Blenders::alphatable[256][256] = {0};