~zsombi/ubuntu-ui-toolkit/listitemSelectModeBugs

« back to all changes in this revision

Viewing changes to src/Ubuntu/Components/tools/createshapetextures.cpp

  • Committer: Zsombor Egri
  • Date: 2015-11-16 06:35:05 UTC
  • mfrom: (1664.1.1 listitemSelectModeBugs)
  • Revision ID: zsombor.egri@canonical.com-20151116063505-cwn2qfks7qzk10g9
re-sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
const int widthMipmap = 256;
47
47
const int heightMipmap = 256;
48
48
const int sizeMipmap = widthMipmap * heightMipmap;
49
 
const int mipmapCount = 5; // Minimum size is 16.
 
49
const int mipmapCount = 9;  // Minimum size is 1.
50
50
const int biggestSize = size > sizeMipmap ? size : sizeMipmap;
51
51
 
52
52
// Shape buffers.
317
317
    cppOut.setIntegerBase(16);
318
318
    cppOut.setFieldWidth(2);
319
319
    cppOut.setPadChar('0');
320
 
    for (int i = 0; i < size; i += 4) {
321
 
        cppOut << "    \""
322
 
                << "\\x" << (data[i] & 0xff)
323
 
                << "\\x" << ((data[i] >> 8) & 0xff)
324
 
                << "\\x" << ((data[i] >> 16) & 0xff)
325
 
                << "\\x" << ((data[i] >> 24) & 0xff)
326
 
                << "\\x" << (data[i+1] & 0xff)
327
 
                << "\\x" << ((data[i+1] >> 8) & 0xff)
328
 
                << "\\x" << ((data[i+1] >> 16) & 0xff)
329
 
                << "\\x" << ((data[i+1] >> 24) & 0xff)
330
 
                << "\\x" << (data[i+2] & 0xff)
331
 
                << "\\x" << ((data[i+2] >> 8) & 0xff)
332
 
                << "\\x" << ((data[i+2] >> 16) & 0xff)
333
 
                << "\\x" << ((data[i+2] >> 24) & 0xff)
334
 
                << "\\x" << (data[i+3] & 0xff)
335
 
                << "\\x" << ((data[i+3] >> 8) & 0xff)
336
 
                << "\\x" << ((data[i+3] >> 16) & 0xff)
337
 
                << "\\x" << ((data[i+3] >> 24) & 0xff);
338
 
        cppOut.setFieldWidth(1);
 
320
    if (size >= 16) {
 
321
        for (int i = 0; i < size; i += 4) {
 
322
            cppOut << "    \""
 
323
                   << "\\x" << (data[i] & 0xff)
 
324
                   << "\\x" << ((data[i] >> 8) & 0xff)
 
325
                   << "\\x" << ((data[i] >> 16) & 0xff)
 
326
                   << "\\x" << ((data[i] >> 24) & 0xff)
 
327
                   << "\\x" << (data[i+1] & 0xff)
 
328
                   << "\\x" << ((data[i+1] >> 8) & 0xff)
 
329
                   << "\\x" << ((data[i+1] >> 16) & 0xff)
 
330
                   << "\\x" << ((data[i+1] >> 24) & 0xff)
 
331
                   << "\\x" << (data[i+2] & 0xff)
 
332
                   << "\\x" << ((data[i+2] >> 8) & 0xff)
 
333
                   << "\\x" << ((data[i+2] >> 16) & 0xff)
 
334
                   << "\\x" << ((data[i+2] >> 24) & 0xff)
 
335
                   << "\\x" << (data[i+3] & 0xff)
 
336
                   << "\\x" << ((data[i+3] >> 8) & 0xff)
 
337
                   << "\\x" << ((data[i+3] >> 16) & 0xff)
 
338
                   << "\\x" << ((data[i+3] >> 24) & 0xff);
 
339
            cppOut.setFieldWidth(0);
 
340
            cppOut << "\"\n";
 
341
            cppOut.setFieldWidth(2);
 
342
        }
 
343
        cppOut.setIntegerBase(10);
 
344
        cppOut.setFieldWidth(0);
 
345
        cppOut.setPadChar(' ');
 
346
    } else {
 
347
        cppOut << "    \"";
 
348
        for (int i = 0; i < size; i++) {
 
349
            cppOut << "\\x" << (data[i] & 0xff)
 
350
                   << "\\x" << ((data[i] >> 8) & 0xff)
 
351
                   << "\\x" << ((data[i] >> 16) & 0xff)
 
352
                   << "\\x" << ((data[i] >> 24) & 0xff);
 
353
        }
 
354
        cppOut.setIntegerBase(10);
 
355
        cppOut.setFieldWidth(0);
 
356
        cppOut.setPadChar(' ');
339
357
        cppOut << "\"\n";
340
 
        cppOut.setFieldWidth(2);
341
358
    }
342
 
    cppOut.setIntegerBase(10);
343
 
    cppOut.setFieldWidth(0);
344
 
    cppOut.setPadChar(' ');
345
359
}
346
360
 
347
361
int main(int argc, char* argv[])
392
406
    cppOut << "const int shapeTextureMipmapWidth = " << widthMipmap << ";\n"
393
407
           << "const int shapeTextureMipmapHeight = " << heightMipmap << ";\n"
394
408
           << "const int shapeTextureMipmapCount = " << mipmapCount << ";\n"
395
 
           << "static const int shapeTextureMipmapOffset[" << mipmapCount << "] = { 0";
 
409
           << "static const int shapeTextureMipmapOffset[" << mipmapCount << "] = {\n"
 
410
           << "    0";
396
411
    int size = 0, i = 0;
397
412
    for (int i = 0; i < mipmapCount-1; i++) {
398
413
        size += (widthMipmap >> i) * (heightMipmap >> i) * 4;
399
414
        cppOut << ", " << size;
400
415
    }
401
416
    size += (widthMipmap >> (mipmapCount-1)) * (heightMipmap >> (mipmapCount-1)) * 4;
402
 
    cppOut << " };\n";
 
417
    cppOut << "\n};\n";
403
418
    cppOut << "static const unsigned char shapeTextureMipmapData[" << textureCount
404
419
           <<   "][" << size + 1 << "] = {\n";
405
420
    for (int i = 0; i < mipmapCount; i++) {