Example #1
0
void gui_widget_on_repaint(gui_widget_t* widget, const rect_t* rect)
{
    painter_t painter;
    
    if(gui_widget_begin_paint(widget, &painter, rect) != E_NO_ERROR) return;
    
    gui_theme_t* theme = gui_theme(gui_widget_gui(widget));
    
    painter_set_pen(&painter, PAINTER_PEN_SOLID);
    painter_set_brush(&painter, PAINTER_BRUSH_SOLID);
    painter_set_brush_color(&painter, widget->back_color);
    
    if(gui_widget_has_focus(widget)){
        painter_set_pen_color(&painter, theme->focus_color);
    }else{
        painter_set_pen_color(&painter, theme->border_color);
    }
    
    if(widget->border == GUI_BORDER_NONE && !gui_widget_has_focus(widget)){
        painter_draw_fillrect(&painter, 0, 0, rect_width(&widget->rect) - 1, rect_height(&widget->rect) - 1);
    }else{
        painter_draw_rect(&painter, 0, 0, rect_width(&widget->rect) - 1, rect_height(&widget->rect) - 1);
    }
    
    gui_widget_end_paint(widget, &painter);
}
Example #2
0
static void update_minmax_state(win_window_info *window)
{
	assert(GetCurrentThreadId() == window_threadid);

	if (!window->fullscreen)
	{
		RECT bounds, minbounds, maxbounds;

		// compare the maximum bounds versus the current bounds
		get_min_bounds(window, &minbounds, video_config.keepaspect);
		get_max_bounds(window, &maxbounds, video_config.keepaspect);
		GetWindowRect(window->hwnd, &bounds);

		// if either the width or height matches, we were maximized
		window->isminimized = (rect_width(&bounds) == rect_width(&minbounds) ||
								rect_height(&bounds) == rect_height(&minbounds));
		window->ismaximized = (rect_width(&bounds) == rect_width(&maxbounds) ||
								rect_height(&bounds) == rect_height(&maxbounds));
	}
	else
	{
		window->isminimized = FALSE;
		window->ismaximized = TRUE;
	}
}
Example #3
0
static void get_min_bounds(win_window_info *window, RECT *bounds, int constrain)
{
	INT32 minwidth, minheight;

	assert(GetCurrentThreadId() == window_threadid);

	// get the minimum target size
	render_target_get_minimum_size(window->target, &minwidth, &minheight);

	// expand to our minimum dimensions
	if (minwidth < MIN_WINDOW_DIM)
		minwidth = MIN_WINDOW_DIM;
	if (minheight < MIN_WINDOW_DIM)
		minheight = MIN_WINDOW_DIM;

	// account for extra window stuff
	minwidth += wnd_extra_width(window);
	minheight += wnd_extra_height(window);

	// if we want it constrained, figure out which one is larger
	if (constrain)
	{
		RECT test1, test2;

		// first constrain with no height limit
		test1.top = test1.left = 0;
		test1.right = minwidth;
		test1.bottom = 10000;
		constrain_to_aspect_ratio(window, &test1, WMSZ_BOTTOMRIGHT);

		// then constrain with no width limit
		test2.top = test2.left = 0;
		test2.right = 10000;
		test2.bottom = minheight;
		constrain_to_aspect_ratio(window, &test2, WMSZ_BOTTOMRIGHT);

		// pick the larger
		if (rect_width(&test1) > rect_width(&test2))
		{
			minwidth = rect_width(&test1);
			minheight = rect_height(&test1);
		}
		else
		{
			minwidth = rect_width(&test2);
			minheight = rect_height(&test2);
		}
	}

	// get the window rect
	GetWindowRect(window->hwnd, bounds);

	// now adjust
	bounds->right = bounds->left + minwidth;
	bounds->bottom = bounds->top + minheight;
}
Example #4
0
static int scrollbar_get_thumbableH(ScrollBar *sb)
{
	int scrollable_h = rect_height(sb->rect) - 2 * sb->inset;
	int thumb_h = scrollbar_get_thumbH(sb);
	
	return scrollable_h - thumb_h;
}
Example #5
0
int renderer_bgfx::create()
{
	// create renderer

#ifdef OSD_WINDOWS
	RECT client;
	GetClientRect(window().m_hwnd, &client);

	bgfx::winSetHwnd(window().m_hwnd);
	bgfx::init();	
	bgfx::reset(rect_width(&client), rect_height(&client), video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
#else
	osd_dim wdim = window().get_size();
	bgfx::sdlSetWindow(window().sdl_window());
	bgfx::init();
	bgfx::reset(wdim.width(), wdim.height(), video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
#endif

	// Enable debug text.
	bgfx::setDebug(BGFX_DEBUG_TEXT); //BGFX_DEBUG_STATS
	// Create program from shaders.
	m_progQuad = loadProgram("vs_quad", "fs_quad");
	m_progQuadTexture = loadProgram("vs_quad_texture", "fs_quad_texture");
	m_progLine = loadProgram("vs_line", "fs_line");
	m_s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);

	osd_printf_verbose("Leave drawsdl2_window_create\n");
	return 0;
}
Example #6
0
static render_primitive_list *drawnone_window_get_primitives(win_window_info *window)
{
	RECT client;
	GetClientRect(window->hwnd, &client);
	window->target->set_bounds(rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor));
	return &window->target->get_primitives();
}
Example #7
0
static const render_primitive_list *drawgdi_window_get_primitives(win_window_info *window)
{
	RECT client;
	GetClientRect(window->hwnd, &client);
	render_target_set_bounds(window->target, rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor));
	return render_target_get_primitives(window->target);
}
Example #8
0
INLINE int wnd_extra_height(win_window_info *window)
{
	RECT temprect = { 100, 100, 200, 200 };
	if (window->fullscreen)
		return 0;
	AdjustWindowRectEx(&temprect, WINDOW_STYLE, win_has_menu(window), WINDOW_STYLE_EX);
	return rect_height(&temprect) - 100;
}
Example #9
0
static void maximize_window(win_window_info *window)
{
	RECT newsize;

	assert(GetCurrentThreadId() == window_threadid);

	get_max_bounds(window, &newsize, video_config.keepaspect);
	SetWindowPos(window->hwnd, NULL, newsize.left, newsize.top, rect_width(&newsize), rect_height(&newsize), SWP_NOZORDER);
}
Example #10
0
static void adjust_window_position_after_major_change(win_window_info *window)
{
	RECT oldrect, newrect;

	assert(GetCurrentThreadId() == window_threadid);

	// get the current size
	GetWindowRect(window->hwnd, &oldrect);

	// adjust the window size so the client area is what we want
	if (!window->fullscreen)
	{
		// constrain the existing size to the aspect ratio
		newrect = oldrect;
		if (video_config.keepaspect)
			constrain_to_aspect_ratio(window, &newrect, WMSZ_BOTTOMRIGHT);
	}

	// in full screen, make sure it covers the primary display
	else
	{
		win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL);
		newrect = monitor->info.rcMonitor;
	}

	// adjust the position if different
	if (oldrect.left != newrect.left || oldrect.top != newrect.top ||
		oldrect.right != newrect.right || oldrect.bottom != newrect.bottom)
		SetWindowPos(window->hwnd, window->fullscreen ? HWND_TOPMOST : HWND_TOP,
				newrect.left, newrect.top,
				rect_width(&newrect), rect_height(&newrect), 0);

	// take note of physical window size (used for lightgun coordinate calculation)
	if (window == win_window_list)
	{
		win_physical_width = rect_width(&newrect);
		win_physical_height = rect_height(&newrect);
		logerror("Physical width %d, height %d\n",win_physical_width,win_physical_height);
	}

	// update the cursor state
	winwindow_update_cursor_state();
}
Example #11
0
render_primitive_list *renderer_gdi::get_primitives()
{
	auto win = try_getwindow();
	if (win == nullptr)
		return nullptr;

	RECT client;
	GetClientRect(win->platform_window<HWND>(), &client);
	win->target()->set_bounds(rect_width(&client), rect_height(&client), win->pixel_aspect());
	return &win->target()->get_primitives();
}
Example #12
0
	virtual render_primitive_list *get_primitives() override
	{
#ifdef OSD_WINDOWS
		RECT client;
		GetClientRect(window().m_hwnd, &client);
		window().target()->set_bounds(rect_width(&client), rect_height(&client), window().aspect());
		return &window().target()->get_primitives();
#else
		osd_dim wdim = window().get_size();
		window().target()->set_bounds(wdim.width(), wdim.height(), window().aspect());
		return &window().target()->get_primitives();
#endif
	}
Example #13
0
static void get_max_bounds(win_window_info *window, RECT *bounds, int constrain)
{
	RECT maximum;

	assert(GetCurrentThreadId() == window_threadid);

	// compute the maximum client area
	winvideo_monitor_refresh(window->monitor);
	maximum = window->monitor->info.rcWork;

	// clamp to the window's max
	if (window->maxwidth != 0)
	{
		int temp = window->maxwidth + wnd_extra_width(window);
		if (temp < rect_width(&maximum))
			maximum.right = maximum.left + temp;
	}
	if (window->maxheight != 0)
	{
		int temp = window->maxheight + wnd_extra_height(window);
		if (temp < rect_height(&maximum))
			maximum.bottom = maximum.top + temp;
	}

	// constrain to fit
	if (constrain)
		constrain_to_aspect_ratio(window, &maximum, WMSZ_BOTTOMRIGHT);
	else
	{
		maximum.right -= wnd_extra_width(window);
		maximum.bottom -= wnd_extra_height(window);
	}

	// center within the work area
	bounds->left = window->monitor->info.rcWork.left + (rect_width(&window->monitor->info.rcWork) - rect_width(&maximum)) / 2;
	bounds->top = window->monitor->info.rcWork.top + (rect_height(&window->monitor->info.rcWork) - rect_height(&maximum)) / 2;
	bounds->right = bounds->left + rect_width(&maximum);
	bounds->bottom = bounds->top + rect_height(&maximum);
}
Example #14
0
float winvideo_monitor_get_aspect(win_monitor_info *monitor)
{
	// refresh the monitor information and compute the aspect
	if (video_config.keepaspect)
	{
		int width, height;
		winvideo_monitor_refresh(monitor);
		width = rect_width(&monitor->info.rcMonitor);
		height = rect_height(&monitor->info.rcMonitor);
		return monitor->aspect / ((float)width / (float)height);
	}
	return 0.0f;
}
Example #15
0
void progressive_display_add_update_order(struct xrdp_screen* self, struct list* p_display, struct list* update_list)
{
  struct ip_image* desktop = self->screen;
  int i;
  update* up;
  int bpp = (self->bpp + 7) / 8;
  if (bpp == 3)
  {
    bpp = 4;
  }
  if (p_display->count > 0)
  {
    for (i = p_display->count - 1; i >= 0; i--)
    {
      struct update_rect* cur = (struct update_rect*) list_get_item(p_display, i);
      up = (update*) g_malloc(sizeof(update), 1);
      up->order_type = paint_rect;
      up->x = cur->rect.left;
      up->y = cur->rect.top;
      int w = rect_width(&cur->rect);
      int h = rect_height(&cur->rect);
      up->cx = w;
      up->cy = h;
      up->width = w;
      up->height = h;
      up->srcx = 0;
      up->srcy = 0;
      up->quality = cur->quality;
      up->data_len = up->cx * up->cy * bpp;
      up->data = g_malloc(up->data_len, 0);
      ip_image_crop(desktop, up->x, up->y, up->cx, up->cy, up->data);
      list_add_item(update_list, (tbus) up);
      if (cur->quality != 0)
      {
        struct update_rect* tmp = (struct update_rect*) g_malloc(sizeof(struct update_rect), 0);
        g_memcpy(tmp, cur, sizeof(struct update_rect));
        tmp->quality = 0;
        tmp->quality_already_send = cur->quality;
        fifo_push(self->candidate_update_rects, tmp);
      }
      list_remove_item(p_display, i);
    }
  }
}
Example #16
0
LoggerWindow *loggerwindow_new(MultiTestApp *app) {
	GHOST_SystemHandle sys= multitestapp_get_system(app);
	GHOST_TUns32 screensize[2];
	GHOST_WindowHandle win;
	
	GHOST_GetMainDisplayDimensions(sys, &screensize[0], &screensize[1]);
	win= GHOST_CreateWindow(sys, "MultiTest:Logger", 40, screensize[1]-432,
		800, 300, GHOST_kWindowStateNormal, 
		GHOST_kDrawingContextTypeOpenGL, FALSE, FALSE);
	
	if (win) {
		LoggerWindow *lw= MEM_callocN(sizeof(*lw), "loggerwindow_new");
		int bbox[2][2];
		lw->app= app;
		lw->win= win;

#ifdef USE_BMF
		lw->font= BMF_GetFont(BMF_kScreen12);
		lw->fonttexid= BMF_GetFontTexture(lw->font);

		BMF_GetBoundingBox(lw->font, &bbox[0][0], &bbox[0][1], &bbox[1][0], &bbox[1][1]);
		lw->fontheight= rect_height(bbox);
#else
		lw->font= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
		BLF_size(lw->font, 11, 72);
		lw->fontheight= BLF_height(lw->font, "A_");
#endif
		
		lw->nloglines= lw->logsize= 0;
		lw->loglines= MEM_mallocN(sizeof(*lw->loglines)*lw->nloglines, "loglines");
		
		lw->scroll= scrollbar_new(2, 40);
		
		GHOST_SetWindowUserData(lw->win, windowdata_new(lw, loggerwindow_handle));

		loggerwindow_do_reshape(lw);

		return lw;
	} else {
		return NULL;
	}
}
Example #17
0
static int drawgdi_window_draw(win_window_info *window, HDC dc, int update)
{
	gdi_info *gdi = (gdi_info *)window->drawdata;
	int width, height, pitch;
	RECT bounds;

	// we don't have any special resize behaviors
	if (window->resize_state == RESIZE_STATE_PENDING)
		window->resize_state = RESIZE_STATE_NORMAL;

	// get the target bounds
	GetClientRect(window->hwnd, &bounds);

	// compute width/height/pitch of target
	width = rect_width(&bounds);
	height = rect_height(&bounds);
	pitch = (width + 3) & ~3;

	// make sure our temporary bitmap is big enough
	if (pitch * height * 4 > gdi->bmsize)
	{
		gdi->bmsize = pitch * height * 4 * 2;
		global_free(gdi->bmdata);
		gdi->bmdata = global_alloc_array(UINT8, gdi->bmsize);
	}

	// draw the primitives to the bitmap
	window->primlist->acquire_lock();
	software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window->primlist, gdi->bmdata, width, height, pitch);
	window->primlist->release_lock();

	// fill in bitmap-specific info
	gdi->bminfo.bmiHeader.biWidth = pitch;
	gdi->bminfo.bmiHeader.biHeight = -height;
	gdi->bminfo.bmiHeader.biBitCount = 32;

	// blit to the screen
	StretchDIBits(dc, 0, 0, width, height,
				0, 0, width, height,
				gdi->bmdata, &gdi->bminfo, DIB_RGB_COLORS, SRCCOPY);
	return 0;
}
Example #18
0
int renderer_gdi::draw(const int update)
{
	auto win = assert_window();

	// we don't have any special resize behaviors
	if (win->m_resize_state == RESIZE_STATE_PENDING)
		win->m_resize_state = RESIZE_STATE_NORMAL;

	// get the target bounds
	RECT bounds;
	GetClientRect(win->platform_window<HWND>(), &bounds);

	// compute width/height/pitch of target
	int width = rect_width(&bounds);
	int height = rect_height(&bounds);
	int pitch = (width + 3) & ~3;

	// make sure our temporary bitmap is big enough
	if (pitch * height * 4 > m_bmsize)
	{
		m_bmsize = pitch * height * 4 * 2;
		global_free_array(m_bmdata);
		m_bmdata = global_alloc_array(uint8_t, m_bmsize);
	}

	// draw the primitives to the bitmap
	win->m_primlist->acquire_lock();
	software_renderer<uint32_t, 0,0,0, 16,8,0>::draw_primitives(*win->m_primlist, m_bmdata, width, height, pitch);
	win->m_primlist->release_lock();

	// fill in bitmap-specific info
	m_bminfo.bmiHeader.biWidth = pitch;
	m_bminfo.bmiHeader.biHeight = -height;

	// blit to the screen
	StretchDIBits(win->m_dc, 0, 0, width, height,
				0, 0, width, height,
				m_bmdata, &m_bminfo, DIB_RGB_COLORS, SRCCOPY);
	return 0;
}
Example #19
0
static int scrollbar_get_thumbH(ScrollBar *sb) {
	int scrollable_h= rect_height(sb->rect) - 2*sb->inset;
	
	return clamp_i(sb->thumbpct*scrollable_h, sb->minthumb, scrollable_h);
}
Example #20
0
void list_rect_progressive_display(struct list* self)
{
  int i;
  struct update_rect* cur;
  struct xrdp_rect rect;
  printf("List : %i elements : \n", self->count);
  for (i = 0; i < self->count; i++)
  {
    cur = (struct update_rect*) list_get_item(self, i);
    rect = cur->rect;
    printf("  rect : [%i %i %i %i] [%i, %i], level %i \n", rect.left, rect.top, rect.right, rect.bottom, rect_width(&rect), rect_height(&rect), cur->quality);
  }
}
Example #21
0
static void blit_to_primary(win_window_info *window, int srcwidth, int srcheight)
{
	dd_info *dd = window->drawdata;
	IDirectDrawSurface7 *target = (dd->back != NULL) ? dd->back : dd->primary;
	win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL);
	DDBLTFX blitfx = { sizeof(DDBLTFX) };
	RECT clear, outer, dest, source;
	INT32 dstwidth, dstheight;
	HRESULT result;

	// compute source rect
	source.left = source.top = 0;
	source.right = srcwidth;
	source.bottom = srcheight;

	// compute outer rect -- windowed version
	if (!window->fullscreen)
	{
		GetClientRect(window->hwnd, &outer);
		ClientToScreen(window->hwnd, &((LPPOINT)&outer)[0]);
		ClientToScreen(window->hwnd, &((LPPOINT)&outer)[1]);

		// adjust to be relative to the monitor
		outer.left -= monitor->info.rcMonitor.left;
		outer.right -= monitor->info.rcMonitor.left;
		outer.top -= monitor->info.rcMonitor.top;
		outer.bottom -= monitor->info.rcMonitor.top;
	}

	// compute outer rect -- full screen version
	else
	{
		calc_fullscreen_margins(window, dd->primarydesc.dwWidth, dd->primarydesc.dwHeight, &outer);
	}

	// if we're respecting the aspect ratio, we need to adjust to fit
	dstwidth = rect_width(&outer);
	dstheight = rect_height(&outer);
	if (!video_config.hwstretch)
	{
		// trim the source if necessary
		if (rect_width(&outer) < srcwidth)
		{
			source.left += (srcwidth - rect_width(&outer)) / 2;
			source.right = source.left + rect_width(&outer);
		}
		if (rect_height(&outer) < srcheight)
		{
			source.top += (srcheight - rect_height(&outer)) / 2;
			source.bottom = source.top + rect_height(&outer);
		}

		// match the destination and source sizes
		dstwidth = srcwidth = source.right - source.left;
		dstheight = srcheight = source.bottom - source.top;
	}
	else if (video_config.keepaspect)
	{
		// compute the appropriate visible area
		render_target_compute_visible_area(window->target, rect_width(&outer), rect_height(&outer), winvideo_monitor_get_aspect(monitor), render_target_get_orientation(window->target), &dstwidth, &dstheight);
	}

	// center within
	dest.left = outer.left + (rect_width(&outer) - dstwidth) / 2;
	dest.right = dest.left + dstwidth;
	dest.top = outer.top + (rect_height(&outer) - dstheight) / 2;
	dest.bottom = dest.top + dstheight;

	// compare against last destination; if different, force a redraw
	if (dest.left != dd->lastdest.left || dest.right != dd->lastdest.right || dest.top != dd->lastdest.top || dest.bottom != dd->lastdest.bottom)
	{
		dd->lastdest = dest;
		update_outer_rects(dd);
	}

	// clear outer rects if we need to
	if (dd->clearouter != 0)
	{
		dd->clearouter--;

		// clear the left edge
		if (dest.left > outer.left)
		{
			clear = outer;
			clear.right = dest.left;
			result = IDirectDrawSurface_Blt(target, &clear, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &blitfx);
			if (result != DD_OK) mame_printf_verbose("DirectDraw: Error %08X clearing the screen\n", (int)result);
		}

		// clear the right edge
		if (dest.right < outer.right)
		{
			clear = outer;
			clear.left = dest.right;
			result = IDirectDrawSurface_Blt(target, &clear, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &blitfx);
			if (result != DD_OK) mame_printf_verbose("DirectDraw: Error %08X clearing the screen\n", (int)result);
		}

		// clear the top edge
		if (dest.top > outer.top)
		{
			clear = outer;
			clear.bottom = dest.top;
			result = IDirectDrawSurface_Blt(target, &clear, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &blitfx);
			if (result != DD_OK) mame_printf_verbose("DirectDraw: Error %08X clearing the screen\n", (int)result);
		}

		// clear the bottom edge
		if (dest.bottom < outer.bottom)
		{
			clear = outer;
			clear.top = dest.bottom;
			result = IDirectDrawSurface_Blt(target, &clear, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &blitfx);
			if (result != DD_OK) mame_printf_verbose("DirectDraw: Error %08X clearing the screen\n", (int)result);
		}
	}

	// do the blit
	result = IDirectDrawSurface7_Blt(target, &dest, dd->blit, &source, DDBLT_WAIT, NULL);
	if (result != DD_OK) mame_printf_verbose("DirectDraw: Error %08X blitting to the screen\n", (int)result);

	// page flip if triple buffered
	if (window->fullscreen && dd->back != NULL)
	{
		result = IDirectDrawSurface7_Flip(dd->primary, NULL, DDFLIP_WAIT);
		if (result != DD_OK) mame_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result);
	}
}
Example #22
0
static void compute_blit_surface_size(win_window_info *window)
{
	dd_info *dd = window->drawdata;
	INT32 newwidth, newheight;
	int xscale, yscale;
	RECT client;

	// start with the minimum size
	render_target_get_minimum_size(window->target, &newwidth, &newheight);

	// get the window's client rectangle
	GetClientRect(window->hwnd, &client);

	// hardware stretch case: apply prescale
	if (video_config.hwstretch)
	{
		int prescale = (video_config.prescale < 1) ? 1 : video_config.prescale;

		// clamp the prescale to something smaller than the target bounds
		xscale = prescale;
		while (xscale > 1 && newwidth * xscale > rect_width(&client))
			xscale--;
		yscale = prescale;
		while (yscale > 1 && newheight * yscale > rect_height(&client))
			yscale--;
	}

	// non stretch case
	else
	{
		INT32 target_width = rect_width(&client);
		INT32 target_height = rect_height(&client);
		float desired_aspect = 1.0f;

		// compute the appropriate visible area if we're trying to keepaspect
		if (video_config.keepaspect)
		{
			win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL);
			render_target_compute_visible_area(window->target, target_width, target_height, winvideo_monitor_get_aspect(monitor), render_target_get_orientation(window->target), &target_width, &target_height);
			desired_aspect = (float)target_width / (float)target_height;
		}

		// compute maximum integral scaling to fit the window
		xscale = (target_width + 2) / newwidth;
		yscale = (target_height + 2) / newheight;

		// try a little harder to keep the aspect ratio if desired
		if (video_config.keepaspect)
		{
			// if we could stretch more in the X direction, and that makes a better fit, bump the xscale
			while (newwidth * (xscale + 1) <= rect_width(&client) &&
				better_mode(newwidth * xscale, newheight * yscale, newwidth * (xscale + 1), newheight * yscale, desired_aspect))
				xscale++;

			// if we could stretch more in the Y direction, and that makes a better fit, bump the yscale
			while (newheight * (yscale + 1) <= rect_height(&client) &&
				better_mode(newwidth * xscale, newheight * yscale, newwidth * xscale, newheight * (yscale + 1), desired_aspect))
				yscale++;

			// now that we've maxed out, see if backing off the maximally stretched one makes a better fit
			if (rect_width(&client) - newwidth * xscale < rect_height(&client) - newheight * yscale)
			{
				while (xscale > 1 && better_mode(newwidth * xscale, newheight * yscale, newwidth * (xscale - 1), newheight * yscale, desired_aspect))
					xscale--;
			}
			else
			{
				while (yscale > 1 && better_mode(newwidth * xscale, newheight * yscale, newwidth * xscale, newheight * (yscale - 1), desired_aspect))
					yscale--;
			}
		}
	}

	// ensure at least a scale factor of 1
	if (xscale == 0) xscale = 1;
	if (yscale == 0) yscale = 1;

	// apply the final scale
	newwidth *= xscale;
	newheight *= yscale;
	if (newwidth != dd->blitwidth || newheight != dd->blitheight)
	{
		// force some updates
		update_outer_rects(dd);
		mame_printf_verbose("DirectDraw: New blit size = %dx%d\n", newwidth, newheight);
	}
	dd->blitwidth = newwidth;
	dd->blitheight = newheight;
}
Example #23
0
static void set_fullscreen(win_window_info *window, int fullscreen)
{
	assert(GetCurrentThreadId() == window_threadid);

	// if we're in the right state, punt
	if (window->fullscreen == fullscreen)
		return;
	window->fullscreen = fullscreen;

	// kill off the drawers
	(*draw.window_destroy)(window);

	// hide ourself
	ShowWindow(window->hwnd, SW_HIDE);

	// configure the window if non-fullscreen
	if (!fullscreen)
	{
		// adjust the style
		SetWindowLong(window->hwnd, GWL_STYLE, WINDOW_STYLE);
		SetWindowLong(window->hwnd, GWL_EXSTYLE, WINDOW_STYLE_EX);
		SetWindowPos(window->hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);

		// force to the bottom, then back on top
		SetWindowPos(window->hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
		SetWindowPos(window->hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

		// if we have previous non-fullscreen bounds, use those
		if (window->non_fullscreen_bounds.right != window->non_fullscreen_bounds.left)
		{
			SetWindowPos(window->hwnd, HWND_TOP, window->non_fullscreen_bounds.left, window->non_fullscreen_bounds.top,
						rect_width(&window->non_fullscreen_bounds), rect_height(&window->non_fullscreen_bounds),
						SWP_NOZORDER);
		}

		// otherwise, set a small size and maximize from there
		else
		{
			SetWindowPos(window->hwnd, HWND_TOP, 0, 0, MIN_WINDOW_DIM, MIN_WINDOW_DIM, SWP_NOZORDER);
			maximize_window(window);
		}
	}

	// configure the window if fullscreen
	else
	{
		// save the bounds
		GetWindowRect(window->hwnd, &window->non_fullscreen_bounds);

		// adjust the style
		SetWindowLong(window->hwnd, GWL_STYLE, FULLSCREEN_STYLE);
		SetWindowLong(window->hwnd, GWL_EXSTYLE, FULLSCREEN_STYLE_EX);
		SetWindowPos(window->hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);

		// set topmost
		SetWindowPos(window->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
	}

	// adjust the window to compensate for the change
	adjust_window_position_after_major_change(window);

	// show ourself
	if (!window->fullscreen || window->fullscreen_safe)
	{
		if (video_config.mode != VIDEO_MODE_NONE)
			ShowWindow(window->hwnd, SW_SHOW);
		if ((*draw.window_init)(window))
			exit(1);
	}

	// ensure we're still adjusted correctly
	adjust_window_position_after_major_change(window);
}
Example #24
0
void gui_widget_set_width(gui_widget_t* widget, graphics_size_t width)
{
    gui_widget_resize(widget, width, rect_height(&widget->rect));
}
static inline bool rect_isempty(struct omap3epfb_update_area *a)
{
        return (rect_width(a)<=0) || (rect_height(a)<=0);
}
static int process_area(int index, struct fb_info *info, struct omap3epfb_area *area, struct omap3epfb_update_area *p)
{
	struct omap3epfb_par *par = info->par;
	int change = 0;

	if (!(area->effect_flags & (EFFECT_ONESHOT | EFFECT_ACTIVE | EFFECT_CLEAR)))
		return change;

	if (!rect_inside(&area->effect_area, p))
	{
		DEBUG_REGION(DEBUG_LEVEL5, p,"no match 0x%02x region %d = ", area->effect_flags, index);
		return change;
	}

	if (area->effect_flags & EFFECT_ONESHOT)
	{
		p->wvfid = area->effect_area.wvfid;
		p->threshold = area->effect_area.threshold;
		DEBUG_REGION(DEBUG_LEVEL2, p,"process ONESHOT region %d = ", index);
		if (area->effect_flags & EFFECT_REGION)
		{
			p->x0 = area->effect_area.x0;
			p->y0 = area->effect_area.y0;
			p->x1 = area->effect_area.x1;
			p->y1 = area->effect_area.y1;
		}
		par->effect_array[index].effect_flags = 0;
		change = 1;
	}
	else if (area->effect_flags & EFFECT_ACTIVE)
	{
		p->wvfid = area->effect_area.wvfid;
		p->threshold = area->effect_area.threshold;
		DEBUG_REGION(DEBUG_LEVEL2, p,"process ACTIVE region %d = ", index);
		change = 1;
		if (p->wvfid == OMAP3EPFB_WVFID_AUTO)
		{
			// Calculate the percentage of the screen that needs an update.
			int percent = ((rect_width(p) * rect_height(p) * 100)) /
			      ((info->var.xres-1) * (info->var.yres-1));

			// Check if we need to do a GC of the whole screen
			if ((par->refresh_percent > 0) && (percent >= par->refresh_percent))
			{
				DEBUG_REGION(DEBUG_LEVEL1, p,"process ACTIVE %d%% region %d = ", percent, index);
				p->x0 = p->y0 = 0;
				p->x1 = info->var.xres-1;
				p->y1 = info->var.yres-1;
				p->wvfid = OMAP3EPFB_WVFID_GC;
				p->threshold = 0;
			}
		}
		else
		{
			if (area->effect_flags & EFFECT_REGION)
			{
				p->x0 = area->effect_area.x0;
				p->y0 = area->effect_area.y0;
				p->x1 = area->effect_area.x1;
				p->y1 = area->effect_area.y1;
			}
		}
	}
	else if ((area->effect_flags & EFFECT_CLEAR) && rect_equal(&area->effect_area, p))
	{
		// Turn the next update of the effect area into a full page flushing update,
		// then clear the effect area.
		// This is used as a hint that a dialog is closing, then we forcing a full screen GC update.
		p->wvfid = area->effect_area.wvfid;
		p->threshold = area->effect_area.threshold;
		DEBUG_REGION(DEBUG_LEVEL2, p,"process RESET region %d = ", index);
		p->x0 = p->y0 = 0;
		p->x1 = info->var.xres-1;
		p->y1 = info->var.yres-1;
		p->wvfid = OMAP3EPFB_WVFID_GC;
		par->effect_array[index].effect_flags = 0;
		change = 1;
	}

	// Update the fast scan flags.
	update_effect(par, index);

	return change;
}
int user_update(struct fb_info *info, struct omap3epfb_update_area *p)
{
	struct omap3epfb_par *par = info->par;
	int percent = 0;
	u32 start_time = 0;

	// Get time of update
	start_time = ktime_to_ms();
	DEBUG_LOG(DEBUG_LEVEL4, "[%u ms] Start user_update\n", start_time);

	// If EPD is disabled, do nothing
	if (par->pgflip_refresh == 1)
	{
		// Tell the caller not to update.
		return 0;
	}

	// If EPD is disabled, do nothing
	if (par->disable_flags > 0)
	{
		DEBUG_REGION(DEBUG_LEVEL3, p,"update DISABLED = ");
		// Tell the caller not to update.
		return 0;
	}
	DEBUG_REGION(DEBUG_LEVEL5, p,"update REQUEST = ");
	
	if (waveform_select(info, p))
	{
		// Tell the caller not to update.
		return 0;
	}

	if (waveform_decompose(info, p))
	{
		// Tell the caller not to update.
		return 0;
	}

	// Calculate the percentage of the screen that needs an update.
	percent = ((rect_width(p) * rect_height(p) * 100)) /
		   ((info->var.xres-1) * (info->var.yres-1));

	// Check if we need to do a GC of the whole screen
	if ((par->refresh_percent > 0) && (percent >= par->refresh_percent))
	{
		// Check again if this needs to be flushing.
		if (buffer_difference_ge_threshold(info, par->refresh_percent))
		{
			DEBUG_REGION(DEBUG_LEVEL1, p,"process FULLSCREEN %d%% AUTO = ", percent);
			p->x0 = p->y0 = 0;
			p->x1 = info->var.xres-1;
			p->y1 = info->var.yres-1;
			p->wvfid = OMAP3EPFB_WVFID_GC;
			p->threshold = 0;
		}
		else
		{
			DEBUG_REGION(DEBUG_LEVEL1, p,"process false FULLSCREEN %d%% AUTO = ", percent);
		}
	}
	else
	{
		DEBUG_REGION(DEBUG_LEVEL1, p,"process AUTO = ");
	}

	batch_update(info, p);

	// Tell the caller not to update.
	return 0;
}
Example #28
0
void run_cpp_recongition(const std::string& classifier_path, const std::string& image_path)
{
	PattCutLib::RecognitionController controller;

	try
	{
		auto classifier_id = controller.load_classifier_from_file(classifier_path);
		std::cout << "Classifier loaded. Classifier id = " << classifier_id.id() << std::endl;

		int time_cum = 0;
		for (int i = 0; i < 10; i++)
		{
			auto res = controller.perform_recognition(image_path);
			std::cout << "total time: " << res.total_time_ms() << std::endl;
			if (res.best_classifier_id() > 0)
			{
				std::cout << "recognized!" << std::endl;
			}
			for (int i = 0; i < res.result_per_classifier(0).areas().size(); i++)
			{
				auto cur_area = res.result_per_classifier(0).areas(i);
				std::cout << "veracity: " << cur_area.veracity() <<
					", wnd_count: " << cur_area.merged_window_count() <<
					", area: [" << cur_area.rect_x() << ", " << cur_area.rect_y() << "; " << cur_area.rect_width() << ", " << cur_area.rect_height() << "]" << std::endl;
			}
			time_cum += res.total_time_ms();
		}
		std::cout << "accumulated time: " << time_cum / 10.0 << std::endl;
	}
	catch (PattCutLib::RecognitionException& exc)
	{
		std::cout << "Error: " << exc.what() << std::endl;
	}
}
Example #29
0
static void constrain_to_aspect_ratio(win_window_info *window, RECT *rect, int adjustment)
{
	win_monitor_info *monitor = winwindow_video_window_monitor(window, rect);
	INT32 extrawidth = wnd_extra_width(window);
	INT32 extraheight = wnd_extra_height(window);
	INT32 propwidth, propheight;
	INT32 minwidth, minheight;
	INT32 maxwidth, maxheight;
	INT32 viswidth, visheight;
	INT32 adjwidth, adjheight;
	float pixel_aspect;

	assert(GetCurrentThreadId() == window_threadid);

	// get the pixel aspect ratio for the target monitor
	pixel_aspect = winvideo_monitor_get_aspect(monitor);

	// determine the proposed width/height
	propwidth = rect_width(rect) - extrawidth;
	propheight = rect_height(rect) - extraheight;

	// based on which edge we are adjusting, take either the width, height, or both as gospel
	// and scale to fit using that as our parameter
	switch (adjustment)
	{
		case WMSZ_BOTTOM:
		case WMSZ_TOP:
			render_target_compute_visible_area(window->target, 10000, propheight, pixel_aspect, render_target_get_orientation(window->target), &propwidth, &propheight);
			break;

		case WMSZ_LEFT:
		case WMSZ_RIGHT:
			render_target_compute_visible_area(window->target, propwidth, 10000, pixel_aspect, render_target_get_orientation(window->target), &propwidth, &propheight);
			break;

		default:
			render_target_compute_visible_area(window->target, propwidth, propheight, pixel_aspect, render_target_get_orientation(window->target), &propwidth, &propheight);
			break;
	}

	// get the minimum width/height for the current layout
	render_target_get_minimum_size(window->target, &minwidth, &minheight);

	// clamp against the absolute minimum
	propwidth = MAX(propwidth, MIN_WINDOW_DIM);
	propheight = MAX(propheight, MIN_WINDOW_DIM);

	// clamp against the minimum width and height
	propwidth = MAX(propwidth, minwidth);
	propheight = MAX(propheight, minheight);

	// clamp against the maximum (fit on one screen for full screen mode)
	if (window->fullscreen)
	{
		maxwidth = rect_width(&monitor->info.rcMonitor) - extrawidth;
		maxheight = rect_height(&monitor->info.rcMonitor) - extraheight;
	}
	else
	{
		maxwidth = rect_width(&monitor->info.rcWork) - extrawidth;
		maxheight = rect_height(&monitor->info.rcWork) - extraheight;

		// further clamp to the maximum width/height in the window
		if (window->maxwidth != 0)
			maxwidth = MIN(maxwidth, window->maxwidth + extrawidth);
		if (window->maxheight != 0)
			maxheight = MIN(maxheight, window->maxheight + extraheight);
	}

	// clamp to the maximum
	propwidth = MIN(propwidth, maxwidth);
	propheight = MIN(propheight, maxheight);

	// compute the visible area based on the proposed rectangle
	render_target_compute_visible_area(window->target, propwidth, propheight, pixel_aspect, render_target_get_orientation(window->target), &viswidth, &visheight);

	// compute the adjustments we need to make
	adjwidth = (viswidth + extrawidth) - rect_width(rect);
	adjheight = (visheight + extraheight) - rect_height(rect);

	// based on which corner we're adjusting, constrain in different ways
	switch (adjustment)
	{
		case WMSZ_BOTTOM:
		case WMSZ_BOTTOMRIGHT:
		case WMSZ_RIGHT:
			rect->right += adjwidth;
			rect->bottom += adjheight;
			break;

		case WMSZ_BOTTOMLEFT:
			rect->left -= adjwidth;
			rect->bottom += adjheight;
			break;

		case WMSZ_LEFT:
		case WMSZ_TOPLEFT:
		case WMSZ_TOP:
			rect->left -= adjwidth;
			rect->top -= adjheight;
			break;

		case WMSZ_TOPRIGHT:
			rect->right += adjwidth;
			rect->top -= adjheight;
			break;
	}
}
Example #30
0
void progressive_display_rect_split_h(struct list* self, struct update_rect* f, struct update_rect* s, bool* remove)
{
  struct xrdp_rect first = f->rect;
  struct xrdp_rect second = s->rect;
  int l = f->quality;
  int w1 = rect_width(&first);
  int h1 = rect_height(&first);
  int w2 = rect_width(&second);
  int h2 = rect_height(&second);
  int send1 = f->quality_already_send;
  int send2 = s->quality_already_send;
  int area1 = w1 * h1;
  int area2 = w2 * h2;
  *remove = false;
  if (first.top < second.top)
  {
    if (first.bottom < second.bottom)
    {
      int temp_area = (first.right - second.left) * (first.bottom - second.top);
      if (temp_area > area1 && temp_area > area2)
      {
        list_add_progressive_display_rect(self, first.left, first.top, first.right, second.top, l, send1);
        list_add_progressive_display_rect(self, second.left, second.top, first.right, first.bottom, l, send2);
        list_add_progressive_display_rect(self, second.left, first.bottom, second.right, second.bottom, l, send2);
        *remove = true;
      }
    }
    else if (first.bottom > second.bottom)
    {
      int temp_area = (first.right - second.left) * (second.bottom - second.top);
      if (temp_area > area1 && temp_area > area2)
      {
        list_add_progressive_display_rect(self, first.left, first.top, first.right, second.top, l, send1);
        list_add_progressive_display_rect(self, second.left, second.top, first.right, second.bottom, l, send2);
        list_add_progressive_display_rect(self, first.left, second.bottom, first.right, first.bottom, l, send1);
        *remove = true;
      }
    }
    else
    {
      int temp_area = (first.right - second.left) * (second.bottom - second.top);
      if (temp_area > area1 && temp_area > area2)
      {
        list_add_progressive_display_rect(self, first.left, first.top, first.right, second.top, l, send1);
        list_add_progressive_display_rect(self, second.left, second.top, first.right, second.bottom, l, send2);
        *remove = true;
      }
    }
  }
  else if (first.top > second.top)
  {
    if (first.bottom < second.bottom)
    {
      int temp_area = (first.right - second.left) * (first.bottom - first.top);
      if (temp_area > area1 && temp_area > area2)
      {
        list_add_progressive_display_rect(self, second.left, second.top, second.right, first.top, l, send2);
        list_add_progressive_display_rect(self, second.left, first.top, first.right, first.bottom, l, send1);
        list_add_progressive_display_rect(self, second.left, first.bottom, second.right, second.bottom, l, send2);
        *remove = true;
      }
    }
    else if (first.bottom > second.bottom)
    {
      int temp_area = (first.right - second.left) * (second.bottom - first.top);
      if (temp_area > area1 && temp_area > area2)
      {
        list_add_progressive_display_rect(self, second.left, second.top, second.right, first.top, l, send2);
        list_add_progressive_display_rect(self, second.left, first.top, first.right, second.bottom, l, send2);
        list_add_progressive_display_rect(self, first.left, second.bottom, first.right, first.bottom, l, send1);
        *remove = true;
      }
    }
    else
    {
      int temp_area = (first.right - second.left) * (second.bottom - first.top);
      if (temp_area > area1 && temp_area > area2)
      {
        list_add_progressive_display_rect(self, second.left, second.top, second.right, first.top, l, send2);
        list_add_progressive_display_rect(self, second.left, first.top, first.right, first.bottom, l, send1);
        *remove = true;
      }
    }
  }
  else
  {
    if (first.bottom < second.bottom)
    {
      int temp_area = (first.right - second.left) * (first.bottom - first.top);
      if (temp_area > area1 && temp_area > area2)
      {
        list_add_progressive_display_rect(self, second.left, first.top, first.right, first.bottom, l, send1);
        list_add_progressive_display_rect(self, second.left, first.bottom, second.right, second.bottom, l, send2);
        *remove = true;
      }
    }
    else if (first.bottom > second.bottom)
    {
      int temp_area = (first.right - second.left) * (second.bottom - first.top);
      if (temp_area > area1 && temp_area > area2)
      {
        list_add_progressive_display_rect(self, second.left, second.top, first.right, second.bottom, l, send2);
        list_add_progressive_display_rect(self, first.left, second.bottom, first.right, first.bottom, l, send1);
        *remove = true;
      }
    }
  }
}