mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-17 20:23:47 -04:00
fix problem with cached movie textures and textures-power-2
This commit is contained in:
parent
b765ec473e
commit
c4cdae59e0
@ -2028,6 +2028,20 @@ rescale_texture() {
|
||||
return do_rescale_texture();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::adjust_this_size
|
||||
// Access: Public
|
||||
// Description: Works like adjust_size, but also considers the
|
||||
// texture class. Movie textures, for instance, always
|
||||
// pad outwards, regardless of textures-power-2.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Texture::
|
||||
adjust_this_size(int &x_size, int &y_size, const string &name,
|
||||
bool for_padding) {
|
||||
MutexHolder holder(_lock);
|
||||
return do_adjust_this_size(x_size, y_size, name, for_padding);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::do_get_ram_image_size
|
||||
// Access: Protected
|
||||
|
@ -2634,6 +2634,19 @@ void Texture::
|
||||
reconsider_dirty() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::do_adjust_this_size
|
||||
// Access: Protected, Virtual
|
||||
// Description: Works like adjust_size, but also considers the
|
||||
// texture class. Movie textures, for instance, always
|
||||
// pad outwards, regardless of textures-power-2.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Texture::
|
||||
do_adjust_this_size(int &x_size, int &y_size, const string &name,
|
||||
bool for_padding) {
|
||||
return adjust_size(x_size, y_size, name, for_padding);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::do_read
|
||||
// Access: Protected, Virtual
|
||||
@ -3067,7 +3080,7 @@ do_read_one(const Filename &fullpath, const Filename &alpha_fullpath,
|
||||
if (get_textures_power_2() == ATS_pad) {
|
||||
int new_x_size = image.get_x_size();
|
||||
int new_y_size = image.get_y_size();
|
||||
if (adjust_size(new_x_size, new_y_size, fullpath.get_basename(), true)) {
|
||||
if (do_adjust_this_size(new_x_size, new_y_size, fullpath.get_basename(), true)) {
|
||||
pad_x_size = new_x_size - image.get_x_size();
|
||||
pad_y_size = new_y_size - image.get_y_size();
|
||||
PNMImage new_image(new_x_size, new_y_size, image.get_num_channels(),
|
||||
@ -3877,7 +3890,7 @@ do_reload_ram_image(bool allow_compression) {
|
||||
// changed, and we want a different-sized texture now.
|
||||
int x_size = _orig_file_x_size;
|
||||
int y_size = _orig_file_y_size;
|
||||
Texture::adjust_size(x_size, y_size, _filename.get_basename(), true);
|
||||
do_adjust_this_size(x_size, y_size, _filename.get_basename(), true);
|
||||
if (x_size != tex->get_x_size() || y_size != tex->get_y_size()) {
|
||||
if (gobj_cat.is_debug()) {
|
||||
gobj_cat.debug()
|
||||
@ -4423,7 +4436,7 @@ do_rescale_texture() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (adjust_size(new_x_size, new_y_size, get_name(), false)) {
|
||||
if (do_adjust_this_size(new_x_size, new_y_size, get_name(), false)) {
|
||||
// OK, we have to scale the image.
|
||||
PNMImage orig_image;
|
||||
if (!do_store_one(orig_image, 0, 0)) {
|
||||
@ -4454,7 +4467,7 @@ do_rescale_texture() {
|
||||
if (get_textures_power_2() == ATS_pad) {
|
||||
new_x_size = _x_size;
|
||||
new_y_size = _y_size;
|
||||
if (adjust_size(new_x_size, new_y_size, get_name(), true)) {
|
||||
if (do_adjust_this_size(new_x_size, new_y_size, get_name(), true)) {
|
||||
pad_x_size = new_x_size - _x_size;
|
||||
pad_y_size = new_y_size - _y_size;
|
||||
|
||||
|
@ -490,6 +490,8 @@ public:
|
||||
|
||||
static bool adjust_size(int &x_size, int &y_size, const string &name,
|
||||
bool for_padding);
|
||||
INLINE bool adjust_this_size(int &x_size, int &y_size, const string &name,
|
||||
bool for_padding);
|
||||
|
||||
protected:
|
||||
virtual void reconsider_dirty();
|
||||
@ -501,6 +503,8 @@ protected:
|
||||
// All of these assume the lock is already held; generally, they
|
||||
// also avoid adjusting the _properties_modified and _image_modified
|
||||
// semaphores.
|
||||
virtual bool do_adjust_this_size(int &x_size, int &y_size, const string &name,
|
||||
bool for_padding);
|
||||
|
||||
virtual bool do_read(const Filename &fullpath, const Filename &alpha_fullpath,
|
||||
int primary_file_num_channels, int alpha_file_channel,
|
||||
|
@ -1092,7 +1092,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename,
|
||||
compressed_cache_record = (tex->get_ram_image_compression() != Texture::CM_off);
|
||||
int x_size = tex->get_orig_file_x_size();
|
||||
int y_size = tex->get_orig_file_y_size();
|
||||
Texture::adjust_size(x_size, y_size, filename.get_basename(), true);
|
||||
tex->adjust_this_size(x_size, y_size, filename.get_basename(), true);
|
||||
|
||||
if (!cache->get_cache_textures() && !compressed_cache_record) {
|
||||
// We're not supposed to be caching uncompressed textures.
|
||||
|
@ -154,10 +154,7 @@ do_reconsider_video_properties(const FFMpegTexture::VideoStream &stream,
|
||||
int x_size = width;
|
||||
int y_size = height;
|
||||
|
||||
if (Texture::get_textures_power_2() != ATS_none) {
|
||||
x_size = up_to_power_2(width);
|
||||
y_size = up_to_power_2(height);
|
||||
}
|
||||
do_adjust_this_size(x_size, y_size, get_name(), true);
|
||||
|
||||
if (grutil_cat.is_debug()) {
|
||||
grutil_cat.debug()
|
||||
@ -312,6 +309,24 @@ update_frame(int frame) {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FFMpegTexture::do_adjust_this_size
|
||||
// Access: Protected, Virtual
|
||||
// Description: Works like adjust_size, but also considers the
|
||||
// texture class. Movie textures, for instance, always
|
||||
// pad outwards, never scale down.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool FFMpegTexture::
|
||||
do_adjust_this_size(int &x_size, int &y_size, const string &name,
|
||||
bool for_padding) {
|
||||
if (Texture::get_textures_power_2() != ATS_none) {
|
||||
x_size = up_to_power_2(x_size);
|
||||
y_size = up_to_power_2(y_size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FFMpegTexture::do_read_one
|
||||
// Access: Protected, Virtual
|
||||
@ -476,13 +491,6 @@ make_from_bam(const FactoryParams ¶ms) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FFMpegTexture::
|
||||
do_write_datagram_rawdata(BamWriter *manager, Datagram &me) {
|
||||
me.add_uint32(_x_size);
|
||||
me.add_uint32(_y_size);
|
||||
me.add_uint32(_z_size);
|
||||
me.add_uint8(_component_type);
|
||||
me.add_uint8(_component_width);
|
||||
me.add_uint8(_ram_image_compression);
|
||||
|
||||
me.add_uint16(_pages.size());
|
||||
for (size_t n = 0; n < _pages.size(); ++n) {
|
||||
VideoPage &page = _pages[n];
|
||||
@ -498,14 +506,6 @@ do_write_datagram_rawdata(BamWriter *manager, Datagram &me) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FFMpegTexture::
|
||||
do_fillin_rawdata(DatagramIterator &scan, BamReader *manager) {
|
||||
_x_size = scan.get_uint32();
|
||||
_y_size = scan.get_uint32();
|
||||
_z_size = scan.get_uint32();
|
||||
_component_type = (ComponentType)scan.get_uint8();
|
||||
_component_width = scan.get_uint8();
|
||||
_ram_image_compression = CM_off;
|
||||
_ram_image_compression = (CompressionMode)scan.get_uint8();
|
||||
|
||||
int num_pages = scan.get_uint16();
|
||||
_pages.clear();
|
||||
for (int n = 0; n < num_pages; ++n) {
|
||||
@ -521,7 +521,6 @@ do_fillin_rawdata(DatagramIterator &scan, BamReader *manager) {
|
||||
}
|
||||
|
||||
_loaded_from_image = true;
|
||||
do_set_pad_size(0, 0, 0);
|
||||
++_image_modified;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@ protected:
|
||||
void do_assign(const FFMpegTexture ©);
|
||||
|
||||
virtual void update_frame(int frame);
|
||||
virtual bool do_adjust_this_size(int &x_size, int &y_size, const string &name,
|
||||
bool for_padding);
|
||||
virtual bool do_read_one(const Filename &fullpath, const Filename &alpha_fullpath,
|
||||
int z, int n, int primary_file_num_channels, int alpha_file_channel,
|
||||
const LoaderOptions &options,
|
||||
|
@ -171,17 +171,8 @@ do_recalculate_image_properties(CDWriter &cdata, const LoaderOptions &options) {
|
||||
cdata->_video_width = x_max;
|
||||
cdata->_video_height = y_max;
|
||||
cdata->_video_length = len;
|
||||
|
||||
if (_texture_type == TT_cube_map) {
|
||||
// Texture must be square.
|
||||
if (x_max > y_max) y_max = x_max;
|
||||
if (y_max > x_max) x_max = y_max;
|
||||
}
|
||||
|
||||
if (Texture::get_textures_power_2() != ATS_none) {
|
||||
x_max = up_to_power_2(x_max);
|
||||
y_max = up_to_power_2(y_max);
|
||||
}
|
||||
do_adjust_this_size(x_max, y_max, get_name(), true);
|
||||
|
||||
do_reconsider_image_properties(x_max, y_max, alpha?4:3,
|
||||
T_unsigned_byte, cdata->_pages.size(),
|
||||
@ -194,6 +185,29 @@ do_recalculate_image_properties(CDWriter &cdata, const LoaderOptions &options) {
|
||||
0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MovieTexture::do_adjust_this_size
|
||||
// Access: Protected, Virtual
|
||||
// Description: Works like adjust_size, but also considers the
|
||||
// texture class. Movie textures, for instance, always
|
||||
// pad outwards, never scale down.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool MovieTexture::
|
||||
do_adjust_this_size(int &x_size, int &y_size, const string &name,
|
||||
bool for_padding) {
|
||||
if (_texture_type == TT_cube_map) {
|
||||
// Texture must be square.
|
||||
x_size = y_size = max(x_size, y_size);
|
||||
}
|
||||
|
||||
if (Texture::get_textures_power_2() != ATS_none) {
|
||||
x_size = up_to_power_2(x_size);
|
||||
y_size = up_to_power_2(y_size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MovieTexture::do_read_one
|
||||
// Access: Protected, Virtual
|
||||
|
@ -73,6 +73,10 @@ protected:
|
||||
virtual bool get_keep_ram_image() const;
|
||||
virtual bool do_has_bam_rawdata() const;
|
||||
virtual void do_get_bam_rawdata();
|
||||
|
||||
virtual bool do_adjust_this_size(int &x_size, int &y_size, const string &name,
|
||||
bool for_padding);
|
||||
|
||||
virtual bool do_read_one(const Filename &fullpath, const Filename &alpha_fullpath,
|
||||
int z, int n, int primary_file_num_channels, int alpha_file_channel,
|
||||
const LoaderOptions &options,
|
||||
|
Loading…
x
Reference in New Issue
Block a user