os/graphics/graphicsdeviceinterface/gdi/lookuptable/lookuptable.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/gdi/lookuptable/lookuptable.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,608 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "lookuptable.h"
    1.20 +
    1.21 +/**
    1.22 +@internalComponent
    1.23 +*/
    1.24 +// Lookup table low word for converting from 16bpp to 32bpp display modes
    1.25 +const TUint16 KBlt16to32Low[256] =
    1.26 +    {
    1.27 +    0x0000,
    1.28 +    0x0008,
    1.29 +    0x0010,
    1.30 +    0x0018,
    1.31 +    0x0021,
    1.32 +    0x0029,
    1.33 +    0x0031,
    1.34 +    0x0039,
    1.35 +    0x0042,
    1.36 +    0x004a,
    1.37 +    0x0052,
    1.38 +    0x005a,
    1.39 +    0x0063,
    1.40 +    0x006b,
    1.41 +    0x0073,
    1.42 +    0x007b,
    1.43 +    0x0084,
    1.44 +    0x008c,
    1.45 +    0x0094,
    1.46 +    0x009c,
    1.47 +    0x00a5,
    1.48 +    0x00ad,
    1.49 +    0x00b5,
    1.50 +    0x00bd,
    1.51 +    0x00c6,
    1.52 +    0x00ce,
    1.53 +    0x00d6,
    1.54 +    0x00de,
    1.55 +    0x00e7,
    1.56 +    0x00ef,
    1.57 +    0x00f7,
    1.58 +    0x00ff,
    1.59 +    0x0400,
    1.60 +    0x0408,
    1.61 +    0x0410,
    1.62 +    0x0418,
    1.63 +    0x0421,
    1.64 +    0x0429,
    1.65 +    0x0431,
    1.66 +    0x0439,
    1.67 +    0x0442,
    1.68 +    0x044a,
    1.69 +    0x0452,
    1.70 +    0x045a,
    1.71 +    0x0463,
    1.72 +    0x046b,
    1.73 +    0x0473,
    1.74 +    0x047b,
    1.75 +    0x0484,
    1.76 +    0x048c,
    1.77 +    0x0494,
    1.78 +    0x049c,
    1.79 +    0x04a5,
    1.80 +    0x04ad,
    1.81 +    0x04b5,
    1.82 +    0x04bd,
    1.83 +    0x04c6,
    1.84 +    0x04ce,
    1.85 +    0x04d6,
    1.86 +    0x04de,
    1.87 +    0x04e7,
    1.88 +    0x04ef,
    1.89 +    0x04f7,
    1.90 +    0x04ff,
    1.91 +    0x0800,
    1.92 +    0x0808,
    1.93 +    0x0810,
    1.94 +    0x0818,
    1.95 +    0x0821,
    1.96 +    0x0829,
    1.97 +    0x0831,
    1.98 +    0x0839,
    1.99 +    0x0842,
   1.100 +    0x084a,
   1.101 +    0x0852,
   1.102 +    0x085a,
   1.103 +    0x0863,
   1.104 +    0x086b,
   1.105 +    0x0873,
   1.106 +    0x087b,
   1.107 +    0x0884,
   1.108 +    0x088c,
   1.109 +    0x0894,
   1.110 +    0x089c,
   1.111 +    0x08a5,
   1.112 +    0x08ad,
   1.113 +    0x08b5,
   1.114 +    0x08bd,
   1.115 +    0x08c6,
   1.116 +    0x08ce,
   1.117 +    0x08d6,
   1.118 +    0x08de,
   1.119 +    0x08e7,
   1.120 +    0x08ef,
   1.121 +    0x08f7,
   1.122 +    0x08ff,
   1.123 +    0x0c00,
   1.124 +    0x0c08,
   1.125 +    0x0c10,
   1.126 +    0x0c18,
   1.127 +    0x0c21,
   1.128 +    0x0c29,
   1.129 +    0x0c31,
   1.130 +    0x0c39,
   1.131 +    0x0c42,
   1.132 +    0x0c4a,
   1.133 +    0x0c52,
   1.134 +    0x0c5a,
   1.135 +    0x0c63,
   1.136 +    0x0c6b,
   1.137 +    0x0c73,
   1.138 +    0x0c7b,
   1.139 +    0x0c84,
   1.140 +    0x0c8c,
   1.141 +    0x0c94,
   1.142 +    0x0c9c,
   1.143 +    0x0ca5,
   1.144 +    0x0cad,
   1.145 +    0x0cb5,
   1.146 +    0x0cbd,
   1.147 +    0x0cc6,
   1.148 +    0x0cce,
   1.149 +    0x0cd6,
   1.150 +    0x0cde,
   1.151 +    0x0ce7,
   1.152 +    0x0cef,
   1.153 +    0x0cf7,
   1.154 +    0x0cff,
   1.155 +    0x1000,
   1.156 +    0x1008,
   1.157 +    0x1010,
   1.158 +    0x1018,
   1.159 +    0x1021,
   1.160 +    0x1029,
   1.161 +    0x1031,
   1.162 +    0x1039,
   1.163 +    0x1042,
   1.164 +    0x104a,
   1.165 +    0x1052,
   1.166 +    0x105a,
   1.167 +    0x1063,
   1.168 +    0x106b,
   1.169 +    0x1073,
   1.170 +    0x107b,
   1.171 +    0x1084,
   1.172 +    0x108c,
   1.173 +    0x1094,
   1.174 +    0x109c,
   1.175 +    0x10a5,
   1.176 +    0x10ad,
   1.177 +    0x10b5,
   1.178 +    0x10bd,
   1.179 +    0x10c6,
   1.180 +    0x10ce,
   1.181 +    0x10d6,
   1.182 +    0x10de,
   1.183 +    0x10e7,
   1.184 +    0x10ef,
   1.185 +    0x10f7,
   1.186 +    0x10ff,
   1.187 +    0x1400,
   1.188 +    0x1408,
   1.189 +    0x1410,
   1.190 +    0x1418,
   1.191 +    0x1421,
   1.192 +    0x1429,
   1.193 +    0x1431,
   1.194 +    0x1439,
   1.195 +    0x1442,
   1.196 +    0x144a,
   1.197 +    0x1452,
   1.198 +    0x145a,
   1.199 +    0x1463,
   1.200 +    0x146b,
   1.201 +    0x1473,
   1.202 +    0x147b,
   1.203 +    0x1484,
   1.204 +    0x148c,
   1.205 +    0x1494,
   1.206 +    0x149c,
   1.207 +    0x14a5,
   1.208 +    0x14ad,
   1.209 +    0x14b5,
   1.210 +    0x14bd,
   1.211 +    0x14c6,
   1.212 +    0x14ce,
   1.213 +    0x14d6,
   1.214 +    0x14de,
   1.215 +    0x14e7,
   1.216 +    0x14ef,
   1.217 +    0x14f7,
   1.218 +    0x14ff,
   1.219 +    0x1800,
   1.220 +    0x1808,
   1.221 +    0x1810,
   1.222 +    0x1818,
   1.223 +    0x1821,
   1.224 +    0x1829,
   1.225 +    0x1831,
   1.226 +    0x1839,
   1.227 +    0x1842,
   1.228 +    0x184a,
   1.229 +    0x1852,
   1.230 +    0x185a,
   1.231 +    0x1863,
   1.232 +    0x186b,
   1.233 +    0x1873,
   1.234 +    0x187b,
   1.235 +    0x1884,
   1.236 +    0x188c,
   1.237 +    0x1894,
   1.238 +    0x189c,
   1.239 +    0x18a5,
   1.240 +    0x18ad,
   1.241 +    0x18b5,
   1.242 +    0x18bd,
   1.243 +    0x18c6,
   1.244 +    0x18ce,
   1.245 +    0x18d6,
   1.246 +    0x18de,
   1.247 +    0x18e7,
   1.248 +    0x18ef,
   1.249 +    0x18f7,
   1.250 +    0x18ff,
   1.251 +    0x1c00,
   1.252 +    0x1c08,
   1.253 +    0x1c10,
   1.254 +    0x1c18,
   1.255 +    0x1c21,
   1.256 +    0x1c29,
   1.257 +    0x1c31,
   1.258 +    0x1c39,
   1.259 +    0x1c42,
   1.260 +    0x1c4a,
   1.261 +    0x1c52,
   1.262 +    0x1c5a,
   1.263 +    0x1c63,
   1.264 +    0x1c6b,
   1.265 +    0x1c73,
   1.266 +    0x1c7b,
   1.267 +    0x1c84,
   1.268 +    0x1c8c,
   1.269 +    0x1c94,
   1.270 +    0x1c9c,
   1.271 +    0x1ca5,
   1.272 +    0x1cad,
   1.273 +    0x1cb5,
   1.274 +    0x1cbd,
   1.275 +    0x1cc6,
   1.276 +    0x1cce,
   1.277 +    0x1cd6,
   1.278 +    0x1cde,
   1.279 +    0x1ce7,
   1.280 +    0x1cef,
   1.281 +    0x1cf7,
   1.282 +    0x1cff
   1.283 +    };
   1.284 +
   1.285 +/**
   1.286 +@internalComponent
   1.287 +*/
   1.288 +// Lookup table high long word for converting from 16bpp to 32bpp display modes
   1.289 +const TUint32 KBlt16to32High[256] =
   1.290 +    {
   1.291 +    0xff000000,
   1.292 +    0xff002000,
   1.293 +    0xff004100,
   1.294 +    0xff006100,
   1.295 +    0xff008200,
   1.296 +    0xff00a200,
   1.297 +    0xff00c300,
   1.298 +    0xff00e300,
   1.299 +    0xff080000,
   1.300 +    0xff082000,
   1.301 +    0xff084100,
   1.302 +    0xff086100,
   1.303 +    0xff088200,
   1.304 +    0xff08a200,
   1.305 +    0xff08c300,
   1.306 +    0xff08e300,
   1.307 +    0xff100000,
   1.308 +    0xff102000,
   1.309 +    0xff104100,
   1.310 +    0xff106100,
   1.311 +    0xff108200,
   1.312 +    0xff10a200,
   1.313 +    0xff10c300,
   1.314 +    0xff10e300,
   1.315 +    0xff180000,
   1.316 +    0xff182000,
   1.317 +    0xff184100,
   1.318 +    0xff186100,
   1.319 +    0xff188200,
   1.320 +    0xff18a200,
   1.321 +    0xff18c300,
   1.322 +    0xff18e300,
   1.323 +    0xff210000,
   1.324 +    0xff212000,
   1.325 +    0xff214100,
   1.326 +    0xff216100,
   1.327 +    0xff218200,
   1.328 +    0xff21a200,
   1.329 +    0xff21c300,
   1.330 +    0xff21e300,
   1.331 +    0xff290000,
   1.332 +    0xff292000,
   1.333 +    0xff294100,
   1.334 +    0xff296100,
   1.335 +    0xff298200,
   1.336 +    0xff29a200,
   1.337 +    0xff29c300,
   1.338 +    0xff29e300,
   1.339 +    0xff310000,
   1.340 +    0xff312000,
   1.341 +    0xff314100,
   1.342 +    0xff316100,
   1.343 +    0xff318200,
   1.344 +    0xff31a200,
   1.345 +    0xff31c300,
   1.346 +    0xff31e300,
   1.347 +    0xff390000,
   1.348 +    0xff392000,
   1.349 +    0xff394100,
   1.350 +    0xff396100,
   1.351 +    0xff398200,
   1.352 +    0xff39a200,
   1.353 +    0xff39c300,
   1.354 +    0xff39e300,
   1.355 +    0xff420000,
   1.356 +    0xff422000,
   1.357 +    0xff424100,
   1.358 +    0xff426100,
   1.359 +    0xff428200,
   1.360 +    0xff42a200,
   1.361 +    0xff42c300,
   1.362 +    0xff42e300,
   1.363 +    0xff4a0000,
   1.364 +    0xff4a2000,
   1.365 +    0xff4a4100,
   1.366 +    0xff4a6100,
   1.367 +    0xff4a8200,
   1.368 +    0xff4aa200,
   1.369 +    0xff4ac300,
   1.370 +    0xff4ae300,
   1.371 +    0xff520000,
   1.372 +    0xff522000,
   1.373 +    0xff524100,
   1.374 +    0xff526100,
   1.375 +    0xff528200,
   1.376 +    0xff52a200,
   1.377 +    0xff52c300,
   1.378 +    0xff52e300,
   1.379 +    0xff5a0000,
   1.380 +    0xff5a2000,
   1.381 +    0xff5a4100,
   1.382 +    0xff5a6100,
   1.383 +    0xff5a8200,
   1.384 +    0xff5aa200,
   1.385 +    0xff5ac300,
   1.386 +    0xff5ae300,
   1.387 +    0xff630000,
   1.388 +    0xff632000,
   1.389 +    0xff634100,
   1.390 +    0xff636100,
   1.391 +    0xff638200,
   1.392 +    0xff63a200,
   1.393 +    0xff63c300,
   1.394 +    0xff63e300,
   1.395 +    0xff6b0000,
   1.396 +    0xff6b2000,
   1.397 +    0xff6b4100,
   1.398 +    0xff6b6100,
   1.399 +    0xff6b8200,
   1.400 +    0xff6ba200,
   1.401 +    0xff6bc300,
   1.402 +    0xff6be300,
   1.403 +    0xff730000,
   1.404 +    0xff732000,
   1.405 +    0xff734100,
   1.406 +    0xff736100,
   1.407 +    0xff738200,
   1.408 +    0xff73a200,
   1.409 +    0xff73c300,
   1.410 +    0xff73e300,
   1.411 +    0xff7b0000,
   1.412 +    0xff7b2000,
   1.413 +    0xff7b4100,
   1.414 +    0xff7b6100,
   1.415 +    0xff7b8200,
   1.416 +    0xff7ba200,
   1.417 +    0xff7bc300,
   1.418 +    0xff7be300,
   1.419 +    0xff840000,
   1.420 +    0xff842000,
   1.421 +    0xff844100,
   1.422 +    0xff846100,
   1.423 +    0xff848200,
   1.424 +    0xff84a200,
   1.425 +    0xff84c300,
   1.426 +    0xff84e300,
   1.427 +    0xff8c0000,
   1.428 +    0xff8c2000,
   1.429 +    0xff8c4100,
   1.430 +    0xff8c6100,
   1.431 +    0xff8c8200,
   1.432 +    0xff8ca200,
   1.433 +    0xff8cc300,
   1.434 +    0xff8ce300,
   1.435 +    0xff940000,
   1.436 +    0xff942000,
   1.437 +    0xff944100,
   1.438 +    0xff946100,
   1.439 +    0xff948200,
   1.440 +    0xff94a200,
   1.441 +    0xff94c300,
   1.442 +    0xff94e300,
   1.443 +    0xff9c0000,
   1.444 +    0xff9c2000,
   1.445 +    0xff9c4100,
   1.446 +    0xff9c6100,
   1.447 +    0xff9c8200,
   1.448 +    0xff9ca200,
   1.449 +    0xff9cc300,
   1.450 +    0xff9ce300,
   1.451 +    0xffa50000,
   1.452 +    0xffa52000,
   1.453 +    0xffa54100,
   1.454 +    0xffa56100,
   1.455 +    0xffa58200,
   1.456 +    0xffa5a200,
   1.457 +    0xffa5c300,
   1.458 +    0xffa5e300,
   1.459 +    0xffad0000,
   1.460 +    0xffad2000,
   1.461 +    0xffad4100,
   1.462 +    0xffad6100,
   1.463 +    0xffad8200,
   1.464 +    0xffada200,
   1.465 +    0xffadc300,
   1.466 +    0xffade300,
   1.467 +    0xffb50000,
   1.468 +    0xffb52000,
   1.469 +    0xffb54100,
   1.470 +    0xffb56100,
   1.471 +    0xffb58200,
   1.472 +    0xffb5a200,
   1.473 +    0xffb5c300,
   1.474 +    0xffb5e300,
   1.475 +    0xffbd0000,
   1.476 +    0xffbd2000,
   1.477 +    0xffbd4100,
   1.478 +    0xffbd6100,
   1.479 +    0xffbd8200,
   1.480 +    0xffbda200,
   1.481 +    0xffbdc300,
   1.482 +    0xffbde300,
   1.483 +    0xffc60000,
   1.484 +    0xffc62000,
   1.485 +    0xffc64100,
   1.486 +    0xffc66100,
   1.487 +    0xffc68200,
   1.488 +    0xffc6a200,
   1.489 +    0xffc6c300,
   1.490 +    0xffc6e300,
   1.491 +    0xffce0000,
   1.492 +    0xffce2000,
   1.493 +    0xffce4100,
   1.494 +    0xffce6100,
   1.495 +    0xffce8200,
   1.496 +    0xffcea200,
   1.497 +    0xffcec300,
   1.498 +    0xffcee300,
   1.499 +    0xffd60000,
   1.500 +    0xffd62000,
   1.501 +    0xffd64100,
   1.502 +    0xffd66100,
   1.503 +    0xffd68200,
   1.504 +    0xffd6a200,
   1.505 +    0xffd6c300,
   1.506 +    0xffd6e300,
   1.507 +    0xffde0000,
   1.508 +    0xffde2000,
   1.509 +    0xffde4100,
   1.510 +    0xffde6100,
   1.511 +    0xffde8200,
   1.512 +    0xffdea200,
   1.513 +    0xffdec300,
   1.514 +    0xffdee300,
   1.515 +    0xffe70000,
   1.516 +    0xffe72000,
   1.517 +    0xffe74100,
   1.518 +    0xffe76100,
   1.519 +    0xffe78200,
   1.520 +    0xffe7a200,
   1.521 +    0xffe7c300,
   1.522 +    0xffe7e300,
   1.523 +    0xffef0000,
   1.524 +    0xffef2000,
   1.525 +    0xffef4100,
   1.526 +    0xffef6100,
   1.527 +    0xffef8200,
   1.528 +    0xffefa200,
   1.529 +    0xffefc300,
   1.530 +    0xffefe300,
   1.531 +    0xfff70000,
   1.532 +    0xfff72000,
   1.533 +    0xfff74100,
   1.534 +    0xfff76100,
   1.535 +    0xfff78200,
   1.536 +    0xfff7a200,
   1.537 +    0xfff7c300,
   1.538 +    0xfff7e300,
   1.539 +    0xffff0000,
   1.540 +    0xffff2000,
   1.541 +    0xffff4100,
   1.542 +    0xffff6100,
   1.543 +    0xffff8200,
   1.544 +    0xffffa200,
   1.545 +    0xffffc300,
   1.546 +    0xffffe300
   1.547 +    };
   1.548 +    
   1.549 +    
   1.550 +const TUint16 NormalisationTable16Bit[256] = {
   1.551 +	0,65280,32640,21760,16320,13056,10880,9326,8160,7254,6528,
   1.552 +	5935,5440,5022,4663,4352,4080,3840,3627,3436,3264,
   1.553 +	3109,2968,2839,2720,2612,2511,2418,2332,2252,2176,
   1.554 +	2106,2040,1979,1920,1866,1814,1765,1718,1674,1632,
   1.555 +	1593,1555,1519,1484,1451,1420,1389,1360,1333,1306,
   1.556 +	1280,1256,1232,1209,1187,1166,1146,1126,1107,1088,
   1.557 +	1071,1053,1037,1020,1005,990,975,960,947,933,
   1.558 +	920,907,895,883,871,859,848,837,827,816,
   1.559 +	806,797,787,778,768,760,751,742,734,726,
   1.560 +	718,710,702,695,688,680,673,667,660,653,
   1.561 +	647,640,634,628,622,616,611,605,599,594,
   1.562 +	589,583,578,573,568,563,558,554,549,544,
   1.563 +	540,536,531,527,523,519,515,510,507,503,
   1.564 +	499,495,491,488,484,480,477,474,470,467,
   1.565 +	463,460,457,454,451,448,445,442,439,436,
   1.566 +	433,430,427,424,422,419,416,414,411,408,
   1.567 +	406,403,401,399,396,394,391,389,387,384,
   1.568 +	382,380,378,376,374,371,369,367,365,363,
   1.569 +	361,359,357,355,353,351,350,348,346,344,
   1.570 +	342,340,339,337,335,334,332,330,329,327,
   1.571 +	325,324,322,320,319,317,316,314,313,311,
   1.572 +	310,308,307,306,304,303,301,300,299,297,
   1.573 +	296,295,293,292,291,289,288,287,286,284,
   1.574 +	283,282,281,279,278,277,276,275,274,272,
   1.575 +	271,270,269,268,267,266,265,264,263,262,
   1.576 +	261,260,259,258,256,
   1.577 +};
   1.578 +
   1.579 +
   1.580 +/**
   1.581 +This function will return value of converted 16bpp to 32bpp display modes. This lookup table is 
   1.582 +used to improve performance.
   1.583 +@internalComponent
   1.584 +*/
   1.585 +
   1.586 + EXPORT_C const TUint16* Convert16to32bppLow()
   1.587 + 	{
   1.588 + 	return KBlt16to32Low;
   1.589 + 	}
   1.590 + 
   1.591 + EXPORT_C const TUint32* Convert16to32bppHigh()
   1.592 + 	{
   1.593 + 	return KBlt16to32High;
   1.594 + 	}
   1.595 +
   1.596 +/**
   1.597 +Returns the pointer to the table of 16-bit normalisation table.
   1.598 +The table is currently used for performing un-multiplying Premultiplied Alpha color channels.
   1.599 +This lookup table for normalised alpha is compluted using this equation: Table[index] = (255*256) / index (where index is an 8 bit value)
   1.600 +Use: Let x be c * a/255, and y = c, then y = (x/a)*255, where a is in 0-255 range.
   1.601 +		To use this table, use y = (x * Table[a])>>8. i.e, the inaccurate division is converted 
   1.602 +		to more accurate multiplication and shift.
   1.603 +		
   1.604 +@return pointer to the normalisation table.
   1.605 +@internalTechnology
   1.606 +*/
   1.607 +EXPORT_C const TUint16* PtrTo16BitNormalisationTable()
   1.608 +	{
   1.609 +	return &NormalisationTable16Bit[0];
   1.610 +	}
   1.611 +