S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_embedded, BOOL use_ellipses) const { LL_RECORD_BLOCK_TIME(FTM_RENDER_FONTS); if(!sDisplayFont) //do not display texts { return wstr.length() ; } if (wstr.empty() || !max_pixels) { return 0; } if (max_chars == -1) max_chars = S32_MAX; const S32 max_index = llmin(llmax(max_chars, begin_offset + max_chars), S32(wstr.length())); if (max_index <= 0 || begin_offset >= max_index || max_pixels <= 0) return 0; gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX); // determine which style flags need to be added programmatically by stripping off the // style bits that are drawn by the underlying Freetype font U8 style_to_add = (style | mFontDescriptor.getStyle()) & ~mFontFreetype->getStyle(); F32 drop_shadow_strength = 0.f; if (shadow != NO_SHADOW) { F32 luminance; color.calcHSL(NULL, NULL, &luminance); drop_shadow_strength = clamp_rescale(luminance, 0.35f, 0.6f, 0.f, 1.f); if (luminance < 0.35f) { shadow = NO_SHADOW; } } gGL.pushUIMatrix(); gGL.loadUIIdentity(); LLVector2 origin(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY)); // Depth translation, so that floating text appears 'in-world' // and is correctly occluded. gGL.translatef(0.f,0.f,sCurDepth); S32 chars_drawn = 0; S32 i; S32 length = max_index - begin_offset; F32 cur_x, cur_y, cur_render_x, cur_render_y; // Not guaranteed to be set correctly gGL.setSceneBlendType(LLRender::BT_ALPHA); cur_x = ((F32)x * sScaleX) + origin.mV[VX]; cur_y = ((F32)y * sScaleY) + origin.mV[VY]; // Offset y by vertical alignment. // use unscaled font metrics here switch (valign) { case TOP: cur_y -= llceil(mFontFreetype->getAscenderHeight()); break; case BOTTOM: cur_y += llceil(mFontFreetype->getDescenderHeight()); break; case VCENTER: cur_y -= llceil((llceil(mFontFreetype->getAscenderHeight()) - llceil(mFontFreetype->getDescenderHeight())) / 2.f); break; case BASELINE: // Baseline, do nothing. break; default: break; } switch (halign) { case LEFT: break; case RIGHT: cur_x -= llmin(scaled_max_pixels, ll_pos_round(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)); break; case HCENTER: cur_x -= llmin(scaled_max_pixels, ll_pos_round(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)) / 2; break; default: break; } cur_render_y = cur_y; cur_render_x = cur_x; F32 start_x = (F32)ll_round(cur_x); const LLFontBitmapCache* font_bitmap_cache = mFontFreetype->getFontBitmapCache(); F32 inv_width = 1.f / font_bitmap_cache->getBitmapWidth(); F32 inv_height = 1.f / font_bitmap_cache->getBitmapHeight(); const S32 LAST_CHARACTER = LLFontFreetype::LAST_CHAR_FULL; BOOL draw_ellipses = FALSE; if (use_ellipses && halign == LEFT) { // check for too long of a string S32 string_width = ll_pos_round(getWidthF32(wstr, begin_offset, max_chars) * sScaleX); if (string_width > scaled_max_pixels) { // use four dots for ellipsis width to generate padding const LLWString dots(utf8str_to_wstring(std::string("...."))); scaled_max_pixels = llmax(0, scaled_max_pixels - ll_pos_round(getWidthF32(dots.c_str()))); draw_ellipses = TRUE; } } const LLFontGlyphInfo* next_glyph = NULL; const S32 GLYPH_BATCH_SIZE = 30; static LL_ALIGN_16(LLVector4a vertices[GLYPH_BATCH_SIZE * GLYPH_VERTICES]); static LLVector2 uvs[GLYPH_BATCH_SIZE * GLYPH_VERTICES]; static LLColor4U colors[GLYPH_BATCH_SIZE * GLYPH_VERTICES]; LLColor4U text_color(color); S32 bitmap_num = -1; S32 glyph_count = 0; for (i = begin_offset; i < begin_offset + length; i++) { llwchar wch = wstr[i]; // Handle embedded characters first, if they're enabled. // Embedded characters are a hack for notecards const embedded_data_t* ext_data = use_embedded ? getEmbeddedCharData(wch) : NULL; if (ext_data) { LLImageGL* ext_image = ext_data->mImage; const LLWString& label = ext_data->mLabel; F32 ext_height = (F32)ext_image->getHeight() * sScaleY; F32 ext_width = (F32)ext_image->getWidth() * sScaleX; F32 ext_advance = (EXT_X_BEARING * sScaleX) + ext_width; if (!label.empty()) { ext_advance += (EXT_X_BEARING + getFontExtChar()->getWidthF32( label.c_str() )) * sScaleX; } if (start_x + scaled_max_pixels < cur_x + ext_advance) { // Not enough room for this character. break; } gGL.getTexUnit(0)->bind(ext_image); // snap origin to whole screen pixel const F32 ext_x = (F32)ll_round(cur_render_x + (EXT_X_BEARING * sScaleX)); const F32 ext_y = (F32)ll_round(cur_render_y + (EXT_Y_BEARING * sScaleY + mFontFreetype->getAscenderHeight() - mFontFreetype->getLineHeight())); LLRectf uv_rect(0.f, 1.f, 1.f, 0.f); LLRectf screen_rect(ext_x, ext_y + ext_height, ext_x + ext_width, ext_y); if (glyph_count > 0) { gGL.begin(LLRender::TRIANGLES); { gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * GLYPH_VERTICES); } gGL.end(); glyph_count = 0; } renderQuad(vertices, uvs, colors, screen_rect, uv_rect, LLColor4U::white, 0); //No batching here. It will never happen. gGL.begin(LLRender::TRIANGLES); { gGL.vertexBatchPreTransformed(vertices, uvs, colors, GLYPH_VERTICES); } gGL.end(); if (!label.empty()) { gGL.pushMatrix(); getFontExtChar()->render(label, 0, /*llfloor*/(ext_x / sScaleX) + ext_image->getWidth() + EXT_X_BEARING - sCurOrigin.mX, /*llfloor*/(cur_render_y / sScaleY) - sCurOrigin.mY, color, halign, BASELINE, UNDERLINE, NO_SHADOW, S32_MAX, S32_MAX, NULL, TRUE ); gGL.popMatrix(); } chars_drawn++; cur_x += ext_advance; if (((i + 1) < length) && wstr[i+1]) { cur_x += EXT_KERNING * sScaleX; } cur_render_x = cur_x; } else { const LLFontGlyphInfo* fgi = next_glyph; next_glyph = NULL; if(!fgi) { fgi = mFontFreetype->getGlyphInfo(wch); } if (!fgi) { LL_ERRS() << "Missing Glyph Info" << LL_ENDL; break; } // Per-glyph bitmap texture. S32 next_bitmap_num = fgi->mBitmapNum; if (next_bitmap_num != bitmap_num) { // Actually draw the queued glyphs before switching their texture; // otherwise the queued glyphs will be taken from wrong textures. if (glyph_count > 0) { gGL.begin(LLRender::TRIANGLES); { gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * GLYPH_VERTICES); } gGL.end(); glyph_count = 0; } bitmap_num = next_bitmap_num; LLImageGL *font_image = font_bitmap_cache->getImageGL(bitmap_num); gGL.getTexUnit(0)->bind(font_image); } if ((start_x + scaled_max_pixels) < (cur_x + fgi->mXBearing + fgi->mWidth)) { // Not enough room for this character. break; } // Draw the text at the appropriate location //Specify vertices and texture coordinates LLRectf uv_rect((fgi->mXBitmapOffset) * inv_width, (fgi->mYBitmapOffset + fgi->mHeight + PAD_UVY) * inv_height, (fgi->mXBitmapOffset + fgi->mWidth) * inv_width, (fgi->mYBitmapOffset - PAD_UVY) * inv_height); // snap glyph origin to whole screen pixel LLRectf screen_rect((F32)ll_round(cur_render_x + (F32)fgi->mXBearing), (F32)ll_round(cur_render_y + (F32)fgi->mYBearing), (F32)ll_round(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth, (F32)ll_round(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight); if (glyph_count >= GLYPH_BATCH_SIZE) { gGL.begin(LLRender::TRIANGLES); { gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * GLYPH_VERTICES); } gGL.end(); glyph_count = 0; } drawGlyph(glyph_count, vertices, uvs, colors, screen_rect, uv_rect, text_color, style_to_add, shadow, drop_shadow_strength); chars_drawn++; cur_x += fgi->mXAdvance; cur_y += fgi->mYAdvance; llwchar next_char = wstr[i+1]; if (next_char && (next_char < LAST_CHARACTER)) { // Kern this puppy. next_glyph = mFontFreetype->getGlyphInfo(next_char); cur_x += mFontFreetype->getXKerning(fgi, next_glyph); } // Round after kerning. // Must do this to cur_x, not just to cur_render_x, otherwise you // will squish sub-pixel kerned characters too close together. // For example, "CCCCC" looks bad. cur_x = (F32)ll_round(cur_x); //cur_y = (F32)ll_round(cur_y); cur_render_x = cur_x; cur_render_y = cur_y; } } if(glyph_count) { gGL.begin(LLRender::TRIANGLES); { gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * GLYPH_VERTICES); } gGL.end(); } if (right_x) { *right_x = (cur_x - origin.mV[VX]) / sScaleX; } //FIXME: add underline as glyph? if (style_to_add & UNDERLINE) { F32 descender = (F32)llfloor(mFontFreetype->getDescenderHeight()); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.begin(LLRender::LINES); gGL.vertex2f(start_x, cur_y - descender); gGL.vertex2f(cur_x, cur_y - descender); gGL.end(); } if (draw_ellipses) { // recursively render ellipses at end of string // we've already reserved enough room gGL.pushUIMatrix(); renderUTF8(std::string("..."), 0, (cur_x - origin.mV[VX]) / sScaleX, (F32)y, color, LEFT, valign, style_to_add, shadow, S32_MAX, max_pixels, right_x, FALSE); gGL.popUIMatrix(); } gGL.popUIMatrix(); return chars_drawn; }
void LLGLTexMemBar::draw() { S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes); S32 max_bound_mem = LLViewerTexture::sMaxBoundTextureMemInMegaBytes; S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sTotalTextureMemoryInBytes); S32 max_total_mem = LLViewerTexture::sMaxTotalTextureMemInMegaBytes; F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; F32 cache_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getUsage()) ; F32 cache_max_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getMaxUsage()) ; S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024); F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024); U32 total_http_requests = LLAppViewer::getTextureFetch()->getTotalNumHTTPRequests(); //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); LLColor4 color; // Gray background using completely magic numbers gGL.color4f(0.f, 0.f, 0.f, 0.25f); // const LLRect & rect(getRect()); // gl_rect_2d(-4, v_offset, rect.mRight - rect.mLeft + 2, v_offset + line_height*4); std::string text = ""; LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6, text_color, LLFontGL::LEFT, LLFontGL::TOP); text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB FBO: %d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB", total_mem, max_total_mem, bound_mem, max_bound_mem, LLRenderTarget::sBytesAllocated/(1024*1024), LLImageRaw::sGlobalRawMemory >> 20, discard_bias, cache_usage, cache_max_usage); //, cache_entries, cache_max_entries // <FS:Ansariel> Texture memory bars //LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*4, LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*5, // </FS:Ansariel> text_color, LLFontGL::LEFT, LLFontGL::TOP); // <FS:Ansariel> Texture memory bars S32 bar_left = 0; S32 bar_width = 200; S32 bar_space = 32; S32 top = line_height*4 - 2 + v_offset; S32 bottom = top - 6; S32 left = bar_left; S32 right = left + bar_width; F32 bar_scale; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // GL Mem Bar left = bar_left; text = "GL"; LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, v_offset + line_height*4, text_color, LLFontGL::LEFT, LLFontGL::TOP); left = bar_left+20; right = left + bar_width; gGL.color4f(0.5f, 0.5f, 0.5f, 0.75f); // grey gl_rect_2d(left, top, right, bottom); bar_scale = (F32)bar_width / (max_total_mem * 1.5f); right = left + llfloor(total_mem * bar_scale); right = llclamp(right, bar_left, bar_left + bar_width); color = (total_mem < llfloor(max_total_mem * texmem_lower_bound_scale)) ? LLColor4::green : (total_mem < max_total_mem) ? LLColor4::yellow : LLColor4::red; color[VALPHA] = .75f; // gGL.diffuseColor4fv(color.mV); gl_rect_2d(left, top, right, bottom, color); // red/yellow/green // bar_left += bar_width + bar_space; //top = bottom - 2; bottom = top - 6; // Bound Mem Bar left = bar_left; text = "Bound"; LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, v_offset + line_height*4, text_color, LLFontGL::LEFT, LLFontGL::TOP); left = bar_left + 42; right = left + bar_width; gGL.color4f(0.5f, 0.5f, 0.5f, 0.75f); gl_rect_2d(left, top, right, bottom); color = (bound_mem < llfloor(max_bound_mem * texmem_lower_bound_scale)) ? LLColor4::green : (bound_mem < max_bound_mem) ? LLColor4::yellow : LLColor4::red; color[VALPHA] = .75f; // gGL.diffuseColor4fv(color.mV); bar_scale = (F32)bar_width / (max_bound_mem * 1.5f); right = left + llfloor(bound_mem * bar_scale); gl_rect_2d(left, top, right, bottom, color); // </FS:Ansariel> U32 cache_read(0U), cache_write(0U), res_wait(0U); LLAppViewer::getTextureFetch()->getStateStats(&cache_read, &cache_write, &res_wait); // <FS:Ansariel> Fast cache stats //text = llformat("Net Tot Tex: %.1f MB Tot Obj: %.1f MB Tot Htp: %d Cread: %u Cwrite: %u Rwait: %u", text = llformat("Net Tot Tex: %.1f MB Tot Obj: %.1f MB Tot Htp: %d Cread: %u Cwrite: %u Rwait: %u FCread: %u", // </FS:Ansariel> total_texture_downloaded, total_object_downloaded, total_http_requests, cache_read, cache_write, // <FS:Ansariel> Fast cache stats //res_wait); res_wait, LLViewerTextureList::sNumFastCacheReads); // </FS:Ansariel> LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3, text_color, LLFontGL::LEFT, LLFontGL::TOP); // <FS:Ansariel> Texture memory bars //S32 left = 0 ; //---------------------------------------------------------------------------- // <FS:Ansariel> Fast cache stats //text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d RAW:%d HTP:%d DEC:%d CRE:%d", text = llformat("Tex: %d Fetch: %d(%d) Pkts:%d(%d) CAC R/W: %d/%d LFS:%d RAW:%d HTP:%d DEC:%d CRE:%d FCA:%d", // </FS:Ansariel> gTextureList.getNumImages(), LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(), LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount, LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(), LLLFSThread::sLocal->getPending(), LLImageRaw::sRawImageCount, LLAppViewer::getTextureFetch()->getNumHTTPRequests(), LLAppViewer::getImageDecodeThread()->getPending(), // <FS:Ansariel> Fast cache stats //gTextureList.mCreateTextureList.size()); gTextureList.mCreateTextureList.size(), gTextureList.mFastCacheList.size()); // </FS:Ansariel> LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*2, text_color, LLFontGL::LEFT, LLFontGL::TOP); // <FS:Ansariel> Move BW figures further to the right to prevent overlapping //left = 550; left = 575; F32 bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth(); // <FS:Ansariel> Speed-up //F32 max_bandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS"); static LLCachedControl<F32> throttleBandwidthKBPS(gSavedSettings, "ThrottleBandwidthKBPS"); F32 max_bandwidth = F32(throttleBandwidthKBPS); // </FS:Ansariel> Speed-up color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color; color[VALPHA] = text_color[VALPHA]; text = llformat("BW:%.0f/%.0f",bandwidth, max_bandwidth); LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, v_offset + line_height*2, color, LLFontGL::LEFT, LLFontGL::TOP); S32 dx1 = 0; if (LLAppViewer::getTextureFetch()->mDebugPause) { LLFontGL::getFontMonospace()->renderUTF8(std::string("!"), 0, title_x1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } if (mTextureView->mFreezeView) { LLFontGL::getFontMonospace()->renderUTF8(std::string("*"), 0, title_x1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } if (mTextureView->mOrderFetch) { LLFontGL::getFontMonospace()->renderUTF8(title_string1b, 0, title_x1+dx1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } else { LLFontGL::getFontMonospace()->renderUTF8(title_string1a, 0, title_x1+dx1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } LLFontGL::getFontMonospace()->renderUTF8(title_string2, 0, title_x2, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); LLFontGL::getFontMonospace()->renderUTF8(title_string3, 0, title_x3, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); LLFontGL::getFontMonospace()->renderUTF8(title_string4, 0, title_x4, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); }
void redraw() { const cv::Mat& img = image.image->getRGBImage(); cv::Mat draw_img = img.clone(); std::stringstream ss; ss << "(" << (crawler.index() + 1) << "/" << crawler.filenames().size() << ") " << crawler.filename(); int i_entity = 1; cv::Mat segm_img(draw_img.rows, draw_img.cols, CV_32SC1, cv::Scalar(0)); for(std::vector<ed::EntityConstPtr>::const_iterator it = image.entities.begin(); it != image.entities.end(); ++it) { const ed::EntityConstPtr& e = *it; ed::MeasurementConstPtr m = e->bestMeasurement(); if (!m) continue; cv::Point p_min(img.cols, img.rows); cv::Point p_max(0, 0); const ed::ImageMask& mask = m->imageMask(); for(ed::ImageMask::const_iterator it = mask.begin(img.cols); it != mask.end(); ++it) { const cv::Point2i& p = *it; segm_img.at<int>(p) = i_entity; p_min.x = std::min(p_min.x, p.x); p_min.y = std::min(p_min.y, p.y); p_max.x = std::max(p_max.x, p.x); p_max.y = std::max(p_max.y, p.y); } cv::rectangle(draw_img, p_min, p_max, cv::Scalar(255, 255, 255), 2); cv::rectangle(draw_img, p_min - cv::Point(2, 2), p_max + cv::Point(2, 2), cv::Scalar(0, 0, 0), 2); cv::rectangle(draw_img, p_min + cv::Point(2, 2), p_max - cv::Point(2, 2), cv::Scalar(0, 0, 0), 2); ++i_entity; } for(int y = 0; y < img.rows; ++y) { for(int x = 0; x < img.cols; ++x) { int i = segm_img.at<int>(y, x); if (i < 1) draw_img.at<cv::Vec3b>(y, x) = 0.5 * draw_img.at<cv::Vec3b>(y, x); } } ss << " (area: " << image.area_name << ")"; cv::rectangle(draw_img, cv::Point(0,0), cv::Point(img.cols,16), CV_RGB(0,0,0), CV_FILLED); cv::putText(draw_img, ss.str().c_str(), cv::Point2i(0, 12), 0, 0.4, cv::Scalar(255,255,255), 1); for (std::vector<Annotation>::const_iterator it = image.annotations.begin(); it != image.annotations.end(); ++it) { const Annotation& a = *it; int x = a.px * img.cols; int y = a.py * img.rows; cv::Scalar text_color(255, 0, 255); if (a.is_supporting) text_color = cv::Scalar(255, 255, 0); cv::circle(draw_img, cv::Point2i(x, y), CIRCLE_RADIUS, cv::Scalar(255,0,0), CV_FILLED); cv::putText(draw_img, a.label.c_str(), cv::Point2i(x+15,y), 0, FONT_SIZE, text_color, 2); } if (!selected_type.empty()) { cv::putText(draw_img, selected_type, cv::Point2i(20, 50), 0, FONT_SIZE, cv::Scalar(100, 100, 255), 2); } else if (!possible_types.empty()) { int n = 3; int i_min = std::max<int>(0, i_possible_types - n + 1); int i_max = std::min<int>(possible_types.size(), i_min + n); for(int i = i_min; i < i_max; ++i) { cv::Scalar text_color(255, 0, 0); if (i == i_possible_types) text_color = cv::Scalar(255, 255, 0); cv::putText(draw_img, possible_types[i], cv::Point2i(20, 50 + 30 * (i - i_min)), 0, FONT_SIZE, text_color, 2); } } cv::imshow(WINDOW_NAME, draw_img); }
void jnx_term_color(jnx_int32 fg_col) { if ( JNX_COL_BLACK <= fg_col && fg_col <= JNX_COL_WHITE ) { text_color(JNX_TERM_RESET, fg_col); } }
std::string HappensBeforeBase::outputname() { std::string outputname = tabs(); outputname += text_color(name(), utils::io::Color::YELLOW); return outputname; }
RenderQueue* BREW::CreateSpinButtonDrawable( SharedPtr<const SpinButton> spinbutton ) const { sf::Color border_color( GetProperty<sf::Color>( "BorderColor", spinbutton ) ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", spinbutton ) ); sf::Color text_color( GetProperty<sf::Color>( "Color", spinbutton ) ); sf::Color cursor_color( GetProperty<sf::Color>( "Color", spinbutton ) ); float text_padding( GetProperty<float>( "Padding", spinbutton ) ); float cursor_thickness( GetProperty<float>( "Thickness", spinbutton ) ); float border_width( GetProperty<float>( "BorderWidth", spinbutton ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", spinbutton ) ); const sf::Font& font( *GetResourceManager().GetFont( GetProperty<std::string>( "FontName", spinbutton ) ) ); const unsigned int& font_size( GetProperty<unsigned int>( "FontSize", spinbutton ) ); float stepper_aspect_ratio( GetProperty<float>( "StepperAspectRatio", spinbutton ) ); sf::Color stepper_color( GetProperty<sf::Color>( "StepperBackgroundColor", spinbutton ) ); sf::Color stepper_border_color( GetProperty<sf::Color>( "BorderColor", spinbutton ) ); sf::Color stepper_arrow_color( GetProperty<sf::Color>( "StepperArrowColor", spinbutton ) ); RenderQueue* queue( new RenderQueue ); // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( spinbutton->GetAllocation().width, spinbutton->GetAllocation().height ), border_width, background_color, border_color, -border_color_shift ) ); float button_width = ( spinbutton->GetAllocation().height / 2.f ) * stepper_aspect_ratio; // Up Stepper. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( spinbutton->GetAllocation().width - button_width - border_width, border_width ), sf::Vector2f( button_width, spinbutton->GetAllocation().height / 2.f - border_width ), border_width, stepper_color, stepper_border_color, spinbutton->IsIncreaseStepperPressed() ? -border_color_shift : border_color_shift ) ); // Up Stepper Triangle. queue->Add( Renderer::Get().CreateTriangle( sf::Vector2f( spinbutton->GetAllocation().width - button_width / 2.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 6.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f * 3.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 3.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f - border_width, ( spinbutton->IsIncreaseStepperPressed() ? 1.f : 0.f ) + border_width + spinbutton->GetAllocation().height / 3.f ), stepper_arrow_color ) ); // Down Stepper. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( spinbutton->GetAllocation().width - button_width - border_width, spinbutton->GetAllocation().height / 2.f ), sf::Vector2f( button_width, spinbutton->GetAllocation().height / 2.f - border_width ), border_width, stepper_color, stepper_border_color, spinbutton->IsDecreaseStepperPressed() ? -border_color_shift : border_color_shift ) ); // Down Stepper Triangle. queue->Add( Renderer::Get().CreateTriangle( sf::Vector2f( spinbutton->GetAllocation().width - button_width / 2.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 6.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 3.f ), sf::Vector2f( spinbutton->GetAllocation().width - button_width / 4.f * 3.f - border_width, ( spinbutton->IsDecreaseStepperPressed() ? 1.f : 0.f ) + spinbutton->GetAllocation().height - border_width - spinbutton->GetAllocation().height / 3.f ), stepper_arrow_color ) ); float line_height = GetFontLineHeight( font, font_size ); sf::Text vis_label( spinbutton->GetVisibleText(), font, font_size ); vis_label.setColor( text_color ); vis_label.setPosition( text_padding, spinbutton->GetAllocation().height / 2.f - line_height / 2.f ); queue->Add( Renderer::Get().CreateText( vis_label ) ); // Draw cursor if spinbutton is active and cursor is visible. if( spinbutton->HasFocus() && spinbutton->IsCursorVisible() ) { sf::String cursor_string( spinbutton->GetVisibleText() ); if( spinbutton->GetCursorPosition() - spinbutton->GetVisibleOffset() < cursor_string.getSize() ) { cursor_string.erase( spinbutton->GetCursorPosition() - spinbutton->GetVisibleOffset(), cursor_string.getSize() ); } // Get metrics. sf::Vector2f metrics( GetTextMetrics( cursor_string, font, font_size ) ); queue->Add( Renderer::Get().CreateRect( sf::FloatRect( metrics.x + text_padding, spinbutton->GetAllocation().height / 2.f - line_height / 2.f, cursor_thickness, line_height ), cursor_color ) ); } return queue; }
void AIGLHTTPHeaderBar::draw(void) { S32 const v_offset = -1; // Offset from the bottom. Move header one pixel down. S32 const h_offset = 4; LLGLSUIDefault gls_ui; LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); std::string text; // First header line. F32 height = v_offset + sLineHeight * number_of_header_lines; text = "HTTP console -- [approved]-commandQ-curlQ,{added/max,downloading}[/max][ completed]"; LLFontGL::getFontMonospace()->renderUTF8(text, 0, h_offset, height, text_color, LLFontGL::LEFT, LLFontGL::TOP); text = " | Added/Max"; U32 start = mHTTPView->updateColumn(mc_col, 100); LLFontGL::getFontMonospace()->renderUTF8(text, 0, start, height, LLColor4::green, LLFontGL::LEFT, LLFontGL::TOP); start += LLFontGL::getFontMonospace()->getWidth(text); text = " | Tot/Max BW (kbit/s)"; start = mHTTPView->updateColumn(bw_col, start); LLFontGL::getFontMonospace()->renderUTF8(text, 0, start, height, LLColor4::green, LLFontGL::LEFT, LLFontGL::TOP); mHTTPView->setWidth(start + LLFontGL::getFontMonospace()->getWidth(text) + h_offset); // Second header line. height -= sLineHeight; start = h_offset; text = "Service (host:port)"; // This must match AICapabilityType! static char const* caption[number_of_capability_types] = { " | Textures", " | Inventory", " | Mesh", " | Other" }; LLFontGL::getFontMonospace()->renderUTF8(text, 0, start, height, LLColor4::green, LLFontGL::LEFT, LLFontGL::TOP); start += LLFontGL::getFontMonospace()->getWidth(text); for (int col = 0; col < number_of_capability_types; ++col) { start = mHTTPView->updateColumn(col, start); text = caption[col]; LLFontGL::getFontMonospace()->renderUTF8(text, 0, start, height, LLColor4::green, LLFontGL::LEFT, LLFontGL::TOP); start += LLFontGL::getFontMonospace()->getWidth(text); } start = mHTTPView->updateColumn(mc_col, start); text = llformat(" | %u/%u", AICurlInterface::getNumHTTPAdded(), AICurlInterface::getMaxHTTPAdded()); LLFontGL::getFontMonospace()->renderUTF8(text, 0, start, height, text_color, LLFontGL::LEFT, LLFontGL::TOP); start += LLFontGL::getFontMonospace()->getWidth(text); // This bandwidth is averaged over 1 seconds (in bytes/s). size_t const bandwidth = AICurlInterface::getHTTPBandwidth(); size_t const max_bandwidth = AIPerService::getHTTPThrottleBandwidth125(); mHTTPView->mMaxBandwidthPerService = max_bandwidth * AIPerService::throttleFraction(); LLColor4 color = (bandwidth > max_bandwidth) ? LLColor4::red : ((bandwidth > max_bandwidth * .75f) ? LLColor4::yellow : text_color); color[VALPHA] = text_color[VALPHA]; start = mHTTPView->updateColumn(bw_col, start); text = " | "; LLFontGL::getFontMonospace()->renderUTF8(text, 0, start, height, LLColor4::green, LLFontGL::LEFT, LLFontGL::TOP); start += LLFontGL::getFontMonospace()->getWidth(text); text = llformat("%lu", bandwidth / 125); LLFontGL::getFontMonospace()->renderUTF8(text, 0, start, height, color, LLFontGL::LEFT, LLFontGL::TOP); start += LLFontGL::getFontMonospace()->getWidth(text); text = llformat("/%lu", max_bandwidth / 125); LLFontGL::getFontMonospace()->renderUTF8(text, 0, start, height, text_color, LLFontGL::LEFT, LLFontGL::TOP); }
void LLGLTexMemBar::draw() { S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes); S32 max_bound_mem = LLViewerTexture::sMaxBoundTextureMemInMegaBytes; S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sTotalTextureMemoryInBytes); S32 max_total_mem = LLViewerTexture::sMaxTotalTextureMemInMegaBytes; F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; F32 cache_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getUsage()) ; F32 cache_max_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getMaxUsage()) ; S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024); F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024); U32 total_http_requests = LLAppViewer::getTextureFetch()->getTotalNumHTTPRequests() ; //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); LLColor4 color; std::string text = ""; LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6, text_color, LLFontGL::LEFT, LLFontGL::TOP); text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB FBO: %d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB", total_mem, max_total_mem, bound_mem, max_bound_mem, LLRenderTarget::sBytesAllocated/(1024*1024), LLImageRaw::sGlobalRawMemory >> 20, discard_bias, cache_usage, cache_max_usage); LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*4, text_color, LLFontGL::LEFT, LLFontGL::TOP); text = llformat("Net Tot Tex: %.1f MB Tot Obj: %.1f MB Tot Htp: %d", total_texture_downloaded, total_object_downloaded, total_http_requests); //, cache_entries, cache_max_entries LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3, text_color, LLFontGL::LEFT, LLFontGL::TOP); S32 left = 0 ; //---------------------------------------------------------------------------- text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d RAW:%d HTP:%d DEC:%d CRE:%d", gTextureList.getNumImages(), LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(), LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount, LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(), LLLFSThread::sLocal->getPending(), LLImageRaw::sRawImageCount, LLAppViewer::getTextureFetch()->getNumHTTPRequests(), LLAppViewer::getImageDecodeThread()->getPending(), gTextureList.mCreateTextureList.size()); LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*2, text_color, LLFontGL::LEFT, LLFontGL::TOP); left = 550; F32 bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth(); F32 max_bandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS"); color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color; color[VALPHA] = text_color[VALPHA]; text = llformat("BW:%.0f/%.0f",bandwidth, max_bandwidth); LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, v_offset + line_height*2, color, LLFontGL::LEFT, LLFontGL::TOP); S32 dx1 = 0; if (LLAppViewer::getTextureFetch()->mDebugPause) { LLFontGL::getFontMonospace()->renderUTF8(std::string("!"), 0, title_x1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } if (mTextureView->mFreezeView) { LLFontGL::getFontMonospace()->renderUTF8(std::string("*"), 0, title_x1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } if (mTextureView->mOrderFetch) { LLFontGL::getFontMonospace()->renderUTF8(title_string1b, 0, title_x1+dx1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } else { LLFontGL::getFontMonospace()->renderUTF8(title_string1a, 0, title_x1+dx1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } LLFontGL::getFontMonospace()->renderUTF8(title_string2, 0, title_x2, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); LLFontGL::getFontMonospace()->renderUTF8(title_string3, 0, title_x3, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); LLFontGL::getFontMonospace()->renderUTF8(title_string4, 0, title_x4, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); }
void run_command() { is_cmd = 1; int size = str_len(command); if(str_startswith(command, "hlt") == 1) { text_color(BLACK, BLACK); clear_screen(); halt(); } else if(str_startswith(command, "println")) { putslns(command, 8, size); } else if(str_startswith(command, "printvln")) { if(letti(command[9]) != -1) putnumln(reg[letti(command[9])]); } else if(str_startswith(command, "printv")) { if(letti(command[7]) != -1) putnum(reg[letti(command[7])]); } else if(str_startswith(command, "print")) { putss(command, 6, size); } else if (str_startswith(command, "clear")) { clear_screen(); index = 0; } else if(str_startswith(command, "setv")) { if(letti(command[5]) != -1) { int r = letti(command[5]); int i = 0; while(i < 7) { command[i] = ' '; i++; } reg[r] = atoi(command); } } else if(str_startswith(command, "add")) { if(letti(command[4])!=-1 && letti(command[6])!=-1) reg[letti(command[4])] += reg[letti(command[6])]; } else if(str_startswith(command, "sub")) { if(letti(command[4])!=-1 && letti(command[6])!=-1) reg[letti(command[4])] -= reg[letti(command[6])]; } else if(str_startswith(command, "mul")) { if(letti(command[4])!=-1 && letti(command[6])!=-1) reg[letti(command[4])] *= reg[letti(command[6])]; } else if(str_startswith(command, "div")) { if(letti(command[4])!=-1 && letti(command[6])!=-1) reg[letti(command[4])] /= reg[letti(command[6])]; } else if(str_startswith(command, "mod")) { if(letti(command[4])!=-1 && letti(command[6])!=-1) reg[letti(command[4])] %= reg[letti(command[6])]; } else if(str_startswith(command, "cc") == 1) { if(str_startswith(command, "cc help")) { putsln("Colors:"); putsln(">>> BLACK :: 0"); putsln(">>> BLUE :: 1"); putsln(">>> GREEN :: 2"); putsln(">>> CYAN :: 3"); putsln(">>> RED :: 4"); putsln(">>> MAGENTA :: 5"); putsln(">>> BROWN :: 6"); putsln(">>> LT GRAY :: 7"); putsln(">>> DK GRAY :: 8"); putsln(">>> LT BLUE :: 9"); putsln(">>> LT GREEN :: A"); putsln(">>> LT CYAN :: B"); putsln(">>> LT RED :: C"); putsln(">>> LT MAGENTA :: D"); putsln(">>> LT BROWN :: E"); putsln(">>> WHITE :: F"); } else { char b = command[4]; char f = command[3]; if(f > '@' && b > '@') text_color(f - '0', b - 55); else if(f > '@') text_color(f - 55, b - '0'); else if(b > '@') text_color(f - '0', b - 55); else text_color(f - '0', b - '0'); } } else if(str_startswith(command, "help") == 1) { putsln("Commands:"); putsln(">>> hlt :: halts cpu"); putsln(">>> cc fb|help :: change text color - (fore, back)"); putsln(">>> print text :: print out a piece of text"); putsln(">>> printv let :: print out the value of variable let"); putsln(">>> printvln let :: print out the value of variable let with a line after"); putsln(">>> println text :: print out a piece of text with a line"); putsln(">>> clear :: Clears the screen"); putsln(">>> setv let val :: set variable let to val"); putsln(">>> add base set :: adds base to set and stores in base"); putsln(">>> sub base set :: subtracts base from set and stores in base"); putsln(">>> mul base set :: multiplies base by set and stores in base"); putsln(">>> div base set :: divides base by set and stores in set"); putsln(">>> mod base set :: divides base by set and stores remainder in set"); putsln(">>> println text :: print out a piece of text with a line"); putsln(">>> help :: show help command"); } else { puts(">>> Unknown command: "); putsln(command); putsln(">>> Try help."); } clear_command(); is_cmd = 0; }
void putch(char c) { scroll(c); if(c == '\n') { is_shift = 0; int i = index/2; i += 80; while(i % 80 > 0) { i--; } index = i*2; move_cursor((index/2)%80, (index/2)/80); if(strt == 0) run_command(); char r = attr; if(strt == 0) { text_color(RED, BLACK); is_cmd = 1; puts("terminal:>"); is_cmd = 0; term_ind = index; } else { strt = 0; } attr = r; } if(c == '\r') { if(is_shift == 0) is_shift = 1; else if(is_shift == 1) is_shift = 0; } else { if(c == '\t') { putch(' '); putch(' '); putch(' '); putch(' '); } else if(c == '\b') { if(index > term_ind) { index -= 2; vidptr[index] = ' '; vidptr[index + 1] = attr; if(is_cmd == 0) { cmd_ind--; command[cmd_ind] = '\0'; } move_cursor((index/2)%80, (index/2)/80); } } else if(c >= ' '){ if(is_shift == 1 && strt == 0) { if(c > '`') c = c - 32; else c = c - 16; } vidptr[index] = c; vidptr[index+1] = attr; if(is_cmd == 0) { command[cmd_ind] = c; cmd_ind++; } index += 2; move_cursor((index/2)%80, (index/2)/80); } } }