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

Function pixel_format_comparator

platform/mac/pixelformat.cpp:642–784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

640
641
642static CFComparisonResult pixel_format_comparator(const void *val1, const void *val2, void *context)
643{
644 CFNumberRef number1 = (CFNumberRef)val1;
645 CFNumberRef number2 = (CFNumberRef)val2;
646 UInt64 code1, code2;
647 pixel_format pf1, pf2;
648 int category1, category2;
649
650 CFNumberGetValue(number1, kCFNumberLongLongType, &code1);
651 CFNumberGetValue(number2, kCFNumberLongLongType, &code2);
652 pf1 = pixel_format_for_code(code1);
653 pf2 = pixel_format_for_code(code2);
654 category1 = pixel_format_category(pf1);
655 category2 = pixel_format_category(pf2);
656
657 if (category1 < category2) {
658 return kCFCompareLessThan;
659 }
660 if (category1 > category2) {
661 return kCFCompareGreaterThan;
662 }
663 /* Within a category, sort the "best" formats toward the front since that's
664 what wglChoosePixelFormatARB() has to do. The ordering implemented here
665 matches at least one Windows 7 machine's behavior.
666 */
667 /* Accelerated before unaccelerated. */
668 if (pf1.accelerated && !pf2.accelerated) {
669 return kCFCompareLessThan;
670 }
671 if (!pf1.accelerated && pf2.accelerated) {
672 return kCFCompareGreaterThan;
673 }
674 /* Explicit color mode ordering. */
675 if (color_modes[pf1.color_mode].color_ordering < color_modes[pf2.color_mode].color_ordering) {
676 return kCFCompareLessThan;
677 }
678 if (color_modes[pf1.color_mode].color_ordering > color_modes[pf2.color_mode].color_ordering) {
679 return kCFCompareGreaterThan;
680 }
681
682 /* Non-pbuffer-capable before pbuffer-capable. */
683 if (!pf1.pbuffer && pf2.pbuffer) {
684 return kCFCompareLessThan;
685 }
686 if (pf1.pbuffer && !pf2.pbuffer) {
687 return kCFCompareGreaterThan;
688 }
689 /* Fewer samples before more samples. */
690 if (pf1.samples < pf2.samples) {
691 return kCFCompareLessThan;
692 }
693 if (pf1.samples > pf2.samples) {
694 return kCFCompareGreaterThan;
695 }
696 /* Monoscopic before stereoscopic. (This is a guess.) */
697 if (!pf1.stereo && pf2.stereo) {
698 return kCFCompareLessThan;
699 }

Callers

nothing calls this directly

Calls 2

pixel_format_for_codeFunction · 0.85
pixel_format_categoryFunction · 0.85

Tested by

no test coverage detected