static bool testtilecache_sprite_renderer(void *p_context, MCContext *p_target, const MCRectangle& p_rectangle) { MCControl *t_control; t_control = (MCControl *)p_context; // A scrolling layer is an unadorned group. bool t_scrolling; t_scrolling = t_control -> layer_isscrolling(); MCRectangle t_control_rect, t_dirty_rect; if (!t_scrolling) { t_control_rect = t_control -> geteffectiverect(); t_dirty_rect = MCU_intersect_rect(t_control_rect, MCU_offset_rect(p_rectangle, t_control_rect . x, t_control_rect . y)); } else { t_control_rect = t_control -> layer_getcontentrect(); t_dirty_rect = MCU_intersect_rect(t_control_rect, MCU_offset_rect(p_rectangle, t_control_rect . x, t_control_rect . y)); } if (MCU_empty_rect(t_dirty_rect)) return true; p_target -> setorigin(t_control_rect . x + p_rectangle . x, t_control_rect . y + p_rectangle . y); p_target -> setclip(t_dirty_rect); p_target -> setfunction(GXcopy); p_target -> setopacity(255); t_control -> draw(p_target, t_dirty_rect, false, true); return true; }
void MCControl::layer_dirtycontentrect(const MCRectangle& p_updated_rect, bool p_update_card) { if (MCU_empty_rect(p_updated_rect)) return; MCRectangle t_content_rect; t_content_rect = layer_getcontentrect(); MCTileCacheRef t_tilecache; t_tilecache = getstack() -> gettilecache(); // Note that this method is only called if layer_isscrolling() is true, which is only // possible if we have a tilecache. if (m_layer_id != 0) MCTileCacheUpdateSprite(t_tilecache, m_layer_id, MCU_offset_rect(p_updated_rect, -t_content_rect . x, -t_content_rect . y)); // Add the rect to the update region - but only if instructed (update_card will be // false if the object was invisible). if (p_update_card) static_cast<MCCard *>(parent) -> layer_dirtyrect(MCU_intersect_rect(p_updated_rect, geteffectiverect())); }
bool MCTileCacheSoftwareCompositor_CompositeTile(void *p_context, int32_t p_x, int32_t p_y, void *p_tile) { MCTileCacheSoftwareCompositorContext *self; self = (MCTileCacheSoftwareCompositorContext *)p_context; MCRectangle t_dst_rect; t_dst_rect . x = p_x; t_dst_rect . y = p_y; t_dst_rect . width = self -> tile_size; t_dst_rect . height = self -> tile_size; t_dst_rect = MCU_intersect_rect(t_dst_rect, self -> clip); MCRectangle t_src_rect; t_src_rect = MCU_offset_rect(t_dst_rect, -p_x, -p_y); void *t_dst_ptr, *t_src_ptr; t_dst_ptr = (uint8_t *)self -> bits + self -> stride * (t_dst_rect . y - self -> dirty . y) + (t_dst_rect . x - self -> dirty . x) * sizeof(uint32_t); t_src_ptr = (uint32_t *)p_tile + self -> tile_size * t_src_rect . y + t_src_rect . x; self -> combiner(t_dst_ptr, self -> stride, t_src_ptr, self -> tile_size * sizeof(uint32_t), t_src_rect . width, t_src_rect . height, self -> opacity); return true; }
void MCControl::layer_dirtyeffectiverect(const MCRectangle& p_effective_rect, bool p_update_card) { // The dirty rect will be the input effective rect expanded by any effects // applied by the parent groups (if any). MCRectangle t_dirty_rect; t_dirty_rect = p_effective_rect; // Expand the effective rect by that of all parent groups. MCControl *t_control; t_control = this; while(t_control -> parent -> gettype() == CT_GROUP) { MCControl *t_parent_control; t_parent_control = static_cast<MCControl *>(t_control -> parent); // If the parent control is scrolling, we are done - defer to content // dirtying. if (t_parent_control -> layer_isscrolling()) { t_parent_control -> layer_dirtycontentrect(t_dirty_rect, p_update_card); return; } // Otherwise intersect the dirty rect with the parent's rect. t_dirty_rect = MCU_intersect_rect(t_dirty_rect, t_control -> parent -> getrect()); // Expand due to bitmap effects (if any). if (t_parent_control -> m_bitmap_effects != nil) MCBitmapEffectsComputeBounds(t_parent_control -> m_bitmap_effects, t_dirty_rect, t_dirty_rect); t_control = t_parent_control; } // Fetch the tilecache we are using (if any). MCTileCacheRef t_tilecache; t_tilecache = t_control -> getstack() -> gettilecache(); // Notify any tilecache of the changes. if (t_tilecache != nil) { // We must be in tile-cache mode with a top-level control, but if the layer // id is zero, there is nothing to do. if (t_control -> m_layer_id == 0) return; // How we handle the layer depends on whether it is a sprite or not. if (!t_control -> layer_issprite()) { // Non-dynamic layers are scenery in the tilecache, their rect is in // canvas co-ords. MCTileCacheUpdateScenery(t_tilecache, t_control -> m_layer_id, t_dirty_rect); } else { // Dynamic layers are sprites in the tilecache, their rect is in // sprite co-ords. MCTileCacheUpdateSprite(t_tilecache, t_control -> m_layer_id, MCU_offset_rect(t_dirty_rect, -t_control -> rect . x, -t_control -> rect . y)); } } // Add the rect to the update region - but only if instructed (update_card will be // false if the object was invisible). if (p_update_card) static_cast<MCCard *>(t_control -> parent) -> layer_dirtyrect(t_dirty_rect); }
bool MCRegionOffset(MCRegionRef self, int32_t p_dx, int32_t p_dy) { self -> rect = MCU_offset_rect(self -> rect, p_dx, p_dy); return true; }