Switch CPDF_MeshStream to use FX_RGB
Consistently use this struct instead of std::array.
Change-Id: I9ccfd55834bc0a118d9e6c937604be6796005522
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117817
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp
index ea90c58..1036c2b 100644
--- a/core/fpdfapi/page/cpdf_meshstream.cpp
+++ b/core/fpdfapi/page/cpdf_meshstream.cpp
@@ -200,7 +200,7 @@
return pos;
}
-std::array<float, 3> CPDF_MeshStream::ReadColor() const {
+FX_RGB<float> CPDF_MeshStream::ReadColor() const {
DCHECK(ShouldCheckBPC(m_type));
float color_value[kMaxComponents];
@@ -210,9 +210,9 @@
m_ComponentMax;
}
- std::array<float, 3> rgb = {};
+ FX_RGB<float> rgb = {};
if (m_funcs.empty()) {
- m_pCS->GetRGB(color_value, &rgb[0], &rgb[1], &rgb[2]);
+ m_pCS->GetRGB(color_value, &rgb.red, &rgb.green, &rgb.blue);
return rgb;
}
@@ -223,7 +223,7 @@
}
}
- m_pCS->GetRGB(result, &rgb[0], &rgb[1], &rgb[2]);
+ m_pCS->GetRGB(result, &rgb.red, &rgb.green, &rgb.blue);
return rgb;
}
diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h
index 48c68e7..591a0be 100644
--- a/core/fpdfapi/page/cpdf_meshstream.h
+++ b/core/fpdfapi/page/cpdf_meshstream.h
@@ -9,12 +9,12 @@
#include <stdint.h>
-#include <array>
#include <memory>
#include <vector>
#include "core/fpdfapi/page/cpdf_shadingpattern.h"
#include "core/fxcrt/retain_ptr.h"
+#include "core/fxge/dib/fx_dib.h"
class CPDF_StreamAcc;
@@ -25,7 +25,7 @@
~CPDF_MeshVertex();
CFX_PointF position;
- std::array<float, 3> rgb = {};
+ FX_RGB<float> rgb = {};
};
class CFX_BitStream;
@@ -53,7 +53,7 @@
uint32_t ReadFlag() const;
CFX_PointF ReadCoords() const;
- std::array<float, 3> ReadColor() const;
+ FX_RGB<float> ReadColor() const;
bool ReadVertex(const CFX_Matrix& pObject2Bitmap,
CPDF_MeshVertex* vertex,
diff --git a/core/fpdfapi/render/cpdf_rendershading.cpp b/core/fpdfapi/render/cpdf_rendershading.cpp
index 7b9b557..93fc3a0 100644
--- a/core/fpdfapi/render/cpdf_rendershading.cpp
+++ b/core/fpdfapi/render/cpdf_rendershading.cpp
@@ -371,11 +371,11 @@
float y_dist = (y - position1.y) / (position2.y - position1.y);
r[nIntersects] =
- vertex1.rgb[0] + ((vertex2.rgb[0] - vertex1.rgb[0]) * y_dist);
- g[nIntersects] =
- vertex1.rgb[1] + ((vertex2.rgb[1] - vertex1.rgb[1]) * y_dist);
+ vertex1.rgb.red + ((vertex2.rgb.red - vertex1.rgb.red) * y_dist);
+ g[nIntersects] = vertex1.rgb.green +
+ ((vertex2.rgb.green - vertex1.rgb.green) * y_dist);
b[nIntersects] =
- vertex1.rgb[2] + ((vertex2.rgb[2] - vertex1.rgb[2]) * y_dist);
+ vertex1.rgb.blue + ((vertex2.rgb.blue - vertex1.rgb.blue) * y_dist);
nIntersects++;
}
if (nIntersects != 2)
@@ -848,10 +848,10 @@
if (!stream.CanReadColor())
break;
- std::array<float, 3> rgb = stream.ReadColor();
- patch.patch_colors[i].comp[0] = static_cast<int32_t>(rgb[0] * 255);
- patch.patch_colors[i].comp[1] = static_cast<int32_t>(rgb[1] * 255);
- patch.patch_colors[i].comp[2] = static_cast<int32_t>(rgb[2] * 255);
+ FX_RGB<float> rgb = stream.ReadColor();
+ patch.patch_colors[i].comp[0] = static_cast<int32_t>(rgb.red * 255);
+ patch.patch_colors[i].comp[1] = static_cast<int32_t>(rgb.green * 255);
+ patch.patch_colors[i].comp[2] = static_cast<int32_t>(rgb.blue * 255);
}
CFX_FloatRect bbox =
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index e4dbbf9..f8043b2 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -1329,12 +1329,10 @@
cubics[i].fY = point.y;
}
for (size_t i = start_color; i < std::size(colors); ++i) {
- float r;
- float g;
- float b;
- std::tie(r, g, b) = stream.ReadColor();
- colors[i] = SkColorSetARGB(0xFF, (U8CPU)(r * 255), (U8CPU)(g * 255),
- (U8CPU)(b * 255));
+ FX_RGB<float> rgb = stream.ReadColor();
+ colors[i] =
+ SkColorSetARGB(0xFF, (U8CPU)(rgb.red * 255),
+ (U8CPU)(rgb.green * 255), (U8CPU)(rgb.blue * 255));
}
m_pCanvas->drawPatch(cubics, colors, /*texCoords=*/nullptr,
SkBlendMode::kDst, paint);