1 /* 2 * Copyright 2020 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkSamplingPriv_DEFINED 9 #define SkSamplingPriv_DEFINED 10 11 #include "include/core/SkSamplingOptions.h" 12 13 class SkReadBuffer; 14 class SkWriteBuffer; 15 16 class SkSamplingPriv { 17 public: 18 enum { 19 kFlatSize = 3 * sizeof(uint32_t) // bool32 + [2 floats | 2 ints] 20 }; 21 22 // Returns true if the sampling can be ignored when the CTM is identity. NoChangeWithIdentityMatrix(const SkSamplingOptions & sampling)23 static bool NoChangeWithIdentityMatrix(const SkSamplingOptions& sampling) { 24 // If B == 0, the cubic resampler should have no effect for identity matrices 25 // https://entropymine.com/imageworsener/bicubic/ 26 return !sampling.useCubic || sampling.cubic.B == 0; 27 } 28 29 static SkSamplingOptions Read(SkReadBuffer&); 30 static void Write(SkWriteBuffer&, const SkSamplingOptions&); 31 }; 32 33 #endif 34