19 #include "pandabase.h"
22 #include "typedWritableReferenceCount.h"
24 #include "internalName.h"
25 #include "graphicsStateGuardianBase.h"
26 #include "updateSeq.h"
28 #include "config_gobj.h"
29 #include "pStatCollector.h"
31 #include "mutexHolder.h"
32 #include "conditionVarFull.h"
33 #include "loaderOptions.h"
34 #include "string_utils.h"
35 #include "cycleData.h"
36 #include "cycleDataLockedReader.h"
37 #include "cycleDataReader.h"
38 #include "cycleDataWriter.h"
39 #include "cycleDataStageReader.h"
40 #include "cycleDataStageWriter.h"
41 #include "pipelineCycler.h"
42 #include "samplerState.h"
44 #include "colorSpace.h"
77 typedef PT(
Texture) MakeTextureFunc();
126 F_luminance_alphamask,
159 enum DeprecatedFilterType {
160 FT_nearest = SamplerState::FT_nearest,
161 FT_linear = SamplerState::FT_linear,
162 FT_nearest_mipmap_nearest = SamplerState::FT_nearest_mipmap_nearest,
163 FT_linear_mipmap_nearest = SamplerState::FT_linear_mipmap_nearest,
164 FT_nearest_mipmap_linear = SamplerState::FT_nearest_mipmap_linear,
165 FT_linear_mipmap_linear = SamplerState::FT_linear_mipmap_linear,
166 FT_shadow = SamplerState::FT_shadow,
167 FT_default = SamplerState::FT_default,
168 FT_invalid = SamplerState::FT_invalid
170 typedef SamplerState::FilterType FilterType;
173 enum DeprecatedWrapMode {
174 WM_clamp = SamplerState::WM_clamp,
175 WM_repeat = SamplerState::WM_repeat,
176 WM_mirror = SamplerState::WM_mirror,
177 WM_mirror_once = SamplerState::WM_mirror_once,
178 WM_border_color = SamplerState::WM_border_color,
179 WM_invalid = SamplerState::WM_invalid
181 typedef SamplerState::WrapMode WrapMode;
183 enum CompressionMode {
213 explicit Texture(
const string &name =
string());
217 void operator = (
const Texture ©);
222 INLINE PT(
Texture) make_copy()
const;
225 INLINE
void setup_texture(TextureType texture_type,
226 int x_size,
int y_size,
int z_size,
227 ComponentType component_type, Format format);
228 INLINE
void setup_1d_texture();
229 INLINE
void setup_1d_texture(
int x_size,
230 ComponentType component_type, Format format);
231 INLINE
void setup_2d_texture();
232 INLINE
void setup_2d_texture(
int x_size,
int y_size,
233 ComponentType component_type, Format format);
234 INLINE
void setup_3d_texture(
int z_size = 1);
235 INLINE
void setup_3d_texture(
int x_size,
int y_size,
int z_size,
236 ComponentType component_type, Format format);
237 INLINE
void setup_cube_map();
238 INLINE
void setup_cube_map(
int size,
239 ComponentType component_type, Format format);
240 INLINE
void setup_2d_texture_array(
int z_size = 1);
241 INLINE
void setup_2d_texture_array(
int x_size,
int y_size,
int z_size,
242 ComponentType component_type, Format format);
243 void generate_normalization_cube_map(
int size);
244 void generate_alpha_scale_map();
246 INLINE
void clear_image();
247 INLINE
bool has_clear_color()
const;
248 INLINE
LColor get_clear_color()
const;
250 INLINE
string get_clear_data()
const;
253 BLOCKING
bool read(
const Filename &fullpath,
const Filename &alpha_fullpath,
254 int primary_file_num_channels,
int alpha_file_channel,
256 BLOCKING
bool read(
const Filename &fullpath,
int z,
int n,
257 bool read_pages,
bool read_mipmaps,
259 BLOCKING
bool read(
const Filename &fullpath,
const Filename &alpha_fullpath,
260 int primary_file_num_channels,
int alpha_file_channel,
261 int z,
int n,
bool read_pages,
bool read_mipmaps,
265 BLOCKING INLINE
bool write(
const Filename &fullpath);
266 BLOCKING INLINE
bool write(
const Filename &fullpath,
int z,
int n,
267 bool write_pages,
bool write_mipmaps);
269 BLOCKING
bool read_txo(istream &in,
const string &filename =
"");
270 BLOCKING
static PT(
Texture) make_from_txo(istream &in,
const string &filename =
"");
271 BLOCKING
bool write_txo(ostream &out,
const string &filename =
"")
const;
272 BLOCKING
bool read_dds(istream &in,
const string &filename =
"",
bool header_only =
false);
278 BLOCKING INLINE
bool load_sub_image(
const PNMImage &pnmimage,
int x,
int y,
int z=0,
int n=0);
279 BLOCKING INLINE
bool store(
PNMImage &pnmimage)
const;
280 BLOCKING INLINE
bool store(
PNMImage &pnmimage,
int z,
int n)
const;
281 BLOCKING INLINE
bool store(
PfmFile &pfm)
const;
282 BLOCKING INLINE
bool store(
PfmFile &pfm,
int z,
int n)
const;
284 BLOCKING INLINE
bool reload();
285 BLOCKING
Texture *load_related(
const InternalName *suffix)
const;
287 INLINE
bool has_filename()
const;
288 INLINE
const Filename &get_filename()
const;
289 INLINE
bool has_alpha_filename()
const;
290 INLINE
const Filename &get_alpha_filename()
const;
292 INLINE
bool has_fullpath()
const;
293 INLINE
const Filename &get_fullpath()
const;
294 INLINE
bool has_alpha_fullpath()
const;
295 INLINE
const Filename &get_alpha_fullpath()
const;
297 INLINE
int get_x_size()
const;
298 INLINE
int get_y_size()
const;
299 INLINE
int get_z_size()
const;
300 INLINE
int get_num_views()
const;
301 INLINE
int get_num_pages()
const;
302 INLINE
int get_num_components()
const;
303 INLINE
int get_component_width()
const;
304 INLINE TextureType get_texture_type()
const;
305 INLINE Format get_format()
const;
306 INLINE ComponentType get_component_type()
const;
308 INLINE
void set_wrap_u(WrapMode wrap);
309 INLINE
void set_wrap_v(WrapMode wrap);
310 INLINE
void set_wrap_w(WrapMode wrap);
311 INLINE
void set_minfilter(FilterType filter);
312 INLINE
void set_magfilter(FilterType filter);
313 INLINE
void set_anisotropic_degree(
int anisotropic_degree);
314 INLINE
void set_border_color(
const LColor &color);
315 INLINE
void set_compression(CompressionMode compression);
316 INLINE
void set_render_to_texture(
bool render_to_texture);
319 INLINE SamplerState::WrapMode get_wrap_u()
const;
320 INLINE SamplerState::WrapMode get_wrap_v()
const;
321 INLINE SamplerState::WrapMode get_wrap_w()
const;
322 INLINE SamplerState::FilterType get_minfilter()
const;
323 INLINE SamplerState::FilterType get_magfilter()
const;
324 INLINE SamplerState::FilterType get_effective_minfilter()
const;
325 INLINE SamplerState::FilterType get_effective_magfilter()
const;
326 INLINE
int get_anisotropic_degree()
const;
327 INLINE
int get_effective_anisotropic_degree()
const;
328 INLINE
LColor get_border_color()
const;
329 INLINE CompressionMode get_compression()
const;
330 INLINE
bool has_compression()
const;
331 INLINE
bool get_render_to_texture()
const;
332 INLINE
bool uses_mipmaps()
const;
334 INLINE
void set_quality_level(QualityLevel quality_level);
335 INLINE QualityLevel get_quality_level()
const;
336 INLINE QualityLevel get_effective_quality_level()
const;
338 INLINE
int get_expected_num_mipmap_levels()
const;
339 INLINE
int get_expected_mipmap_x_size(
int n)
const;
340 INLINE
int get_expected_mipmap_y_size(
int n)
const;
341 INLINE
int get_expected_mipmap_z_size(
int n)
const;
342 INLINE
int get_expected_mipmap_num_pages(
int n)
const;
344 INLINE
bool has_ram_image()
const;
345 INLINE
bool has_uncompressed_ram_image()
const;
346 INLINE
bool might_have_ram_image()
const;
347 INLINE
size_t get_ram_image_size()
const;
348 INLINE
size_t get_ram_view_size()
const;
349 INLINE
size_t get_ram_page_size()
const;
350 INLINE
size_t get_expected_ram_image_size()
const;
351 INLINE
size_t get_expected_ram_page_size()
const;
353 INLINE CompressionMode get_ram_image_compression()
const;
354 INLINE
CPTA_uchar get_uncompressed_ram_image();
355 CPTA_uchar get_ram_image_as(
const string &requested_format);
356 INLINE PTA_uchar modify_ram_image();
357 INLINE PTA_uchar make_ram_image();
358 INLINE
void set_ram_image(
CPTA_uchar image, CompressionMode compression = CM_off,
359 size_t page_size = 0);
360 void set_ram_image_as(
CPTA_uchar image,
const string &provided_format);
361 INLINE
void clear_ram_image();
362 INLINE
void set_keep_ram_image(
bool keep_ram_image);
363 virtual bool get_keep_ram_image()
const;
364 virtual bool is_cacheable()
const;
366 INLINE
bool compress_ram_image(CompressionMode compression = CM_on,
367 QualityLevel quality_level = QL_default,
369 INLINE
bool uncompress_ram_image();
371 INLINE
int get_num_ram_mipmap_images()
const;
372 INLINE
bool has_ram_mipmap_image(
int n)
const;
373 int get_num_loadable_ram_mipmap_images()
const;
374 INLINE
bool has_all_ram_mipmap_images()
const;
375 INLINE
size_t get_ram_mipmap_image_size(
int n)
const;
376 INLINE
size_t get_ram_mipmap_view_size(
int n)
const;
377 INLINE
size_t get_ram_mipmap_page_size(
int n)
const;
378 INLINE
size_t get_expected_ram_mipmap_image_size(
int n)
const;
379 INLINE
size_t get_expected_ram_mipmap_view_size(
int n)
const;
380 INLINE
size_t get_expected_ram_mipmap_page_size(
int n)
const;
382 void *get_ram_mipmap_pointer(
int n)
const;
383 INLINE PTA_uchar modify_ram_mipmap_image(
int n);
384 INLINE PTA_uchar make_ram_mipmap_image(
int n);
385 void set_ram_mipmap_pointer(
int n,
void *image,
size_t page_size = 0);
386 void set_ram_mipmap_pointer_from_int(
long long pointer,
int n,
int page_size);
387 INLINE
void set_ram_mipmap_image(
int n,
CPTA_uchar image,
size_t page_size = 0);
388 void clear_ram_mipmap_image(
int n);
389 INLINE
void clear_ram_mipmap_images();
390 INLINE
void generate_ram_mipmap_images();
392 INLINE
int get_simple_x_size()
const;
393 INLINE
int get_simple_y_size()
const;
394 INLINE
bool has_simple_ram_image()
const;
395 INLINE
size_t get_simple_ram_image_size()
const;
396 INLINE
CPTA_uchar get_simple_ram_image()
const;
397 INLINE
void set_simple_ram_image(
CPTA_uchar image,
int x_size,
int y_size);
398 PTA_uchar modify_simple_ram_image();
399 PTA_uchar new_simple_ram_image(
int x_size,
int y_size);
400 void generate_simple_ram_image();
401 INLINE
void clear_simple_ram_image();
405 INLINE
UpdateSeq get_properties_modified()
const;
406 INLINE
UpdateSeq get_image_modified()
const;
407 INLINE
UpdateSeq get_simple_image_modified()
const;
409 INLINE
void set_auto_texture_scale(AutoTextureScale scale);
410 INLINE AutoTextureScale get_auto_texture_scale()
const;
411 INLINE
bool has_auto_texture_scale()
const;
423 void write(ostream &out,
int indent_level)
const;
425 size_t estimate_texture_memory()
const;
428 void clear_aux_data(
const string &key);
431 INLINE
static void set_textures_power_2(AutoTextureScale scale);
432 INLINE
static AutoTextureScale get_textures_power_2();
433 INLINE
static bool has_textures_power_2();
439 INLINE
void set_filename(
const Filename &filename);
440 INLINE
void clear_filename();
441 INLINE
void set_alpha_filename(
const Filename &alpha_filename);
442 INLINE
void clear_alpha_filename();
444 INLINE
void set_fullpath(
const Filename &fullpath);
445 INLINE
void clear_fullpath();
446 INLINE
void set_alpha_fullpath(
const Filename &alpha_fullpath);
447 INLINE
void clear_alpha_fullpath();
449 INLINE
void set_x_size(
int x_size);
450 INLINE
void set_y_size(
int y_size);
451 INLINE
void set_z_size(
int z_size);
452 INLINE
void set_num_views(
int num_views);
454 INLINE
int get_pad_x_size()
const;
455 INLINE
int get_pad_y_size()
const;
456 INLINE
int get_pad_z_size()
const;
459 INLINE
void set_pad_size(
int x=0,
int y=0,
int z=0);
460 void set_size_padded(
int x=1,
int y=1,
int z=1);
462 INLINE
int get_orig_file_x_size()
const;
463 INLINE
int get_orig_file_y_size()
const;
464 INLINE
int get_orig_file_z_size()
const;
466 void set_orig_file_size(
int x,
int y,
int z = 1);
468 INLINE
void set_format(Format format);
469 INLINE
void set_component_type(ComponentType component_type);
470 INLINE
void set_loaded_from_image();
471 INLINE
bool get_loaded_from_image()
const;
473 INLINE
void set_loaded_from_txo();
474 INLINE
bool get_loaded_from_txo()
const;
476 INLINE
bool get_match_framebuffer_format()
const;
477 INLINE
void set_match_framebuffer_format(
bool flag);
479 INLINE
bool get_post_load_store_cache()
const;
480 INLINE
void set_post_load_store_cache(
bool flag);
486 static int up_to_power_2(
int value);
487 static int down_to_power_2(
int value);
489 void consider_rescale(
PNMImage &pnmimage);
490 static void consider_rescale(
PNMImage &pnmimage,
const string &name, AutoTextureScale auto_texture_scale = ATS_unspecified);
491 INLINE
bool rescale_texture();
493 static string format_texture_type(TextureType tt);
494 static TextureType string_texture_type(
const string &str);
496 static string format_component_type(ComponentType ct);
497 static ComponentType string_component_type(
const string &str);
499 static string format_format(Format f);
500 static Format string_format(
const string &str);
502 static string format_compression_mode(CompressionMode cm);
503 static CompressionMode string_compression_mode(
const string &str);
505 static string format_quality_level(QualityLevel tql);
506 static QualityLevel string_quality_level(
const string &str);
509 void texture_uploaded();
511 virtual bool has_cull_callback()
const;
514 static PT(
Texture) make_texture();
517 static bool is_specific(CompressionMode compression);
518 static bool has_alpha(Format format);
519 static bool has_binary_alpha(Format format);
520 static bool is_srgb(Format format);
522 static bool adjust_size(
int &x_size,
int &y_size,
const string &name,
523 bool for_padding, AutoTextureScale auto_texture_scale = ATS_unspecified);
524 INLINE
bool adjust_this_size(
int &x_size,
int &y_size,
const string &name,
525 bool for_padding)
const;
527 virtual void ensure_loader_type(
const Filename &filename);
532 virtual void reconsider_dirty();
542 virtual bool do_adjust_this_size(
const CData *cdata,
543 int &x_size,
int &y_size,
const string &name,
544 bool for_padding)
const;
546 virtual bool do_read(CData *cdata,
548 int primary_file_num_channels,
int alpha_file_channel,
549 int z,
int n,
bool read_pages,
bool read_mipmaps,
551 virtual bool do_read_one(CData *cdata,
553 int z,
int n,
int primary_file_num_channels,
int alpha_file_channel,
556 virtual bool do_load_one(CData *cdata,
557 const PNMImage &pnmimage,
const string &name,
559 virtual bool do_load_one(CData *cdata,
560 const PfmFile &pfm,
const string &name,
562 virtual bool do_load_sub_image(CData *cdata,
const PNMImage &image,
563 int x,
int y,
int z,
int n);
564 bool do_read_txo_file(CData *cdata,
const Filename &fullpath);
565 bool do_read_txo(CData *cdata, istream &in,
const string &filename);
566 bool do_read_dds_file(CData *cdata,
const Filename &fullpath,
bool header_only);
567 bool do_read_dds(CData *cdata, istream &in,
const string &filename,
bool header_only);
569 bool do_write(CData *cdata,
const Filename &fullpath,
int z,
int n,
570 bool write_pages,
bool write_mipmaps);
571 bool do_write_one(CData *cdata,
const Filename &fullpath,
int z,
int n);
572 bool do_store_one(CData *cdata,
PNMImage &pnmimage,
int z,
int n);
573 bool do_store_one(CData *cdata,
PfmFile &pfm,
int z,
int n);
574 bool do_write_txo_file(
const CData *cdata,
const Filename &fullpath)
const;
575 bool do_write_txo(
const CData *cdata, ostream &out,
const string &filename)
const;
577 virtual CData *unlocked_ensure_ram_image(
bool allow_compression);
578 virtual void do_reload_ram_image(CData *cdata,
bool allow_compression);
580 PTA_uchar do_modify_ram_image(CData *cdata);
581 PTA_uchar do_make_ram_image(CData *cdata);
582 void do_set_ram_image(CData *cdata,
CPTA_uchar image,
583 CompressionMode compression = CM_off,
size_t page_size = 0);
584 PTA_uchar do_modify_ram_mipmap_image(CData *cdata,
int n);
585 PTA_uchar do_make_ram_mipmap_image(CData *cdata,
int n);
586 void do_set_ram_mipmap_image(CData *cdata,
int n,
CPTA_uchar image,
size_t page_size);
587 int do_get_clear_data(
const CData *cdata,
unsigned char *into)
const;
589 bool consider_auto_process_ram_image(
bool generate_mipmaps,
bool allow_compression);
590 bool do_consider_auto_process_ram_image(CData *cdata,
bool generate_mipmaps,
591 bool allow_compression);
592 bool do_compress_ram_image(CData *cdata, CompressionMode compression,
593 QualityLevel quality_level,
595 bool do_uncompress_ram_image(CData *cdata);
596 bool do_has_all_ram_mipmap_images(
const CData *cdata)
const;
598 bool do_reconsider_z_size(CData *cdata,
int z,
const LoaderOptions &options);
599 virtual void do_allocate_pages(CData *cdata);
600 bool do_reconsider_image_properties(CData *cdata,
601 int x_size,
int y_size,
int num_components,
602 ComponentType component_type,
int z,
604 bool do_rescale_texture(CData *cdata);
606 virtual PT(
Texture) make_copy_impl()
const;
607 PT(
Texture) do_make_copy(
const CData *cdata)
const;
608 void do_assign(CData *cdata,
const Texture *copy,
const CData *cdata_copy);
609 virtual void do_clear(CData *cdata);
610 void do_setup_texture(CData *cdata,
611 TextureType texture_type,
int x_size,
int y_size,
612 int z_size, ComponentType component_type,
614 void do_set_num_views(CData *cdata,
int num_views);
615 void do_set_format(CData *cdata, Format format);
616 void do_set_component_type(CData *cdata, ComponentType component_type);
617 void do_set_x_size(CData *cdata,
int x_size);
618 void do_set_y_size(CData *cdata,
int y_size);
619 void do_set_z_size(CData *cdata,
int z_size);
621 void do_set_wrap_u(CData *cdata, WrapMode wrap);
622 void do_set_wrap_v(CData *cdata, WrapMode wrap);
623 void do_set_wrap_w(CData *cdata, WrapMode wrap);
624 void do_set_minfilter(CData *cdata, FilterType filter);
625 void do_set_magfilter(CData *cdata, FilterType filter);
626 void do_set_anisotropic_degree(CData *cdata,
int anisotropic_degree);
627 void do_set_border_color(CData *cdata,
const LColor &color);
628 void do_set_compression(CData *cdata, CompressionMode compression);
629 void do_set_quality_level(CData *cdata, QualityLevel quality_level);
631 bool do_has_compression(
const CData *cdata)
const;
632 virtual bool do_has_ram_image(
const CData *cdata)
const;
633 virtual bool do_has_uncompressed_ram_image(
const CData *cdata)
const;
635 CPTA_uchar do_get_uncompressed_ram_image(CData *cdata);
636 void do_set_simple_ram_image(CData *cdata,
CPTA_uchar image,
int x_size,
int y_size);
637 INLINE
size_t do_get_ram_image_size(
const CData *cdata)
const;
638 INLINE
bool do_has_ram_mipmap_image(
const CData *cdata,
int n)
const;
639 int do_get_expected_num_mipmap_levels(
const CData *cdata)
const;
640 INLINE
size_t do_get_expected_ram_image_size(
const CData *cdata)
const;
641 INLINE
size_t do_get_expected_ram_view_size(
const CData *cdata)
const;
642 INLINE
size_t do_get_expected_ram_page_size(
const CData *cdata)
const;
643 size_t do_get_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
644 INLINE
size_t do_get_expected_ram_mipmap_image_size(
const CData *cdata,
int n)
const;
645 INLINE
size_t do_get_expected_ram_mipmap_view_size(
const CData *cdata,
int n)
const;
646 INLINE
size_t do_get_expected_ram_mipmap_page_size(
const CData *cdata,
int n)
const;
647 int do_get_expected_mipmap_x_size(
const CData *cdata,
int n)
const;
648 int do_get_expected_mipmap_y_size(
const CData *cdata,
int n)
const;
649 int do_get_expected_mipmap_z_size(
const CData *cdata,
int n)
const;
650 INLINE
int do_get_expected_mipmap_num_pages(
const CData *cdata,
int n)
const;
651 INLINE
void do_clear_ram_image(CData *cdata);
652 void do_clear_simple_ram_image(CData *cdata);
653 void do_clear_ram_mipmap_images(CData *cdata);
654 void do_generate_ram_mipmap_images(CData *cdata);
655 void do_set_pad_size(CData *cdata,
int x,
int y,
int z);
656 virtual bool do_can_reload(
const CData *cdata)
const;
657 bool do_reload(CData *cdata);
659 INLINE AutoTextureScale do_get_auto_texture_scale(
const CData *cdata)
const;
661 virtual bool do_has_bam_rawdata(
const CData *cdata)
const;
662 virtual void do_get_bam_rawdata(CData *cdata);
674 void *_pointer_image;
678 static void convert_from_pnmimage(PTA_uchar &image,
size_t page_size,
679 int row_stride,
int x,
int y,
int z,
681 int num_components,
int component_width);
682 static void convert_from_pfm(PTA_uchar &image,
size_t page_size,
684 int num_components,
int component_width);
685 static bool convert_to_pnmimage(
PNMImage &pnmimage,
int x_size,
int y_size,
686 int num_components,
int component_width,
689 static bool convert_to_pfm(
PfmFile &pfm,
int x_size,
int y_size,
690 int num_components,
int component_width,
693 static PTA_uchar read_dds_level_bgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
695 static PTA_uchar read_dds_level_rgb8(
Texture *tex, CData *cdata,
const DDSHeader &header,
697 static PTA_uchar read_dds_level_abgr8(
Texture *tex, CData *cdata,
const DDSHeader &header,
699 static PTA_uchar read_dds_level_rgba8(
Texture *tex, CData *cdata,
const DDSHeader &header,
701 static PTA_uchar read_dds_level_generic_uncompressed(
Texture *tex, CData *cdata,
704 static PTA_uchar read_dds_level_luminance_uncompressed(
Texture *tex, CData *cdata,
707 static PTA_uchar read_dds_level_dxt1(
Texture *tex, CData *cdata,
710 static PTA_uchar read_dds_level_dxt23(
Texture *tex, CData *cdata,
713 static PTA_uchar read_dds_level_dxt45(
Texture *tex, CData *cdata,
719 static void consider_downgrade(
PNMImage &pnmimage,
int num_channels,
const string &name);
723 INLINE
static void store_unscaled_byte(
unsigned char *&p,
int value);
724 INLINE
static void store_unscaled_short(
unsigned char *&p,
int value);
725 INLINE
static void store_scaled_byte(
unsigned char *&p,
int value,
double scale);
726 INLINE
static void store_scaled_short(
unsigned char *&p,
int value,
double scale);
727 INLINE
static double get_unsigned_byte(
const unsigned char *&p);
728 INLINE
static double get_unsigned_short(
const unsigned char *&p);
730 INLINE
static bool is_txo_filename(
const Filename &fullpath);
731 INLINE
static bool is_dds_filename(
const Filename &fullpath);
733 void do_filter_2d_mipmap_pages(
const CData *cdata,
734 RamImage &to,
const RamImage &from,
735 int x_size,
int y_size)
const;
737 void do_filter_3d_mipmap_level(
const CData *cdata,
738 RamImage &to,
const RamImage &from,
739 int x_size,
int y_size,
int z_size)
const;
741 typedef void Filter2DComponent(
unsigned char *&p,
742 const unsigned char *&q,
743 size_t pixel_size,
size_t row_size);
745 typedef void Filter3DComponent(
unsigned char *&p,
746 const unsigned char *&q,
747 size_t pixel_size,
size_t row_size,
750 static void filter_2d_unsigned_byte(
unsigned char *&p,
751 const unsigned char *&q,
752 size_t pixel_size,
size_t row_size);
753 static void filter_2d_unsigned_byte_srgb(
unsigned char *&p,
754 const unsigned char *&q,
755 size_t pixel_size,
size_t row_size);
756 static void filter_2d_unsigned_byte_srgb_sse2(
unsigned char *&p,
757 const unsigned char *&q,
758 size_t pixel_size,
size_t row_size);
759 static void filter_2d_unsigned_short(
unsigned char *&p,
760 const unsigned char *&q,
761 size_t pixel_size,
size_t row_size);
762 static void filter_2d_float(
unsigned char *&p,
const unsigned char *&q,
763 size_t pixel_size,
size_t row_size);
765 static void filter_3d_unsigned_byte(
unsigned char *&p,
766 const unsigned char *&q,
767 size_t pixel_size,
size_t row_size,
769 static void filter_3d_unsigned_byte_srgb(
unsigned char *&p,
770 const unsigned char *&q,
771 size_t pixel_size,
size_t row_size,
773 static void filter_3d_unsigned_byte_srgb_sse2(
unsigned char *&p,
774 const unsigned char *&q,
775 size_t pixel_size,
size_t row_size,
777 static void filter_3d_unsigned_short(
unsigned char *&p,
778 const unsigned char *&q,
779 size_t pixel_size,
size_t row_size,
781 static void filter_3d_float(
unsigned char *&p,
const unsigned char *&q,
782 size_t pixel_size,
size_t row_size,
size_t page_size);
784 bool do_squish(CData *cdata, CompressionMode compression,
int squish_flags);
785 bool do_unsquish(CData *cdata,
int squish_flags);
791 class EXPCL_PANDA_GOBJ CData :
public CycleData {
794 CData(
const CData ©);
795 ALLOC_DELETED_CHAIN(CData);
801 return Texture::get_class_type();
804 void do_assign(
const CData *copy);
805 INLINE
void inc_properties_modified();
806 INLINE
void inc_image_modified();
807 INLINE
void inc_simple_image_modified();
815 int _primary_file_num_channels;
821 int _alpha_file_channel;
828 int _component_width;
829 TextureType _texture_type;
831 ComponentType _component_type;
833 bool _loaded_from_image;
834 bool _loaded_from_txo;
835 bool _has_read_pages;
836 bool _has_read_mipmaps;
837 int _num_mipmap_levels_read;
840 bool _keep_ram_image;
842 CompressionMode _compression;
843 bool _render_to_texture;
844 bool _match_framebuffer_format;
845 bool _post_load_store_cache;
846 QualityLevel _quality_level;
852 int _orig_file_x_size;
853 int _orig_file_y_size;
855 AutoTextureScale _auto_texture_scale;
856 CompressionMode _ram_image_compression;
865 RamImage _simple_ram_image;
868 PN_int32 _simple_image_date_generated;
871 bool _has_clear_color;
882 static void init_type() {
883 register_type(_type_handle,
"Texture::CData");
929 static AutoTextureScale _textures_power_2;
934 static void register_with_read_factory();
937 virtual void finalize(
BamReader *manager);
940 void do_write_datagram_header(CData *cdata,
BamWriter *manager,
Datagram &me,
bool &has_rawdata);
941 virtual void do_write_datagram_body(CData *cdata,
BamWriter *manager,
Datagram &me);
942 virtual void do_write_datagram_rawdata(CData *cdata,
BamWriter *manager,
Datagram &me);
947 virtual void do_fillin_from(CData *cdata,
const Texture *dummy);
953 static void init_type() {
954 TypedWritableReferenceCount::init_type();
955 register_type(_type_handle,
"Texture",
956 TypedWritableReferenceCount::get_class_type());
960 return get_class_type();
962 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
976 EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::TextureType tt);
977 EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::ComponentType ct);
978 EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::Format f);
980 EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::CompressionMode cm);
981 EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::QualityLevel tql);
982 EXPCL_PANDA_GOBJ istream &operator >> (istream &in, Texture::QualityLevel &tql);
This is our own Panda specialization on the default STL map.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Specifies parameters that may be passed to the loader.
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
A single page of data maintained by a PipelineCycler.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Base class for objects that can be written to and read from Bam files.
This is a special class object that holds all the information returned by a particular GSG to indicat...
This collects together the pieces of data that are accumulated for each node while walking the scene ...
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
A standard mutex, or mutual exclusion lock.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is our own Panda specialization on the default STL list.
A table of objects that are saved within the graphics context for reference by handle later...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
A lightweight class that represents a single element that may be timed and/or counted via stats...
A base class for all things which can have a name.
The name of a file, such as a texture file or an Egg file.
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component, or with a special extension, 2- or 4-component.
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This is the base class for all two-component vectors and points.
This class specializes ConfigVariable as an enumerated type.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
An instance of this object is returned by Texture::peek().
Represents a set of settings that indicate how a texture is sampled.
This is the base class for all three-component vectors and points.
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
This class implements a condition variable; see ConditionVar for a brief introduction to this class...
A class to retrieve the individual data elements previously stored in a Datagram. ...
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is the preferred interface for loading textures from image files.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...