Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cpdf_expintfunc.cpp
Go to the documentation of this file.
1
// Copyright 2017 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7
#
include
"core/fpdfapi/page/cpdf_expintfunc.h"
8
9
#
include
<
math
.
h
>
10
11
#
include
"core/fpdfapi/parser/cpdf_array.h"
12
#
include
"core/fpdfapi/parser/cpdf_dictionary.h"
13
#
include
"core/fpdfapi/parser/cpdf_number.h"
14
#
include
"core/fxcrt/data_vector.h"
15
#
include
"core/fxcrt/fx_2d_size.h"
16
#
include
"core/fxcrt/fx_safe_types.h"
17
#
include
"core/fxcrt/stl_util.h"
18
19
CPDF_ExpIntFunc::
CPDF_ExpIntFunc
()
20
:
CPDF_Function
(
Type
::
kType2ExponentialInterpolation
)
{}
21
22
CPDF_ExpIntFunc::~
CPDF_ExpIntFunc
() =
default
;
23
24
bool
CPDF_ExpIntFunc::
v_Init
(
const
CPDF_Object
* pObj, VisitedSet* pVisited) {
25
CHECK
(pObj
->
IsDictionary
(
)
|| pObj
->
IsStream
(
)
);
26
RetainPtr
<
const
CPDF_Dictionary
> pDict = pObj->GetDict();
27
RetainPtr
<
const
CPDF_Number> pExponent = pDict->GetNumberFor(
"N"
);
28
if
(!pExponent)
29
return
false
;
30
31
m_Exponent = pExponent->GetNumber();
32
33
RetainPtr
<
const
CPDF_Array
> pArray0 = pDict->GetArrayFor(
"C0"
);
34
if
(pArray0 && m_nOutputs == 0)
35
m_nOutputs = fxcrt::CollectionSize<uint32_t>(*pArray0);
36
if
(m_nOutputs == 0)
37
m_nOutputs = 1;
38
39
RetainPtr
<
const
CPDF_Array
> pArray1 = pDict->GetArrayFor(
"C1"
);
40
m_BeginValues = DataVector<
float
>(Fx2DSizeOrDie(m_nOutputs, 2));
41
m_EndValues = DataVector<
float
>(m_BeginValues.size());
42
for
(uint32_t i = 0; i < m_nOutputs; i++) {
43
m_BeginValues[i] = pArray0 ? pArray0->GetFloatAt(i) : 0.0f;
44
m_EndValues[i] = pArray1 ? pArray1->GetFloatAt(i) : 1.0f;
45
}
46
47
FX_SAFE_UINT32
nOutputs = m_nOutputs;
48
nOutputs *= m_nInputs;
49
if
(!nOutputs.IsValid())
50
return
false
;
51
52
m_nOrigOutputs = m_nOutputs;
53
m_nOutputs = nOutputs.ValueOrDie();
54
return
true
;
55
}
56
57
bool
CPDF_ExpIntFunc::
v_Call
(pdfium::span<
const
float
> inputs,
58
pdfium::span<
float
> results)
const
{
59
for
(uint32_t i = 0; i < m_nInputs; i++) {
60
for
(uint32_t j = 0; j < m_nOrigOutputs; j++) {
61
results[i * m_nOrigOutputs + j] =
62
m_BeginValues[j] +
63
powf(inputs[i], m_Exponent) * (m_EndValues[j] - m_BeginValues[j]);
64
}
65
}
66
return
true
;
67
}
CPDF_Array::const_iterator
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
Definition
cpdf_array.h:29
CPDF_Dictionary::DictMap
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
Definition
cpdf_dictionary.h:31
CPDF_ExpIntFunc::~CPDF_ExpIntFunc
~CPDF_ExpIntFunc() override
CPDF_ExpIntFunc::v_Init
bool v_Init(const CPDF_Object *pObj, VisitedSet *pVisited) override
Definition
cpdf_expintfunc.cpp:24
CPDF_ExpIntFunc::v_Call
bool v_Call(pdfium::span< const float > inputs, pdfium::span< float > results) const override
Definition
cpdf_expintfunc.cpp:57
CPDF_ExpIntFunc::CPDF_ExpIntFunc
CPDF_ExpIntFunc()
Definition
cpdf_expintfunc.cpp:19
CPDF_Function
Definition
cpdf_function.h:23
CPDF_Function::CPDF_Function
CPDF_Function(Type type)
Definition
cpdf_function.cpp:84
CPDF_Function::Type
Type
Definition
cpdf_function.h:26
CPDF_Function::Type::kType2ExponentialInterpolation
@ kType2ExponentialInterpolation
Definition
cpdf_function.h:29
CPDF_Object
Definition
cpdf_object.h:50
CPDF_Object::IsDictionary
bool IsDictionary() const
Definition
cpdf_object.h:137
CPDF_Object::IsStream
bool IsStream() const
Definition
cpdf_object.h:142
fxcrt::RetainPtr
Definition
retain_ptr.h:28
FX_SAFE_UINT32
pdfium::CheckedNumeric< uint32_t > FX_SAFE_UINT32
Definition
fx_safe_types.h:14
CHECK
#define CHECK(cvref)
Definition
q23utility.cpp:15
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfapi
page
cpdf_expintfunc.cpp
Generated on
for Qt by
1.18.0