void EC_ChatBubble::Refresh() { if (renderer_.expired() || !billboardSet_ || !billboard_) return; // If no messages in the log, hide the chat bubble. if (messages_.isEmpty()) { billboardSet_->setVisible(false); return; } else billboardSet_->setVisible(true); // Get image buffer and texture QImage buffer = GetChatBubblePixmap().toImage(); Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(texture_name_); if (buffer.isNull() || texture.isNull()) return; // Check texture size if ((int)texture->getWidth() != buffer.width() || (int)texture->getHeight() != buffer.height()) { texture->freeInternalResources(); texture->setWidth(buffer.width()); texture->setHeight(buffer.height()); texture->createInternalResources(); } // Update texture buffer Ogre::Box update_box(0,0, buffer.width(), buffer.height()); Ogre::PixelBox pixel_box(update_box, Ogre::PF_A8R8G8B8, (void*)buffer.bits()); if (!texture->getBuffer().isNull()) texture->getBuffer()->blitFromMemory(pixel_box, update_box); }
/* * Update all scene animations, calc positions and so on */ void scene::update(void) { update_animations(); update_hierarchy(); update_renderlist(); update_box(); }
static void view_size_allocate(GtkWidget * widget, GtkAllocation* allocation) { #ifdef DEBUG_GRADIENT g_debug("start resize (%dx%d) => (%dx%d)", allocation->x, allocation->y, allocation->x + allocation->width - 1, allocation->y + allocation->height - 1); item_debug_bounds(rrect, CC_VIEW(widget)); #endif cc_rectangle_set_position(CC_RECTANGLE(rrect), 0.0, 0.0, allocation->width - 50, allocation->height - 50); #ifdef DEBUG_GRADIENT item_debug_bounds(rrect, CC_VIEW(widget)); g_debug("end resize"); #endif cc_text_set_anchor(CC_TEXT(text), 0.5 * (allocation->width - 50), allocation->height - 65); cc_circle_set_anchor(CC_CIRCLE(knobs[0]), rect.x1 * (allocation->width - 50), rect.y1 * (allocation->height - 50)); cc_circle_set_anchor(CC_CIRCLE(knobs[2]), rect.x2 * (allocation->width - 50), rect.y2 * (allocation->height - 50)); update_box(); }
void render_thunk_extractor::operator()(markers_symbolizer const& sym) const { using context_type = detail::thunk_markers_renderer_context; context_type renderer_context(sym, feature_, vars_, thunks_); render_markers_symbolizer( sym, feature_, prj_trans_, common_, clipping_extent_, renderer_context); update_box(); }
void render_thunk_extractor::extract_text_thunk(helper_ptr && helper, text_symbolizer const& sym) const { double opacity = get<double>(sym, keys::opacity, feature_, common_.vars_, 1.0); composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature_, common_.vars_, src_over); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature_, common_.vars_, HALO_RASTERIZER_FULL); text_render_thunk thunk(std::move(helper), opacity, comp_op, halo_rasterizer); thunks_.push_back(std::make_unique<render_thunk>(std::move(thunk))); update_box(); }
void render_thunk_extractor::extract_text_thunk(text_symbolizer_helper & helper, text_symbolizer const& sym) const { double opacity = get<double>(sym, keys::opacity, feature_, common_.vars_, 1.0); composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature_, common_.vars_, src_over); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature_, common_.vars_, HALO_RASTERIZER_FULL); placements_list const& placements = helper.get(); text_render_thunk thunk(placements, opacity, comp_op, halo_rasterizer); thunks_.push_back(std::make_shared<render_thunk>(thunk)); update_box(); }
void render_thunk_extractor::operator()(markers_symbolizer const& sym) const { auto renderer_context = std::tie(thunks_); using context_type = decltype(renderer_context); using vector_dispatch_type = detail::vector_marker_thunk_dispatch<label_collision_detector4, context_type>; using raster_dispatch_type = detail::raster_marker_thunk_dispatch<label_collision_detector4, context_type>; render_markers_symbolizer<vector_dispatch_type, raster_dispatch_type>( sym, feature_, prj_trans_, common_, clipping_extent_, renderer_context); update_box(); }
static void set_margin(glw_t *w, const int16_t *v) { glw_image_t *gi = (void *)w; gi->gi_margin_left = v[0]; gi->gi_margin_top = v[1]; gi->gi_margin_right = v[2]; gi->gi_margin_bottom = v[3]; update_box(gi); gi->gi_update = 1; glw_image_update_constraints(gi); }
void render_thunk_extractor::operator()(point_symbolizer const& sym) const { composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature_, common_.vars_, src_over); render_point_symbolizer( sym, feature_, prj_trans_, common_, [&](pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity) { point_render_thunk thunk(pos, marker, tr, opacity, comp_op); thunks_.push_back(std::make_shared<render_thunk>(std::move(thunk))); }); update_box(); }
static void set_border(glw_t *w, const int16_t *v) { glw_image_t *gi = (void *)w; if(gi->gi_mode != GI_MODE_BORDER_ONLY_SCALING) gi->gi_mode = GI_MODE_BORDER_SCALING; gi->gi_border_left = v[0]; gi->gi_border_top = v[1]; gi->gi_border_right = v[2]; gi->gi_border_bottom = v[3]; update_box(gi); gi->gi_update = 1; glw_image_update_constraints(gi); }
static gboolean knob_button_release_event(CcItem * knob, CcView * view, GdkEventButton* ev) { gdouble* offset = g_object_get_data(G_OBJECT(knob), "CccDemoKnobOffset"); if(knob == knobs[0] || knob == knobs[2]) { cc_circle_set_anchor(CC_CIRCLE(knob), ev->x + offset[0], ev->y + offset[1]); update_box(); } else { update_offset(ev->x, ev->y); } g_object_set_data(G_OBJECT(knob), "CccDemoKnobOffset", NULL); cc_view_ungrab_item(view, CC_ITEM(knob), ev->time); return TRUE; }
// Read in lines from line.in and add them into collision world for simulation. void LineDemo_createLines(LineDemo* lineDemo) { unsigned int lineId = 0; unsigned int numOfLines; window_dimension px1; window_dimension py1; window_dimension px2; window_dimension py2; window_dimension vx; window_dimension vy; int isGray; FILE *fin; fin = fopen("line.in", "r"); assert(fin != NULL); fscanf(fin, "%d\n", &numOfLines); lineDemo->collisionWorld = CollisionWorld_new(numOfLines); while (EOF != fscanf(fin, "(%lf, %lf), (%lf, %lf), %lf, %lf, %d\n", &px1, &py1, &px2, &py2, &vx, &vy, &isGray)) { Line *line = malloc(sizeof(Line)); // convert window coordinates to box coordinates windowToBox(&line->p1.x, &line->p1.y, px1, py1); windowToBox(&line->p2.x, &line->p2.y, px2, py2); line->max_x_is_p1 = (line->p1.x > line->p2.x); line->max_y_is_p1 = (line->p1.y > line->p2.y); // convert window velocity to box velocity velocityWindowToBox(&line->velocity.x, &line->velocity.y, vx, vy); update_box(line, lineDemo->collisionWorld->timeStep); // store color line->color = (Color) isGray; // store line ID line->id = lineId; lineId++; // transfer ownership of line to collisionWorld CollisionWorld_addLine(lineDemo->collisionWorld, line); } fclose(fin); }
static gboolean knob_motion_notify_event(CcItem * knob, CcView * view, GdkEventMotion* ev) { gdouble* offset = g_object_get_data(G_OBJECT(knob), "CccDemoKnobOffset"); if(G_LIKELY(offset)) { if(knob == knobs[0] || knob == knobs[2]) { cc_circle_set_anchor(CC_CIRCLE(knob), ev->x + offset[0], ev->y + offset[1]); update_box(); } else { update_offset(ev->x, ev->y); } return TRUE; } return FALSE; }
void render_thunk_extractor::extract_text_thunk(text_symbolizer const& sym) const { auto placements(Helper::get( sym, feature_, vars_, prj_trans_, common_.width_, common_.height_, common_.scale_factor_, common_.t_, common_.font_manager_, *common_.detector_, clipping_extent_, agg::trans_affine::identity, common_.symbol_cache_)); double opacity = get<double>(sym, keys::opacity, feature_, common_.vars_, 1.0); composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature_, common_.vars_, src_over); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature_, common_.vars_, HALO_RASTERIZER_FULL); base_text_render_thunk thunk(std::move(placements), opacity, comp_op, halo_rasterizer); thunks_.emplace_back(std::move(thunk)); update_box(); }
bool EC_WidgetCanvas::Blit(const QImage &source, Ogre::TexturePtr destination) { #if defined(DIRECTX_ENABLED) && defined(WIN32) Ogre::HardwarePixelBufferSharedPtr pb = destination->getBuffer(); Ogre::D3D9HardwarePixelBuffer *pixelBuffer = dynamic_cast<Ogre::D3D9HardwarePixelBuffer*>(pb.get()); if (!pixelBuffer) return false; LPDIRECT3DSURFACE9 surface = pixelBuffer->getSurface(Ogre::D3D9RenderSystem::getActiveD3D9Device()); if (surface) { D3DSURFACE_DESC desc; HRESULT hr = surface->GetDesc(&desc); if (SUCCEEDED(hr)) { D3DLOCKED_RECT lock; HRESULT hr = surface->LockRect(&lock, 0, 0); if (SUCCEEDED(hr)) { const int bytesPerPixel = 4; ///\todo Count from Ogre::PixelFormat! const int sourceStride = bytesPerPixel * source.width(); if (lock.Pitch == sourceStride) memcpy(lock.pBits, source.bits(), sourceStride * source.height()); else for(int y = 0; y < source.height(); ++y) memcpy((u8*)lock.pBits + lock.Pitch * y, source.bits() + sourceStride * y, sourceStride); surface->UnlockRect(); } } } #else if (!destination->getBuffer().isNull()) { Ogre::Box update_box(0, 0, source.width(), source.height()); Ogre::PixelBox pixel_box(update_box, Ogre::PF_A8R8G8B8, (void*)source.bits()); destination->getBuffer()->blitFromMemory(pixel_box, update_box); } #endif return true; }
static void glw_image_layout_tesselated(glw_root_t *gr, glw_rctx_t *rc, glw_image_t *gi, glw_loadable_texture_t *glt) { float tex[4][2]; float vex[4][2]; int x, y, i = 0, BL, BR; if(gr->gr_normalized_texture_coords) { tex[1][0] = 0.0f + (float)gi->gi_border_left / glt->glt_xs; tex[2][0] = glt->glt_s - (float)gi->gi_border_right / glt->glt_xs; tex[0][0] = gi->gi_bitmap_flags & GLW_IMAGE_BORDER_LEFT ? 0.0f : tex[1][0]; tex[3][0] = gi->gi_bitmap_flags & GLW_IMAGE_BORDER_RIGHT ? glt->glt_s : tex[2][0]; tex[0][1] = 0.0f; tex[1][1] = 0.0f + (float)gi->gi_border_top / glt->glt_ys; tex[2][1] = glt->glt_t - (float)gi->gi_border_bottom / glt->glt_ys; tex[3][1] = glt->glt_t; } else { tex[1][0] = gi->gi_border_left; tex[2][0] = glt->glt_xs - gi->gi_border_right; tex[0][0] = gi->gi_bitmap_flags & GLW_IMAGE_BORDER_LEFT ? 0.0f : tex[1][0]; tex[3][0] = gi->gi_bitmap_flags & GLW_IMAGE_BORDER_RIGHT ? glt->glt_xs : tex[2][0]; tex[0][1] = 0.0f; tex[1][1] = gi->gi_border_top; tex[2][1] = glt->glt_ys - gi->gi_border_bottom; tex[3][1] = glt->glt_ys; } if(gi->gi_bitmap_flags & GLW_IMAGE_ASPECT_FIXED_BORDERS) { BL = rc->rc_height * gi->gi_border_left / glt->glt_ys; BR = rc->rc_height * gi->gi_border_right / glt->glt_ys; gi->gi_border_left_afix = BL; gi->gi_border_right_afix = BR; update_box(gi); } else { BL = gi->gi_border_left; BR = gi->gi_border_right; } vex[0][0] = GLW_MIN(-1.0f + 2.0f * (gi->gi_margin_left) / rc->rc_width, 0.0f); vex[1][0] = GLW_MIN(-1.0f + 2.0f * (BL + gi->gi_margin_left) / rc->rc_width, 0.0f); vex[2][0] = GLW_MAX( 1.0f - 2.0f * (BR + gi->gi_margin_right) / rc->rc_width, 0.0f); vex[3][0] = GLW_MAX( 1.0f - 2.0f * (gi->gi_margin_right) / rc->rc_width, 0.0f); vex[0][1] = GLW_MAX( 1.0f - 2.0f * (gi->gi_margin_top) / rc->rc_height, 0.0f); vex[1][1] = GLW_MAX( 1.0f - 2.0f * (gi->gi_border_top + gi->gi_margin_top) / rc->rc_height, 0.0f); vex[2][1] = GLW_MIN(-1.0f + 2.0f * (gi->gi_border_bottom + gi->gi_margin_bottom) / rc->rc_height, 0.0f); vex[3][1] = GLW_MIN(-1.0f + 2.0f * (gi->gi_margin_bottom) / rc->rc_height, 0.0f); for(y = 0; y < 4; y++) { for(x = 0; x < 4; x++) { glw_renderer_vtx_pos(&gi->gi_gr, i, vex[x][0], vex[y][1], 0.0f); glw_renderer_vtx_st (&gi->gi_gr, i, tex[x][0], tex[y][1]); i++; } } }
static void glw_image_layout_tesselated(glw_root_t *gr, glw_rctx_t *rc, glw_image_t *gi, glw_loadable_texture_t *glt) { float tex[4][2]; float vex[4][2]; int x, y, i = 0, BL, BR; if(gi->w.glw_flags2 & GLW2_AUTOMARGIN) { gi->gi_automargin_left = 0; gi->gi_automargin_top = 0; gi->gi_automargin_right = 0; gi->gi_automargin_bottom = 0; glw_t *c = TAILQ_FIRST(&gi->w.glw_childs); if(c != NULL && (c->glw_flags & (GLW_CONSTRAINT_X | GLW_CONSTRAINT_Y)) == (GLW_CONSTRAINT_X | GLW_CONSTRAINT_Y)) { int hspill = rc->rc_width - c->glw_req_size_x - gi->gi_box_left - gi->gi_box_right; if(hspill > 0) { gi->gi_automargin_left = hspill / 2 + (hspill & 1); gi->gi_automargin_right = hspill / 2; } int vspill = rc->rc_height - c->glw_req_size_y - gi->gi_box_top - gi->gi_box_bottom; if(vspill > 0) { gi->gi_automargin_top = vspill / 2 + (vspill & 1); gi->gi_automargin_bottom = vspill / 2; } } else if(c != NULL && c->glw_flags & GLW_CONSTRAINT_W && c->glw_req_weight < 0) { float aspect = -c->glw_req_weight; float cw = rc->rc_width - gi->gi_box_left - gi->gi_box_right; float ch = rc->rc_height - gi->gi_box_top - gi->gi_box_bottom; float myaspect = cw / ch; if(myaspect > aspect) { // We are wider than our child wants int cwidth = ch * aspect; int hspill = cw - cwidth; if(hspill > 0) { gi->gi_automargin_left = hspill / 2 + (hspill & 1); gi->gi_automargin_right = hspill / 2; } } else { int cheight = cw / aspect; int vspill = ch - cheight; if(vspill > 0) { gi->gi_automargin_top = vspill / 2 + (vspill & 1); gi->gi_automargin_bottom = vspill / 2; } } } else if(gi->gi_child_aspect > 0) { int px = rc->rc_height * gi->gi_child_aspect; int hspill = rc->rc_width - px - gi->gi_box_left - gi->gi_box_right; if(hspill > 0) { gi->gi_automargin_left = hspill / 2 + (hspill & 1); gi->gi_automargin_right = hspill / 2; } } if(gi->w.glw_flags & GLW_DEBUG) printf("Automargin %d,%d,%d,%d\n", gi->gi_automargin_left, gi->gi_automargin_top, gi->gi_automargin_right, gi->gi_automargin_bottom); update_box(gi); } if(gr->gr_normalized_texture_coords) { tex[1][0] = 0.0f + (float)gi->gi_border_left / glt->glt_xs; tex[2][0] = glt->glt_s - (float)gi->gi_border_right / glt->glt_xs; tex[0][0] = gi->gi_bitmap_flags & GLW_IMAGE_BORDER_LEFT ? 0.0f : tex[1][0]; tex[3][0] = gi->gi_bitmap_flags & GLW_IMAGE_BORDER_RIGHT ? glt->glt_s : tex[2][0]; tex[0][1] = 0.0f; tex[1][1] = 0.0f + (float)gi->gi_border_top / glt->glt_ys; tex[2][1] = glt->glt_t - (float)gi->gi_border_bottom / glt->glt_ys; tex[3][1] = glt->glt_t; } else { tex[1][0] = gi->gi_border_left; tex[2][0] = glt->glt_xs - gi->gi_border_right; tex[0][0] = gi->gi_bitmap_flags & GLW_IMAGE_BORDER_LEFT ? 0.0f : tex[1][0]; tex[3][0] = gi->gi_bitmap_flags & GLW_IMAGE_BORDER_RIGHT ? glt->glt_xs : tex[2][0]; tex[0][1] = 0.0f; tex[1][1] = gi->gi_border_top; tex[2][1] = glt->glt_ys - gi->gi_border_bottom; tex[3][1] = glt->glt_ys; } if(gi->gi_bitmap_flags & GLW_IMAGE_ASPECT_FIXED_BORDERS) { BL = rc->rc_height * gi->gi_border_left / glt->glt_ys; BR = rc->rc_height * gi->gi_border_right / glt->glt_ys; gi->gi_border_left_afix = BL; gi->gi_border_right_afix = BR; update_box(gi); } else { BL = gi->gi_border_left; BR = gi->gi_border_right; } vex[0][0] = GLW_MIN(-1.0f + 2.0f * (gi->gi_margin_left + gi->gi_automargin_left) / rc->rc_width, 0.0f); vex[1][0] = GLW_MIN(-1.0f + 2.0f * (BL + gi->gi_margin_left + gi->gi_automargin_left) / rc->rc_width, 0.0f); vex[2][0] = GLW_MAX( 1.0f - 2.0f * (BR + gi->gi_margin_right + gi->gi_automargin_right) / rc->rc_width, 0.0f); vex[3][0] = GLW_MAX( 1.0f - 2.0f * (gi->gi_margin_right + gi->gi_automargin_right) / rc->rc_width, 0.0f); vex[0][1] = GLW_MAX( 1.0f - 2.0f * (gi->gi_margin_top + gi->gi_automargin_top) / rc->rc_height, 0.0f); vex[1][1] = GLW_MAX( 1.0f - 2.0f * (gi->gi_border_top + gi->gi_margin_top + gi->gi_automargin_top) / rc->rc_height, 0.0f); vex[2][1] = GLW_MIN(-1.0f + 2.0f * (gi->gi_border_bottom + gi->gi_margin_bottom + gi->gi_automargin_bottom) / rc->rc_height, 0.0f); vex[3][1] = GLW_MIN(-1.0f + 2.0f * (gi->gi_margin_bottom + gi->gi_automargin_bottom) / rc->rc_height, 0.0f); for(y = 0; y < 4; y++) { for(x = 0; x < 4; x++) { glw_renderer_vtx_pos(&gi->gi_gr, i, vex[x][0], vex[y][1], 0.0f); glw_renderer_vtx_st (&gi->gi_gr, i, tex[x][0], tex[y][1]); i++; } } }