Better encapsulate CFX_MeshStream::m_Bitstream
Avoid std::unique_ptr<>::get() in accessors.
Change-Id: Ia843bbd6bc76c10b257ae326224b8ac402fd8bab
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/95670
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp
index 60759f0..7484f30 100644
--- a/core/fpdfapi/page/cpdf_meshstream.cpp
+++ b/core/fpdfapi/page/cpdf_meshstream.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
+#include "core/fxcrt/cfx_bitstream.h"
#include "third_party/base/check.h"
#include "third_party/base/span.h"
@@ -149,6 +150,18 @@
return true;
}
+void CPDF_MeshStream::SkipBits(uint32_t nbits) {
+ m_BitStream->SkipBits(nbits);
+}
+
+void CPDF_MeshStream::ByteAlign() {
+ m_BitStream->ByteAlign();
+}
+
+bool CPDF_MeshStream::IsEOF() const {
+ return m_BitStream->IsEOF();
+}
+
bool CPDF_MeshStream::CanReadFlag() const {
return m_BitStream->BitsRemaining() >= m_nFlagBits;
}
diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h
index e012b52..e828108 100644
--- a/core/fpdfapi/page/cpdf_meshstream.h
+++ b/core/fpdfapi/page/cpdf_meshstream.h
@@ -14,7 +14,6 @@
#include <vector>
#include "core/fpdfapi/page/cpdf_shadingpattern.h"
-#include "core/fxcrt/cfx_bitstream.h"
#include "core/fxcrt/retain_ptr.h"
class CPDF_StreamAcc;
@@ -31,6 +30,7 @@
float b = 0.0f;
};
+class CFX_BitStream;
class CFX_Matrix;
class CPDF_ColorSpace;
class CPDF_Function;
@@ -45,7 +45,10 @@
~CPDF_MeshStream();
bool Load();
+ void SkipBits(uint32_t nbits);
+ void ByteAlign();
+ bool IsEOF() const;
bool CanReadFlag() const;
bool CanReadCoords() const;
bool CanReadColor() const;
@@ -60,7 +63,6 @@
std::vector<CPDF_MeshVertex> ReadVertexRow(const CFX_Matrix& pObject2Bitmap,
int count);
- CFX_BitStream* BitStream() { return m_BitStream.get(); }
uint32_t ComponentBits() const { return m_nComponentBits; }
uint32_t Components() const { return m_nComponents; }
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index b2a80ce..d7034c7 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -94,7 +94,7 @@
else
color_count = kSingleColorPerPatch;
- while (!stream.BitStream()->IsEOF()) {
+ while (!stream.IsEOF()) {
uint32_t flag = 0;
if (type != kLatticeFormGouraudTriangleMeshShading) {
if (!stream.CanReadFlag())
@@ -125,9 +125,9 @@
if (!nBits.IsValid())
break;
- stream.BitStream()->SkipBits(nBits.ValueOrDie());
+ stream.SkipBits(nBits.ValueOrDie());
if (bGouraud)
- stream.BitStream()->ByteAlign();
+ stream.ByteAlign();
}
return matrix.TransformRect(rect);
}
diff --git a/core/fpdfapi/render/cpdf_rendershading.cpp b/core/fpdfapi/render/cpdf_rendershading.cpp
index f9751bd..a931a31 100644
--- a/core/fpdfapi/render/cpdf_rendershading.cpp
+++ b/core/fpdfapi/render/cpdf_rendershading.cpp
@@ -428,7 +428,7 @@
return;
CPDF_MeshVertex triangle[3];
- while (!stream.BitStream()->IsEOF()) {
+ while (!stream.IsEOF()) {
CPDF_MeshVertex vertex;
uint32_t flag;
if (!stream.ReadVertex(mtObject2Bitmap, &vertex, &flag))
@@ -804,7 +804,7 @@
CFX_PointF coords[16];
int point_count = type == kTensorProductPatchMeshShading ? 16 : 12;
- while (!stream.BitStream()->IsEOF()) {
+ while (!stream.IsEOF()) {
if (!stream.CanReadFlag())
break;
uint32_t flag = stream.ReadFlag();
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index a32ebf9..1531be4 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -2310,7 +2310,7 @@
if (!skClip.isEmpty())
m_pCanvas->clipPath(skClip, SkClipOp::kIntersect, true);
m_pCanvas->concat(skMatrix);
- while (!stream.BitStream()->IsEOF()) {
+ while (!stream.IsEOF()) {
uint32_t flag = stream.ReadFlag();
int iStartPoint = flag ? 4 : 0;
int iStartColor = flag ? 2 : 0;