protect against zero-sized windows

This commit is contained in:
David Rose 2012-01-15 17:56:49 +00:00
parent eb4b58eade
commit 38a73900f1
4 changed files with 18 additions and 2 deletions

View File

@ -296,7 +296,19 @@ has_size() const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE bool GraphicsOutput:: INLINE bool GraphicsOutput::
is_valid() const { is_valid() const {
return _is_valid; return _is_valid && _is_nonzero_size;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsOutput::is_nonzero_size
// Access: Published
// Description: Returns true if the output has a nonzero size in both
// X and Y, or false if it is zero (and therefore
// invalid).
////////////////////////////////////////////////////////////////////
INLINE bool GraphicsOutput::
is_nonzero_size() const {
return _is_nonzero_size;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -97,6 +97,7 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe,
_y_size = win_prop.get_y_size(); _y_size = win_prop.get_y_size();
} }
_is_valid = false; _is_valid = false;
_is_nonzero_size = false;
_flip_ready = false; _flip_ready = false;
_cube_map_index = -1; _cube_map_index = -1;
_cube_map_dr = NULL; _cube_map_dr = NULL;
@ -1207,6 +1208,8 @@ set_size_and_recalc(int x, int y) {
_y_size = y; _y_size = y;
_has_size = true; _has_size = true;
_is_nonzero_size = (_x_size > 0 && _y_size > 0);
int fb_x_size = get_fb_x_size(); int fb_x_size = get_fb_x_size();
int fb_y_size = get_fb_y_size(); int fb_y_size = get_fb_y_size();

View File

@ -123,6 +123,7 @@ PUBLISHED:
INLINE int get_sbs_right_y_size() const; INLINE int get_sbs_right_y_size() const;
INLINE bool has_size() const; INLINE bool has_size() const;
INLINE bool is_valid() const; INLINE bool is_valid() const;
INLINE bool is_nonzero_size() const;
void set_active(bool active); void set_active(bool active);
virtual bool is_active() const; virtual bool is_active() const;
@ -356,6 +357,7 @@ protected:
int _y_size; int _y_size;
bool _has_size; bool _has_size;
bool _is_valid; bool _is_valid;
bool _is_nonzero_size;
static PStatCollector _make_current_pcollector; static PStatCollector _make_current_pcollector;
static PStatCollector _copy_texture_pcollector; static PStatCollector _copy_texture_pcollector;

View File

@ -1168,7 +1168,6 @@ consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool wdxGraphicsWindow9:: bool wdxGraphicsWindow9::
reset_device_resize_window(UINT new_xsize, UINT new_ysize) { reset_device_resize_window(UINT new_xsize, UINT new_ysize) {
nassertr((new_xsize > 0) && (new_ysize > 0), false);
bool retval = true; bool retval = true;
DXScreenData *screen = NULL; DXScreenData *screen = NULL;