From c9114fb40de777f6bd70e40b920bd4f75e0317ed Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 1 Dec 2009 07:35:26 +0000 Subject: [PATCH] expose consider_rescale() --- panda/src/gobj/texture.cxx | 56 ++++++++++++++++++++++++-------------- panda/src/gobj/texture.h | 4 ++- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index b349d649b4..11f059a1f5 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -1643,6 +1643,42 @@ down_to_power_2(int value) { return (1 << bit); } +//////////////////////////////////////////////////////////////////// +// Function: Texture::consider_rescale +// Access: Published +// Description: Asks the PNMImage to change its scale when it reads +// the image, according to the whims of the Config.prc +// file. +// +// This method should be called after +// pnmimage.read_header() has been called, but before +// pnmimage.read(). +//////////////////////////////////////////////////////////////////// +void Texture:: +consider_rescale(PNMImage &pnmimage) { + consider_rescale(pnmimage, get_name()); +} + +//////////////////////////////////////////////////////////////////// +// Function: Texture::consider_rescale +// Access: Published, Static +// Description: Asks the PNMImage to change its scale when it reads +// the image, according to the whims of the Config.prc +// file. +// +// This method should be called after +// pnmimage.read_header() has been called, but before +// pnmimage.read(). +//////////////////////////////////////////////////////////////////// +void Texture:: +consider_rescale(PNMImage &pnmimage, const string &name) { + int new_x_size = pnmimage.get_x_size(); + int new_y_size = pnmimage.get_y_size(); + if (adjust_size(new_x_size, new_y_size, name)) { + pnmimage.set_read_size(new_x_size, new_y_size); + } +} + //////////////////////////////////////////////////////////////////// // Function: Texture::texture_uploaded @@ -5294,26 +5330,6 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::consider_rescale -// Access: Private, Static -// Description: Asks the PNMImage to change its scale when it reads -// the image, according to the whims of the Config.prc -// file. -// -// This method should be called after -// pnmimage.read_header() has been called, but before -// pnmimage.read(). -//////////////////////////////////////////////////////////////////// -void Texture:: -consider_rescale(PNMImage &pnmimage, const string &name) { - int new_x_size = pnmimage.get_x_size(); - int new_y_size = pnmimage.get_y_size(); - if (adjust_size(new_x_size, new_y_size, name)) { - pnmimage.set_read_size(new_x_size, new_y_size); - } -} - //////////////////////////////////////////////////////////////////// // Function: Texture::consider_downgrade // Access: Private, Static diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 2b4dd7e52b..558d0ce8ce 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -438,6 +438,9 @@ PUBLISHED: static int up_to_power_2(int value); static int down_to_power_2(int value); + void consider_rescale(PNMImage &pnmimage); + static void consider_rescale(PNMImage &pnmimage, const string &name); + public: void texture_uploaded(); @@ -600,7 +603,6 @@ private: void clear_prepared(PreparedGraphicsObjects *prepared_objects); - static void consider_rescale(PNMImage &pnmimage, const string &name); static void consider_downgrade(PNMImage &pnmimage, int num_channels, const string &name); static bool compare_images(const PNMImage &a, const PNMImage &b);