Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: src/core/SkColorSpace.cpp

Issue 1952063002: Create SkColorSpaceXform to handle color conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Multiply by the inverse of 255.0f Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkAtomics.h" 8 #include "SkAtomics.h"
9 #include "SkColorSpace.h" 9 #include "SkColorSpace.h"
10 #include "SkOncePtr.h" 10 #include "SkOncePtr.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } else if (len < 12 + 2 * count) { 315 } else if (len < 12 + 2 * count) {
316 SkColorSpacePrintf("gamma tag is too small (%d bytes)", len) ; 316 SkColorSpacePrintf("gamma tag is too small (%d bytes)", len) ;
317 return false; 317 return false;
318 } 318 }
319 319
320 const uint16_t* table = (const uint16_t*) (src + 12); 320 const uint16_t* table = (const uint16_t*) (src + 12);
321 if (1 == count) { 321 if (1 == count) {
322 // The table entry is the gamma (with a bias of 256). 322 // The table entry is the gamma (with a bias of 256).
323 uint16_t value = read_big_endian_short((const uint8_t*) tabl e); 323 uint16_t value = read_big_endian_short((const uint8_t*) tabl e);
324 gammas[i].fValue = value / 256.0f; 324 gammas[i].fValue = value / 256.0f;
325 SkColorSpacePrintf("gamma %d %g\n", value, *gamma); 325 SkColorSpacePrintf("gamma %d %g\n", value, gammas[i].fValue) ;
326 break; 326 break;
327 } 327 }
328 328
329 // Fill in the interpolation table. 329 // Fill in the interpolation table.
330 // FIXME (msarett): 330 // FIXME (msarett):
331 // We should recognize commonly occurring tables and just set ga mma to 2.2f. 331 // We should recognize commonly occurring tables and just set ga mma to 2.2f.
332 gammas[i].fTableSize = count; 332 gammas[i].fTableSize = count;
333 gammas[i].fTable = std::unique_ptr<float[]>(new float[count]); 333 gammas[i].fTable = std::unique_ptr<float[]>(new float[count]);
334 for (uint32_t j = 0; j < count; j++) { 334 for (uint32_t j = 0; j < count; j++) {
335 gammas[i].fTable[j] = 335 gammas[i].fTable[j] =
(...skipping 28 matching lines...) Expand all
364 SkColorSpacePrintf("Invalid parametric curve type\n"); 364 SkColorSpacePrintf("Invalid parametric curve type\n");
365 return false; 365 return false;
366 } 366 }
367 break; 367 break;
368 default: 368 default:
369 SkColorSpacePrintf("Unsupported gamma tag type %d\n", type); 369 SkColorSpacePrintf("Unsupported gamma tag type %d\n", type);
370 return false; 370 return false;
371 } 371 }
372 372
373 // Adjust src and len if there is another gamma curve to load. 373 // Adjust src and len if there is another gamma curve to load.
374 if (0 != numGammas) { 374 if (i != numGammas - 1) {
375 // Each curve is padded to 4-byte alignment. 375 // Each curve is padded to 4-byte alignment.
376 tagBytes = SkAlign4(tagBytes); 376 tagBytes = SkAlign4(tagBytes);
377 if (len < tagBytes) { 377 if (len < tagBytes) {
378 return false; 378 return false;
379 } 379 }
380 380
381 src += tagBytes; 381 src += tagBytes;
382 len -= tagBytes; 382 len -= tagBytes;
383 } 383 }
384 } 384 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 toXYZ)); 632 toXYZ));
633 } 633 }
634 634
635 } 635 }
636 default: 636 default:
637 break; 637 break;
638 } 638 }
639 639
640 return_null("ICC profile contains unsupported colorspace"); 640 return_null("ICC profile contains unsupported colorspace");
641 } 641 }
OLDNEW
« dm/DMSrcSink.cpp ('K') | « src/core/SkColorSpace.h ('k') | src/core/SkColorSpaceXform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698