1 /* 2 * Copyright 2013 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 SkMatrixUtils_DEFINED 9 #define SkMatrixUtils_DEFINED 10 11 #include "include/core/SkPoint.h" 12 #include "include/core/SkSize.h" 13 14 class SkMatrix; 15 class SkPaint; 16 struct SkSamplingOptions; 17 18 /** 19 * Given a matrix, size and paint, return true if the computed dst-rect would 20 * align such that there is a 1-to-1 coorspondence between src and dst pixels. 21 * This can be called by drawing code to see if drawBitmap can be turned into 22 * drawSprite (which is faster). 23 * 24 * The src-rect is defined to be { 0, 0, size.width(), size.height() } 25 */ 26 bool SkTreatAsSprite(const SkMatrix&, const SkISize& size, const SkSamplingOptions&, 27 const SkPaint&); 28 29 /** Decomposes the upper-left 2x2 of the matrix into a rotation (represented by 30 the cosine and sine of the rotation angle), followed by a non-uniform scale, 31 followed by another rotation. If there is a reflection, one of the scale 32 factors will be negative. 33 Returns true if successful. Returns false if the matrix is degenerate. 34 */ 35 bool SkDecomposeUpper2x2(const SkMatrix& matrix, 36 SkPoint* rotation1, 37 SkPoint* scale, 38 SkPoint* rotation2); 39 40 #endif 41