void Previewer::paintEvent( QPaintEvent * ) { QSize input_size = INPUT_SIZE; const QRect & rct = rect(); QPainter painter(this); painter.setRenderHint( QPainter::Antialiasing , true ); QColor color1( BASE_COLOR_1 ); QColor color2( BASE_COLOR_2 ); QColor shadow_color( "#000000" ); color1.setAlpha( MAGNIFIER_ALPHA ); color2.setAlpha( MAGNIFIER_ALPHA ); QLinearGradient gradiant(QPointF(0, rct.y()), QPointF(0,rct.y()+rct.height())); gradiant.setColorAt(0, color1); gradiant.setColorAt(1, color2); painter.fillPath( magnifierPath( input_size , rct , SHADOW_SIZE ) , gradiant ); for( int i=SHADOW_SIZE-1 ; i>=0 ; i-- ) { QSize top_size( input_size.width() + 2*(SHADOW_SIZE-i) , input_size.height() ); shadow_color.setAlpha( ((double)i/SHADOW_SIZE)*MAGNIFIER_ALPHA/2 ); painter.setPen( shadow_color ); painter.drawPath( magnifierPath(top_size , rct , i) ); } }
//Draws a line for each ray that is slightly transparent void RayTree::setupVBOs() { raytree_verts.clear(); raytree_edge_indices.clear(); //Sets different colors for each type and the constant for making the lines transparent double alpha = .5; Vec main_color(.7,.7,.7); Vec shadow_color(.1,.9,.1); Vec reflected_color(.9,.1,.1); Vec single_scatter_color(.1,.1,.9); Vec multiple_scatter_color(.9,.1,.9); unsigned int i; int count = 0; for(i = 0;i < main_segments.size();++i){ raytree_verts.push_back(VBOPosColor4(main_segments[i].getStart(),main_color,alpha)); raytree_verts.push_back(VBOPosColor4(main_segments[i].getEnd(),main_color,alpha)); raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1)); count+=2; } for(i = 0;i < shadow_segments.size();++i){ raytree_verts.push_back(VBOPosColor4(shadow_segments[i].getStart(),shadow_color,alpha)); raytree_verts.push_back(VBOPosColor4(shadow_segments[i].getEnd(),shadow_color,alpha)); raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1)); count+=2; } for(i = 0;i < reflected_segments.size();++i){ raytree_verts.push_back(VBOPosColor4(reflected_segments[i].getStart(),reflected_color,alpha)); raytree_verts.push_back(VBOPosColor4(reflected_segments[i].getEnd(),reflected_color,alpha)); raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1)); count+=2; } for(i = 0;i < single_scatter_segments.size();++i){ raytree_verts.push_back(VBOPosColor4(single_scatter_segments[i].getStart(),single_scatter_color,alpha)); raytree_verts.push_back(VBOPosColor4(single_scatter_segments[i].getEnd(),single_scatter_color,alpha)); raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1)); count+=2; } for(i = 0;i < multiple_scatter_segments.size();++i){ raytree_verts.push_back(VBOPosColor4(multiple_scatter_segments[i].getStart(),multiple_scatter_color,alpha)); raytree_verts.push_back(VBOPosColor4(multiple_scatter_segments[i].getEnd(),multiple_scatter_color,alpha)); raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1)); count+=2; } int ne = raytree_edge_indices.size(); cleanupVBOs(); if(ne > 0) { glBindBuffer(GL_ARRAY_BUFFER,raytree_verts_VBO); glBufferData(GL_ARRAY_BUFFER,sizeof(VBOPosColor4) * ne *2,&raytree_verts[0],GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,raytree_edge_indices_VBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(VBOIndexedEdge) * ne,&raytree_edge_indices[0],GL_STATIC_DRAW); } }
void LLHUDText::renderText() { if (!mVisible || mHidden) { return; } gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); LLGLState gls_blend(GL_BLEND, TRUE); LLGLState gls_alpha(GL_ALPHA_TEST, TRUE); LLColor4 shadow_color(0.f, 0.f, 0.f, 1.f); F32 alpha_factor = 1.f; LLColor4 text_color = mColor; if (mDoFade) { if (mLastDistance > mFadeDistance) { alpha_factor = llmax(0.f, 1.f - (mLastDistance - mFadeDistance)/mFadeRange); text_color.mV[3] = text_color.mV[3]*alpha_factor; } } if (text_color.mV[3] < 0.01f) { return; } shadow_color.mV[3] = text_color.mV[3]; mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f)); // *TODO: cache this image LLUIImagePtr imagep = LLUI::getUIImage("Rounded_Square"); // *TODO: make this a per-text setting LLColor4 bg_color = LLUIColorTable::instance().getColor("ObjectBubbleColor"); bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor); const S32 border_height = 16; const S32 border_width = 16; // *TODO move this into helper function F32 border_scale = 1.f; if (border_height * 2 > mHeight) { border_scale = (F32)mHeight / ((F32)border_height * 2.f); } if (border_width * 2 > mWidth) { border_scale = llmin(border_scale, (F32)mWidth / ((F32)border_width * 2.f)); } // scale screen size of borders down //RN: for now, text on hud objects is never occluded LLVector3 x_pixel_vec; LLVector3 y_pixel_vec; if (mOnHUDAttachment) { x_pixel_vec = LLVector3::y_axis / (F32)gViewerWindow->getWorldViewWidthRaw(); y_pixel_vec = LLVector3::z_axis / (F32)gViewerWindow->getWorldViewHeightRaw(); } else { LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); } LLVector2 border_scale_vec((F32)border_width / (F32)imagep->getTextureWidth(), (F32)border_height / (F32)imagep->getTextureHeight()); LLVector3 width_vec = mWidth * x_pixel_vec; LLVector3 height_vec = mHeight * y_pixel_vec; LLVector3 scaled_border_width = (F32)llfloor(border_scale * (F32)border_width) * x_pixel_vec; LLVector3 scaled_border_height = (F32)llfloor(border_scale * (F32)border_height) * y_pixel_vec; mRadius = (width_vec + height_vec).magVec() * 0.5f; LLVector2 screen_offset; screen_offset = mPositionOffset; LLVector3 render_position = mPositionAgent + (x_pixel_vec * screen_offset.mV[VX]) + (y_pixel_vec * screen_offset.mV[VY]); F32 y_offset = (F32)mOffsetY; // Render label { gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); } // Render text { // -1 mMaxLines means unlimited lines. S32 start_segment; S32 max_lines = getMaxLines(); if (max_lines < 0) { start_segment = 0; } else { start_segment = llmax((S32)0, (S32)mTextSegments.size() - max_lines); } for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin() + start_segment; segment_iter != mTextSegments.end(); ++segment_iter ) { const LLFontGL* fontp = segment_iter->mFont; y_offset -= fontp->getLineHeight() - 1; // correction factor to match legacy font metrics U8 style = segment_iter->mStyle; LLFontGL::ShadowType shadow = LLFontGL::DROP_SHADOW; F32 x_offset; if (mTextAlignment== ALIGN_TEXT_CENTER) { x_offset = -0.5f*segment_iter->getWidth(fontp); } else // ALIGN_LEFT { x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f); } text_color = segment_iter->mColor; text_color.mV[VALPHA] *= alpha_factor; hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, mOnHUDAttachment); } } /// Reset the default color to white. The renderer expects this to be the default. gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f); }
void Text::Draw(Bitmap& dest, int x, int y, int color, std::string const& text, Text::Alignment align) { if (text.length() == 0) return; FontRef font = dest.GetFont(); Rect dst_rect = Font::Default()->GetSize(text); switch (align) { case Text::AlignCenter: dst_rect.x = x - dst_rect.width / 2; break; case Text::AlignRight: dst_rect.x = x - dst_rect.width; break; case Text::AlignLeft: dst_rect.x = x; break; default: assert(false); } dst_rect.y = y; dst_rect.width += 1; dst_rect.height += 1; // Need place for shadow if (dst_rect.IsOutOfBounds(dest.GetWidth(), dest.GetHeight())) return; BitmapRef text_surface; // Complete text will be on this surface text_surface = Bitmap::Create(dst_rect.width, dst_rect.height, true); text_surface->SetTransparentColor(dest.GetTransparentColor()); text_surface->Clear(); // Load the system file for the shadow and text color BitmapRef system = Cache::System(Data::system.system_name); // Load the exfont-file BitmapRef exfont = Cache::Exfont(); // Get the Shadow color Color shadow_color(Cache::system_info.sh_color); // If shadow is pure black, increase blue channel // so it doesn't become transparent if ((shadow_color.red == 0) && (shadow_color.green == 0) && (shadow_color.blue == 0) ) { if (text_surface->bytes() >= 3) { shadow_color.blue++; } else { shadow_color.blue += 8; } } // Where to draw the next glyph (x pos) int next_glyph_pos = 0; // The current char is an exfont bool is_exfont = false; // This loops always renders a single char, color blends it and then puts // it onto the text_surface (including the drop shadow) for (boost::u8_to_u32_iterator<std::string::const_iterator> c(text.begin(), text.begin(), text.end()), end(text.end(), text.begin(), text.end()); c != end; ++c) { Rect next_glyph_rect(next_glyph_pos, 0, 0, 0); boost::u8_to_u32_iterator<std::string::const_iterator> next_c_it = boost::next(c); uint32_t const next_c = std::distance(c, end) > 1? *next_c_it : 0; // ExFont-Detection: Check for A-Z or a-z behind the $ if (*c == '$' && std::isalpha(next_c)) { int exfont_value = -1; // Calculate which exfont shall be rendered if (islower(next_c)) { exfont_value = 26 + next_c - 'a'; } else if (isupper(next_c)) { exfont_value = next_c - 'A'; } else { assert(false); } is_exfont = true; BitmapRef mask = Bitmap::Create(12, 12, true); // Get exfont from graphic Rect const rect_exfont((exfont_value % 13) * 12, (exfont_value / 13) * 12, 12, 12); // Create a mask mask->Clear(); mask->Blit(0, 0, *exfont, rect_exfont, 255); // Get color region from system graphic Rect clip_system(8+16*(color%10), 4+48+16*(color/10), 6, 12); BitmapRef char_surface = Bitmap::Create(mask->GetWidth(), mask->GetHeight(), true); char_surface->SetTransparentColor(dest.GetTransparentColor()); char_surface->Clear(); // Blit gradient color background (twice because of full glyph) char_surface->Blit(0, 0, *system, clip_system, 255); char_surface->Blit(6, 0, *system, clip_system, 255); // Blit mask onto background char_surface->MaskBlit(0, 0, *mask, mask->GetRect()); BitmapRef char_shadow = Bitmap::Create(mask->GetWidth(), mask->GetHeight(), true); char_shadow->SetTransparentColor(dest.GetTransparentColor()); char_shadow->Clear(); // Blit solid color background char_shadow->Fill(shadow_color); // Blit mask onto background char_shadow->MaskBlit(0, 0, *mask, mask->GetRect()); // Blit first shadow and then text text_surface->Blit(next_glyph_rect.x + 1, next_glyph_rect.y + 1, *char_shadow, char_shadow->GetRect(), 255); text_surface->Blit(next_glyph_rect.x, next_glyph_rect.y, *char_surface, char_surface->GetRect(), 255); } else { // Not ExFont, draw normal text font->Render(*text_surface, next_glyph_rect.x, next_glyph_rect.y, *system, color, *c); } // If it's a full size glyph, add the size of a half-size glypth twice if (is_exfont) { is_exfont = false; next_glyph_pos += 12; // Skip the next character ++c; } else { std::string const glyph(c.base(), next_c_it.base()); next_glyph_pos += Font::Default()->GetSize(glyph).width; } } BitmapRef text_bmp = Bitmap::Create(*text_surface, text_surface->GetRect()); Rect src_rect(0, 0, dst_rect.width, dst_rect.height); int iy = dst_rect.y; if (dst_rect.height > text_bmp->GetHeight()) { iy += ((dst_rect.height - text_bmp->GetHeight()) / 2); } int ix = dst_rect.x; dest.Blit(ix, iy, *text_bmp, src_rect, 255); }
RenderQueue* BREW::CreateWindowDrawable( SharedPtr<const Window> window ) const { RenderQueue* queue( new RenderQueue ); sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", window ) ); sf::Color border_color( GetProperty<sf::Color>( "BorderColor", window ) ); sf::Color title_background_color( GetProperty<sf::Color>( "TitleBackgroundColor", window ) ); sf::Color title_text_color( GetProperty<sf::Color>( "Color", window ) ); int border_color_shift( GetProperty<int>( "BorderColorShift", window ) ); float border_width( GetProperty<float>( "BorderWidth", window ) ); float title_padding( GetProperty<float>( "TitlePadding", window ) ); float shadow_distance( GetProperty<float>( "ShadowDistance", window ) ); float handle_size( GetProperty<float>( "HandleSize", window ) ); sf::Uint8 shadow_alpha( GetProperty<sf::Uint8>( "ShadowAlpha", window ) ); unsigned int title_font_size( GetProperty<unsigned int>( "FontSize", window ) ); const sf::Font& title_font( *GetResourceManager().GetFont( GetProperty<std::string>( "FontName", window ) ) ); float title_size( GetFontLineHeight( title_font, title_font_size ) + 2 * title_padding ); if( window->HasStyle( Window::SHADOW ) ) { // Shadow. sf::Color shadow_color( 0, 0, 0, shadow_alpha ); sf::FloatRect shadow_rect( shadow_distance, shadow_distance, window->GetAllocation().width, window->GetAllocation().height ); queue->Add( Renderer::Get().CreateRect( shadow_rect, shadow_color ) ); } if( window->HasStyle( Window::BACKGROUND ) ) { // Pane. queue->Add( Renderer::Get().CreatePane( sf::Vector2f( 0.f, 0.f ), sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height ), border_width, background_color, border_color, border_color_shift ) ); } if( window->HasStyle( Window::RESIZE ) ) { queue->Add( Renderer::Get().CreateTriangle( sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height - handle_size ), sf::Vector2f( window->GetAllocation().width - handle_size, window->GetAllocation().height ), sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height ), title_background_color ) ); } if( !window->HasStyle( Window::TITLEBAR ) ) { title_size = 0; } if( title_size > 0 ) { queue->Add( Renderer::Get().CreateRect( sf::FloatRect( border_width + .1f, border_width + .1f, window->GetAllocation().width - 2 * border_width, title_size ), title_background_color ) ); // Find out visible text, count in "...". float avail_width( window->GetAllocation().width - 2.f * border_width - 2.f * title_padding ); sf::Text title_text( window->GetTitle(), title_font, title_font_size ); if( title_text.getLocalBounds().width > avail_width ) { sf::Text dots( "...", title_font, title_font_size ); const sf::String& title_string( window->GetTitle() ); sf::String visible_title; avail_width = window->GetAllocation().width - 2.f * border_width - 2.f * title_padding - dots.getLocalBounds().width; for( std::size_t ch_index = 0; ch_index < title_string.getSize(); ++ch_index ) { avail_width -= static_cast<float>( title_font.getGlyph( title_string[ch_index], title_font_size, false ).advance ); if( avail_width < 0.f ) { visible_title += "..."; break; } visible_title += title_string[ch_index]; } title_text.setString( visible_title ); } // Calculate title text position. sf::Vector2f title_position( border_width + title_padding, border_width + title_size / 2.f - static_cast<float>( title_font_size ) / 2.f ); title_text.setPosition( title_position ); title_text.setColor( title_text_color ); queue->Add( Renderer::Get().CreateText( title_text ) ); } return queue; }
void PlaylistView::paintEvent(QPaintEvent* event) { // Reimplemented to draw the background image. // Reimplemented also to draw the drop indicator // When the user is dragging some stuff over the playlist paintEvent gets // called for the entire viewport every time the user moves the mouse. // The drawTree is kinda expensive, so we cache the result and draw from the // cache while the user is dragging. The cached pixmap gets invalidated in // dragLeaveEvent, dropEvent and scrollContentsBy. // Draw background if (background_image_type_ == Custom || background_image_type_ == AlbumCover) { if (!background_image_.isNull() || !previous_background_image_.isNull()) { QPainter background_painter(viewport()); // Check if we should recompute the background image if (height() != last_height_ || width() != last_width_ || force_background_redraw_) { if (background_image_.isNull()) { cached_scaled_background_image_ = QPixmap(); } else { cached_scaled_background_image_ = QPixmap::fromImage(background_image_.scaled( width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation)); } last_height_ = height(); last_width_ = width(); force_background_redraw_ = false; } // Actually draw the background image if (!cached_scaled_background_image_.isNull()) { // Set opactiy only if needed, as this deactivate hardware acceleration if (!qFuzzyCompare(previous_background_image_opacity_, qreal(0.0))) { background_painter.setOpacity(1.0 - previous_background_image_opacity_); } background_painter.drawPixmap( (width() - cached_scaled_background_image_.width()) / 2, (height() - cached_scaled_background_image_.height()) / 2, cached_scaled_background_image_); } // Draw the previous background image if we're fading if (!previous_background_image_.isNull()) { background_painter.setOpacity(previous_background_image_opacity_); background_painter.drawPixmap( (width() - previous_background_image_.width()) / 2, (height() - previous_background_image_.height()) / 2, previous_background_image_); } } } QPainter p(viewport()); if (drop_indicator_row_ != -1) { if (cached_tree_.isNull()) { cached_tree_ = QPixmap(size()); cached_tree_.fill(Qt::transparent); QPainter cache_painter(&cached_tree_); drawTree(&cache_painter, event->region()); } p.drawPixmap(0, 0, cached_tree_); } else { drawTree(&p, event->region()); return; } const int first_column = header_->logicalIndex(0); // Find the y position of the drop indicator QModelIndex drop_index = model()->index(drop_indicator_row_, first_column); int drop_pos = -1; switch (dropIndicatorPosition()) { case QAbstractItemView::OnItem: return; // Don't draw anything case QAbstractItemView::AboveItem: drop_pos = visualRect(drop_index).top(); break; case QAbstractItemView::BelowItem: drop_pos = visualRect(drop_index).bottom() + 1; break; case QAbstractItemView::OnViewport: if (model()->rowCount() == 0) drop_pos = 1; else drop_pos = 1 + visualRect(model()->index(model()->rowCount() - 1, first_column)).bottom(); break; } // Draw a nice gradient first QColor line_color(QApplication::palette().color(QPalette::Highlight)); QColor shadow_color(line_color.lighter(140)); QColor shadow_fadeout_color(shadow_color); shadow_color.setAlpha(255); shadow_fadeout_color.setAlpha(0); QLinearGradient gradient(QPoint(0, drop_pos - kDropIndicatorGradientWidth), QPoint(0, drop_pos + kDropIndicatorGradientWidth)); gradient.setColorAt(0.0, shadow_fadeout_color); gradient.setColorAt(0.5, shadow_color); gradient.setColorAt(1.0, shadow_fadeout_color); QPen gradient_pen(QBrush(gradient), kDropIndicatorGradientWidth * 2); p.setPen(gradient_pen); p.drawLine(QPoint(0, drop_pos), QPoint(width(), drop_pos)); // Now draw the line on top QPen line_pen(line_color, kDropIndicatorWidth); p.setPen(line_pen); p.drawLine(QPoint(0, drop_pos), QPoint(width(), drop_pos)); }
void LLHUDNameTag::renderText(BOOL for_select) { if (!mVisible || mHidden) { return; } // don't pick text that isn't bound to a viewerobject if (for_select && (!mSourceObject || mSourceObject->mDrawable.isNull())) { return; } if (for_select) { gGL.getTexUnit(0)->disable(); } else { gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); } LLGLState gls_blend(GL_BLEND, for_select ? FALSE : TRUE); LLGLState gls_alpha(GL_ALPHA_TEST, for_select ? FALSE : TRUE); LLColor4 shadow_color(0.f, 0.f, 0.f, 1.f); F32 alpha_factor = 1.f; LLColor4 text_color = mColor; if (mDoFade) { if (mLastDistance > mFadeDistance) { alpha_factor = llmax(0.f, 1.f - (mLastDistance - mFadeDistance)/mFadeRange); text_color.mV[3] = text_color.mV[3]*alpha_factor; } } if (text_color.mV[3] < 0.01f) { return; } shadow_color.mV[3] = text_color.mV[3]; mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f)); // *TODO: cache this image // <FS:Ansariel> Performance improvement //LLUIImagePtr imagep = LLUI::getUIImage("Rounded_Rect"); // *TODO: make this a per-text setting //LLColor4 bg_color = LLUIColorTable::instance().getColor("NameTagBackground"); //bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor); static LLUIColor s_bg_color = LLUIColorTable::instance().getColor("NameTagBackground"); static LLCachedControl<F32> chatBubbleOpacity(gSavedSettings, "ChatBubbleOpacity"); LLColor4 bg_color = s_bg_color.get(); F32 color_alpha = chatBubbleOpacity * alpha_factor; bg_color.setAlpha(color_alpha); // </FS:Ansariel> // scale screen size of borders down //RN: for now, text on hud objects is never occluded LLVector3 x_pixel_vec; LLVector3 y_pixel_vec; LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); LLVector3 width_vec = mWidth * x_pixel_vec; LLVector3 height_vec = mHeight * y_pixel_vec; mRadius = (width_vec + height_vec).magVec() * 0.5f; LLCoordGL screen_pos; LLViewerCamera::getInstance()->projectPosAgentToScreen(mPositionAgent, screen_pos, FALSE); LLVector2 screen_offset = updateScreenPos(mPositionOffset); LLVector3 render_position = mPositionAgent + (x_pixel_vec * screen_offset.mV[VX]) + (y_pixel_vec * screen_offset.mV[VY]); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); LLRect screen_rect; screen_rect.setCenterAndSize(0, static_cast<S32>(lltrunc(-mHeight / 2 + mOffsetY)), static_cast<S32>(lltrunc(mWidth)), static_cast<S32>(lltrunc(mHeight))); // <FS:Ansariel> Performance improvement //imagep->draw3D(render_position, x_pixel_vec, y_pixel_vec, screen_rect, bg_color); mRoundedRectImg->draw3D(render_position, x_pixel_vec, y_pixel_vec, screen_rect, bg_color); // </FS:Ansariel> if (mLabelSegments.size()) { // <FS:Ansariel> Performance improvement //LLUIImagePtr rect_top_image = LLUI::getUIImage("Rounded_Rect_Top"); LLRect label_top_rect = screen_rect; const S32 label_height = ll_round((mFontp->getLineHeight() * (F32)mLabelSegments.size() + (VERTICAL_PADDING / 3.f))); label_top_rect.mBottom = label_top_rect.mTop - label_height; LLColor4 label_top_color = text_color; // <FS:Ansariel> Performance improvement //label_top_color.mV[VALPHA] = gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor; label_top_color.mV[VALPHA] = color_alpha; // </FS:Ansariel> // <FS:Ansariel> Performance improvement //rect_top_image->draw3D(render_position, x_pixel_vec, y_pixel_vec, label_top_rect, label_top_color); mRoundedRectTopImg->draw3D(render_position, x_pixel_vec, y_pixel_vec, label_top_rect, label_top_color); // </FS:Ansariel> } F32 y_offset = (F32)mOffsetY; // Render label { //gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); for(std::vector<LLHUDTextSegment>::iterator segment_iter = mLabelSegments.begin(); segment_iter != mLabelSegments.end(); ++segment_iter ) { // Label segments use default font const LLFontGL* fontp = (segment_iter->mStyle == LLFontGL::BOLD) ? mBoldFontp : mFontp; y_offset -= fontp->getLineHeight(); F32 x_offset; if (mTextAlignment == ALIGN_TEXT_CENTER) { x_offset = -0.5f*segment_iter->getWidth(fontp); } else // ALIGN_LEFT { x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f); } LLColor4 label_color(0.f, 0.f, 0.f, 1.f); label_color.mV[VALPHA] = alpha_factor; hud_render_text(segment_iter->getText(), render_position, *fontp, segment_iter->mStyle, LLFontGL::NO_SHADOW, x_offset, y_offset, label_color, FALSE); } } // Render text { // -1 mMaxLines means unlimited lines. S32 start_segment; S32 max_lines = getMaxLines(); if (max_lines < 0) { start_segment = 0; } else { start_segment = llmax((S32)0, (S32)mTextSegments.size() - max_lines); } for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin() + start_segment; segment_iter != mTextSegments.end(); ++segment_iter ) { const LLFontGL* fontp = segment_iter->mFont; y_offset -= fontp->getLineHeight(); y_offset -= LINE_PADDING; U8 style = segment_iter->mStyle; LLFontGL::ShadowType shadow = LLFontGL::DROP_SHADOW; F32 x_offset; if (mTextAlignment== ALIGN_TEXT_CENTER) { x_offset = -0.5f*segment_iter->getWidth(fontp); } else // ALIGN_LEFT { x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f); // *HACK x_offset += 1; } text_color = segment_iter->mColor; text_color.mV[VALPHA] *= alpha_factor; hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, FALSE); } } /// Reset the default color to white. The renderer expects this to be the default. gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f); if (for_select) { gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); } }