MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / getPixelFormats

Function getPixelFormats

platform/mac/pixelformat.cpp:879–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

877static bool initialized = false;
878
879int getPixelFormats(PixelFormat* pfs, int maxPfs) {
880 if (!initialized) {
881 init_pixel_formats();
882 initialized = true;
883 }
884 const pixel_format *pf;
885 const struct color_mode *mode;
886 int count = nb_displayable_formats;
887 int result = 0;
888
889 if (count > maxPfs) {
890 count = maxPfs;
891 }
892 for (int i=1;i<=nb_formats && result < count;i++) {
893
894 if (!(pf = get_pixel_format(i, FALSE))) {
895 continue;
896 }
897
898
899 memset(&pfs[result], 0, sizeof(PixelFormat));
900 pfs[result].nSize = 40;
901 pfs[result].nVersion = 1;
902
903 pfs[result].dwFlags = K_PFD_SUPPORT_OPENGL;
904 if (pf->window) pfs[result].dwFlags |= K_PFD_DRAW_TO_WINDOW;
905 if (!pf->accelerated) pfs[result].dwFlags |= K_PFD_GENERIC_FORMAT;
906 if (pf->double_buffer) pfs[result].dwFlags |= K_PFD_DOUBLEBUFFER;
907 if (pf->stereo) pfs[result].dwFlags |= K_PFD_STEREO;
908 if (pf->backing_store) pfs[result].dwFlags |= K_PFD_SWAP_COPY;
909
910 pfs[result].iPixelType = K_PFD_TYPE_RGBA;
911
912 mode = &color_modes[pf->color_mode];
913 /* If the mode doesn't have alpha, return bits per pixel instead of color bits.
914 On Windows, color bits sometimes exceeds r+g+b (e.g. it's 32 for an
915 R8G8B8A0 pixel format). If an app depends on that and expects that
916 cColorBits >= 32 for such a pixel format, we need to accommodate that. */
917 if (mode->alpha_bits) {
918 pfs[result].cColorBits = mode->color_bits;
919 } else {
920 pfs[result].cColorBits = mode->bits_per_pixel;
921 }
922 pfs[result].cRedBits = mode->red_bits;
923 pfs[result].cRedShift = mode->red_shift;
924 pfs[result].cGreenBits = mode->green_bits;
925 pfs[result].cGreenShift = mode->green_shift;
926 pfs[result].cBlueBits = mode->blue_bits;
927 pfs[result].cBlueShift = mode->blue_shift;
928 pfs[result].cAlphaBits = mode->alpha_bits;
929 pfs[result].cAlphaShift = mode->alpha_shift;
930
931 if (pf->accum_mode) {
932 mode = &color_modes[pf->accum_mode - 1];
933 pfs[result].cAccumBits = mode->color_bits;
934 pfs[result].cAccumRedBits = mode->red_bits;
935 pfs[result].cAccumGreenBits = mode->green_bits;
936 pfs[result].cAccumBlueBits = mode->blue_bits;

Callers

nothing calls this directly

Calls 2

init_pixel_formatsFunction · 0.85
get_pixel_formatFunction · 0.85

Tested by

no test coverage detected