- Timestamp:
- May 3, 2010, 8:45:22 AM (16 years ago)
- Location:
- branches/simmosaic_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simmosaic_branches
- Property svn:mergeinfo changed
-
branches/simmosaic_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simmosaic_branches/Ohana/src/kapa2/src/CheckVisual.c
r21153 r27839 10 10 11 11 int i, Nfound, N; 12 int isColor, isDefault , isDynamic;12 int isColor, isDefault; 13 13 XVisualInfo *visual_list, visual_temp; 14 14 unsigned long planes[3]; … … 34 34 } 35 35 36 // skip the default and the PseudoColor visuals, go for TrueColor first37 # if (0)38 /* check default visual first */39 for (i = 0; (i < Nfound) && (graphic[0].visual != visual_list[i].visual); i++);40 if (i == Nfound) {41 fprintf (stderr, "default visual not found??\n");42 exit (0);43 }44 # endif45 46 36 // set these based on selected visual 47 isColor = isDefault = isDynamic = FALSE; 48 49 # if (0) 50 // attempt to select the most desirable type of visual: Default as PseudoColor (XXX is it still true?) 51 if (DEBUG) fprintf (stderr, "default visual class is %d\n", visual_list[i].class); 52 if (visual_list[i].class == PseudoColor) { 53 isColor = isDefault = isDynamic = TRUE; 54 graphic[0].visual = visual_list[i].visual; 55 graphic[0].visualclass = TRUE; 56 goto test_pixels; 57 } 58 # endif 59 60 // attempt to select the most desirable type of visual: TrueColor (XXX is it still true?) 37 isColor = isDefault = FALSE; 38 39 // attempt to select the most desirable type of visual: TrueColor 61 40 for (i = 0; (i < Nfound) && (visual_list[i].class != TrueColor); i++); 62 41 if (i != Nfound) { … … 65 44 isDefault = (graphic[0].visual == visual_list[i].visual); 66 45 graphic[0].visual = visual_list[i].visual; 67 graphic[0].visualclass = FALSE; 46 graphic[0].dynamicColors = FALSE; 47 if (DEBUG) fprintf (stderr, "got TrueColor visual\n"); 48 goto test_pixels; 49 } 50 51 // attempt to select the most desirable type of visual: DirectColor 52 for (i = 0; (i < Nfound) && (visual_list[i].class != DirectColor); i++); 53 if (i != Nfound) { 54 isColor = TRUE; 55 if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class); 56 isDefault = (graphic[0].visual == visual_list[i].visual); 57 graphic[0].visual = visual_list[i].visual; 58 graphic[0].dynamicColors = TRUE; 59 if (DEBUG) fprintf (stderr, "got DirectColor visual\n"); 68 60 goto test_pixels; 69 61 } … … 72 64 for (i = 0; (i < Nfound) && (visual_list[i].class != PseudoColor); i++); 73 65 if (i != Nfound) { 74 isColor = isDynamic =TRUE;66 isColor = TRUE; 75 67 if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class); 76 68 isDefault = (graphic[0].visual == visual_list[i].visual); 77 69 graphic[0].visual = visual_list[i].visual; 78 graphic[0].visualclass = TRUE; 70 graphic[0].dynamicColors = TRUE; 71 if (DEBUG) fprintf (stderr, "got PseudoColor visual\n"); 79 72 goto test_pixels; 80 73 } … … 83 76 for (i = 0; (i < Nfound) && (visual_list[i].class != GrayScale); i++); 84 77 if (i != Nfound) { 85 isDynamic = TRUE;86 78 if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class); 87 79 isDefault = (graphic[0].visual == visual_list[i].visual); 88 80 graphic[0].visual = visual_list[i].visual; 89 graphic[0].visualclass = TRUE; 81 graphic[0].dynamicColors = TRUE; 82 if (DEBUG) fprintf (stderr, "got GrayScale visual\n"); 90 83 goto test_pixels; 91 84 } … … 97 90 isDefault = (graphic[0].visual == visual_list[i].visual); 98 91 graphic[0].visual = visual_list[i].visual; 99 graphic[0].visualclass = FALSE; 92 graphic[0].dynamicColors = FALSE; 93 if (DEBUG) fprintf (stderr, "got StaticColor visual\n"); 100 94 goto test_pixels; 101 95 } … … 107 101 isDefault = (graphic[0].visual == visual_list[i].visual); 108 102 graphic[0].visual = visual_list[i].visual; 109 graphic[0].visualclass = FALSE; 103 graphic[0].dynamicColors = FALSE; 104 if (DEBUG) fprintf (stderr, "got StaticGray visual\n"); 110 105 goto test_pixels; 111 106 } … … 115 110 /* need to make a colormap if 116 111 1) the selected visual is not the default 112 XXX not sure if I need to / am allowed to alloc a colormap if I've grabbed the default. 117 113 2) there are not enough colors available */ 118 114 … … 125 121 } 126 122 127 // allocate a private colormap, if needed 123 // dynamic visual classes can accept AllocAll and can use XAllocColorCells while AllocNone must use XAllocColor 124 // int allocMode = graphic[0].dynamicColors ? AllocAll : AllocNone; 125 int allocMode = AllocNone; 126 127 // allocate a private colormap, if desired or needed 128 128 if (!isDefault) { 129 129 if (DEBUG) fprintf (stderr, "allocated private colormap\n"); 130 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);131 } 132 133 if ( isDynamic) {130 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, allocMode); 131 } 132 133 if (graphic[0].dynamicColors) { 134 134 Npixels = NPIXELS_DYNAMIC; 135 135 if ((N = get_argument (*argc, argv, "-ncolors"))) { … … 144 144 for (graphic[0].Npixels = Npixels; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) { 145 145 if (DEBUG) fprintf (stderr, "trying %d colors\n", (int) graphic[0].Npixels); 146 if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)) {146 if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 0, graphic[0].pixels, graphic[0].Npixels)) { 147 147 break; 148 } 149 for (i = 0; i < graphic[0].Npixels; i++) { 150 graphic[0].cmap[i].pixel = graphic[0].pixels[i]; 148 151 } 149 152 } … … 152 155 if (graphic[0].Npixels < 16) { 153 156 if (!isDefault) { 157 // We've already tried to allocate a colormap above... 154 158 fprintf (stderr, "can't allocate enough cells in private colormap\n"); 155 159 exit (0); 156 160 } 157 161 if (DEBUG) fprintf (stderr, "can't allocate enough cells, using private colormap\n"); 158 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);162 graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, allocMode); 159 163 160 164 for (graphic[0].Npixels = NPIXELS_DYNAMIC; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) { … … 163 167 break; 164 168 } 165 } 166 169 for (i = 0; i < graphic[0].Npixels; i++) { 170 graphic[0].cmap[i].pixel = graphic[0].pixels[i]; 171 } 172 } 167 173 if ((N = get_argument (*argc, argv, "-colorcount"))) { 168 174 fprintf (stderr, "kapa can grab %d colors\n", graphic[0].Npixels);
Note:
See TracChangeset
for help on using the changeset viewer.
