~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to source/blender/imbuf/intern/dds/BlockDXT.cpp

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-04-28 12:11:12 UTC
  • mto: (14.1.6 experimental) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: package-import@ubuntu.com-20120428121112-2zi0vp8b6vejda8i
Tags: upstream-2.63
ImportĀ upstreamĀ versionĀ 2.63

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
//      c.u |= (c.u >> 6) & 0x000300;
91
91
//      color_array[1].u = c.u;
92
92
        
93
 
        if( col0.u > col1.u ) {
 
93
        if ( col0.u > col1.u ) {
94
94
                // Four-color block: derive the other two colors.
95
95
                color_array[2].r = (2 * color_array[0].r + color_array[1].r) / 3;
96
96
                color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3;
135
135
        color_array[1].b = (3 * col1.b * 22) / 8;
136
136
        color_array[1].a = 0xFF;
137
137
        
138
 
    int gdiff = color_array[1].g - color_array[0].g;
 
138
        int gdiff = color_array[1].g - color_array[0].g;
139
139
 
140
 
        if( col0.u > col1.u ) {
 
140
        if ( col0.u > col1.u ) {
141
141
                // Four-color block: derive the other two colors.
142
 
        color_array[2].r = ((2 * col0.r + col1.r) * 22) / 8;
143
 
        color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 80) / 256;
144
 
        color_array[2].b = ((2 * col0.b + col1.b) * 22) / 8;
 
142
                color_array[2].r = ((2 * col0.r + col1.r) * 22) / 8;
 
143
                color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 80) / 256;
 
144
                color_array[2].b = ((2 * col0.b + col1.b) * 22) / 8;
145
145
                color_array[2].a = 0xFF;
146
146
                
147
 
        color_array[3].r = ((2 * col1.r + col0.r) * 22) / 8;
148
 
        color_array[3].g = (256 * color_array[1].g - gdiff / 4 + 128 - gdiff * 80) / 256;
149
 
        color_array[3].b = ((2 * col1.b + col0.b) * 22) / 8;
 
147
                color_array[3].r = ((2 * col1.r + col0.r) * 22) / 8;
 
148
                color_array[3].g = (256 * color_array[1].g - gdiff / 4 + 128 - gdiff * 80) / 256;
 
149
                color_array[3].b = ((2 * col1.b + col0.b) * 22) / 8;
150
150
                color_array[3].a = 0xFF;
151
151
 
152
152
                return 4;
153
153
        }
154
154
        else {
155
155
                // Three-color block: derive the other color.
156
 
        color_array[2].r = ((col0.r + col1.r) * 33) / 8;
157
 
        color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256;
158
 
        color_array[2].b = ((col0.b + col1.b) * 33) / 8;
 
156
                color_array[2].r = ((col0.r + col1.r) * 33) / 8;
 
157
                color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256;
 
158
                color_array[2].b = ((col0.b + col1.b) * 33) / 8;
159
159
                color_array[2].a = 0xFF;
160
160
                
161
161
                // Set all components to 0 to match DXT specs.
227
227
        evaluatePalette(color_array);
228
228
        
229
229
        // Write color block.
230
 
        for( uint j = 0; j < 4; j++ ) {
231
 
                for( uint i = 0; i < 4; i++ ) {
 
230
        for ( uint j = 0; j < 4; j++ ) {
 
231
                for ( uint i = 0; i < 4; i++ ) {
232
232
                        uint idx = (row[j] >> (2 * i)) & 3;
233
233
                        block->color(i, j) = color_array[idx];
234
234
                }
242
242
        evaluatePaletteNV5x(color_array);
243
243
 
244
244
        // Write color block.
245
 
        for( uint j = 0; j < 4; j++ ) {
246
 
                for( uint i = 0; i < 4; i++ ) {
 
245
        for ( uint j = 0; j < 4; j++ ) {
 
246
                for ( uint i = 0; i < 4; i++ ) {
247
247
                        uint idx = (row[j] >> (2 * i)) & 3;
248
248
                        block->color(i, j) = color_array[idx];
249
249
                }
253
253
void BlockDXT1::setIndices(int * idx)
254
254
{
255
255
        indices = 0;
256
 
        for(uint i = 0; i < 16; i++) {
 
256
        for (uint i = 0; i < 16; i++) {
257
257
                indices |= (idx[i] & 3) << (2 * i);
258
258
        }
259
259
}
423
423
        uint8 index_array[16];
424
424
        indices(index_array);
425
425
        
426
 
        for(uint i = 0; i < 16; i++) {
 
426
        for (uint i = 0; i < 16; i++) {
427
427
                block->color(i).a = alpha_array[index_array[i]];
428
428
        }
429
429
}
496
496
        uint8 index_array[16];
497
497
        alpha.indices(index_array);
498
498
        
499
 
        for(uint i = 0; i < 16; i++) {
 
499
        for (uint i = 0; i < 16; i++) {
500
500
                Color32 & c = block->color(i);
501
501
                c.b = c.g = c.r = alpha_array[index_array[i]];
502
502
                c.a = 255;
525
525
        x.evaluatePalette(alpha_array);
526
526
        x.indices(index_array);
527
527
        
528
 
        for(uint i = 0; i < 16; i++) {
 
528
        for (uint i = 0; i < 16; i++) {
529
529
                Color32 & c = block->color(i);
530
530
                c.r = alpha_array[index_array[i]];
531
531
        }
533
533
        y.evaluatePalette(alpha_array);
534
534
        y.indices(index_array);
535
535
        
536
 
        for(uint i = 0; i < 16; i++) {
 
536
        for (uint i = 0; i < 16; i++) {
537
537
                Color32 & c = block->color(i);
538
538
                c.g = alpha_array[index_array[i]];
539
539
                c.b = 0;
587
587
        evaluatePalette(color_array);
588
588
        
589
589
        // Write color block.
590
 
        for( uint j = 0; j < 4; j++ ) {
591
 
                for( uint i = 0; i < 4; i++ ) {
 
590
        for ( uint j = 0; j < 4; j++ ) {
 
591
                for ( uint i = 0; i < 4; i++ ) {
592
592
                        uint idx = (row[j] >> (2 * i)) & 3;
593
593
                        block->color(i, j) = color_array[idx];
594
594
                }
598
598
void BlockCTX1::setIndices(int * idx)
599
599
{
600
600
        indices = 0;
601
 
        for(uint i = 0; i < 16; i++) {
 
601
        for (uint i = 0; i < 16; i++) {
602
602
                indices |= (idx[i] & 3) << (2 * i);
603
603
        }
604
604
}