Example #1
0
void MCCard::layer_setviewport(int32_t p_x, int32_t p_y, int32_t p_width, int32_t p_height)
{
	MCTileCacheRef t_tilecache;
	t_tilecache = getstack() -> gettilecache();

	// Notify any tilecache of the changes.
	if (t_tilecache != nil)
		MCTileCacheSetViewport(t_tilecache, MCU_make_rect(p_x, p_y, p_width, p_height));

	// Get the current rect, before updating it.
	MCRectangle t_old_rect;
	t_old_rect = rect;
	
	// Update the rect.
	resize(p_width, p_height);
	
	// Add the rects to the update region.

	// MW-2012-05-01: [[ Bug 10157 ]] If the card has a border then add the whole card
	//   rect to the update region; otherwise just add the exposed rects.
	if (!getflag(F_SHOW_BORDER))
	{
		if (p_width > t_old_rect.width)
			layer_dirtyrect(MCU_make_rect(t_old_rect.width, 0, p_width - t_old_rect.width, p_height));
		if (p_height > t_old_rect.height)
			layer_dirtyrect(MCU_make_rect(0, t_old_rect.height, p_width, p_height - t_old_rect.height));
	}
	else
		layer_dirtyrect(rect);
}
Example #2
0
void MCStack::setacceleratedrendering(bool p_value)
{
	// If we are turning accelerated rendering off, then destroy the tilecache.
	if (!p_value)
	{
		MCTileCacheDestroy(m_tilecache);
		m_tilecache = nil;
		
		// MW-2012-03-15: [[ Bug ]] Make sure we dirty the stack to ensure all the
		//   layer mode attrs are rest.
		dirtyall();
		
		return;
	}
	
	// If we are turning accelerated rendering on, and we already have a tile-
	// cache, then do nothing.
	if (m_tilecache != nil)
		return;
		
	// Otherwise, we configure based on platform settings.
	int32_t t_tile_size;
	int32_t t_cache_limit;
	MCTileCacheCompositorType t_compositor_type;
#ifdef _MAC_DESKTOP
	t_compositor_type = kMCTileCacheCompositorCoreGraphics;
	t_tile_size = 32;
	t_cache_limit = 32 * 1024 * 1024;
#elif defined(_WINDOWS_DESKTOP) || defined(_LINUX_DESKTOP)
	t_compositor_type = kMCTileCacheCompositorSoftware;
	t_tile_size = 32;
	t_cache_limit = 32 * 1024 * 1024;
#elif defined(_IOS_MOBILE) || defined(_ANDROID_MOBILE)
	t_compositor_type = kMCTileCacheCompositorStaticOpenGL;
	
	const MCDisplay *t_display;
	MCscreen -> getdisplays(t_display, false);
	
	MCRectangle t_viewport;
	t_viewport = t_display -> viewport;
	
	bool t_small_screen, t_medium_screen;
	t_small_screen = MCMin(t_viewport . width, t_viewport . height) <= 480 && MCMax(t_viewport . width, t_viewport . height) <= 640;
	t_medium_screen = MCMin(t_viewport . width, t_viewport . height) <= 768 && MCMax(t_viewport . width, t_viewport . height) <= 1024;

	if (t_small_screen)
		t_tile_size = 32, t_cache_limit = 16 * 1024 * 1024;
	else if (t_medium_screen)
		t_tile_size = 64, t_cache_limit = 32 * 1024 * 1024;
	else
		t_tile_size = 64, t_cache_limit = 64 * 1024 * 1024;
#endif

	MCTileCacheCreate(t_tile_size, t_cache_limit, m_tilecache);
	MCTileCacheSetViewport(m_tilecache, curcard -> getrect());
	MCTileCacheSetCompositor(m_tilecache, t_compositor_type);
	
	dirtyall();
}
Example #3
0
void MCStack::view_updatetilecacheviewport(void)
{
	if (m_view_tilecache == nil)
		return;
	
	// IM-2013-10-02: [[ FullscreenMode ]] Use view rect when setting the size of the tilecache
	// IM-2013-10-10: [[ FullscreenMode ]] Align tilecache viewport to origin
	// IM-2014-01-24: [[ HiDPI ]] Set tilecache viewport in backing surface coords
	MCRectangle t_view_rect;
	t_view_rect = MCRectangleMake(0, 0, m_view_rect.width, m_view_rect.height);
	
	MCRectangle t_surface_rect;
	t_surface_rect = MCRectangleGetScaledBounds(t_view_rect, view_getbackingscale());
	
	MCTileCacheSetViewport(m_view_tilecache, t_surface_rect);
}