From f363088cb2a1c4961bb7740f09e4d0fff51a38d6 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 30 Sep 2016 00:21:12 +0200 Subject: [PATCH 1/4] Fix exception when creating intervals before ShowBase is started --- direct/src/showbase/ShowBase.py | 4 ---- direct/src/task/Task.py | 5 ++++- doc/ReleaseNotes | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index e5a9e18bce..e06583423f 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -131,10 +131,6 @@ class ShowBase(DirectObject.DirectObject): ## just before Python is about to shut down. self.finalExitCallbacks = [] - Task.TaskManager.taskTimerVerbose = self.config.GetBool('task-timer-verbose', 0) - Task.TaskManager.extendedExceptions = self.config.GetBool('extended-exceptions', 0) - Task.TaskManager.pStatsTasks = self.config.GetBool('pstats-tasks', 0) - # Set up the TaskManager to reset the PStats clock back # whenever we resume from a pause. This callback function is # a little hacky, but we can't call it directly from within diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index 6d8f38acbd..ba3f50f0b0 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -102,7 +102,10 @@ Task.DtoolClassDict['loop'] = staticmethod(loop) class TaskManager: notify = directNotify.newCategory("TaskManager") - extendedExceptions = False + taskTimerVerbose = ConfigVariableBool('task-timer-verbose', False) + extendedExceptions = ConfigVariableBool('extended-exceptions', False) + pStatsTasks = ConfigVariableBool('pstats-tasks', False) + MaxEpochSpeed = 1.0/30.0 def __init__(self): diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 0728f34023..cdaba3cc7a 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -40,6 +40,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix inoperative -tbn/-tbnall/-tbnauto options in egg-optchar * Fix tinydisplay texture errors on shutdown * Fix mipmap filtering issues in tinydisplay renderer +* Fix exception when creating intervals before ShowBase is started ------------------------ RELEASE 1.9.2 ------------------------ From a973107bd9abba79d25a2494c79a46be2afe68ff Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 10 Oct 2016 10:04:41 +0200 Subject: [PATCH 2/4] Remove duplicate definition of USE_GENERIC_DXERR_LIBRARY in ppremake --- dtool/LocalSetup.pp | 3 --- 1 file changed, 3 deletions(-) diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index cdea47c29f..920e42b979 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -376,9 +376,6 @@ $[cdefine HAVE_CGDX9] /* Define if we have CGDX10 installed. */ $[cdefine HAVE_CGDX10] -/* Define for dxerr.h instead of dxerr9.h. */ -$[cdefine USE_GENERIC_DXERR_LIBRARY] - /* Define if we have zlib installed. */ $[cdefine HAVE_ZLIB] From 7c45e891f5e6c668d6fa0d524e5545894e76f6d5 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 13 Oct 2016 00:16:40 +0200 Subject: [PATCH 3/4] X11: fix .ico cursor bug. Support PNG-compressed .ico files. --- doc/ReleaseNotes | 1 + panda/src/x11display/x11GraphicsWindow.cxx | 231 ++++++++++++--------- 2 files changed, 135 insertions(+), 97 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index cdaba3cc7a..35d25a5dea 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -41,6 +41,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix tinydisplay texture errors on shutdown * Fix mipmap filtering issues in tinydisplay renderer * Fix exception when creating intervals before ShowBase is started +* Fix rare X11 .ico cursor bug; also now supports PNG-compressed icons ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 82a1180cf3..3b18605ac2 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -28,6 +28,8 @@ #include "nativeWindowHandle.h" #include "virtualFileSystem.h" #include "get_x11.h" +#include "pnmImage.h" +#include "pnmFileTypeRegistry.h" #include #include @@ -2303,109 +2305,144 @@ read_ico(istream &ico) { // Seek to the image in the ICO. ico.seekg(entries[entry].offset); if (!ico.good()) goto cleanup; - ico.read(reinterpret_cast(&infoHeader), sizeof(IcoInfoHeader)); - if (!ico.good()) goto cleanup; - bitsPerPixel = infoHeader.bitsPerPixel; - // TODO: Support PNG compressed ICOs. - if (infoHeader.compression != 0) goto cleanup; + if (ico.peek() == 0x89) { + // Hang on, this is actually a PNG header. + PNMImage img; + PNMFileTypeRegistry *reg = PNMFileTypeRegistry::get_global_ptr(); + if (!img.read(ico, "", reg->get_type_from_extension("png"))) { + goto cleanup; + } + img.set_maxval(255); - // Load the color palette, if one exists. - if (bitsPerPixel != 24 && bitsPerPixel != 32) { - colorCount = 1 << bitsPerPixel; - palette = new IcoColor[colorCount]; - ico.read(reinterpret_cast(palette), colorCount * sizeof(IcoColor)); + image = XcursorImageCreate(img.get_x_size(), img.get_y_size()); + + xel *ptr = img.get_array(); + xelval *alpha = img.get_alpha_array(); + size_t num_pixels = (size_t)img.get_x_size() * (size_t)img.get_y_size(); + unsigned int *dest = image->pixels; + + if (alpha != NULL) { + for (size_t p = 0; p < num_pixels; ++p) { + *dest++ = (*alpha << 24U) | (ptr->r << 16U) | (ptr->g << 8U) | (ptr->b); + ++ptr; + ++alpha; + } + } else { + for (size_t p = 0; p < num_pixels; ++p) { + *dest++ = 0xff000000U | (ptr->r << 16U) | (ptr->g << 8U) | (ptr->b); + ++ptr; + } + } + + } else { + ico.read(reinterpret_cast(&infoHeader), sizeof(IcoInfoHeader)); if (!ico.good()) goto cleanup; + bitsPerPixel = infoHeader.bitsPerPixel; + + if (infoHeader.compression != 0) goto cleanup; + + // Load the color palette, if one exists. + if (bitsPerPixel != 24 && bitsPerPixel != 32) { + colorCount = 1 << bitsPerPixel; + palette = new IcoColor[colorCount]; + ico.read(reinterpret_cast(palette), colorCount * sizeof(IcoColor)); + if (!ico.good()) goto cleanup; + } + + // Read in the pixel data. + xorBmpSize = (infoHeader.width * (infoHeader.height / 2) * bitsPerPixel) / 8; + andBmpSize = (infoHeader.width * (infoHeader.height / 2)) / 8; + curXor = xorBmp = new char[xorBmpSize]; + curAnd = andBmp = new char[andBmpSize]; + ico.read(xorBmp, xorBmpSize); + if (!ico.good()) goto cleanup; + ico.read(andBmp, andBmpSize); + if (!ico.good()) goto cleanup; + + image = XcursorImageCreate(infoHeader.width, infoHeader.height / 2); + + // Support all the formats that GIMP supports. + switch (bitsPerPixel) { + case 1: + case 4: + case 8: + // For colors less that a byte wide, shift and mask the palette indices + // off each element of the xorBmp and append them to the image. + mask = ((1 << bitsPerPixel) - 1); + for (i = image->height - 1; i >= 0; i--) { + for (j = 0; j < image->width; j += 8 / bitsPerPixel) { + for (k = 0; k < 8 / bitsPerPixel; k++) { + shift = 8 - ((k + 1) * bitsPerPixel); + color = palette[(*curXor & (mask << shift)) >> shift]; + image->pixels[(i * image->width) + j + k] = (color.red << 16) + + (color.green << 8) + + (color.blue); + } + + curXor++; + } + + // Set the alpha byte properly according to the andBmp. + for (j = 0; j < image->width; j += 8) { + for (k = 0; k < 8; k++) { + shift = 7 - k; + image->pixels[(i * image->width) + j + k] |= + ((*curAnd & (1 << shift)) >> shift) ? 0x0 : (0xff << 24); + } + + curAnd++; + } + } + break; + + case 24: + // Pack each of the three bytes into a single color, BGR -> 0RGB + for (i = image->height - 1; i >= 0; i--) { + for (j = 0; j < image->width; j++) { + image->pixels[(i * image->width) + j] = (*(curXor + 2) << 16) + + (*(curXor + 1) << 8) + (*curXor); + curXor += 3; + } + + // Set the alpha byte properly according to the andBmp. + for (j = 0; j < image->width; j += 8) { + for (k = 0; k < 8; k++) { + shift = 7 - k; + image->pixels[(i * image->width) + j + k] |= + ((*curAnd & (1 << shift)) >> shift) ? 0x0 : (0xff << 24); + } + + curAnd++; + } + } + break; + + case 32: + // Pack each of the four bytes into a single color, BGRA -> ARGB + for (i = image->height - 1; i >= 0; i--) { + for (j = 0; j < image->width; j++) { + image->pixels[(i * image->width) + j] = (*(curXor + 3) << 24) + + (*(curXor + 2) << 16) + + (*(curXor + 1) << 8) + + (*curXor); + curXor += 4; + } + } + break; + + default: + goto cleanup; + } } - // Read in the pixel data. - xorBmpSize = (infoHeader.width * (infoHeader.height / 2) * bitsPerPixel) / 8; - andBmpSize = (infoHeader.width * (infoHeader.height / 2)) / 8; - curXor = xorBmp = new char[xorBmpSize]; - curAnd = andBmp = new char[andBmpSize]; - ico.read(xorBmp, xorBmpSize); - if (!ico.good()) goto cleanup; - ico.read(andBmp, andBmpSize); - if (!ico.good()) goto cleanup; - // If this is an actual CUR not an ICO set up the hotspot properly. - image = XcursorImageCreate(infoHeader.width, infoHeader.height / 2); - if (header.type == 2) { image->xhot = entries[entry].xhot; image->yhot = entries[entry].yhot; } - - // Support all the formats that GIMP supports, minus PNG compressed ICOs. - // Would need to use libpng to decode the compressed ones. - switch (bitsPerPixel) { - case 1: - case 4: - case 8: - // For colors less that a byte wide, shift and mask the palette indices - // off each element of the xorBmp and append them to the image. - mask = ((1 << bitsPerPixel) - 1); - for (i = image->height - 1; i >= 0; i--) { - for (j = 0; j < image->width; j += 8 / bitsPerPixel) { - for (k = 0; k < 8 / bitsPerPixel; k++) { - shift = 8 - ((k + 1) * bitsPerPixel); - color = palette[(*curXor & (mask << shift)) >> shift]; - image->pixels[(i * image->width) + j + k] = (color.red << 16) + - (color.green << 8) + - (color.blue); - } - - curXor++; - } - - // Set the alpha byte properly according to the andBmp. - for (j = 0; j < image->width; j += 8) { - for (k = 0; k < 8; k++) { - shift = 7 - k; - image->pixels[(i * image->width) + j + k] |= - ((*curAnd & (1 << shift)) >> shift) ? 0x0 : (0xff << 24); - } - - curAnd++; - } - } - - break; - case 24: - // Pack each of the three bytes into a single color, BGR -> 0RGB - for (i = image->height - 1; i >= 0; i--) { - for (j = 0; j < image->width; j++) { - image->pixels[(i * image->width) + j] = (*(curXor + 2) << 16) + - (*(curXor + 1) << 8) + (*curXor); - curXor += 3; - } - - // Set the alpha byte properly according to the andBmp. - for (j = 0; j < image->width; j += 8) { - for (k = 0; k < 8; k++) { - shift = 7 - k; - image->pixels[(i * image->width) + j + k] |= - ((*curAnd & (1 << shift)) >> shift) ? 0x0 : (0xff << 24); - } - - curAnd++; - } - - } - - break; - case 32: - // Pack each of the four bytes into a single color, BGRA -> ARGB - for (i = image->height - 1; i >= 0; i--) { - for (j = 0; j < image->width; j++) { - image->pixels[(i * image->width) + j] = (*(curXor + 3) << 24) + - (*(curXor + 2) << 16) + - (*(curXor + 1) << 8) + - (*curXor); - curXor += 4; - } - } - - break; - default: - goto cleanup; - break; + if (header.type == 2) { + image->xhot = entries[entry].xhot; + image->yhot = entries[entry].yhot; + } else { + image->xhot = 0; + image->yhot = 0; } ret = XcursorImageLoadCursor(_display, image); From 955ca0d3340b4786b2be1d2161984cf9813ad27a Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 13 Oct 2016 00:21:03 +0200 Subject: [PATCH 4/4] Fix support for passing keyword arguments to methods named make() such as *Attrib.make() and Shader.make() --- doc/ReleaseNotes | 1 + dtool/src/interrogate/functionRemap.cxx | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 35d25a5dea..da8e24ae0f 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -42,6 +42,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix mipmap filtering issues in tinydisplay renderer * Fix exception when creating intervals before ShowBase is started * Fix rare X11 .ico cursor bug; also now supports PNG-compressed icons +* Add keyword argument support to make() methods such as Shader.make() ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index b2f703c926..f975a57904 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -810,6 +810,11 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak _flags |= F_coerce_constructor; } + if (_args_type == InterfaceMaker::AT_varargs) { + // Of course methods named "make" can still take kwargs. + _args_type = InterfaceMaker::AT_keyword_args; + } + } else if (fname == "operator /") { if (_has_this && _parameters.size() == 2 && TypeManager::is_float(_parameters[1]._remap->get_new_type())) {