aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CSoftwareTexture2.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CSoftwareTexture2.cpp312
1 files changed, 156 insertions, 156 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CSoftwareTexture2.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CSoftwareTexture2.cpp
index 32d150f..964ffb6 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CSoftwareTexture2.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CSoftwareTexture2.cpp
@@ -1,156 +1,156 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten 1// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#include "IrrCompileConfig.h" 5#include "IrrCompileConfig.h"
6#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ 6#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
7 7
8#include "SoftwareDriver2_compile_config.h" 8#include "SoftwareDriver2_compile_config.h"
9#include "SoftwareDriver2_helper.h" 9#include "SoftwareDriver2_helper.h"
10#include "CSoftwareTexture2.h" 10#include "CSoftwareTexture2.h"
11#include "os.h" 11#include "os.h"
12 12
13namespace irr 13namespace irr
14{ 14{
15namespace video 15namespace video
16{ 16{
17 17
18//! constructor 18//! constructor
19CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, 19CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name,
20 u32 flags, void* mipmapData) 20 u32 flags, void* mipmapData)
21 : ITexture(name), MipMapLOD(0), Flags ( flags ), OriginalFormat(video::ECF_UNKNOWN) 21 : ITexture(name), MipMapLOD(0), Flags ( flags ), OriginalFormat(video::ECF_UNKNOWN)
22{ 22{
23 #ifdef _DEBUG 23 #ifdef _DEBUG
24 setDebugName("CSoftwareTexture2"); 24 setDebugName("CSoftwareTexture2");
25 #endif 25 #endif
26 26
27 #ifndef SOFTWARE_DRIVER_2_MIPMAPPING 27 #ifndef SOFTWARE_DRIVER_2_MIPMAPPING
28 Flags &= ~GEN_MIPMAP; 28 Flags &= ~GEN_MIPMAP;
29 #endif 29 #endif
30 30
31 memset32 ( MipMap, 0, sizeof ( MipMap ) ); 31 memset32 ( MipMap, 0, sizeof ( MipMap ) );
32 32
33 if (image) 33 if (image)
34 { 34 {
35 OrigSize = image->getDimension(); 35 OrigSize = image->getDimension();
36 OriginalFormat = image->getColorFormat(); 36 OriginalFormat = image->getColorFormat();
37 37
38 core::setbit_cond(Flags, 38 core::setbit_cond(Flags,
39 image->getColorFormat () == video::ECF_A8R8G8B8 || 39 image->getColorFormat () == video::ECF_A8R8G8B8 ||
40 image->getColorFormat () == video::ECF_A1R5G5B5, 40 image->getColorFormat () == video::ECF_A1R5G5B5,
41 HAS_ALPHA); 41 HAS_ALPHA);
42 42
43 core::dimension2d<u32> optSize( 43 core::dimension2d<u32> optSize(
44 OrigSize.getOptimalSize( 0 != ( Flags & NP2_SIZE ), 44 OrigSize.getOptimalSize( 0 != ( Flags & NP2_SIZE ),
45 false, false, 45 false, false,
46 ( Flags & NP2_SIZE ) ? SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE : 0) 46 ( Flags & NP2_SIZE ) ? SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE : 0)
47 ); 47 );
48 48
49 if ( OrigSize == optSize ) 49 if ( OrigSize == optSize )
50 { 50 {
51 MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, image->getDimension()); 51 MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, image->getDimension());
52 image->copyTo(MipMap[0]); 52 image->copyTo(MipMap[0]);
53 } 53 }
54 else 54 else
55 { 55 {
56 char buf[256]; 56 char buf[256];
57 core::stringw showName ( name ); 57 core::stringw showName ( name );
58 snprintf ( buf, 256, "Burningvideo: Warning Texture %ls reformat %dx%d -> %dx%d,%d", 58 snprintf ( buf, 256, "Burningvideo: Warning Texture %ls reformat %dx%d -> %dx%d,%d",
59 showName.c_str(), 59 showName.c_str(),
60 OrigSize.Width, OrigSize.Height, optSize.Width, optSize.Height, 60 OrigSize.Width, OrigSize.Height, optSize.Width, optSize.Height,
61 BURNINGSHADER_COLOR_FORMAT 61 BURNINGSHADER_COLOR_FORMAT
62 ); 62 );
63 63
64 OrigSize = optSize; 64 OrigSize = optSize;
65 os::Printer::log ( buf, ELL_WARNING ); 65 os::Printer::log ( buf, ELL_WARNING );
66 MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, optSize); 66 MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, optSize);
67 image->copyToScalingBoxFilter ( MipMap[0],0, false ); 67 image->copyToScalingBoxFilter ( MipMap[0],0, false );
68 } 68 }
69 69
70 OrigImageDataSizeInPixels = (f32) 0.3f * MipMap[0]->getImageDataSizeInPixels(); 70 OrigImageDataSizeInPixels = (f32) 0.3f * MipMap[0]->getImageDataSizeInPixels();
71 } 71 }
72 72
73 regenerateMipMapLevels(mipmapData); 73 regenerateMipMapLevels(mipmapData);
74} 74}
75 75
76 76
77//! destructor 77//! destructor
78CSoftwareTexture2::~CSoftwareTexture2() 78CSoftwareTexture2::~CSoftwareTexture2()
79{ 79{
80 for ( s32 i = 0; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) 80 for ( s32 i = 0; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i )
81 { 81 {
82 if ( MipMap[i] ) 82 if ( MipMap[i] )
83 MipMap[i]->drop(); 83 MipMap[i]->drop();
84 } 84 }
85} 85}
86 86
87 87
88//! Regenerates the mip map levels of the texture. Useful after locking and 88//! Regenerates the mip map levels of the texture. Useful after locking and
89//! modifying the texture 89//! modifying the texture
90void CSoftwareTexture2::regenerateMipMapLevels(void* mipmapData) 90void CSoftwareTexture2::regenerateMipMapLevels(void* mipmapData)
91{ 91{
92 if ( !hasMipMaps () ) 92 if ( !hasMipMaps () )
93 return; 93 return;
94 94
95 s32 i; 95 s32 i;
96 96
97 // release 97 // release
98 for ( i = 1; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) 98 for ( i = 1; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i )
99 { 99 {
100 if ( MipMap[i] ) 100 if ( MipMap[i] )
101 MipMap[i]->drop(); 101 MipMap[i]->drop();
102 } 102 }
103 103
104 core::dimension2d<u32> newSize; 104 core::dimension2d<u32> newSize;
105 core::dimension2d<u32> origSize=OrigSize; 105 core::dimension2d<u32> origSize=OrigSize;
106 106
107 for (i=1; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i) 107 for (i=1; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i)
108 { 108 {
109 newSize = MipMap[i-1]->getDimension(); 109 newSize = MipMap[i-1]->getDimension();
110 newSize.Width = core::s32_max ( 1, newSize.Width >> SOFTWARE_DRIVER_2_MIPMAPPING_SCALE ); 110 newSize.Width = core::s32_max ( 1, newSize.Width >> SOFTWARE_DRIVER_2_MIPMAPPING_SCALE );
111 newSize.Height = core::s32_max ( 1, newSize.Height >> SOFTWARE_DRIVER_2_MIPMAPPING_SCALE ); 111 newSize.Height = core::s32_max ( 1, newSize.Height >> SOFTWARE_DRIVER_2_MIPMAPPING_SCALE );
112 origSize.Width = core::s32_max(1, origSize.Width >> 1); 112 origSize.Width = core::s32_max(1, origSize.Width >> 1);
113 origSize.Height = core::s32_max(1, origSize.Height >> 1); 113 origSize.Height = core::s32_max(1, origSize.Height >> 1);
114 114
115 if (mipmapData) 115 if (mipmapData)
116 { 116 {
117 if (OriginalFormat != BURNINGSHADER_COLOR_FORMAT) 117 if (OriginalFormat != BURNINGSHADER_COLOR_FORMAT)
118 { 118 {
119 IImage* tmpImage = new CImage(OriginalFormat, origSize, mipmapData, true, false); 119 IImage* tmpImage = new CImage(OriginalFormat, origSize, mipmapData, true, false);
120 MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize); 120 MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize);
121 if (origSize==newSize) 121 if (origSize==newSize)
122 tmpImage->copyTo(MipMap[i]); 122 tmpImage->copyTo(MipMap[i]);
123 else 123 else
124 tmpImage->copyToScalingBoxFilter(MipMap[i]); 124 tmpImage->copyToScalingBoxFilter(MipMap[i]);
125 tmpImage->drop(); 125 tmpImage->drop();
126 } 126 }
127 else 127 else
128 { 128 {
129 if (origSize==newSize) 129 if (origSize==newSize)
130 MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize, mipmapData, false); 130 MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize, mipmapData, false);
131 else 131 else
132 { 132 {
133 MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize); 133 MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize);
134 IImage* tmpImage = new CImage(BURNINGSHADER_COLOR_FORMAT, origSize, mipmapData, true, false); 134 IImage* tmpImage = new CImage(BURNINGSHADER_COLOR_FORMAT, origSize, mipmapData, true, false);
135 tmpImage->copyToScalingBoxFilter(MipMap[i]); 135 tmpImage->copyToScalingBoxFilter(MipMap[i]);
136 tmpImage->drop(); 136 tmpImage->drop();
137 } 137 }
138 } 138 }
139 mipmapData = (u8*)mipmapData+origSize.getArea()*IImage::getBitsPerPixelFromFormat(OriginalFormat)/8; 139 mipmapData = (u8*)mipmapData+origSize.getArea()*IImage::getBitsPerPixelFromFormat(OriginalFormat)/8;
140 } 140 }
141 else 141 else
142 { 142 {
143 MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize); 143 MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize);
144 144
145 //static u32 color[] = { 0, 0xFFFF0000, 0xFF00FF00,0xFF0000FF,0xFFFFFF00,0xFFFF00FF,0xFF00FFFF,0xFF0F0F0F }; 145 //static u32 color[] = { 0, 0xFFFF0000, 0xFF00FF00,0xFF0000FF,0xFFFFFF00,0xFFFF00FF,0xFF00FFFF,0xFF0F0F0F };
146 MipMap[i]->fill ( 0 ); 146 MipMap[i]->fill ( 0 );
147 MipMap[0]->copyToScalingBoxFilter( MipMap[i], 0, false ); 147 MipMap[0]->copyToScalingBoxFilter( MipMap[i], 0, false );
148 } 148 }
149 } 149 }
150} 150}
151 151
152 152
153} // end namespace video 153} // end namespace video
154} // end namespace irr 154} // end namespace irr
155 155
156#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ 156#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_