blob: 098bc936b310904192555360238ca10a4ddcd21f [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/viz/service/display/renderer_utils.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkScalar.h"
namespace viz {
static inline bool IsScalarNearlyInteger(SkScalar scalar) {
return SkScalarNearlyZero(scalar - SkScalarRoundToScalar(scalar));
}
bool IsScaleAndIntegerTranslate(const SkMatrix& matrix) {
return IsScalarNearlyInteger(matrix[SkMatrix::kMTransX]) &&
IsScalarNearlyInteger(matrix[SkMatrix::kMTransY]) &&
SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) &&
SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) &&
SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) &&
SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) &&
SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f);
}
} // namespace viz