Coverage Report

Created: 2021-08-22 09:07

/src/skia/third_party/externals/dng_sdk/source/dng_xy_coord.cpp
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************/
2
// Copyright 2006-2007 Adobe Systems Incorporated
3
// All Rights Reserved.
4
//
5
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
6
// accordance with the terms of the Adobe license agreement accompanying it.
7
/*****************************************************************************/
8
9
/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_xy_coord.cpp#1 $ */ 
10
/* $DateTime: 2012/05/30 13:28:51 $ */
11
/* $Change: 832332 $ */
12
/* $Author: tknoll $ */
13
14
/*****************************************************************************/
15
16
#include "dng_xy_coord.h"
17
18
#include "dng_matrix.h"
19
#include "dng_utils.h"
20
21
/******************************************************************************/
22
23
dng_xy_coord XYZtoXY (const dng_vector_3 &coord)
24
0
  {
25
  
26
0
  real64 X = coord [0];
27
0
  real64 Y = coord [1];
28
0
  real64 Z = coord [2];
29
  
30
0
  real64 total = X + Y + Z;
31
  
32
0
  if (total > 0.0)
33
0
    {
34
    
35
0
    return dng_xy_coord (X / total,
36
0
                 Y / total);
37
            
38
0
    }
39
    
40
0
  return D50_xy_coord ();
41
    
42
0
  }
43
44
/*****************************************************************************/
45
46
dng_vector_3 XYtoXYZ (const dng_xy_coord &coord)
47
0
  {
48
  
49
0
  dng_xy_coord temp = coord;
50
  
51
  // Restrict xy coord to someplace inside the range of real xy coordinates.
52
  // This prevents math from doing strange things when users specify
53
  // extreme temperature/tint coordinates.
54
  
55
0
  temp.x = Pin_real64 (0.000001, temp.x, 0.999999);
56
0
  temp.y = Pin_real64 (0.000001, temp.y, 0.999999);
57
  
58
0
  if (temp.x + temp.y > 0.999999)
59
0
    {
60
0
    real64 scale = 0.999999 / (temp.x + temp.y);
61
0
    temp.x *= scale;
62
0
    temp.y *= scale;
63
0
    }
64
  
65
0
  return dng_vector_3 (temp.x / temp.y,
66
0
               1.0,
67
0
               (1.0 - temp.x - temp.y) / temp.y);
68
  
69
0
  }
70
71
/*****************************************************************************/
72
73
dng_xy_coord PCStoXY ()
74
0
  {
75
  
76
0
  return D50_xy_coord ();
77
  
78
0
  }
79
80
/*****************************************************************************/
81
82
dng_vector_3 PCStoXYZ ()
83
0
  {
84
  
85
0
  return XYtoXYZ (PCStoXY ());
86
  
87
0
  }
88
89
/*****************************************************************************/