// Initialises the range from a unicode range in string form. bool UnicodeRange::Initialise(const String& unicode_range) { // Check for a 'U+' at the start. if (unicode_range.Length() < 2 || unicode_range[0] != 'U' || unicode_range[1] != '+') return false; // Check if there's a '-' sign; if so, we've got a range. String::size_type separator_index = unicode_range.Find("-", 2); if (separator_index != String::npos) { const char* end = unicode_range.CString() + separator_index; min_codepoint = strtoul(unicode_range.CString() + 2, (char **) &end, 16); end = unicode_range.CString() + unicode_range.Length(); max_codepoint = strtoul(unicode_range.CString() + separator_index + 1, (char **) &end, 16); return min_codepoint <= max_codepoint; } // No range! Check if we have any wildcards. String::size_type wildcard_index = unicode_range.Find("?", 2); if (wildcard_index != String::npos) { String range_min(unicode_range.CString() + 2, unicode_range.CString() + wildcard_index); String range_max(range_min); for (String::size_type i = 0; i < unicode_range.Length() - wildcard_index; ++i) { range_min += "0"; range_max += "F"; } const char* end = range_min.CString() + range_min.Length(); min_codepoint = strtoul(range_min.CString(), (char**) &end, 16); end = range_max.CString() + range_max.Length(); max_codepoint = strtoul(range_max.CString(), (char**) &end, 16); return true; } const char* end = unicode_range.CString() + unicode_range.Length(); min_codepoint = strtoul(unicode_range.CString() + 2, (char**) &end, 16); max_codepoint = min_codepoint; return true; }
static void * combine_shaders(const struct shader_asm_info *shaders[SHADER_STAGES], int num_shaders, struct pipe_context *pipe, struct pipe_shader_state *shader) { VGboolean declare_input = VG_FALSE; VGint start_const = -1, end_const = 0; VGint start_temp = -1, end_temp = 0; VGint start_sampler = -1, end_sampler = 0; VGint i, current_shader = 0; VGint num_consts, num_temps, num_samplers; struct ureg_program *ureg; struct ureg_src in[2]; struct ureg_src *sampler = NULL; struct ureg_src *constant = NULL; struct ureg_dst out, *temp = NULL; void *p = NULL; for (i = 0; i < num_shaders; ++i) { if (shaders[i]->num_consts) start_const = range_min(start_const, shaders[i]->start_const); if (shaders[i]->num_temps) start_temp = range_min(start_temp, shaders[i]->start_temp); if (shaders[i]->num_samplers) start_sampler = range_min(start_sampler, shaders[i]->start_sampler); end_const = range_max(end_const, shaders[i]->start_const + shaders[i]->num_consts); end_temp = range_max(end_temp, shaders[i]->start_temp + shaders[i]->num_temps); end_sampler = range_max(end_sampler, shaders[i]->start_sampler + shaders[i]->num_samplers); if (shaders[i]->needs_position) declare_input = VG_TRUE; } /* if they're still unitialized, initialize them */ if (start_const < 0) start_const = 0; if (start_temp < 0) start_temp = 0; if (start_sampler < 0) start_sampler = 0; num_consts = end_const - start_const; num_temps = end_temp - start_temp; num_samplers = end_sampler - start_sampler; ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT); if (!ureg) return NULL; if (declare_input) { in[0] = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_POSITION, 0, TGSI_INTERPOLATE_LINEAR); in[1] = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_GENERIC, 0, TGSI_INTERPOLATE_PERSPECTIVE); } /* we always have a color output */ out = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0); if (num_consts >= 1) { constant = (struct ureg_src *) malloc(sizeof(struct ureg_src) * end_const); for (i = start_const; i < end_const; i++) { constant[i] = ureg_DECL_constant(ureg, i); } } if (num_temps >= 1) { temp = (struct ureg_dst *) malloc(sizeof(struct ureg_dst) * end_temp); for (i = start_temp; i < end_temp; i++) { temp[i] = ureg_DECL_temporary(ureg); } } if (num_samplers >= 1) { sampler = (struct ureg_src *) malloc(sizeof(struct ureg_src) * end_sampler); for (i = start_sampler; i < end_sampler; i++) { sampler[i] = ureg_DECL_sampler(ureg, i); } } while (current_shader < num_shaders) { if ((current_shader + 1) == num_shaders) { shaders[current_shader]->func(ureg, &out, in, sampler, temp, constant); } else { shaders[current_shader]->func(ureg, &temp[0], in, sampler, temp, constant); } current_shader++; } ureg_END(ureg); shader->tokens = ureg_finalize(ureg); if(!shader->tokens) return NULL; p = pipe->create_fs_state(pipe, shader); ureg_destroy(ureg); if (num_temps >= 1) { for (i = start_temp; i < end_temp; i++) { ureg_release_temporary(ureg, temp[i]); } } if (temp) free(temp); if (constant) free(constant); if (sampler) free(sampler); return p; }