blending.cpp 1.2 KB

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