Guard legacy matrixtransforms, and expose new one
Bug: skia:11236
Bug: skia:11235
Change-Id: I53fc0532a6067c5b30fc0345ded95d50d9955d38
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363098
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 4c95e82..5ebd523 100755
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -16,6 +16,7 @@
#include "src/core/SkOpts.h"
#include "src/core/SkRasterPipeline.h"
#include "src/core/SkReadBuffer.h"
+#include "src/core/SkSamplingPriv.h"
#include "src/core/SkScopeExit.h"
#include "src/core/SkVM.h"
#include "src/core/SkWriteBuffer.h"
@@ -145,29 +146,6 @@
return SkImageShader::Make(std::move(img), tmx, tmy, nullptr, &localMatrix);
}
-static void write_sampling(SkWriteBuffer& buffer, SkSamplingOptions sampling) {
- buffer.writeBool(sampling.useCubic);
- if (sampling.useCubic) {
- buffer.writeScalar(sampling.cubic.B);
- buffer.writeScalar(sampling.cubic.C);
- } else {
- buffer.writeUInt((unsigned)sampling.filter);
- buffer.writeUInt((unsigned)sampling.mipmap);
- }
-}
-
-static SkSamplingOptions read_sampling(SkReadBuffer& buffer) {
- if (buffer.readBool()) {
- SkScalar B = buffer.readScalar(),
- C = buffer.readScalar();
- return SkSamplingOptions({B,C});
- } else {
- auto filter = buffer.read32LE<SkFilterMode>(SkFilterMode::kLinear);
- auto mipmap = buffer.read32LE<SkMipmapMode>(SkMipmapMode::kLinear);
- return SkSamplingOptions(filter, mipmap);
- }
-}
-
// fClampAsIfUnpremul is always false when constructed through public APIs,
// so there's no need to read or write it here.
@@ -183,7 +161,7 @@
*samplingPtr = nullptr;
if (buffer.readBool()) { // fUseSamplingOptions
- sampling = read_sampling(buffer);
+ sampling = SkSamplingPriv::Read(buffer);
samplingPtr = &sampling;
}
@@ -203,7 +181,7 @@
buffer.writeBool(fUseSamplingOptions);
if (fUseSamplingOptions) {
- write_sampling(buffer, fSampling);
+ SkSamplingPriv::Write(buffer, fSampling);
}
buffer.writeMatrix(this->getLocalMatrix());