Beispiel #1
0
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;
}
Beispiel #2
0
static bool testtilecache_scenery_renderer(void *p_context, MCContext *p_target, const MCRectangle& p_rectangle)
{
	MCControl *t_control;
	t_control = (MCControl *)p_context;

	// Don't render anything if the control is invisible.
	if (!t_control -> getflag(F_VISIBLE) && !MCshowinvisibles)
		return true;
	
	MCRectangle t_control_rect;
	t_control_rect = t_control -> geteffectiverect();

	MCRectangle t_dirty_rect;
	t_dirty_rect = MCU_intersect_rect(t_control_rect, p_rectangle);
	
	if (MCU_empty_rect(t_dirty_rect))
		return true;

	p_target -> setclip(t_dirty_rect);
	p_target -> setfunction(GXcopy);
	p_target -> setopacity(255);

	t_control -> draw(p_target, t_dirty_rect, false, false);

	return true;
}
Beispiel #3
0
	bool LockPixels(MCRegionRef p_area, MCGRaster& r_raster)
	{
		if (m_bitmap == nil || m_locked)
			return false;

		MCRectangle t_bounds = MCRegionGetBoundingBox(m_region);
		MCRectangle t_actual_area;
		t_actual_area = MCU_intersect_rect(MCRegionGetBoundingBox(p_area), t_bounds);
		if (MCU_empty_rect(t_actual_area))
			return false;

		/* UNCHECKED */ MCRegionIncludeRect(m_redraw_region, t_actual_area);

		uint8_t *t_bits = (uint8_t*)m_raster.pixels + (t_actual_area.y - t_bounds.y) * m_raster.stride + (t_actual_area.x - t_bounds.x) * sizeof(uint32_t);

		m_locked_area = t_actual_area;

		r_raster . format = kMCGRasterFormat_ARGB;
		r_raster . width = t_actual_area . width;
		r_raster . height = t_actual_area . height;
		r_raster . stride = m_raster.stride;
		r_raster . pixels = t_bits;

		m_locked = true;

		return true;
	}
Beispiel #4
0
	bool LockGraphics(MCRegionRef p_area, MCContext*& r_context)
	{
		MCRectangle t_actual_area;
		t_actual_area = MCU_intersect_rect(MCRegionGetBoundingBox(p_area), MCRegionGetBoundingBox(m_region));
		
		if (MCU_empty_rect(t_actual_area))
			return false;
		
		m_locked_pixmap = MCscreen -> createpixmap(t_actual_area . width, t_actual_area . height, 0, False);
		if (m_locked_pixmap != nil)
		{
			m_locked_context = MCscreen -> createcontext(m_locked_pixmap, False, False);
			if (m_locked_context != nil)
			{
				m_locked_context -> setorigin(t_actual_area . x, t_actual_area . y);
				m_locked_context -> setclip(t_actual_area);
				
				m_locked_area = t_actual_area;
				r_context = m_locked_context;
				
				return true;
			}
			
			MCscreen -> freepixmap(m_locked_pixmap);
		}
		
		return false;
	}
Beispiel #5
0
	bool LockPixmap(MCRegionRef p_area, Pixmap& r_pixmap)
	{
		MCRectangle t_actual_area;
		t_actual_area = MCU_intersect_rect(MCRegionGetBoundingBox(p_area), MCRegionGetBoundingBox(m_region));
		if (MCU_empty_rect(t_actual_area))
			return false;

		m_locked_pixmap = MCscreen -> createpixmap(t_actual_area . width, t_actual_area . height, 0, False);
		if (m_locked_pixmap == nil)
			return false;

		m_locked_area = t_actual_area;
		r_pixmap = m_locked_pixmap;
		
		return true;	
	}
Beispiel #6
0
	bool Lock(void)
	{
		if (m_bitmap != nil)
			return false;

		MCRectangle t_actual_area;
		t_actual_area = MCRegionGetBoundingBox(m_region);
		if (MCU_empty_rect(t_actual_area))
			return false;

		bool t_success = true;

		void *t_bits = nil;

		if (t_success)
			t_success = MCRegionCreate(m_redraw_region);

		if (t_success)
			t_success = create_temporary_dib(m_dc, t_actual_area . width, t_actual_area . height, m_bitmap, t_bits);

		if (t_success)
		{
			m_raster . format = kMCGRasterFormat_ARGB;
			m_raster . width = t_actual_area . width;
			m_raster . height = t_actual_area . height;
			m_raster . stride = t_actual_area . width * sizeof(uint32_t);
			m_raster . pixels = t_bits;

			m_area = t_actual_area;

			return true;
		}

		MCRegionDestroy(m_redraw_region);
		m_redraw_region = nil;

		if (m_bitmap != nil)
			DeleteObject(m_bitmap);
		m_bitmap = nil;

		return false;
	}
Beispiel #7
0
	bool LockPixels(MCRegionRef p_area, void*& r_bits, uint32_t& r_stride)
	{
		MCRectangle t_actual_area;
		t_actual_area = MCU_intersect_rect(MCRegionGetBoundingBox(p_area), MCRegionGetBoundingBox(m_region));
		
		if (MCU_empty_rect(t_actual_area))
			return false;
		
		m_locked_bits = malloc(t_actual_area . width * t_actual_area . height * sizeof(uint32_t));
		if (m_locked_bits != nil)
		{
			m_locked_area = t_actual_area;
			
			r_bits = m_locked_bits;
			r_stride = t_actual_area . width * sizeof(uint32_t);
			return true;
		}
		
		return false;
	}
Beispiel #8
0
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()));
}
Beispiel #9
0
bool MCRegionIsEmpty(MCRegionRef self)
{
	return MCU_empty_rect(self -> rect);
}