summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2017-02-14 14:59:30 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-02-14 14:59:52 +0000
commitceb3ab55ca5ad1fae590f50a09f04b7ed47656b1 (patch)
tree068a52577d5bb66f64777c5adcf7d25b6961cf4d /core/fpdfapi/page
parent92a32db931c1303388158f8a9e045e922d0b8dfa (diff)
downloadpdfium-ceb3ab55ca5ad1fae590f50a09f04b7ed47656b1.tar.xz
Revert "Cleanup CPDF_MeshStream"
This reverts commit 9787a7441a905e582b10d9ffc425098b3233d36c. Reason for revert: Reverting chain to see if fixes Chrome roll. Original change's description: > Cleanup CPDF_MeshStream > > This CL converts the MeshVertex to a point and the TransformPoint to the > CFX_PointF override. > > Change-Id: I3faa5c14cedcf5af6aafca1c566acbc68577cca7 > Reviewed-on: https://pdfium-review.googlesource.com/2610 > Commit-Queue: dsinclair <dsinclair@chromium.org> > Reviewed-by: Nicolás Peña <npm@chromium.org> > TBR=tsepez@chromium.org,dsinclair@chromium.org,npm@chromium.org,caryclark@google.com,pdfium-reviews@googlegroups.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ie1b1dae3ede7581128a81cf7cd86a348c651233b Reviewed-on: https://pdfium-review.googlesource.com/2695 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_meshstream.cpp69
-rw-r--r--core/fpdfapi/page/cpdf_meshstream.h25
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp10
3 files changed, 41 insertions, 63 deletions
diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp
index 75069cab7f..b852901794 100644
--- a/core/fpdfapi/page/cpdf_meshstream.cpp
+++ b/core/fpdfapi/page/cpdf_meshstream.cpp
@@ -83,12 +83,6 @@ bool IsValidBitsPerFlag(uint32_t x) {
} // namespace
-CPDF_MeshVertex::CPDF_MeshVertex() = default;
-
-CPDF_MeshVertex::CPDF_MeshVertex(const CPDF_MeshVertex&) = default;
-
-CPDF_MeshVertex::~CPDF_MeshVertex() = default;
-
CPDF_MeshStream::CPDF_MeshStream(
ShadingType type,
const std::vector<std::unique_ptr<CPDF_Function>>& funcs,
@@ -154,47 +148,37 @@ bool CPDF_MeshStream::Load() {
return true;
}
-uint32_t CPDF_MeshStream::ReadFlag() {
+uint32_t CPDF_MeshStream::GetFlag() {
ASSERT(ShouldCheckBitsPerFlag(m_type));
return m_BitStream.GetBits(m_nFlagBits) & 0x03;
}
-CFX_PointF CPDF_MeshStream::ReadCoords() {
+void CPDF_MeshStream::GetCoords(FX_FLOAT& x, FX_FLOAT& y) {
ASSERT(ShouldCheckBPC(m_type));
-
- CFX_PointF pos;
if (m_nCoordBits == 32) {
- pos.x = m_xmin +
- m_BitStream.GetBits(m_nCoordBits) * (m_xmax - m_xmin) /
- static_cast<double>(m_CoordMax);
- pos.y = m_ymin +
- m_BitStream.GetBits(m_nCoordBits) * (m_ymax - m_ymin) /
- static_cast<double>(m_CoordMax);
+ x = m_xmin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) *
+ (m_xmax - m_xmin) / (double)m_CoordMax);
+ y = m_ymin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) *
+ (m_ymax - m_ymin) / (double)m_CoordMax);
} else {
- pos.x = m_xmin +
- m_BitStream.GetBits(m_nCoordBits) * (m_xmax - m_xmin) / m_CoordMax;
- pos.y = m_ymin +
- m_BitStream.GetBits(m_nCoordBits) * (m_ymax - m_ymin) / m_CoordMax;
+ x = m_xmin +
+ m_BitStream.GetBits(m_nCoordBits) * (m_xmax - m_xmin) / m_CoordMax;
+ y = m_ymin +
+ m_BitStream.GetBits(m_nCoordBits) * (m_ymax - m_ymin) / m_CoordMax;
}
- return pos;
}
-std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT> CPDF_MeshStream::ReadColor() {
+void CPDF_MeshStream::GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b) {
ASSERT(ShouldCheckBPC(m_type));
-
FX_FLOAT color_value[kMaxComponents];
for (uint32_t i = 0; i < m_nComponents; ++i) {
color_value[i] = m_ColorMin[i] +
m_BitStream.GetBits(m_nComponentBits) *
(m_ColorMax[i] - m_ColorMin[i]) / m_ComponentMax;
}
-
- FX_FLOAT r;
- FX_FLOAT g;
- FX_FLOAT b;
if (m_funcs.empty()) {
m_pCS->GetRGB(color_value, r, g, b);
- return std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT>(r, g, b);
+ return;
}
FX_FLOAT result[kMaxComponents];
@@ -204,32 +188,29 @@ std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT> CPDF_MeshStream::ReadColor() {
if (func && func->CountOutputs() <= kMaxComponents)
func->Call(color_value, 1, result, nResults);
}
-
m_pCS->GetRGB(result, r, g, b);
- return std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT>(r, g, b);
}
-CPDF_MeshVertex CPDF_MeshStream::ReadVertex(const CFX_Matrix& pObject2Bitmap,
- uint32_t* flag) {
- *flag = ReadFlag();
-
- CPDF_MeshVertex vertex;
- vertex.position = pObject2Bitmap.Transform(ReadCoords());
- std::tie(vertex.r, vertex.g, vertex.b) = ReadColor();
+uint32_t CPDF_MeshStream::GetVertex(CPDF_MeshVertex& vertex,
+ CFX_Matrix* pObject2Bitmap) {
+ uint32_t flag = GetFlag();
+ GetCoords(vertex.x, vertex.y);
+ pObject2Bitmap->TransformPoint(vertex.x, vertex.y);
+ GetColor(vertex.r, vertex.g, vertex.b);
m_BitStream.ByteAlign();
-
- return vertex;
+ return flag;
}
-bool CPDF_MeshStream::ReadVertexRow(const CFX_Matrix& pObject2Bitmap,
- int count,
- CPDF_MeshVertex* vertex) {
+bool CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex,
+ int count,
+ CFX_Matrix* pObject2Bitmap) {
for (int i = 0; i < count; i++) {
if (m_BitStream.IsEOF())
return false;
- vertex[i].position = pObject2Bitmap.Transform(ReadCoords());
- std::tie(vertex[i].r, vertex[i].g, vertex[i].b) = ReadColor();
+ GetCoords(vertex[i].x, vertex[i].y);
+ pObject2Bitmap->TransformPoint(vertex[i].x, vertex[i].y);
+ GetColor(vertex[i].r, vertex[i].g, vertex[i].b);
m_BitStream.ByteAlign();
}
return true;
diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h
index 24f1d66cfd..21a6c2fa8c 100644
--- a/core/fpdfapi/page/cpdf_meshstream.h
+++ b/core/fpdfapi/page/cpdf_meshstream.h
@@ -8,7 +8,6 @@
#define CORE_FPDFAPI_PAGE_CPDF_MESHSTREAM_H_
#include <memory>
-#include <tuple>
#include <vector>
#include "core/fpdfapi/page/cpdf_shadingpattern.h"
@@ -16,13 +15,9 @@
#include "core/fxcrt/fx_basic.h"
#include "core/fxcrt/fx_system.h"
-class CPDF_MeshVertex {
- public:
- CPDF_MeshVertex();
- CPDF_MeshVertex(const CPDF_MeshVertex&);
- ~CPDF_MeshVertex();
-
- CFX_PointF position;
+struct CPDF_MeshVertex {
+ FX_FLOAT x;
+ FX_FLOAT y;
FX_FLOAT r;
FX_FLOAT g;
FX_FLOAT b;
@@ -42,14 +37,14 @@ class CPDF_MeshStream {
bool Load();
- uint32_t ReadFlag();
- CFX_PointF ReadCoords();
- std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT> ReadColor();
+ uint32_t GetFlag();
+ void GetCoords(FX_FLOAT& x, FX_FLOAT& y);
+ void GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b);
- CPDF_MeshVertex ReadVertex(const CFX_Matrix& pObject2Bitmap, uint32_t* flag);
- bool ReadVertexRow(const CFX_Matrix& pObject2Bitmap,
- int count,
- CPDF_MeshVertex* vertex);
+ uint32_t GetVertex(CPDF_MeshVertex& vertex, CFX_Matrix* pObject2Bitmap);
+ bool GetVertexRow(CPDF_MeshVertex* vertex,
+ int count,
+ CFX_Matrix* pObject2Bitmap);
CFX_BitStream* BitStream() { return &m_BitStream; }
uint32_t ComponentBits() const { return m_nComponentBits; }
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 0af43d08b2..61efb48529 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -99,7 +99,7 @@ CFX_FloatRect GetShadingBBox(CPDF_ShadingPattern* pShading,
while (!stream.BitStream()->IsEOF()) {
uint32_t flag = 0;
if (type != kLatticeFormGouraudTriangleMeshShading)
- flag = stream.ReadFlag();
+ flag = stream.GetFlag();
if (!bGouraud && flag) {
point_count -= 4;
@@ -107,11 +107,13 @@ CFX_FloatRect GetShadingBBox(CPDF_ShadingPattern* pShading,
}
for (int i = 0; i < point_count; i++) {
- CFX_PointF origin = stream.ReadCoords();
+ FX_FLOAT x;
+ FX_FLOAT y;
+ stream.GetCoords(x, y);
if (bStarted) {
- rect.UpdateRect(origin.x, origin.y);
+ rect.UpdateRect(x, y);
} else {
- rect.InitRect(origin.x, origin.y);
+ rect.InitRect(x, y);
bStarted = true;
}
}