74 typedef PT(
Texture) MakeTextureFunc();
129 F_luminance_alphamask,
177 enum DeprecatedFilterType {
178 FT_nearest = SamplerState::FT_nearest,
179 FT_linear = SamplerState::FT_linear,
180 FT_nearest_mipmap_nearest = SamplerState::FT_nearest_mipmap_nearest,
181 FT_linear_mipmap_nearest = SamplerState::FT_linear_mipmap_nearest,
182 FT_nearest_mipmap_linear = SamplerState::FT_nearest_mipmap_linear,
183 FT_linear_mipmap_linear = SamplerState::FT_linear_mipmap_linear,
184 FT_shadow = SamplerState::FT_shadow,
185 FT_default = SamplerState::FT_default,
186 FT_invalid = SamplerState::FT_invalid
188 typedef SamplerState::FilterType FilterType;
191 enum DeprecatedWrapMode {
192 WM_clamp = SamplerState::WM_clamp,
193 WM_repeat = SamplerState::WM_repeat,
194 WM_mirror = SamplerState::WM_mirror,
195 WM_mirror_once = SamplerState::WM_mirror_once,
196 WM_border_color = SamplerState::WM_border_color,
197 WM_invalid = SamplerState::WM_invalid
199 typedef SamplerState::WrapMode WrapMode;
201 enum CompressionMode {
234 explicit Texture(
const std::string &name = std::string());
238 void operator = (
const Texture ©);
243 INLINE PT(
Texture) make_copy()
const;
246 INLINE
void setup_texture(TextureType texture_type,
247 int x_size,
int y_size,
int z_size,
248 ComponentType component_type, Format format);
249 INLINE
void setup_1d_texture();
250 INLINE
void setup_1d_texture(
int x_size,
251 ComponentType component_type, Format format);
252 INLINE
void setup_2d_texture();
253 INLINE
void setup_2d_texture(
int x_size,
int y_size,
254 ComponentType component_type, Format format);
255 INLINE
void setup_3d_texture(
int z_size = 1);
256 INLINE
void setup_3d_texture(
int x_size,
int y_size,
int z_size,
257 ComponentType component_type, Format format);
258 INLINE
void setup_cube_map();
259 INLINE
void setup_cube_map(
int size,
260 ComponentType component_type, Format format);
261 INLINE
void setup_2d_texture_array(
int z_size = 1);
262 INLINE
void setup_2d_texture_array(
int x_size,
int y_size,
int z_size,
263 ComponentType component_type, Format format);
264 INLINE
void setup_cube_map_array(
int num_cube_maps);
265 INLINE
void setup_cube_map_array(
int size,
int num_cube_maps,
266 ComponentType component_type, Format format);
267 INLINE
void setup_buffer_texture(
int size, ComponentType component_type,
268 Format format, GeomEnums::UsageHint usage);
269 void generate_normalization_cube_map(
int size);
270 void generate_alpha_scale_map();
272 INLINE
void clear_image();
273 INLINE
bool has_clear_color()
const;
274 INLINE LColor get_clear_color()
const;
275 INLINE
void set_clear_color(
const LColor &color);
276 INLINE
void clear_clear_color();
277 INLINE vector_uchar get_clear_data()
const;
278 MAKE_PROPERTY2(clear_color, has_clear_color, get_clear_color,
279 set_clear_color, clear_clear_color);
282 BLOCKING
bool read(
const Filename &fullpath,
const Filename &alpha_fullpath,
283 int primary_file_num_channels,
int alpha_file_channel,
285 BLOCKING
bool read(
const Filename &fullpath,
int z,
int n,
286 bool read_pages,
bool read_mipmaps,
288 BLOCKING
bool read(
const Filename &fullpath,
const Filename &alpha_fullpath,
289 int primary_file_num_channels,
int alpha_file_channel,
290 int z,
int n,
bool read_pages,
bool read_mipmaps,
294 BLOCKING INLINE
bool write(
const Filename &fullpath);
295 BLOCKING INLINE
bool write(
const Filename &fullpath,
int z,
int n,
296 bool write_pages,
bool write_mipmaps);
298 BLOCKING
bool read_txo(std::istream &in,
const std::string &filename =
"");
299 BLOCKING
static PT(
Texture) make_from_txo(std::istream &in,
const std::string &filename =
"");
300 BLOCKING
bool write_txo(std::ostream &out,
const std::string &filename =
"")
const;
301 BLOCKING
bool read_dds(std::istream &in,
const std::string &filename =
"",
bool header_only =
false);
302 BLOCKING
bool read_ktx(std::istream &in,
const std::string &filename =
"",
bool header_only =
false);
308 BLOCKING INLINE
bool load_sub_image(
const PNMImage &pnmimage,
int x,
int y,
int z=0,
int n=0);
309 BLOCKING INLINE
bool store(
PNMImage &pnmimage)
const;
310 BLOCKING INLINE
bool store(
PNMImage &pnmimage,
int z,
int n)
const;
311 BLOCKING INLINE
bool store(
PfmFile &pfm)
const;
312 BLOCKING INLINE
bool store(
PfmFile &pfm,
int z,
int n)
const;
314 BLOCKING INLINE
bool reload();
317 INLINE
bool has_filename()
const;
318 INLINE
const Filename &get_filename()
const;
319 INLINE
void set_filename(
const Filename &filename);
320 INLINE
void clear_filename();
321 MAKE_PROPERTY2(filename, has_filename, get_filename, set_filename, clear_filename);
323 INLINE
bool has_alpha_filename()
const;
324 INLINE
const Filename &get_alpha_filename()
const;
325 INLINE
void set_alpha_filename(
const Filename &alpha_filename);
326 INLINE
void clear_alpha_filename();
327 MAKE_PROPERTY2(alpha_filename, has_alpha_filename, get_alpha_filename, set_alpha_filename, clear_alpha_filename);
329 INLINE
bool has_fullpath()
const;
330 INLINE
const Filename &get_fullpath()
const;
331 INLINE
void set_fullpath(
const Filename &fullpath);
332 INLINE
void clear_fullpath();
333 MAKE_PROPERTY2(fullpath, has_fullpath, get_fullpath, set_fullpath, clear_fullpath);
335 INLINE
bool has_alpha_fullpath()
const;
336 INLINE
const Filename &get_alpha_fullpath()
const;
337 INLINE
void set_alpha_fullpath(
const Filename &alpha_fullpath);
338 INLINE
void clear_alpha_fullpath();
339 MAKE_PROPERTY2(alpha_fullpath, has_alpha_fullpath, get_alpha_fullpath, set_alpha_fullpath, clear_alpha_fullpath);
341 INLINE
int get_x_size()
const;
342 INLINE
void set_x_size(
int x_size);
343 MAKE_PROPERTY(x_size, get_x_size, set_x_size);
345 INLINE
int get_y_size()
const;
346 INLINE
void set_y_size(
int y_size);
347 MAKE_PROPERTY(y_size, get_y_size, set_y_size);
349 INLINE
int get_z_size()
const;
350 INLINE
void set_z_size(
int z_size);
351 MAKE_PROPERTY(z_size, get_z_size, set_z_size);
353 INLINE
int get_num_views()
const;
354 INLINE
void set_num_views(
int num_views);
355 MAKE_PROPERTY(num_views, get_num_views, set_num_views);
357 INLINE
int get_num_pages()
const;
358 INLINE
int get_num_components()
const;
359 INLINE
int get_component_width()
const;
360 INLINE TextureType get_texture_type()
const;
361 INLINE GeomEnums::UsageHint get_usage_hint()
const;
363 MAKE_PROPERTY(num_pages, get_num_pages);
364 MAKE_PROPERTY(num_components, get_num_components);
365 MAKE_PROPERTY(component_width, get_component_width);
366 MAKE_PROPERTY(texture_type, get_texture_type);
367 MAKE_PROPERTY(usage_hint, get_usage_hint);
369 INLINE Format get_format()
const;
370 INLINE
void set_format(Format format);
371 MAKE_PROPERTY(format, get_format, set_format);
373 INLINE ComponentType get_component_type()
const;
374 INLINE
void set_component_type(ComponentType component_type);
375 MAKE_PROPERTY(component_type, get_component_type, set_component_type);
377 INLINE SamplerState::WrapMode get_wrap_u()
const;
378 INLINE
void set_wrap_u(WrapMode wrap);
379 MAKE_PROPERTY(wrap_u, get_wrap_u, set_wrap_u);
381 INLINE SamplerState::WrapMode get_wrap_v()
const;
382 INLINE
void set_wrap_v(WrapMode wrap);
383 MAKE_PROPERTY(wrap_v, get_wrap_v, set_wrap_v);
385 INLINE SamplerState::WrapMode get_wrap_w()
const;
386 INLINE
void set_wrap_w(WrapMode wrap);
387 MAKE_PROPERTY(wrap_w, get_wrap_w, set_wrap_w);
389 INLINE SamplerState::FilterType get_minfilter()
const;
390 INLINE SamplerState::FilterType get_effective_minfilter()
const;
391 INLINE
void set_minfilter(FilterType filter);
392 MAKE_PROPERTY(minfilter, get_minfilter, set_minfilter);
393 MAKE_PROPERTY(effective_minfilter, get_effective_minfilter);
395 INLINE SamplerState::FilterType get_magfilter()
const;
396 INLINE SamplerState::FilterType get_effective_magfilter()
const;
397 INLINE
void set_magfilter(FilterType filter);
398 MAKE_PROPERTY(magfilter, get_magfilter, set_magfilter);
399 MAKE_PROPERTY(effective_magfilter, get_effective_magfilter);
401 INLINE
int get_anisotropic_degree()
const;
402 INLINE
int get_effective_anisotropic_degree()
const;
403 INLINE
void set_anisotropic_degree(
int anisotropic_degree);
404 MAKE_PROPERTY(anisotropic_degree, get_anisotropic_degree, set_anisotropic_degree);
405 MAKE_PROPERTY(effective_anisotropic_degree, get_effective_anisotropic_degree);
407 INLINE LColor get_border_color()
const;
408 INLINE
void set_border_color(
const LColor &color);
409 MAKE_PROPERTY(border_color, get_border_color, set_border_color);
411 INLINE
bool has_compression()
const;
412 INLINE CompressionMode get_compression()
const;
413 INLINE
void set_compression(CompressionMode compression);
414 MAKE_PROPERTY(compression, get_compression, set_compression);
416 INLINE
bool get_render_to_texture()
const;
417 INLINE
void set_render_to_texture(
bool render_to_texture);
418 MAKE_PROPERTY(render_to_texture, get_render_to_texture, set_render_to_texture);
421 INLINE
void set_default_sampler(
const SamplerState &sampler);
422 MAKE_PROPERTY(default_sampler, get_default_sampler, set_default_sampler);
423 INLINE
bool uses_mipmaps()
const;
425 INLINE QualityLevel get_quality_level()
const;
426 INLINE QualityLevel get_effective_quality_level()
const;
427 INLINE
void set_quality_level(QualityLevel quality_level);
428 MAKE_PROPERTY(quality_level, get_quality_level, set_quality_level);
429 MAKE_PROPERTY(effective_quality_level, get_effective_quality_level);
431 INLINE
int get_expected_num_mipmap_levels()
const;
432 INLINE
int get_expected_mipmap_x_size(
int n)
const;
433 INLINE
int get_expected_mipmap_y_size(
int n)
const;
434 INLINE
int get_expected_mipmap_z_size(
int n)
const;
435 INLINE
int get_expected_mipmap_num_pages(
int n)
const;
436 MAKE_PROPERTY(expected_num_mipmap_levels, get_expected_num_mipmap_levels);
438 INLINE
bool has_ram_image()
const;
439 INLINE
bool has_uncompressed_ram_image()
const;
440 INLINE
bool might_have_ram_image()
const;
441 INLINE
size_t get_ram_image_size()
const;
442 INLINE
size_t get_ram_view_size()
const;
443 INLINE
size_t get_ram_page_size()
const;
444 INLINE
size_t get_expected_ram_image_size()
const;
445 INLINE
size_t get_expected_ram_page_size()
const;
446 MAKE_PROPERTY(ram_image_size, get_ram_image_size);
447 MAKE_PROPERTY(ram_view_size, get_ram_view_size);
448 MAKE_PROPERTY(ram_page_size, get_ram_page_size);
449 MAKE_PROPERTY(expected_ram_image_size, get_expected_ram_image_size);
450 MAKE_PROPERTY(expected_ram_page_size, get_expected_ram_page_size);
453 INLINE CompressionMode get_ram_image_compression()
const;
454 INLINE
CPTA_uchar get_uncompressed_ram_image();
455 CPTA_uchar get_ram_image_as(
const std::string &requested_format);
456 INLINE PTA_uchar modify_ram_image();
457 INLINE PTA_uchar make_ram_image();
459 INLINE
void set_ram_image(
CPTA_uchar image, CompressionMode compression = CM_off,
460 size_t page_size = 0);
461 void set_ram_image_as(
CPTA_uchar image,
const std::string &provided_format);
463 EXTEND
void set_ram_image(PyObject *image, CompressionMode compression = CM_off,
464 size_t page_size = 0);
465 EXTEND
void set_ram_image_as(PyObject *image,
const std::string &provided_format);
467 INLINE
void clear_ram_image();
468 INLINE
void set_keep_ram_image(
bool keep_ram_image);
469 virtual bool get_keep_ram_image()
const;
470 virtual bool is_cacheable()
const;
472 MAKE_PROPERTY(ram_image_compression, get_ram_image_compression);
473 MAKE_PROPERTY(keep_ram_image, get_keep_ram_image, set_keep_ram_image);
474 MAKE_PROPERTY(cacheable, is_cacheable);
476 EXTENSION(PT(
Texture) __deepcopy__(PyObject *memo)
const);
478 BLOCKING INLINE
bool compress_ram_image(CompressionMode compression = CM_on,
479 QualityLevel quality_level = QL_default,
481 BLOCKING INLINE
bool uncompress_ram_image();
483 INLINE
int get_num_ram_mipmap_images()
const;
484 INLINE
bool has_ram_mipmap_image(
int n)
const;
485 int get_num_loadable_ram_mipmap_images()
const;
486 INLINE
bool has_all_ram_mipmap_images()
const;
487 INLINE
size_t get_ram_mipmap_image_size(
int n)
const;
488 INLINE
size_t get_ram_mipmap_view_size(
int n)
const;
489 INLINE
size_t get_ram_mipmap_page_size(
int n)
const;
490 INLINE
size_t get_expected_ram_mipmap_image_size(
int n)
const;
491 INLINE
size_t get_expected_ram_mipmap_view_size(
int n)
const;
492 INLINE
size_t get_expected_ram_mipmap_page_size(
int n)
const;
494 void *get_ram_mipmap_pointer(
int n)
const;
495 INLINE PTA_uchar modify_ram_mipmap_image(
int n);
496 INLINE PTA_uchar make_ram_mipmap_image(
int n);
497 void set_ram_mipmap_pointer(
int n,
void *image,
size_t page_size = 0);
498 void set_ram_mipmap_pointer_from_int(
long long pointer,
int n,
int page_size);
499 INLINE
void set_ram_mipmap_image(
int n,
CPTA_uchar image,
size_t page_size = 0);
500 void clear_ram_mipmap_image(
int n);
501 INLINE
void clear_ram_mipmap_images();
502 INLINE
void generate_ram_mipmap_images();
504 MAKE_PROPERTY(num_ram_mipmap_images, get_num_ram_mipmap_images);
505 MAKE_PROPERTY(num_loadable_ram_mipmap_images, get_num_loadable_ram_mipmap_images);
507 INLINE
int get_simple_x_size()
const;
508 INLINE
int get_simple_y_size()
const;
509 INLINE
bool has_simple_ram_image()
const;
510 INLINE
size_t get_simple_ram_image_size()
const;
511 INLINE
CPTA_uchar get_simple_ram_image()
const;
512 INLINE
void set_simple_ram_image(
CPTA_uchar image,
int x_size,
int y_size);
513 PTA_uchar modify_simple_ram_image();
514 PTA_uchar new_simple_ram_image(
int x_size,
int y_size);
515 void generate_simple_ram_image();
516 INLINE
void clear_simple_ram_image();
518 MAKE_PROPERTY(simple_x_size, get_simple_x_size);
519 MAKE_PROPERTY(simple_y_size, get_simple_y_size);
520 MAKE_PROPERTY2(simple_ram_image, has_simple_ram_image, get_simple_ram_image);
524 INLINE
UpdateSeq get_properties_modified()
const;
525 INLINE
UpdateSeq get_image_modified()
const;
526 INLINE
UpdateSeq get_simple_image_modified()
const;
527 MAKE_PROPERTY(properties_modified, get_properties_modified);
528 MAKE_PROPERTY(image_modified, get_image_modified);
529 MAKE_PROPERTY(simple_image_modified, get_simple_image_modified);
531 INLINE
bool has_auto_texture_scale()
const;
532 INLINE AutoTextureScale get_auto_texture_scale()
const;
533 INLINE
void set_auto_texture_scale(AutoTextureScale scale);
534 MAKE_PROPERTY(auto_texture_scale, get_auto_texture_scale,
535 set_auto_texture_scale);
547 void write(std::ostream &out,
int indent_level)
const;
549 size_t estimate_texture_memory()
const;
552 void clear_aux_data(
const std::string &key);
554 MAKE_MAP_PROPERTY(aux_data, get_aux_data, get_aux_data,
555 set_aux_data, clear_aux_data);
557 INLINE
static void set_textures_power_2(AutoTextureScale scale);
558 INLINE
static AutoTextureScale get_textures_power_2();
559 INLINE
static bool has_textures_power_2();
563 INLINE
int get_pad_x_size()
const;
564 INLINE
int get_pad_y_size()
const;
565 INLINE
int get_pad_z_size()
const;
566 INLINE LVecBase2 get_tex_scale()
const;
568 INLINE
void set_pad_size(
int x=0,
int y=0,
int z=0);
569 void set_size_padded(
int x=1,
int y=1,
int z=1);
571 INLINE
int get_orig_file_x_size()
const;
572 INLINE
int get_orig_file_y_size()
const;
573 INLINE
int get_orig_file_z_size()
const;
575 MAKE_PROPERTY(orig_file_x_size, get_orig_file_x_size);
576 MAKE_PROPERTY(orig_file_y_size, get_orig_file_y_size);
577 MAKE_PROPERTY(orig_file_z_size, get_orig_file_z_size);
579 void set_orig_file_size(
int x,
int y,
int z = 1);
581 INLINE
void set_loaded_from_image(
bool flag =
true);
582 INLINE
bool get_loaded_from_image()
const;
583 MAKE_PROPERTY(loaded_from_image, get_loaded_from_image, set_loaded_from_image);
585 INLINE
void set_loaded_from_txo(
bool flag =
true);
586 INLINE
bool get_loaded_from_txo()
const;
587 MAKE_PROPERTY(loaded_from_txo, get_loaded_from_txo, set_loaded_from_txo);
589 INLINE
bool get_match_framebuffer_format()
const;
590 INLINE
void set_match_framebuffer_format(
bool flag);
591 MAKE_PROPERTY(match_framebuffer_format, get_match_framebuffer_format,
592 set_match_framebuffer_format);
594 INLINE
bool get_post_load_store_cache()
const;
595 INLINE
void set_post_load_store_cache(
bool flag);
596 MAKE_PROPERTY(post_load_store_cache, get_post_load_store_cache,
597 set_post_load_store_cache);
603 static int up_to_power_2(
int value);
604 static int down_to_power_2(
int value);
606 void consider_rescale(
PNMImage &pnmimage);
607 static void consider_rescale(
PNMImage &pnmimage,
const std::string &name, AutoTextureScale auto_texture_scale = ATS_unspecified);
608 INLINE
bool rescale_texture();
610 static std::string format_texture_type(TextureType tt);
611 static TextureType string_texture_type(
const std::string &str);
613 static std::string format_component_type(ComponentType ct);
614 static ComponentType string_component_type(
const std::string &str);
616 static std::string format_format(Format f);
617 static Format string_format(
const std::string &str);
619 static std::string format_compression_mode(CompressionMode cm);
620 static CompressionMode string_compression_mode(
const std::string &str);
622 static std::string format_quality_level(QualityLevel tql);
623 static QualityLevel string_quality_level(
const std::string &str);
626 void texture_uploaded();
628 virtual bool has_cull_callback()
const;
631 static PT(
Texture) make_texture();
634 static bool is_unsigned(ComponentType ctype);
635 static bool is_specific(CompressionMode compression);
636 static bool has_alpha(Format format);
637 static bool has_binary_alpha(Format format);
638 static bool is_srgb(Format format);
639 static bool is_integer(Format format);
641 static bool adjust_size(
int &x_size,
int &y_size,
const std::string &name,
642 bool for_padding, AutoTextureScale auto_texture_scale = ATS_unspecified);
643 INLINE
bool adjust_this_size(
int &x_size,
int &y_size,
const std::string &name,
644 bool for_padding)
const;
646 virtual void ensure_loader_type(
const Filename &filename);
652 virtual void reconsider_dirty();
661 virtual bool do_adjust_this_size(
const CData *cdata,
662 int &x_size,
int &y_size,
const std::string &name,
663 bool for_padding)
const;
665 virtual bool do_read(CData *cdata,
667 int primary_file_num_channels,
int alpha_file_channel,
668 int z,
int n,
bool read_pages,
bool read_mipmaps,
670 virtual bool do_read_one(CData *cdata,
672 int z,
int n,
int primary_file_num_channels,
int alpha_file_channel,
675 virtual bool do_load_one(CData *cdata,
676 const PNMImage &pnmimage,
const std::string &name,
678 virtual bool do_load_one(CData *cdata,
679 const PfmFile &pfm,
const std::string &name,
681 virtual bool do_load_sub_image(CData *cdata,
const PNMImage &image,
682 int x,
int y,
int z,
int n);
683 bool do_read_txo_file(CData *cdata,
const Filename &fullpath);
684 bool do_read_txo(CData *cdata, std::istream &in,
const std::string &filename);
685 bool do_read_dds_file(CData *cdata,
const Filename &fullpath,
bool header_only);
686 bool do_read_dds(CData *cdata, std::istream &in,
const std::string &filename,
bool header_only);
687 bool do_read_ktx_file(CData *cdata,
const Filename &fullpath,
bool header_only);
688 bool do_read_ktx(CData *cdata, std::istream &in,
const std::string &filename,
bool header_only);
690 bool do_write(CData *cdata,
const Filename &fullpath,
int z,
int n,
691 bool write_pages,
bool write_mipmaps);
692 bool do_write_one(CData *cdata,
const Filename &fullpath,
int z,
int n);
693 bool do_store_one(CData *cdata,
PNMImage &pnmimage,
int z,
int n);
694 bool do_store_one(CData *cdata,
PfmFile &pfm,
int z,
int n);
695 bool do_write_txo_file(
const CData *cdata,
const Filename &fullpath)
const;
696 bool do_write_txo(
const CData *cdata, std::ostream &out,
const std::string &filename)
const;
698 virtual CData *unlocked_ensure_ram_image(
bool allow_compression);
699 virtual void do_reload_ram_image(CData *cdata,
bool allow_compression);
701 PTA_uchar do_modify_ram_image(CData *cdata);
702 PTA_uchar do_make_ram_image(CData *cdata);
703 void do_set_ram_image(CData *cdata,
CPTA_uchar image,
704 CompressionMode compression = CM_off,
size_t page_size = 0);
705 PTA_uchar do_modify_ram_mipmap_image(CData *cdata,
int n);
706 PTA_uchar do_make_ram_mipmap_image(CData *cdata,
int n);
707 void do_set_ram_mipmap_image(CData *cdata,
int n,
CPTA_uchar image,
size_t page_size);
708 size_t do_get_clear_data(
const CData *cdata,
unsigned char *into)
const;
710 bool consider_auto_process_ram_image(
bool generate_mipmaps,
bool allow_compression);
711 bool do_consider_auto_process_ram_image(CData *cdata,
bool generate_mipmaps,
712 bool allow_compression);
713 bool do_compress_ram_image(CData *cdata, CompressionMode compression,
714 QualityLevel quality_level,
716 bool do_uncompress_ram_image(CData *cdata);
718 static void do_compress_ram_image_bc4(
const RamImage &src, RamImage &dest,
719 int x_size,
int y_size,
int z_size);
720 static void do_compress_ram_image_bc5(
const RamImage &src, RamImage &dest,
721 int x_size,
int y_size,
int z_size);
722 static void do_uncompress_ram_image_bc4(
const RamImage &src, RamImage &dest,
723 int x_size,
int y_size,
int z_size);
724 static void do_uncompress_ram_image_bc5(
const RamImage &src, RamImage &dest,
725 int x_size,
int y_size,
int z_size);
726 bool do_has_all_ram_mipmap_images(
const CData *cdata)
const;
728 bool do_reconsider_z_size(CData *cdata,
int z,
const LoaderOptions &options);
729 virtual void do_allocate_pages(CData *cdata);
730 bool do_reconsider_image_properties(CData *cdata,
731 int x_size,
int y_size,
int num_components,
732 ComponentType component_type,
int z,
734 bool do_rescale_texture(CData *cdata);
736 virtual PT(
Texture) make_copy_impl()
const;
737 PT(
Texture) do_make_copy(
const CData *cdata)
const;
738 void do_assign(CData *cdata,
const Texture *copy,
const CData *cdata_copy);
739 virtual void do_clear(CData *cdata);
740 void do_setup_texture(CData *cdata,
741 TextureType texture_type,
int x_size,
int y_size,
742 int z_size, ComponentType component_type,
744 void do_set_num_views(CData *cdata,
int num_views);
745 void do_set_format(CData *cdata, Format format);
746 void do_set_component_type(CData *cdata, ComponentType component_type);
747 void do_set_x_size(CData *cdata,
int x_size);
748 void do_set_y_size(CData *cdata,
int y_size);
749 void do_set_z_size(CData *cdata,
int z_size);
751 void do_set_wrap_u(CData *cdata, WrapMode wrap);
752 void do_set_wrap_v(CData *cdata, WrapMode wrap);
753 void do_set_wrap_w(CData *cdata, WrapMode wrap);
754 void do_set_minfilter(CData *cdata, FilterType filter);
755 void do_set_magfilter(CData *cdata, FilterType filter);
756 void do_set_anisotropic_degree(CData *cdata,
int anisotropic_degree);
757 void do_set_border_color(CData *cdata,
const LColor &color);
758 void do_set_compression(CData *cdata, CompressionMode compression);
759 void do_set_quality_level(CData *cdata, QualityLevel quality_level);
761 bool do_has_compression(
const CData *cdata)
const;
762 virtual bool do_has_ram_image(
const CData *cdata)
const;
763 virtual bool do_has_uncompressed_ram_image(
const CData *cdata)
const;
765 CPTA_uchar do_get_uncompressed_ram_image(CData *cdata);
766 void do_set_simple_ram_image(CData *cdata,
CPTA_uchar image,
int x_size,
int y_size);
767 INLINE
size_t do_get_ram_image_size(
const CData *cdata)
const;
768 INLINE
bool do_has_ram_mipmap_image(
const CData *cdata,
int n)
const;
769 int do_get_expected_num_mipmap_levels(
const CData *cdata)
const;
770 INLINE
size_t do_get_expected_ram_image_size(
const CData *cdata)
const;
771 INLINE
size_t do_get_expected_ram_view_size(
const CData *cdata)
const;
772 INLINE
size_t do_get_expected_ram_page_size(
const CData *cdata)
const;
773 size_t do_get_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
774 INLINE
size_t do_get_expected_ram_mipmap_image_size(
const CData *cdata,
int n)
const;
775 INLINE
size_t do_get_expected_ram_mipmap_view_size(
const CData *cdata,
int n)
const;
776 INLINE
size_t do_get_expected_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
777 int do_get_expected_mipmap_x_size(
const CData *cdata,
int n)
const;
778 int do_get_expected_mipmap_y_size(
const CData *cdata,
int n)
const;
779 int do_get_expected_mipmap_z_size(
const CData *cdata,
int n)
const;
780 INLINE
int do_get_expected_mipmap_num_pages(
const CData *cdata,
int n)
const;
781 INLINE
void do_clear_ram_image(CData *cdata);
782 void do_clear_simple_ram_image(CData *cdata);
783 void do_clear_ram_mipmap_images(CData *cdata);
784 void do_generate_ram_mipmap_images(CData *cdata,
bool allow_recompress);
785 void do_set_pad_size(CData *cdata,
int x,
int y,
int z);
786 virtual bool do_can_reload(
const CData *cdata)
const;
787 bool do_reload(CData *cdata);
789 INLINE AutoTextureScale do_get_auto_texture_scale(
const CData *cdata)
const;
791 virtual bool do_has_bam_rawdata(
const CData *cdata)
const;
792 virtual void do_get_bam_rawdata(CData *cdata);
804 void *_pointer_image;
808 static void convert_from_pnmimage(PTA_uchar &image,
size_t page_size,
809 int row_stride,
int x,
int y,
int z,
811 int num_components,
int component_width);
812 static void convert_from_pfm(PTA_uchar &image,
size_t page_size,
814 int num_components,
int component_width);
815 static bool convert_to_pnmimage(
PNMImage &pnmimage,
int x_size,
int y_size,
817 ComponentType component_type,
bool is_srgb,
820 static bool convert_to_pfm(
PfmFile &pfm,
int x_size,
int y_size,
821 int num_components,
int component_width,
824 static PTA_uchar read_dds_level_bgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
825 int n, std::istream &in);
826 static PTA_uchar read_dds_level_rgb8(
Texture *tex, CData *cdata,
const DDSHeader &header,
827 int n, std::istream &in);
828 static PTA_uchar read_dds_level_abgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
829 int n, std::istream &in);
830 static PTA_uchar read_dds_level_rgba8(
Texture *tex, CData *cdata,
const DDSHeader &header,
831 int n, std::istream &in);
832 static PTA_uchar read_dds_level_abgr16(
Texture *tex, CData *cdata,
const DDSHeader &header,
833 int n, std::istream &in);
834 static PTA_uchar read_dds_level_abgr32(
Texture *tex, CData *cdata,
const DDSHeader &header,
835 int n, std::istream &in);
836 static PTA_uchar read_dds_level_raw(
Texture *tex, CData *cdata,
const DDSHeader &header,
837 int n, std::istream &in);
838 static PTA_uchar read_dds_level_generic_uncompressed(
Texture *tex, CData *cdata,
839 const DDSHeader &header,
840 int n, std::istream &in);
841 static PTA_uchar read_dds_level_luminance_uncompressed(
Texture *tex, CData *cdata,
842 const DDSHeader &header,
843 int n, std::istream &in);
844 static PTA_uchar read_dds_level_bc1(
Texture *tex, CData *cdata,
845 const DDSHeader &header,
846 int n, std::istream &in);
847 static PTA_uchar read_dds_level_bc2(
Texture *tex, CData *cdata,
848 const DDSHeader &header,
849 int n, std::istream &in);
850 static PTA_uchar read_dds_level_bc3(
Texture *tex, CData *cdata,
851 const DDSHeader &header,
852 int n, std::istream &in);
853 static PTA_uchar read_dds_level_bc4(
Texture *tex, CData *cdata,
854 const DDSHeader &header,
855 int n, std::istream &in);
856 static PTA_uchar read_dds_level_bc5(
Texture *tex, CData *cdata,
857 const DDSHeader &header,
858 int n, std::istream &in);
862 static void consider_downgrade(
PNMImage &pnmimage,
int num_channels,
const std::string &name);
866 INLINE
static void store_unscaled_byte(
unsigned char *&p,
int value);
867 INLINE
static void store_unscaled_short(
unsigned char *&p,
int value);
868 INLINE
static void store_scaled_byte(
unsigned char *&p,
int value,
double scale);
869 INLINE
static void store_scaled_short(
unsigned char *&p,
int value,
double scale);
870 INLINE
static double get_unsigned_byte(
const unsigned char *&p);
871 INLINE
static double get_unsigned_short(
const unsigned char *&p);
872 INLINE
static double get_unsigned_int(
const unsigned char *&p);
873 INLINE
static double get_unsigned_int_24(
const unsigned char *&p);
874 INLINE
static double get_float(
const unsigned char *&p);
875 INLINE
static double get_half_float(
const unsigned char *&p);
877 INLINE
static bool is_txo_filename(
const Filename &fullpath);
878 INLINE
static bool is_dds_filename(
const Filename &fullpath);
879 INLINE
static bool is_ktx_filename(
const Filename &fullpath);
881 void do_filter_2d_mipmap_pages(
const CData *cdata,
882 RamImage &to,
const RamImage &from,
883 int x_size,
int y_size)
const;
885 void do_filter_3d_mipmap_level(
const CData *cdata,
886 RamImage &to,
const RamImage &from,
887 int x_size,
int y_size,
int z_size)
const;
889 typedef void Filter2DComponent(
unsigned char *&p,
890 const unsigned char *&q,
891 size_t pixel_size,
size_t row_size);
893 typedef void Filter3DComponent(
unsigned char *&p,
894 const unsigned char *&q,
895 size_t pixel_size,
size_t row_size,
898 static void filter_2d_unsigned_byte(
unsigned char *&p,
899 const unsigned char *&q,
900 size_t pixel_size,
size_t row_size);
901 static void filter_2d_unsigned_byte_srgb(
unsigned char *&p,
902 const unsigned char *&q,
903 size_t pixel_size,
size_t row_size);
904 static void filter_2d_unsigned_byte_srgb_sse2(
unsigned char *&p,
905 const unsigned char *&q,
906 size_t pixel_size,
size_t row_size);
907 static void filter_2d_unsigned_short(
unsigned char *&p,
908 const unsigned char *&q,
909 size_t pixel_size,
size_t row_size);
910 static void filter_2d_float(
unsigned char *&p,
const unsigned char *&q,
911 size_t pixel_size,
size_t row_size);
913 static void filter_3d_unsigned_byte(
unsigned char *&p,
914 const unsigned char *&q,
915 size_t pixel_size,
size_t row_size,
917 static void filter_3d_unsigned_byte_srgb(
unsigned char *&p,
918 const unsigned char *&q,
919 size_t pixel_size,
size_t row_size,
921 static void filter_3d_unsigned_byte_srgb_sse2(
unsigned char *&p,
922 const unsigned char *&q,
923 size_t pixel_size,
size_t row_size,
925 static void filter_3d_unsigned_short(
unsigned char *&p,
926 const unsigned char *&q,
927 size_t pixel_size,
size_t row_size,
929 static void filter_3d_float(
unsigned char *&p,
const unsigned char *&q,
930 size_t pixel_size,
size_t row_size,
size_t page_size);
932 bool do_squish(CData *cdata, CompressionMode compression,
int squish_flags);
933 bool do_unsquish(CData *cdata,
int squish_flags);
939 class EXPCL_PANDA_GOBJ CData :
public CycleData {
942 CData(
const CData ©);
943 ALLOC_DELETED_CHAIN(CData);
949 return Texture::get_class_type();
952 void do_assign(
const CData *copy);
953 INLINE
void inc_properties_modified();
954 INLINE
void inc_image_modified();
955 INLINE
void inc_simple_image_modified();
963 int _primary_file_num_channels;
968 int _alpha_file_channel;
975 int _component_width;
976 TextureType _texture_type;
978 ComponentType _component_type;
979 GeomEnums::UsageHint _usage_hint;
981 bool _loaded_from_image;
982 bool _loaded_from_txo;
983 bool _has_read_pages;
984 bool _has_read_mipmaps;
985 int _num_mipmap_levels_read;
988 bool _keep_ram_image;
989 LColor _border_color;
990 CompressionMode _compression;
991 bool _render_to_texture;
992 bool _match_framebuffer_format;
993 bool _post_load_store_cache;
994 QualityLevel _quality_level;
1000 int _orig_file_x_size;
1001 int _orig_file_y_size;
1003 AutoTextureScale _auto_texture_scale;
1004 CompressionMode _ram_image_compression;
1009 RamImages _ram_images;
1013 RamImage _simple_ram_image;
1016 int32_t _simple_image_date_generated;
1019 bool _has_clear_color;
1020 LColor _clear_color;
1028 return _type_handle;
1030 static void init_type() {
1059 PreparedViews _prepared_views;
1067 RelatedTextures _related_textures;
1077 static AutoTextureScale _textures_power_2;
1082 static void register_with_read_factory();
1088 void do_write_datagram_header(CData *cdata,
BamWriter *manager,
Datagram &me,
bool &has_rawdata);
1089 virtual void do_write_datagram_body(CData *cdata,
BamWriter *manager,
Datagram &me);
1090 virtual void do_write_datagram_rawdata(CData *cdata,
BamWriter *manager,
Datagram &me);
1095 virtual void do_fillin_from(CData *cdata,
const Texture *dummy);
1099 return _type_handle;
1101 static void init_type() {
1102 TypedWritableReferenceCount::init_type();
1104 TypedWritableReferenceCount::get_class_type());
1108 return get_class_type();
1110 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}