void *CGLBase::loadTexture(int width, int height, int channels, const char* filePathDummy){ // 画像を読み込む(ここでは仮として自動生成する) typedef unsigned char* iterator_t; int image_size = width * height * channels * sizeof(unsigned char); void *image = ::malloc( image_size ); // nullチェック略 iterator_t itr_dest = iterator_t(image); iterator_t itr_dest_end = itr_dest + image_size; // ストライプ作成 int pixel = 0; int stride = 3; while (itr_dest != itr_dest_end) { *itr_dest++ = 255-50 * pixel ; *itr_dest++ = 255-50 * pixel ; *itr_dest++ = 255-10 * pixel ; if (channels == RGBA) { *itr_dest++ = 100; // 半透明 } pixel = ++pixel % stride; } // 上左端に目印をつける itr_dest = iterator_t(image); for(int i = 0 ; i < width / 3; i++){ *itr_dest++ = 50; // cyan *itr_dest++ = 255; *itr_dest++ = 255; if (channels == RGBA) { *itr_dest++ = 100; } } return image; }
iterator_t insert_node(const comparator_type& compare, node_type* node, const Synchronized&) { lock_scope_t<const self_type, Synchronized> l(this); if (!m_root) { node->set_black(); m_root = node; return iterator_t(node); } bool ok = node_type::insert(m_root, node, &m_root, compare); if (!ok) { return end(); } return iterator_t(node); }
void read_polish( std::string str , Tree &tree , NodeMapper const& mapper , std::string const& sep = "|" , std::string const &opening = "" , std::string const& closing = "" ) { using iterator_t = boost::split_iterator< std::string::const_iterator >; if( opening != "" ) boost::algorithm::erase_all( str , opening ); if( closing != "" ) boost::algorithm::erase_all( str , closing ); iterator_t first = iterator_t( str , boost::first_finder( sep , boost::is_iequal() ) ); detail::read_polish_impl( first , tree , tree.root() , mapper ); }
iterator_t insert(arena_type* arena, const comparator_type& compare, const NewKey& key, const Synchronized& sync) { node_type* toins = new_node(arena, key); UF_ALERT_AND_RETURN_UNLESS(toins, iterator_t(0), "failed to allocate new node!"); iterator_t ret = insert_node(compare, toins, sync); if (ret.atend()) { delete_node(arena, toins); } return ret; }
iterator_t ensure(arena_type* arena, const comparator_type& compare, const NewKey& key, const Synchronized& sync) { iterator_t found = end(sync); while (found.atend()) { iterator_t found = find(compare, key, sync); if (found.good()) { return found; } node_type* toins = new_node(arena, key); UF_ALERT_AND_RETURN_UNLESS(toins, iterator_t(0), "failed to allocate new node!"); iterator_t ret = insert_node(compare, toins, sync); if (ret.atend()) { /* * another thread have already inserted same node: * so we remove ours and retry find again. */ delete_node(arena, toins); } } return found; }
iterator_t find(const comparator_type& compare, const FindKey& k, const Synchronized& sync) { return iterator_t(find_node(compare, k, sync)); }
iterator_t end(const Synchronized&) { return iterator_t(0); }
iterator_t begin(const Synchronized& sync) { return iterator_t(begin_node(sync)); }