more cleanup

This commit is contained in:
David Rose 2009-09-10 00:00:53 +00:00
parent 205a478b9d
commit f340a4ea3f
3 changed files with 18 additions and 19 deletions

View File

@ -918,7 +918,6 @@ splash_button_clicked() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void P3DInstance:: void P3DInstance::
scan_app_desc_file(TiXmlDocument *doc) { scan_app_desc_file(TiXmlDocument *doc) {
cerr << "scan_app_desc_file\n";
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
TiXmlElement *xpackage = doc->FirstChildElement("package"); TiXmlElement *xpackage = doc->FirstChildElement("package");
@ -1285,6 +1284,7 @@ make_splash_window() {
set_background_image(IT_download); set_background_image(IT_download);
// Go get the required images. // Go get the required images.
bool any_standard_images = false;
for (int i = 0; i < (int)IT_none; ++i) { for (int i = 0; i < (int)IT_none; ++i) {
string token_keyword = string(_image_type_names[i]) + "_img"; string token_keyword = string(_image_type_names[i]) + "_img";
if (!_fparams.has_token(token_keyword)) { if (!_fparams.has_token(token_keyword)) {
@ -1292,11 +1292,7 @@ make_splash_window() {
// image. We do this via the P3DPackage interface, so we can // image. We do this via the P3DPackage interface, so we can
// use the cached version on disk if it's good. // use the cached version on disk if it's good.
_image_files[i]._use_standard_image = true; _image_files[i]._use_standard_image = true;
if (_image_package == NULL) { any_standard_images = true;
P3DHost *host = inst_mgr->get_host(PANDA_PACKAGE_HOST_URL);
_image_package = host->get_package("images", "");
_image_package->add_instance(this);
}
} else { } else {
// We have an explicit image specified for this slot, so just // We have an explicit image specified for this slot, so just
@ -1321,6 +1317,16 @@ make_splash_window() {
start_download(download); start_download(download);
} }
} }
if (any_standard_images) {
// If any of the images requires an image from the standard image
// package, go get that package.
if (_image_package == NULL) {
P3DHost *host = inst_mgr->get_host(PANDA_PACKAGE_HOST_URL);
_image_package = host->get_package("images", "");
_image_package->add_instance(this);
}
}
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -211,6 +211,7 @@ begin_info_download() {
if (_info_ready) { if (_info_ready) {
// Already downloaded. // Already downloaded.
report_info_ready();
return; return;
} }

View File

@ -167,6 +167,10 @@ read_image_data(ImageData &image, string &data,
image._num_channels = 0; image._num_channels = 0;
data.clear(); data.clear();
if (image_filename.empty()) {
return false;
}
// We only support JPEG or PNG images. // We only support JPEG or PNG images.
FILE *fp = fopen(image_filename.c_str(), "rb"); FILE *fp = fopen(image_filename.c_str(), "rb");
if (fp == NULL) { if (fp == NULL) {
@ -283,7 +287,6 @@ read_image_data_jpeg(ImageData &image, string &data,
bool P3DSplashWindow:: bool P3DSplashWindow::
read_image_data_png(ImageData &image, string &data, read_image_data_png(ImageData &image, string &data,
FILE *fp, const string &image_filename) { FILE *fp, const string &image_filename) {
cerr << "read_image_data_png\n";
png_structp png; png_structp png;
png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
png_error, png_warning); png_error, png_warning);
@ -320,29 +323,20 @@ read_image_data_png(ImageData &image, string &data,
png_get_IHDR(png, info, &width, &height, png_get_IHDR(png, info, &width, &height,
&bit_depth, &color_type, NULL, NULL, NULL); &bit_depth, &color_type, NULL, NULL, NULL);
cerr
<< "width = " << width << " height = " << height << " bit_depth = "
<< bit_depth << " color_type = " << color_type << "\n";
image._width = width; image._width = width;
image._height = height; image._height = height;
switch (color_type) { switch (color_type) {
case PNG_COLOR_TYPE_RGB: case PNG_COLOR_TYPE_RGB:
cerr
<< "PNG_COLOR_TYPE_RGB\n";
image._num_channels = 3; image._num_channels = 3;
break; break;
case PNG_COLOR_TYPE_RGB_ALPHA: case PNG_COLOR_TYPE_RGB_ALPHA:
cerr
<< "PNG_COLOR_TYPE_RGB_ALPHA\n";
image._num_channels = 4; image._num_channels = 4;
break; break;
default: default:
cerr nout << "Unsupported color type: " << color_type << "\n";
<< "Unsupported color type: " << color_type << "\n";
png_destroy_read_struct(&png, &info, NULL); png_destroy_read_struct(&png, &info, NULL);
return false; return false;
} }
@ -354,8 +348,6 @@ read_image_data_png(ImageData &image, string &data,
} }
png_destroy_read_struct(&png, &info, NULL); png_destroy_read_struct(&png, &info, NULL);
cerr << "successfully read\n";
return true; return true;
} }