Coverage Report

Created: 2021-08-22 09:07

/src/skia/third_party/externals/dng_sdk/source/dng_simple_image.cpp
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************/
2
// Copyright 2006-2008 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_simple_image.cpp#1 $ */ 
10
/* $DateTime: 2012/05/30 13:28:51 $ */
11
/* $Change: 832332 $ */
12
/* $Author: tknoll $ */
13
14
/*****************************************************************************/
15
16
#include "dng_simple_image.h"
17
18
#include "dng_memory.h"
19
#include "dng_orientation.h"
20
#include "dng_tag_types.h"
21
#include "dng_tag_values.h"
22
23
/*****************************************************************************/
24
25
dng_simple_image::dng_simple_image (const dng_rect &bounds,
26
                  uint32 planes,
27
                    uint32 pixelType,
28
                    dng_memory_allocator &allocator)
29
                    
30
  : dng_image (bounds,
31
           planes,
32
           pixelType)
33
           
34
  , fMemory    ()
35
  , fAllocator (allocator)
36
           
37
0
  {
38
  
39
0
  uint32 bytes =
40
0
    ComputeBufferSize (pixelType, bounds.Size (), planes, pad16Bytes);
41
           
42
0
  fMemory.Reset (allocator.Allocate (bytes));
43
  
44
0
  fBuffer = dng_pixel_buffer (bounds, 0, planes, pixelType, pcInterleaved, fMemory->Buffer ());
45
  
46
0
  }
47
48
/*****************************************************************************/
49
50
dng_simple_image::~dng_simple_image ()
51
0
  {
52
  
53
0
  }
54
55
/*****************************************************************************/
56
57
dng_image * dng_simple_image::Clone () const
58
0
  {
59
  
60
0
  AutoPtr<dng_simple_image> result (new dng_simple_image (Bounds (),
61
0
                              Planes (),
62
0
                              PixelType (),
63
0
                              fAllocator));
64
                              
65
0
  result->fBuffer.CopyArea (fBuffer,
66
0
                Bounds (),
67
0
                0,
68
0
                Planes ());
69
                              
70
0
  return result.Release ();
71
  
72
0
  }
73
74
/*****************************************************************************/
75
76
void dng_simple_image::SetPixelType (uint32 pixelType)
77
0
  {
78
  
79
0
  dng_image::SetPixelType (pixelType);
80
  
81
0
  fBuffer.fPixelType = pixelType;
82
  
83
0
  }
84
85
/*****************************************************************************/
86
87
void dng_simple_image::Trim (const dng_rect &r)
88
0
  {
89
  
90
0
  fBounds.t = 0;
91
0
  fBounds.l = 0;
92
  
93
0
  fBounds.b = r.H ();
94
0
  fBounds.r = r.W ();
95
  
96
0
  fBuffer.fData = fBuffer.DirtyPixel (r.t, r.l);
97
                   
98
0
  fBuffer.fArea = fBounds;
99
  
100
0
  }
101
    
102
/*****************************************************************************/
103
104
void dng_simple_image::Rotate (const dng_orientation &orientation)
105
0
  {
106
  
107
0
  int32 originH = fBounds.l;
108
0
  int32 originV = fBounds.t;
109
  
110
0
  int32 colStep = fBuffer.fColStep;
111
0
  int32 rowStep = fBuffer.fRowStep;
112
  
113
0
  uint32 width  = fBounds.W ();
114
0
  uint32 height = fBounds.H ();
115
  
116
0
  if (orientation.FlipH ())
117
0
    {
118
    
119
0
    originH += width - 1;
120
    
121
0
    colStep = -colStep;
122
    
123
0
    }
124
125
0
  if (orientation.FlipV ())
126
0
    {
127
    
128
0
    originV += height - 1;
129
    
130
0
    rowStep = -rowStep;
131
    
132
0
    }
133
    
134
0
  if (orientation.FlipD ())
135
0
    {
136
    
137
0
    int32 temp = colStep;
138
    
139
0
    colStep = rowStep;
140
0
    rowStep = temp;
141
    
142
0
    width  = fBounds.H ();
143
0
    height = fBounds.W ();
144
    
145
0
    }
146
    
147
0
  fBuffer.fData = fBuffer.DirtyPixel (originV, originH);
148
  
149
0
  fBuffer.fColStep = colStep;
150
0
  fBuffer.fRowStep = rowStep;
151
    
152
0
  fBounds.r = fBounds.l + width;
153
0
  fBounds.b = fBounds.t + height;
154
  
155
0
  fBuffer.fArea = fBounds;
156
                
157
0
  }
158
    
159
/*****************************************************************************/
160
161
void dng_simple_image::AcquireTileBuffer (dng_tile_buffer &buffer,
162
                      const dng_rect &area,
163
                      bool dirty) const
164
0
  {
165
  
166
0
  buffer.fArea = area;
167
  
168
0
  buffer.fPlane      = fBuffer.fPlane;
169
0
  buffer.fPlanes     = fBuffer.fPlanes;
170
0
  buffer.fRowStep    = fBuffer.fRowStep;
171
0
  buffer.fColStep    = fBuffer.fColStep;
172
0
  buffer.fPlaneStep  = fBuffer.fPlaneStep;
173
0
  buffer.fPixelType  = fBuffer.fPixelType;
174
0
  buffer.fPixelSize  = fBuffer.fPixelSize;
175
176
0
  buffer.fData = (void *) fBuffer.ConstPixel (buffer.fArea.t,
177
0
                          buffer.fArea.l,
178
0
                          buffer.fPlane);
179
                      
180
0
  buffer.fDirty = dirty;
181
                  
182
0
  }
183
    
184
/*****************************************************************************/
185